/* CalcSolver Scientific Calculator - design: CalcSolver Clean Ink */
.cs-calc {
  --cs-bg: #FFFFFF;
  --cs-surface: #F6F4F1;
  --cs-surface-hover: #EFECE7;
  --cs-line: #E7E3DD;
  --cs-ink: #161514;
  --cs-muted: #66625C;
  --cs-placeholder: #9A958E;
  --cs-accent: #15803D;
  --cs-accent-soft: #E7EEE2;
  --cs-accent-line: #D2E2C9;
  --cs-accent-hover: #DCE8D4;
  --cs-eq: #161514;
  --cs-eq-hover: #2A2825;
  --cs-on-eq: #FFFFFF;
  --cs-error: #B42318;
  --cs-success: #15803D;
  --cs-shadow: 0 1px 2px rgba(22, 21, 20, .04), 0 12px 32px -12px rgba(22, 21, 20, .14);
  --cs-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  --cs-sans: "DM Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  box-sizing: border-box;
  width: 100%;
  max-width: 880px;
  margin: 0 auto;
  padding: 20px;
  background: var(--cs-bg);
  color: var(--cs-ink);
  font-family: var(--cs-sans);
  border: 1px solid var(--cs-line);
  border-radius: 18px;
  box-shadow: var(--cs-shadow);
  -webkit-tap-highlight-color: transparent;
}
.cs-calc.is-dark {
  --cs-bg: #161514;
  --cs-surface: #211F1D;
  --cs-surface-hover: #2A2825;
  --cs-line: #35322E;
  --cs-ink: #F3F1EE;
  --cs-muted: #AAA59E;
  --cs-placeholder: #7D786F;
  --cs-accent: #4ADE80;
  --cs-accent-soft: #1D2A20;
  --cs-accent-line: #2A3D2E;
  --cs-accent-hover: #243427;
  --cs-eq: #F3F1EE;
  --cs-eq-hover: #FFFFFF;
  --cs-on-eq: #161514;
  --cs-error: #F97066;
  --cs-success: #4ADE80;
  --cs-shadow: 0 12px 32px -12px rgba(0, 0, 0, .5);
}
.cs-calc *, .cs-calc *::before, .cs-calc *::after { box-sizing: border-box; }
.cs-calc button { font: inherit; margin: 0; }
.cs-calc [hidden] { display: none !important; }

.cs-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* top bar */
.cs-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.cs-seg { display: inline-flex; padding: 3px; background: var(--cs-surface); border: 1px solid var(--cs-line); border-radius: 8px; }
.cs-seg button {
  border: 0; background: transparent; color: var(--cs-muted);
  font-family: var(--cs-mono); font-size: 13px; font-weight: 500; letter-spacing: .04em;
  padding: 6px 12px; border-radius: 6px; cursor: pointer;
}
.cs-seg button.is-on { background: var(--cs-bg); color: var(--cs-accent); box-shadow: 0 1px 2px rgba(19, 32, 44, .1); }
.cs-calc.is-code .cs-angle { visibility: hidden; }

.cs-switch {
  display: inline-flex; align-items: center; gap: 8px;
  border: 0; background: transparent; color: var(--cs-ink); cursor: pointer;
  font-size: 14px; font-weight: 500; padding: 4px 2px;
}
.cs-switch-track {
  position: relative; width: 36px; height: 20px; border-radius: 999px;
  background: var(--cs-line); transition: background-color .15s ease;
}
.cs-switch-thumb {
  position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%;
  background: var(--cs-bg); box-shadow: 0 1px 2px rgba(19, 32, 44, .25); transition: transform .15s ease;
}
.cs-switch[aria-checked="true"] .cs-switch-track { background: var(--cs-accent); }
.cs-switch[aria-checked="true"] .cs-switch-thumb { transform: translateX(16px); }

.cs-link {
  border: 0; background: transparent; color: var(--cs-accent); font-size: 14px; font-weight: 500;
  padding: 6px 10px; border-radius: 8px; cursor: pointer;
}
.cs-link:hover { background: var(--cs-accent-soft); }

/* screen */
.cs-screen {
  position: relative;
  background: var(--cs-surface); border: 1px solid var(--cs-line); border-radius: 12px;
  padding: 14px 16px 12px; margin-bottom: 16px;
}
.cs-expr {
  display: block; width: 100%; border: 0; outline: 0; background: transparent; padding: 0;
  font-family: var(--cs-mono); font-size: 18px; line-height: 1.4; color: var(--cs-muted);
  text-align: right; caret-color: var(--cs-accent);
}
.cs-expr::placeholder { color: var(--cs-placeholder); }
.cs-mem {
  position: absolute; top: 10px; left: 12px; padding: 1px 7px; border-radius: 6px;
  background: var(--cs-accent-soft); color: var(--cs-accent); font-family: var(--cs-mono); font-size: 12px; font-weight: 500;
}
.cs-calc.is-code .cs-mem { display: none; }
.cs-result-row { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; min-height: 52px; margin-top: 4px; }
.cs-frac { font-family: var(--cs-mono); font-size: 15px; color: var(--cs-accent); white-space: nowrap; }
.cs-result {
  display: block; flex: 1; min-width: 0; text-align: right;
  font-family: var(--cs-mono); font-weight: 500; font-size: 40px; line-height: 1.15; color: var(--cs-ink);
  overflow-x: auto; white-space: nowrap; scrollbar-width: none;
}
.cs-result::-webkit-scrollbar { display: none; }
.cs-result.is-preview { color: var(--cs-placeholder); }
.cs-result.is-error { color: var(--cs-error); font-family: var(--cs-sans); font-size: 18px; font-weight: 500; white-space: normal; }

/* keypads */
.cs-pads { display: grid; grid-template-columns: 5fr 4fr; gap: 16px; align-items: stretch; }
.cs-pad { display: grid; gap: 8px; }
.cs-pad-sci { grid-template-columns: repeat(5, 1fr); grid-auto-rows: 1fr; }
.cs-pad-num { grid-template-columns: repeat(4, 1fr); grid-auto-rows: 1fr; }
.cs-lab sup { font-size: .62em; line-height: 0; vertical-align: super; margin-left: 1px; }
.cs-lab i { font-style: italic; }
.cs-mem-k { font-size: 15px; }
.cs-sci-toggle { display: none; }
.cs-k {
  display: flex; align-items: center; justify-content: center;
  min-height: 52px; padding: 0 4px;
  background: var(--cs-bg); color: var(--cs-ink);
  border: 1px solid var(--cs-line); border-radius: 14px;
  font-family: var(--cs-mono); font-size: 20px; font-weight: 500;
  cursor: pointer; user-select: none; touch-action: manipulation;
  transition: background-color .12s ease, transform .06s ease;
}
.cs-k:hover { background: var(--cs-surface); }
.cs-k:active { transform: translateY(1px); }
.cs-fn { background: var(--cs-surface); font-family: var(--cs-sans); font-size: 16px; color: var(--cs-ink); }
.cs-fn:hover { background: var(--cs-surface-hover); }
.cs-op { background: var(--cs-accent-soft); border-color: var(--cs-accent-line); color: var(--cs-accent); font-size: 26px; font-family: var(--cs-sans); }
.cs-op:hover { background: var(--cs-accent-hover); }
.cs-clear { background: var(--cs-surface); color: var(--cs-ink); font-family: var(--cs-sans); font-size: 17px; font-weight: 600; }
.cs-eq { background: var(--cs-eq); border-color: var(--cs-eq); color: var(--cs-on-eq); font-size: 28px; font-family: var(--cs-sans); }
.cs-eq:hover { background: var(--cs-eq-hover); border-color: var(--cs-eq-hover); }
.cs-calc button:focus-visible, .cs-calc textarea:focus-visible { outline: 2px solid var(--cs-accent); outline-offset: 2px; }
.cs-screen:focus-within { border-color: var(--cs-accent); }
.cs-expr:focus, .cs-expr:focus-visible { outline: none; box-shadow: none; }

/* tools bar */
.cs-tools { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 14px; padding-top: 10px; border-top: 1px solid var(--cs-line); }
.cs-tool {
  border: 1px solid transparent; background: transparent; color: var(--cs-accent);
  font-size: 14px; font-weight: 500; padding: 6px 12px; border-radius: 8px; cursor: pointer;
}
.cs-tool:hover { background: var(--cs-accent-soft); }
.cs-tool[aria-expanded="true"], .cs-tool[aria-pressed="true"] { background: var(--cs-accent-soft); border-color: var(--cs-accent-line); }

/* panels: history + notes */
.cs-panel { margin-top: 12px; padding: 12px 14px; background: var(--cs-surface); border: 1px solid var(--cs-line); border-radius: 12px; }
.cs-panel-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-weight: 600; font-size: 15px; margin-bottom: 6px; }
.cs-panel-actions { display: flex; gap: 2px; }
.cs-history-list { list-style: none; margin: 0; padding: 0; max-height: 220px; overflow-y: auto; }
.cs-history-list li { margin: 0; }
.cs-history-item {
  display: flex; width: 100%; justify-content: space-between; gap: 16px;
  border: 0; border-bottom: 1px solid var(--cs-line); background: transparent; color: var(--cs-ink);
  padding: 10px 4px; cursor: pointer; text-align: left; font-family: var(--cs-mono); font-size: 15px;
}
.cs-history-item:hover { background: var(--cs-surface-hover); }
.cs-h-e { color: var(--cs-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cs-h-r { color: var(--cs-ink); white-space: nowrap; }
.cs-history-empty { color: var(--cs-muted); font-size: 14px; padding: 8px 4px; }
.cs-notes-text {
  display: block; width: 100%; min-height: 120px; resize: vertical; margin: 0;
  padding: 10px 12px; border: 1px solid var(--cs-line); border-radius: 8px;
  background: var(--cs-bg); color: var(--cs-ink); font-family: var(--cs-mono); font-size: 15px; line-height: 1.55;
}
.cs-notes-text::placeholder { color: var(--cs-placeholder); }
.cs-notes-meta { display: flex; justify-content: space-between; margin-top: 6px; font-size: 13px; color: var(--cs-muted); }

/* try chips */
.cs-try { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 16px; }
.cs-try-label { font-size: 14px; color: var(--cs-muted); margin-right: 2px; }
.cs-chip {
  border: 1px solid var(--cs-line); background: var(--cs-bg); color: var(--cs-ink);
  font-family: var(--cs-mono); font-size: 13px; padding: 6px 12px; border-radius: 999px; cursor: pointer;
}
.cs-chip:hover { border-color: var(--cs-accent); color: var(--cs-accent); }
.cs-note { margin: 12px 0 0; font-size: 13px; line-height: 1.5; color: var(--cs-muted); }

/* code mode: games */
.cs-games-title { margin: 4px 0 4px; font-size: 20px; font-weight: 700; line-height: 1.2; color: var(--cs-ink); }
.cs-games-sub { margin: 0 0 16px; font-size: 14px; line-height: 1.5; color: var(--cs-muted); }
.cs-game-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }
.cs-game-card {
  display: flex; flex-direction: column; align-items: flex-start; gap: 6px; text-align: left;
  padding: 16px; min-height: 132px; border: 1px solid var(--cs-line); border-radius: 12px;
  background: var(--cs-surface); color: var(--cs-ink); cursor: pointer;
}
.cs-game-card:hover { border-color: var(--cs-accent); }
.cs-game-name { font-size: 17px; font-weight: 700; }
.cs-game-desc { font-size: 14px; line-height: 1.45; color: var(--cs-muted); }
.cs-game-best { margin-top: auto; font-family: var(--cs-mono); font-size: 13px; color: var(--cs-accent); }
.cs-game-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.cs-game-stat { font-family: var(--cs-mono); font-size: 14px; color: var(--cs-muted); }
.cs-game-stage {
  display: flex; flex-direction: column; align-items: center; gap: 14px;
  padding: 28px 16px; background: var(--cs-surface); border: 1px solid var(--cs-line); border-radius: 12px; text-align: center;
}
.cs-game-prompt { margin: 0; font-family: var(--cs-mono); font-size: 40px; font-weight: 500; line-height: 1.15; color: var(--cs-ink); }
.cs-game-msg { margin: 0; min-height: 22px; font-size: 15px; color: var(--cs-muted); }
.cs-game-msg.is-good { color: var(--cs-success); }
.cs-game-msg.is-bad { color: var(--cs-error); }
.cs-game-options { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; max-width: 520px; }
.cs-game-options:empty { display: none; }
.cs-game-options .cs-k { min-width: 56px; }
.cs-game-form { display: flex; gap: 8px; width: 100%; max-width: 360px; }
.cs-game-input {
  flex: 1; min-width: 0; height: 52px; padding: 0 14px; border: 1px solid var(--cs-line); border-radius: 12px;
  background: var(--cs-bg); color: var(--cs-ink); font-family: var(--cs-mono); font-size: 22px; text-align: center;
}
.cs-game-input:focus { outline: 2px solid var(--cs-accent); outline-offset: 1px; }
.cs-game-go { padding: 0 20px; font-size: 17px; }
.cs-game-again { padding: 0 24px; font-size: 17px; }

/* code mode: activity code entry */
.cs-screen-label, .cs-code-hint { display: none; }
.cs-calc.is-code .cs-screen-label { display: block; font-family: var(--cs-mono); font-size: 12px; letter-spacing: .08em; text-transform: uppercase; color: var(--cs-muted); }
.cs-calc.is-code .cs-code-hint { display: block; margin: 6px 0 0; text-align: right; font-size: 13px; color: var(--cs-muted); }
.cs-calc.is-code .cs-expr { display: none; }
.cs-calc.is-code .cs-pad-sci .cs-k, .cs-calc.is-code .cs-op, .cs-calc.is-code .cs-k[data-insert="."], .cs-calc.is-code .cs-k[data-insert="Ans"], .cs-calc.is-code .cs-k[data-act="sign"] { opacity: .35; pointer-events: none; }
.cs-calc.is-code .cs-sci-toggle { display: none !important; }
.cs-opt { min-width: 120px; font-family: var(--cs-mono); font-size: 20px; }
.cs-calc.is-code .cs-tools, .cs-calc.is-code .cs-panel, .cs-calc.is-code .cs-try, .cs-calc.is-code .cs-note { display: none !important; }
.cs-games-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.cs-game-code { font-family: var(--cs-mono); font-size: 12px; letter-spacing: .04em; color: var(--cs-muted); }

/* mobile */
@media (max-width: 760px) {
  .cs-calc { padding: 14px; border-radius: 16px; }
  .cs-pads { grid-template-columns: 1fr; gap: 10px; }
  .cs-pad { gap: 6px; }
  .cs-k { min-height: 46px; font-size: 19px; }
  .cs-pad-sci .cs-k { min-height: 40px; font-size: 14px; }
  .cs-result { font-size: 32px; }
  .cs-sci-toggle {
    display: flex; align-items: center; justify-content: center; width: 100%; margin: 0 0 10px;
    padding: 10px 12px; border: 1px solid var(--cs-line); border-radius: 12px;
    background: var(--cs-surface); color: var(--cs-accent); font-size: 14px; font-weight: 500; cursor: pointer;
  }
  .cs-calc:not(.sci-open) .cs-pad-sci { display: none; }
  .cs-pad-num .cs-k { min-height: 56px; font-size: 21px; }
  .cs-tools { gap: 2px; }
  .cs-tool { padding: 6px 8px; }
  .cs-game-prompt { font-size: 32px; }
}
@media (max-width: 360px) {
  .cs-calc { padding: 10px; }
  .cs-pad-sci .cs-k { font-size: 13px; }
  .cs-tool { padding: 6px 8px; }
}
@media (prefers-reduced-motion: reduce) {
  .cs-k, .cs-switch-track, .cs-switch-thumb { transition: none; }
}

/* ---------- below the calculator: scratch notes + key guide ---------- */
.cs-extras {
  --cs-bg: #FFFFFF;
  --cs-surface: #F6F4F1;
  --cs-surface-hover: #EFECE7;
  --cs-line: #E7E3DD;
  --cs-ink: #161514;
  --cs-muted: #66625C;
  --cs-placeholder: #9A958E;
  --cs-accent: #15803D;
  --cs-accent-soft: #E7EEE2;
  --cs-accent-line: #D2E2C9;
  --cs-accent-hover: #DCE8D4;
  --cs-eq: #161514;
  --cs-eq-hover: #2A2825;
  --cs-on-eq: #FFFFFF;
  --cs-error: #B42318;
  --cs-success: #15803D;
  --cs-shadow: 0 1px 2px rgba(22, 21, 20, .04), 0 12px 32px -12px rgba(22, 21, 20, .14);
  --cs-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  --cs-sans: "DM Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  box-sizing: border-box; width: 100%; max-width: 880px; margin: 20px auto 0;
  display: grid; gap: 20px; color: var(--cs-ink); font-family: var(--cs-sans); text-align: left;
}
.cs-extras.is-dark {
  --cs-bg: #161514;
  --cs-surface: #211F1D;
  --cs-surface-hover: #2A2825;
  --cs-line: #35322E;
  --cs-ink: #F3F1EE;
  --cs-muted: #AAA59E;
  --cs-placeholder: #7D786F;
  --cs-accent: #4ADE80;
  --cs-accent-soft: #1D2A20;
  --cs-accent-line: #2A3D2E;
  --cs-accent-hover: #243427;
  --cs-eq: #F3F1EE;
  --cs-eq-hover: #FFFFFF;
  --cs-on-eq: #161514;
  --cs-error: #F97066;
  --cs-success: #4ADE80;
  --cs-shadow: 0 12px 32px -12px rgba(0, 0, 0, .5);
}
.cs-extras *, .cs-extras *::before, .cs-extras *::after { box-sizing: border-box; }
.cs-extras button { font: inherit; margin: 0; }
.cs-box { background: var(--cs-bg); border: 1px solid var(--cs-line); border-radius: 18px; box-shadow: var(--cs-shadow); padding: 20px; }
.cs-box-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 0 0 14px; }
.cs-box-title { display: flex; align-items: center; gap: 10px; margin: 0; font-size: 20px; font-weight: 700; line-height: 1.2; }
.cs-box-title label { cursor: text; }
.cs-box-title svg, .cs-nb svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.cs-box-title svg { color: var(--cs-accent); }
.cs-notes-saved { font-size: 13px; color: var(--cs-accent); font-weight: 500; min-height: 1em; }
.cs-notebar { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.cs-nb {
  display: inline-flex; align-items: center; gap: 6px; min-height: 40px; padding: 0 14px;
  background: var(--cs-bg); color: var(--cs-ink); border: 1px solid var(--cs-line); border-radius: 999px;
  font-size: 14px; font-weight: 600; cursor: pointer; transition: background-color .15s ease, border-color .15s ease;
}
.cs-nb svg { width: 16px; height: 16px; }
.cs-nb:hover:not(:disabled) { background: var(--cs-surface); border-color: var(--cs-accent-line); }
.cs-nb:disabled { color: var(--cs-placeholder); background: var(--cs-surface); cursor: default; }
.cs-nb[data-note="insert"] { color: var(--cs-accent); background: var(--cs-accent-soft); border-color: var(--cs-accent-line); }
.cs-paper {
  --line: 32px;
  border: 1px solid var(--cs-line); border-radius: 12px; overflow: hidden;
  background-color: var(--cs-paper, #FFFDF8);
  background-image: linear-gradient(90deg, transparent 47px, var(--cs-margin, #F1C9B8) 47px, var(--cs-margin, #F1C9B8) 48px, transparent 48px),
                    repeating-linear-gradient(180deg, transparent 0, transparent calc(var(--line) - 1px), var(--cs-rule, #E6E1D8) calc(var(--line) - 1px), var(--cs-rule, #E6E1D8) var(--line));
  background-position: 0 0, 0 8px;
}
.cs-extras.is-dark .cs-paper { --cs-paper: #1B1A18; --cs-rule: #2E2B28; --cs-margin: #5A3A30; }
.cs-notes-text {
  display: block; width: 100%; min-height: calc(var(--line) * 9 + 16px); margin: 0; resize: vertical;
  padding: 8px 16px 8px 62px; border: 0; outline: 0; background: transparent; color: var(--cs-ink);
  font-family: var(--cs-mono); font-size: 16px; line-height: var(--line);
}
.cs-notes-text::placeholder { color: var(--cs-placeholder); }
.cs-paper:focus-within { border-color: var(--cs-accent); }
.cs-notes-meta { display: flex; justify-content: space-between; gap: 12px; margin-top: 8px; font-size: 13px; color: var(--cs-muted); }
.cs-extras button:focus-visible, .cs-howto summary:focus-visible { outline: 2px solid var(--cs-accent); outline-offset: 2px; }

.cs-howto { padding: 0; overflow: hidden; }
.cs-howto summary { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 18px 20px; cursor: pointer; list-style: none; }
.cs-howto summary::-webkit-details-marker { display: none; }
.cs-box-h2 { margin: 0; font-family: var(--cs-sans); font-size: 20px; font-weight: 700; line-height: 1.3; color: var(--cs-ink); letter-spacing: 0; }
.cs-chev { flex: none; width: 36px; height: 36px; border: 1px solid var(--cs-line); border-radius: 50%; position: relative; background: var(--cs-bg); }
.cs-chev::before { content: ""; position: absolute; left: 50%; top: 50%; width: 9px; height: 9px; border-right: 2px solid var(--cs-ink); border-bottom: 2px solid var(--cs-ink); transform: translate(-50%, -70%) rotate(45deg); transition: transform .2s ease; }
.cs-howto[open] .cs-chev::before { transform: translate(-50%, -30%) rotate(-135deg); }
.cs-howto-table { border-top: 1px solid var(--cs-line); overflow-x: auto; }
.cs-howto table { width: 100%; border-collapse: collapse; font-size: 15px; line-height: 1.55; }
.cs-howto th { padding: 12px 20px; background: var(--cs-surface); text-align: left; font-size: 12px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--cs-muted); }
.cs-howto td { padding: 16px 20px; vertical-align: top; border-top: 1px solid var(--cs-line); color: var(--cs-muted); }
.cs-howto td:first-child { width: 34%; }
.cs-howto td strong { color: var(--cs-ink); font-weight: 600; }
.cs-howto code { font-family: var(--cs-mono); font-size: 13px; padding: 2px 6px; border-radius: 6px; background: var(--cs-surface); border: 1px solid var(--cs-line); color: var(--cs-ink); white-space: nowrap; }
.ck {
  display: inline-flex; align-items: center; justify-content: center; min-width: 34px; height: 34px; margin: 0 6px 6px 0; padding: 0 9px;
  border: 1px solid var(--cs-line); border-bottom-width: 3px; border-radius: 10px; background: var(--cs-bg); color: var(--cs-ink);
  font-family: var(--cs-mono); font-size: 14px; font-weight: 500; white-space: nowrap; vertical-align: middle;
}
.ck sup { display: inline-block; font-size: .65em; line-height: 1; margin-left: 1px; transform: translateY(-.45em); }
.ck-f, .ck-c, .ck-m { background: var(--cs-surface); font-family: var(--cs-sans); }
.ck-o { background: var(--cs-accent-soft); border-color: var(--cs-accent-line); color: var(--cs-accent); font-family: var(--cs-sans); font-size: 16px; }
.ck-e { background: var(--cs-eq); border-color: var(--cs-eq); color: var(--cs-on-eq); font-family: var(--cs-sans); font-size: 16px; }
.ck-m { font-family: var(--cs-mono); font-size: 12px; letter-spacing: .04em; }
.ck-ex { display: flex; flex-wrap: wrap; align-items: center; margin-top: 10px; }
.ck-ex .ck { margin-bottom: 0; }
.ck-ex b { margin-left: 6px; font-family: var(--cs-mono); font-size: 16px; color: var(--cs-ink); }
.ck-type { display: block; margin-top: 10px; font-size: 14px; }

/* fit the whole calculator on short laptop screens */
@media (min-width: 761px) {
  .cs-k { min-height: clamp(38px, calc((100vh - 440px) / 6), 52px); }
}
@media (min-width: 761px) and (max-height: 820px) {
  .cs-calc { padding: 16px; }
  .cs-top { margin-bottom: 8px; }
  .cs-screen { padding: 10px 14px 8px; margin-bottom: 12px; }
  .cs-result { font-size: 34px; }
  .cs-result-row { min-height: 44px; }
  .cs-pads { gap: 12px; }
  .cs-pad { gap: 6px; }
  .cs-tools { margin-top: 10px; padding-top: 8px; }
}
@media (max-width: 760px) {
  .cs-screen { position: sticky; top: 86px; z-index: 3; box-shadow: 0 6px 14px -10px rgba(22, 21, 20, .35); }
  .cs-extras { margin-top: 14px; gap: 14px; }
  .cs-box { padding: 14px; border-radius: 16px; }
  .cs-box-title, .cs-box-h2 { font-size: 18px; }
  .cs-nb { min-height: 38px; padding: 0 11px; font-size: 13px; }
  .cs-howto summary { padding: 14px; }
  .cs-howto table, .cs-howto tbody, .cs-howto tr, .cs-howto td { display: block; width: 100%; }
  .cs-howto thead { display: none; }
  .cs-howto td { padding: 12px 14px 0; border-top: 0; }
  .cs-howto tr { border-top: 1px solid var(--cs-line); padding-bottom: 14px; }
  .cs-howto td:first-child { width: 100%; padding-bottom: 0; }
  .cs-notes-text { padding-left: 58px; font-size: 15px; }
}
@media print { .cs-extras .cs-notebar { display: none; } }
@media (prefers-reduced-motion: reduce) { .cs-chev::before, .cs-nb { transition: none; } }

/* ---------- v4: colour groups, tools bar, chips, light motion ---------- */
.cs-calc, .cs-extras {
  --cs-trig-bg: #E6F0FA; --cs-trig-fg: #1D4F91; --cs-trig-line: #CFE0F3; --cs-trig-hover: #D8E7F7;
  --cs-log-bg: #FFEDE0; --cs-log-fg: #9A3412; --cs-log-line: #F7D5BE; --cs-log-hover: #FDE1CD;
  --cs-pow-bg: #EFEAFB; --cs-pow-fg: #5B3FA8; --cs-pow-line: #DDD3F5; --cs-pow-hover: #E5DDF8;
  --cs-mem-bg: #FFF6D6; --cs-mem-fg: #7A5600; --cs-mem-line: #F2E2A6; --cs-mem-hover: #FCEDBB;
}
.cs-calc.is-dark, .cs-extras.is-dark {
  --cs-trig-bg: #17263A; --cs-trig-fg: #93C5FD; --cs-trig-line: #22364F; --cs-trig-hover: #1C2F47;
  --cs-log-bg: #33221A; --cs-log-fg: #FDBA8C; --cs-log-line: #4A3022; --cs-log-hover: #3D2920;
  --cs-pow-bg: #261F3A; --cs-pow-fg: #C4B5FD; --cs-pow-line: #382D55; --cs-pow-hover: #2E2646;
  --cs-mem-bg: #2E2914; --cs-mem-fg: #FCD34D; --cs-mem-line: #443C1C; --cs-mem-hover: #383219;
}
.cs-g-trig, .ck-trig { background: var(--cs-trig-bg); border-color: var(--cs-trig-line); color: var(--cs-trig-fg); }
.cs-g-log, .ck-log { background: var(--cs-log-bg); border-color: var(--cs-log-line); color: var(--cs-log-fg); }
.cs-g-pow, .ck-pow { background: var(--cs-pow-bg); border-color: var(--cs-pow-line); color: var(--cs-pow-fg); }
.cs-g-mem, .ck-mem { background: var(--cs-mem-bg); border-color: var(--cs-mem-line); color: var(--cs-mem-fg); }
.cs-g-trig:hover { background: var(--cs-trig-hover); }
.cs-g-log:hover { background: var(--cs-log-hover); }
.cs-g-pow:hover { background: var(--cs-pow-hover); }
.cs-g-mem:hover { background: var(--cs-mem-hover); }

/* tools bar: coloured pills with icons */
.cs-tools { gap: 8px; padding-top: 14px; }
.cs-tool {
  display: inline-flex; align-items: center; gap: 7px; min-height: 38px; padding: 0 15px;
  border: 1px solid transparent; border-radius: 999px; font-size: 14px; font-weight: 600;
  transition: transform .18s ease, background-color .18s ease, border-color .18s ease, box-shadow .18s ease;
}
.cs-tool svg, .cs-note svg { width: 16px; height: 16px; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.cs-t-sky { background: var(--cs-trig-bg); border-color: var(--cs-trig-line); color: var(--cs-trig-fg); }
.cs-t-peach { background: var(--cs-log-bg); border-color: var(--cs-log-line); color: var(--cs-log-fg); }
.cs-t-sage { background: var(--cs-accent-soft); border-color: var(--cs-accent-line); color: var(--cs-accent); }
.cs-t-lilac { background: var(--cs-pow-bg); border-color: var(--cs-pow-line); color: var(--cs-pow-fg); }
.cs-tool:hover { transform: translateY(-1px); box-shadow: 0 6px 14px -8px rgba(22, 21, 20, .3); }
.cs-t-sky:hover { background: var(--cs-trig-hover); }
.cs-t-peach:hover { background: var(--cs-log-hover); }
.cs-t-sage:hover { background: var(--cs-accent-hover); }
.cs-t-lilac:hover { background: var(--cs-pow-hover); }
.cs-tool[aria-expanded="true"], .cs-tool[aria-pressed="true"] { border-color: currentColor; }
.cs-tool[aria-expanded="true"].cs-t-peach { background: var(--cs-log-bg); }
.cs-tool[aria-pressed="true"].cs-t-lilac { background: var(--cs-pow-bg); }
.cs-tool.is-done { border-color: currentColor; }

/* try chips */
.cs-try { gap: 8px; padding: 14px; background: var(--cs-surface); border: 1px solid var(--cs-line); border-radius: 14px; }
.cs-try-label { font-weight: 600; color: var(--cs-ink); }
.cs-chip { font-weight: 500; transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease; }
.cs-chip:hover { transform: translateY(-2px); box-shadow: 0 6px 14px -8px rgba(22, 21, 20, .3); }
.cs-c-sky { background: var(--cs-trig-bg); border-color: var(--cs-trig-line); color: var(--cs-trig-fg); }
.cs-c-peach { background: var(--cs-log-bg); border-color: var(--cs-log-line); color: var(--cs-log-fg); }
.cs-c-sage { background: var(--cs-accent-soft); border-color: var(--cs-accent-line); color: var(--cs-accent); }
.cs-c-lilac { background: var(--cs-pow-bg); border-color: var(--cs-pow-line); color: var(--cs-pow-fg); }
.cs-c-sun { background: var(--cs-mem-bg); border-color: var(--cs-mem-line); color: var(--cs-mem-fg); }
.cs-chip:hover { border-color: currentColor; color: inherit; }
.cs-c-sky:hover { color: var(--cs-trig-fg); } .cs-c-peach:hover { color: var(--cs-log-fg); } .cs-c-sage:hover { color: var(--cs-accent); }
.cs-c-lilac:hover { color: var(--cs-pow-fg); } .cs-c-sun:hover { color: var(--cs-mem-fg); }

/* keyboard hint */
.cs-note { display: flex; align-items: center; gap: 8px; margin-top: 12px; }
.cs-note svg { color: var(--cs-muted); }
.cs-note kbd, .cs-howto kbd {
  display: inline-block; padding: 1px 7px; margin: 0 1px; border: 1px solid var(--cs-line); border-bottom-width: 2px; border-radius: 6px;
  background: var(--cs-bg); color: var(--cs-ink); font-family: var(--cs-mono); font-size: 12px; line-height: 1.5;
}

/* key guide: group accent + row hover */
.cs-howto tbody tr { transition: background-color .2s ease; }
.cs-howto tbody tr:hover { background: var(--cs-surface); }
.cs-howto td:first-child { position: relative; }
.ck { transition: transform .15s ease; }
.cs-howto tr:hover td:first-child .ck { transform: translateY(-1px); }
.cs-legend { display: flex; flex-wrap: wrap; gap: 8px 16px; padding: 0 20px 16px; font-size: 13px; color: var(--cs-muted); }
.cs-legend span { display: inline-flex; align-items: center; gap: 6px; }
.cs-legend i { width: 14px; height: 14px; border-radius: 4px; border: 1.5px solid; }
.cs-legend .l-trig { background: var(--cs-trig-bg); border-color: var(--cs-trig-fg); }
.cs-legend .l-log { background: var(--cs-log-bg); border-color: var(--cs-log-fg); }
.cs-legend .l-pow { background: var(--cs-pow-bg); border-color: var(--cs-pow-fg); }
.cs-legend .l-mem { background: var(--cs-mem-bg); border-color: var(--cs-mem-fg); }
.cs-legend .l-op { background: var(--cs-accent-soft); border-color: var(--cs-accent); }

/* light motion */
.cs-k { transition: background-color .12s ease, transform .1s ease, box-shadow .12s ease; }
.cs-k:active { transform: scale(.96); }
@keyframes cs-pop { 0% { transform: translateY(4px); opacity: .4; } 100% { transform: none; opacity: 1; } }
.cs-result.is-pop { animation: cs-pop .28s ease-out; }
@keyframes cs-fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.cs-panel:not([hidden]), .cs-games:not([hidden]), .cs-howto[open] .cs-howto-table { animation: cs-fade .25s ease-out; }
.cs-calc, .cs-calc .cs-screen, .cs-extras .cs-box { transition: background-color .25s ease, border-color .25s ease, color .25s ease; }
@media (max-width: 760px) {
  .cs-tool { min-height: 36px; padding: 0 11px; font-size: 13px; gap: 6px; }
  .cs-try { padding: 10px; }
  .cs-note { align-items: flex-start; }
  .cs-legend { padding: 0 14px 14px; }
}
@media (prefers-reduced-motion: reduce) {
  .cs-result.is-pop, .cs-panel:not([hidden]), .cs-games:not([hidden]), .cs-howto[open] .cs-howto-table { animation: none; }
  .cs-tool:hover, .cs-chip:hover, .cs-k:active, .cs-howto tr:hover td:first-child .ck { transform: none; }
}

/* v5: plain calculator keys, solid legend dots */
.cs-calc .cs-g-trig, .cs-calc .cs-g-log, .cs-calc .cs-g-pow, .cs-calc .cs-g-mem { background: var(--cs-surface); border-color: var(--cs-line); color: var(--cs-ink); }
.cs-calc .cs-g-trig:hover, .cs-calc .cs-g-log:hover, .cs-calc .cs-g-pow:hover, .cs-calc .cs-g-mem:hover { background: var(--cs-surface-hover); }
.cs-legend i { width: 10px; height: 10px; border: 0; border-radius: 50%; }
.cs-legend .l-trig { background: var(--cs-trig-fg); }
.cs-legend .l-log { background: var(--cs-log-fg); }
.cs-legend .l-pow { background: var(--cs-pow-fg); }
.cs-legend .l-mem { background: var(--cs-mem-fg); }
.cs-legend .l-op { background: var(--cs-accent); }

/* v6: compact, quieter tools and example chips */
.cs-tools { gap: 6px; padding-top: 12px; }
.cs-tool { min-height: 32px; padding: 0 12px; gap: 6px; font-size: 13px; font-weight: 600; background: var(--cs-bg); border-color: var(--cs-line); color: var(--cs-ink); box-shadow: none; }
.cs-tool svg { width: 15px; height: 15px; }
.cs-t-sky svg { color: var(--cs-trig-fg); }
.cs-t-peach svg { color: var(--cs-log-fg); }
.cs-t-sage svg { color: var(--cs-accent); }
.cs-t-lilac svg { color: var(--cs-pow-fg); }
.cs-tool:hover, .cs-t-sky:hover, .cs-t-peach:hover, .cs-t-sage:hover, .cs-t-lilac:hover { background: var(--cs-surface); border-color: var(--cs-accent-line); transform: translateY(-1px); box-shadow: none; }
.cs-tool[aria-expanded="true"], .cs-tool[aria-pressed="true"], .cs-tool.is-done,
.cs-tool[aria-expanded="true"].cs-t-peach, .cs-tool[aria-pressed="true"].cs-t-lilac { background: var(--cs-accent-soft); border-color: var(--cs-accent-line); color: var(--cs-accent); }
.cs-try { gap: 6px; margin-top: 12px; padding: 0; background: none; border: 0; border-radius: 0; }
.cs-try-label { font-size: 13px; font-weight: 600; color: var(--cs-muted); }
.cs-chip, .cs-c-sky, .cs-c-peach, .cs-c-sage, .cs-c-lilac, .cs-c-sun {
  padding: 4px 10px; font-size: 12.5px; font-weight: 500; background: var(--cs-surface); border-color: var(--cs-line); color: var(--cs-ink);
}
.cs-chip:hover, .cs-c-sky:hover, .cs-c-peach:hover, .cs-c-sage:hover, .cs-c-lilac:hover, .cs-c-sun:hover {
  background: var(--cs-accent-soft); border-color: var(--cs-accent-line); color: var(--cs-accent); transform: translateY(-1px); box-shadow: none;
}
.cs-note { margin-top: 10px; font-size: 12.5px; }
.cs-note kbd { font-size: 11px; padding: 0 6px; }
@media (max-width: 760px) {
  .cs-tool { min-height: 32px; padding: 0 10px; font-size: 12.5px; }
}

/* v7: smaller tool buttons, chips and notes buttons */
.cs-tool { min-height: 30px; padding: 0 11px; font-size: 12.5px; gap: 5px; }
.cs-tool svg { width: 14px; height: 14px; }
.cs-chip, .cs-c-sky, .cs-c-peach, .cs-c-sage, .cs-c-lilac, .cs-c-sun { padding: 3px 9px; font-size: 12px; }
.cs-nb { min-height: 32px; padding: 0 11px; font-size: 12.5px; gap: 5px; }
.cs-nb svg { width: 14px; height: 14px; }
.cs-notebar { gap: 6px; }
@media (max-width: 760px) {
  .cs-tool { min-height: 30px; padding: 0 9px; font-size: 12px; }
  .cs-nb { min-height: 32px; padding: 0 9px; font-size: 12px; }
  .site-head-hidden .cs-screen { top: 8px; }
}

/* v9: link to the equation solver */
.cs-chip.cs-chip-go { display: inline-flex; align-items: center; gap: 6px; background: #0C2141; border-color: #0C2141; color: #FFFFFF; text-decoration: none; font-weight: 600; }
.cs-chip.cs-chip-go span { color: #34D399; transition: transform .18s ease; }
.cs-chip.cs-chip-go:hover, .cs-chip.cs-chip-go:focus-visible { background: #15803D; border-color: #15803D; color: #FFFFFF; }
.cs-chip.cs-chip-go:hover span { transform: translateX(3px); color: #FFFFFF; }
.cs-frac a { color: #15803D; font-weight: 700; text-decoration: underline; text-underline-offset: 2px; }
.cs-chip.cs-chip-go { font-family: "DM Sans", system-ui, sans-serif; }
