:root {
  --teal: #0f5c58;
  --teal-dark: #0a3f3c;
  --teal-soft: #e5f1f0;
  --gold: #c9a227;
  --gold-soft: #f7efd2;
  --bg: #f4f6f6;
  --card: #ffffff;
  --text: #1b2a2a;
  --muted: #5b6b6b;
  --line: #dbe3e3;
  --err: #8f1d16;
  --err-bg: #fbeceb;
  --shadow: 0 1px 2px rgba(10, 63, 60, .06), 0 4px 14px rgba(10, 63, 60, .06);
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 16px/1.6 "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", sans-serif;
}
.wrap { max-width: 1200px; margin: 0 auto; padding: 0 16px; }
.skip { position: absolute; left: -999px; } .skip:focus { left: 8px; top: 8px; background: #fff; padding: 6px 10px; z-index: 10; }
a { color: var(--teal); }
h1, h2, h3 { line-height: 1.25; }
h2 { font-size: 1.25rem; margin: 0 0 12px; }

/* header */
.site { background: var(--teal-dark); color: #fff; border-bottom: 3px solid var(--gold); }
.bar { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; padding-top: 10px; padding-bottom: 10px; }
.brand { display: flex; align-items: center; gap: 12px; color: #fff; text-decoration: none; }
.brand strong { display: block; font-size: 1.2rem; letter-spacing: .01em; }
.brand small { display: block; color: #bfd8d6; font-size: .82rem; margin-top: -2px; }
.logo { display: grid; place-items: center; width: 42px; height: 42px; border-radius: 10px; background: var(--gold); color: var(--teal-dark); font: 700 1.6rem/1 Georgia, serif; }
.nav { display: flex; flex-wrap: wrap; gap: 4px; }
.nav a { color: #dcebea; text-decoration: none; padding: 7px 12px; border-radius: 8px; font-size: .95rem; }
.nav a:hover { background: rgba(255, 255, 255, .1); }
.nav a[aria-current="page"] { background: rgba(255, 255, 255, .16); color: #fff; box-shadow: inset 0 -2px 0 var(--gold); }

main { padding-top: 22px; padding-bottom: 30px; outline: none; }
.site-foot { padding-top: 10px; padding-bottom: 34px; color: var(--muted); font-size: .85rem; display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; }

/* cards */
.card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 18px; box-shadow: var(--shadow); margin-bottom: 16px; }
.muted { color: var(--muted); }

.hero { padding: 6px 0 18px; }
.hero h1 { margin: 0 0 6px; font-size: clamp(1.7rem, 4.2vw, 2.4rem); color: var(--teal-dark); }
.hero p { margin: 0; color: var(--muted); max-width: 70ch; }

/* input */
.input-card textarea {
  width: 100%; min-height: 110px; resize: vertical; padding: 12px 14px; font: inherit; color: var(--text);
  border: 1.5px solid var(--line); border-radius: 10px; background: #fbfdfd;
}
.input-card textarea:focus { outline: 3px solid rgba(15, 92, 88, .25); border-color: var(--teal); }
.btns { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 12px; }
button, .btn {
  font: inherit; cursor: pointer; padding: 9px 18px; border-radius: 10px; border: 1.5px solid var(--teal);
  background: var(--teal); color: #fff; font-weight: 600; text-decoration: none; display: inline-block;
}
button:hover, .btn:hover { background: var(--teal-dark); border-color: var(--teal-dark); }
button.secondary, .btn.secondary { background: #fff; color: var(--teal); }
button.secondary:hover, .btn.secondary:hover { background: var(--teal-soft); }
button.small { padding: 5px 12px; font-size: .85rem; }
button:focus-visible, a:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }
.hint { font-size: .86rem; color: var(--muted); margin: 10px 0 0; }

/* output */
.problem-card { border-left: 5px solid var(--gold); }
.problem-card .label { text-transform: uppercase; letter-spacing: .08em; font-size: .75rem; color: var(--muted); font-weight: 700; }
.problem-card p { margin: 4px 0 0; font-size: 1.05rem; }
.layout { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.layout .card { margin-bottom: 0; }
.graph-card { position: sticky; top: 10px; }
.plot { width: 100%; height: 470px; }
.graph-tools { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.answer-banner { background: var(--teal); color: #fff; border-radius: 12px; padding: 12px 16px; margin-bottom: 14px; display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.answer-banner .lab { font-size: .8rem; text-transform: uppercase; letter-spacing: .08em; color: #c5e0de; }
.answer-banner .katex { font-size: 1.3em; }

.sec { border-top: 1px solid var(--line); padding: 12px 0 4px; }
.sec:first-of-type { border-top: 0; padding-top: 0; }
.sec h3 { margin: 0 0 6px; font-size: 1rem; color: var(--teal-dark); }
.sec p { margin: 6px 0; }
.math { overflow-x: auto; overflow-y: hidden; padding: 2px 0; }
.math .katex-display { margin: .35em 0; }
.math .katex { font-size: 1.08em; }
table.pts { border-collapse: collapse; margin: 8px 0; font-size: .95rem; }
table.pts th, table.pts td { border: 1px solid var(--line); padding: 4px 12px; text-align: center; }
table.pts th { background: var(--teal-soft); }

.error-card { border-left: 5px solid #b3261e; background: var(--err-bg); color: var(--err); }
.error-card h2 { color: var(--err); }
.error-card p { margin: 6px 0; white-space: pre-line; }
.error-card .detail { font-size: .85rem; opacity: .8; }

/* history */
.history ul { list-style: none; padding: 0; margin: 0; }
.history li { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-top: 1px solid var(--line); }
.history li:first-child { border-top: 0; }
.history .txt { flex: 1; min-width: 0; }
.history .txt b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.history .txt small { color: var(--muted); }
.head-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; }

/* examples / how */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }
.cards .card { margin-bottom: 0; display: flex; flex-direction: column; gap: 8px; }
.cards h3 { margin: 0; font-size: 1.02rem; color: var(--teal-dark); }
.cards p { margin: 0; flex: 1; }
.tag { display: inline-block; background: var(--gold-soft); color: #6d5608; border-radius: 99px; padding: 1px 10px; font-size: .75rem; font-weight: 700; }
.expected { color: var(--muted); font-size: .9rem; }
.how-steps { counter-reset: s; list-style: none; padding: 0; margin: 0; display: grid; gap: 14px; }
.how-steps li { counter-increment: s; background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 16px 16px 16px 64px; position: relative; box-shadow: var(--shadow); }
.how-steps li::before { content: counter(s); position: absolute; left: 16px; top: 14px; width: 34px; height: 34px; border-radius: 50%; background: var(--teal); color: #fff; display: grid; place-items: center; font-weight: 700; }
.how-steps h3 { margin: 0 0 4px; }
.how-steps p { margin: 4px 0; }
.prose { max-width: 75ch; }

@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  .graph-card { position: static; }
  .plot { height: 380px; }
}
@media (max-width: 520px) {
  .wrap { padding: 0 12px; }
  .card { padding: 14px; }
  .plot { height: 320px; }
}

.dbg { margin-left: auto; align-self: center; font-size: .85rem; color: var(--muted); cursor: pointer; }
.debug { border-left: 5px solid var(--gold); background: #fffdf3; }
.debug h4 { margin: 10px 0 2px; font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.debug pre { margin: 0; padding: 8px 10px; background: #f3f1e4; border-radius: 8px; overflow-x: auto; font: .85rem/1.45 ui-monospace, Consolas, monospace; white-space: pre-wrap; }

/* fullscreen graph */
.tool-btns { display: flex; gap: 8px; flex-wrap: wrap; }
.plot.is-fs { height: 100%; width: 100%; min-height: 0; }
body.fs-lock { overflow: hidden; }
.fs-overlay { position: fixed; inset: 0; z-index: 1000; background: rgba(6, 24, 23, .9); display: flex; padding: 12px; }
.fs-panel { flex: 1; min-width: 0; display: flex; flex-direction: column; background: #fff; border-radius: 14px; overflow: hidden; box-shadow: 0 10px 40px rgba(0, 0, 0, .45); }
.fs-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px 16px; background: var(--teal-dark); color: #fff; border-bottom: 3px solid var(--gold); }
.fs-head strong { font-size: 1.1rem; }
.fs-head button { background: var(--gold); border-color: var(--gold); color: var(--teal-dark); }
.fs-head button:hover { background: #dab93c; border-color: #dab93c; }
.fs-body { flex: 1; min-height: 0; padding: 8px; }
.fs-foot { padding: 7px 16px; font-size: .85rem; color: var(--muted); background: var(--bg); border-top: 1px solid var(--line); text-align: center; }
@supports (height: 100dvh) { .fs-overlay { height: 100dvh; } }
@media (max-width: 600px) {
  .fs-overlay { padding: 0; }
  .fs-panel { border-radius: 0; }
  .fs-head { padding: 8px 12px; }
  .fs-foot { font-size: .75rem; padding: 5px 8px; }
  .fs-body { padding: 2px; }
}

/* signature */
.signature { display: inline-flex; align-items: baseline; gap: 8px; white-space: nowrap; user-select: none; }
.signature small { font-size: .7rem; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); opacity: .8; }
.signature b {
  font: 400 1.9rem/1 "Great Vibes", "Segoe Script", "Brush Script MT", cursive; color: var(--teal);
  padding-bottom: 4px; border-bottom: 2px solid var(--gold); letter-spacing: .01em;
}
.fs-foot { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.fs-foot .signature b { font-size: 1.4rem; }
@media (max-width: 520px) { .site-foot { flex-direction: column; align-items: flex-start; } .fs-foot .signature small { display: none; } }

/* fullscreen solution */
.fs-body.fs-scroll { overflow-y: auto; padding: 18px 24px 28px; background: var(--bg); }
.sol-card.is-fs-sol { max-width: 1050px; margin: 0 auto; font-size: 1.2rem; line-height: 1.65; }
.sol-card.is-fs-sol #fsSolBtn { display: none; }
.sol-card.is-fs-sol .answer-banner { padding: 16px 22px; border-radius: 14px; }
.sol-card.is-fs-sol .answer-banner .lab { font-size: .95rem; }
.sol-card.is-fs-sol .answer-banner .katex { font-size: 1.9em; }
.sol-card.is-fs-sol .sec h3 { font-size: 1.3rem; margin-bottom: 8px; }
.sol-card.is-fs-sol .math .katex { font-size: 1.4em; }
.sol-card.is-fs-sol table.pts { font-size: 1.15rem; }
@media (max-width: 600px) {
  .fs-body.fs-scroll { padding: 10px 12px 20px; }
  .sol-card.is-fs-sol { font-size: 1.05rem; }
  .sol-card.is-fs-sol .math .katex { font-size: 1.15em; }
}

/* fullscreen solution + graph */
.fs-body.fs-split { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr); gap: 14px; padding: 12px; overflow: hidden; background: var(--bg); }
.fs-split .fs-sol { overflow-y: auto; min-height: 0; padding-right: 4px; }
.fs-split .fs-sol .sol-card.is-fs-sol { margin: 0; max-width: none; font-size: 1.1rem; }
.fs-split .fs-sol .sol-card.is-fs-sol .math .katex { font-size: 1.3em; }
.fs-split .fs-graph { min-height: 0; background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 6px; }
@media (max-width: 1000px) {
  .fs-body.fs-split { display: block; overflow-y: auto; }
  .fs-split .fs-sol { overflow: visible; }
  .fs-split .fs-graph { height: 85vh; margin-top: 14px; }
  @supports (height: 100dvh) { .fs-split .fs-graph { height: 85dvh; } }
}

/* PowerPoint export */
.ppt-status { margin: 0 0 10px; color: var(--teal); font-weight: 600; }
.ppt-status.bad { color: var(--err); }
.sol-card.is-fs-sol #dlPptx, .sol-card.is-fs-sol .ppt-status { display: none; }
button:disabled { opacity: .6; cursor: progress; }
