/* ==========================================================================
   Teen Finance Coach — base layer
   Reset, typography, app shell, and the shared components every page uses.
   Page stylesheets extend this; they should not redefine it.
   ========================================================================== */

*,
*::before,
*::after {
  box-sizing: border-box;
}

/* The browser's own [hidden] rule is display:none at the lowest possible
   priority, so any author `display` beats it. Components here set display
   on .button, .news-banner, .summary-card and others, which left elements
   the scripts had hidden still on screen. Restate it so hidden means hidden. */
[hidden] {
  display: none !important;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100dvh;
  color: var(--text);
  background-color: var(--bg);
  font-family: var(--font-body);
  font-size: var(--text-body);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* The plotted-grid substrate. Every surface in the app sits on a faint
   chart grid, so the whole product reads as something drawn on axes. */
body::before {
  position: fixed;
  z-index: -1;
  inset: 0;
  background-image:
    linear-gradient(var(--grid-line) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-line) 1px, transparent 1px);
  background-size: 64px 64px;
  -webkit-mask-image: radial-gradient(ellipse 120% 80% at 50% 0%, #000 20%, transparent 78%);
  mask-image: radial-gradient(ellipse 120% 80% at 50% 0%, #000 20%, transparent 78%);
  content: "";
  pointer-events: none;
}

h1,
h2,
h3,
h4 {
  margin: 0;
  color: var(--text-strong);
  font-family: var(--font-display);
  font-weight: 600;
  letter-spacing: var(--tracking-tight);
  line-height: 1.15;
}

h1 { font-size: var(--text-h1); }
h2 { font-size: var(--text-h2); }
h3 { font-size: var(--text-h3); }

p {
  margin: 0;
}

a {
  color: var(--accent-text);
  text-decoration-color: var(--accent-line);
  text-underline-offset: 0.2em;
}

a:hover {
  text-decoration-color: currentColor;
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

button,
label,
select,
summary {
  -webkit-tap-highlight-color: transparent;
}

img,
svg {
  display: block;
  max-width: 100%;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

::selection {
  color: var(--text-on-accent);
  background: var(--accent);
}

/* ---------- Typographic roles ------------------------------------------- */

/* The eyebrow labels a region. It is a signpost, so it stays quiet. */
.eyebrow {
  display: block;
  color: var(--text-faint);
  font-family: var(--font-data);
  font-size: var(--text-micro);
  font-weight: 500;
  letter-spacing: var(--tracking-eyebrow);
  text-transform: uppercase;
}

.section-intro,
.helper-text {
  max-width: var(--reading-max);
  color: var(--text-muted);
}

.helper-text {
  font-size: var(--text-small);
}

/* Every figure that represents money, a count, or a percentage.
   Tabular numerals so columns of numbers line up and digits do not
   jitter while they animate. */
.figure,
.money,
[data-odometer],
[data-count-to] {
  font-family: var(--font-data);
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1;
  letter-spacing: -0.01em;
}

.figure-xl {
  display: block;
  color: var(--text-strong);
  font-family: var(--font-data);
  font-size: var(--text-figure);
  font-variant-numeric: tabular-nums;
  font-weight: 500;
  letter-spacing: -0.03em;
  line-height: 1;
}

/* ---------- App shell ---------------------------------------------------- */

.shell {
  width: min(100%, var(--shell-max));
  margin: 0 auto;
  padding: var(--space-5) var(--space-4) var(--space-8);
}

@media (min-width: 48rem) {
  .shell {
    padding: var(--space-6) var(--space-5) var(--space-8);
  }
}

@media (min-width: 90rem) {
  .shell {
    padding-right: var(--space-6);
    padding-left: var(--space-6);
  }
}

/* Pages built from grids of cards can use the extra room; pages built from
   prose keep their reading measure. */
.shell.is-wide {
  width: min(100%, var(--wide-max));
}

.stack {
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
}

/* ---------- Top bar ------------------------------------------------------ */

.topbar {
  position: sticky;
  z-index: 40;
  top: 0;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.topbar-inner {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  width: min(100%, var(--wide-max));
  margin: 0 auto;
  padding: var(--space-3) var(--space-4);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: var(--space-3);
  color: var(--text-strong);
  font-family: var(--font-display);
  font-size: var(--text-body);
  font-weight: 600;
  letter-spacing: var(--tracking-tight);
  text-decoration: none;
}

.brand-mark {
  display: block;
  flex: none;
  width: 1.875rem;
  height: 1.875rem;
  border-radius: var(--radius-sm);
  box-shadow: 0 2px 10px -3px var(--accent-glow);
  transition: transform var(--dur-base) var(--ease-spring);
}

.brand:hover .brand-mark {
  transform: rotate(-6deg) scale(1.06);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-left: auto;
}

.topbar-actions form {
  margin: 0;
}

/* ---------- Page heading ------------------------------------------------- */

.page-heading {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  margin-bottom: var(--space-6);
}

.page-heading h1 {
  text-wrap: balance;
}

/* A hairline that carries a label: used to open a region. */
.rule {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin: var(--space-6) 0 var(--space-4);
  color: var(--text-faint);
}

.rule::after {
  flex: 1;
  height: 1px;
  background: var(--line);
  content: "";
}

/* ---------- Buttons ------------------------------------------------------ */

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: 0.625rem 1.125rem;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-md);
  color: var(--text);
  background: var(--surface-raised);
  font-family: var(--font-body);
  font-size: var(--text-small);
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
  transition:
    background var(--dur-fast) var(--ease-out),
    border-color var(--dur-fast) var(--ease-out),
    color var(--dur-fast) var(--ease-out);
}

.button:hover {
  border-color: var(--line-strong);
  background: var(--surface-hover);
}

/* The accent is a pastel wash. On the light ground its fill sits at about
   1.4:1, so the button needs a deeper edge of its own hue to read as a
   shape rather than a floating label. */
.button.primary {
  border-color: var(--accent-edge);
  color: var(--text-on-accent);
  background: var(--accent);
  box-shadow: var(--shadow-accent);
}

.button.primary:hover {
  background: var(--accent-hover);
}

.button.quiet {
  border-color: transparent;
  background: transparent;
}

.button.quiet:hover {
  background: var(--surface-hover);
}

.button.danger {
  border-color: var(--danger-line);
  color: var(--danger);
  background: var(--danger-fill);
}

.button.full {
  width: 100%;
}

.button:disabled,
.button[aria-disabled="true"] {
  opacity: 0.5;
  cursor: not-allowed;
}

.header-link,
.text-button {
  padding: 0.375rem 0.625rem;
  border: 0;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  background: transparent;
  font-size: var(--text-small);
  text-decoration: none;
  cursor: pointer;
  transition: color var(--dur-fast) var(--ease-out), background var(--dur-fast) var(--ease-out);
}

.header-link:hover,
.text-button:hover {
  color: var(--text);
  background: var(--surface-hover);
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  color: var(--text-muted);
  font-size: var(--text-small);
  text-decoration: none;
}

.back-link:hover {
  color: var(--text);
}

/* ---------- Card --------------------------------------------------------- */

.card {
  position: relative;
  padding: var(--space-5);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

/* One hairline of light on the top edge. Solid surfaces, not glass —
   financial figures need to stay crisp. */
.card::before {
  position: absolute;
  top: 0;
  right: var(--radius-lg);
  left: var(--radius-lg);
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--edge-light), transparent);
  content: "";
  pointer-events: none;
}

.card-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-4);
  margin-bottom: var(--space-4);
}

.card-heading h2,
.card-heading h3 {
  margin-top: var(--space-1);
  font-size: var(--text-h3);
}

.card-link {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  margin-top: var(--space-4);
  color: var(--accent-text);
  font-size: var(--text-small);
  font-weight: 500;
  text-decoration: none;
}

.card-link::after {
  content: "→";
  transition: transform var(--dur-fast) var(--ease-out);
}

.card-link:hover::after {
  transform: translateX(3px);
}

.card-icon {
  display: grid;
  flex: none;
  place-items: center;
  width: 2rem;
  height: 2rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  background: var(--surface-inset);
  font-family: var(--font-data);
  font-size: var(--text-small);
}

/* These sit on tinted cards, and --gold-fill / --accent-fill are the same
   washes the tints are made of — a transparent-bordered chip disappears into
   whichever tint it lands on. They keep the card's own surface and state
   their hue through the border and glyph instead. */
.card-icon.is-gold {
  border-color: var(--gold);
  color: var(--gold);
  background: var(--surface-raised);
}

.card-icon.is-accent {
  border-color: var(--accent-edge);
  color: var(--accent-text);
  background: var(--surface-raised);
}

/* ---------- Grid --------------------------------------------------------- */

/* Card grids rotate through the tint set so a page reads as blocks of
   colour rather than a wall of white panels. The rotation is positional, not
   semantic — it carries no meaning, so nothing depends on which card lands
   on which tint. */
.grid > .card:nth-child(4n + 1),
.course-grid > .card:nth-child(4n + 1) {
  border-color: var(--tint-1-line);
  background: var(--tint-1);
}

.grid > .card:nth-child(4n + 2),
.course-grid > .card:nth-child(4n + 2) {
  border-color: var(--tint-2-line);
  background: var(--tint-2);
}

.grid > .card:nth-child(4n + 3),
.course-grid > .card:nth-child(4n + 3) {
  border-color: var(--tint-3-line);
  background: var(--tint-3);
}

.grid > .card:nth-child(4n + 4),
.course-grid > .card:nth-child(4n + 4) {
  border-color: var(--tint-4-line);
  background: var(--tint-4);
}

.grid {
  display: grid;
  gap: var(--space-4);
  grid-template-columns: 1fr;
}

@media (min-width: 40rem) {
  .grid.cols-2,
  .grid.cols-3 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (min-width: 64rem) {
  .grid.cols-3 {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .grid.cols-4 {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

@media (min-width: 40rem) {
  .grid.cols-4 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

/* ---------- Stat --------------------------------------------------------- */

.stat-label {
  display: block;
  margin-bottom: var(--space-1);
  color: var(--text-muted);
  font-size: var(--text-small);
}

.stat-value {
  display: block;
  color: var(--text-strong);
  font-family: var(--font-data);
  font-size: var(--text-h2);
  font-variant-numeric: tabular-nums;
  font-weight: 500;
  letter-spacing: -0.02em;
}

/* ---------- Delta: direction of a number --------------------------------- */

.delta {
  display: inline-flex;
  align-items: center;
  gap: 0.3em;
  padding: 0.1875rem 0.5rem;
  border-radius: var(--radius-sm);
  font-family: var(--font-data);
  font-size: var(--text-caption);
  font-variant-numeric: tabular-nums;
  font-weight: 500;
}

.delta.is-up {
  color: var(--up);
  background: var(--up-fill);
}

.delta.is-down {
  color: var(--down);
  background: var(--down-fill);
}

.delta.is-flat {
  color: var(--text-muted);
  background: var(--surface-inset);
}

.delta.is-up::before { content: "▲"; font-size: 0.7em; }
.delta.is-down::before { content: "▼"; font-size: 0.7em; }

/* ---------- Progress ----------------------------------------------------- */

.progress-track {
  overflow: hidden;
  height: 6px;
  border-radius: var(--radius-pill);
  background: var(--surface-inset);
}

.progress-fill {
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
  transform-origin: left center;
}

.progress-fill.is-gold {
  background: var(--gold-bright);
}

.progress-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-3);
  margin-bottom: var(--space-2);
  color: var(--text-muted);
  font-size: var(--text-small);
}

.progress-row strong {
  color: var(--text);
  font-family: var(--font-data);
  font-variant-numeric: tabular-nums;
}

/* ---------- Chip / badge ------------------------------------------------- */

.chip {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: 0.25rem 0.625rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  color: var(--text-muted);
  background: var(--surface-inset);
  font-size: var(--text-caption);
  white-space: nowrap;
}

.chip.is-accent {
  border-color: var(--accent-line);
  color: var(--accent-text);
  background: var(--accent-fill);
}

.chip.is-gold {
  border-color: transparent;
  color: var(--gold);
  background: var(--gold-fill);
}

/* ---------- Forms -------------------------------------------------------- */

.field {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.field > label,
.field-label {
  color: var(--text);
  font-size: var(--text-small);
  font-weight: 500;
}

.field-hint {
  color: var(--text-faint);
  font-size: var(--text-caption);
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="date"],
input[type="search"],
select,
textarea {
  width: 100%;
  padding: 0.625rem 0.75rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  color: var(--text);
  background: var(--surface-inset);
  font-size: var(--text-body);
  transition: border-color var(--dur-fast) var(--ease-out), box-shadow var(--dur-fast) var(--ease-out);
}

input[type="number"],
input[inputmode="decimal"],
input[inputmode="numeric"] {
  font-family: var(--font-data);
  font-variant-numeric: tabular-nums;
}

/* Spinners crowd a currency field and nobody nudges money a cent at a time. */
input[type="number"] {
  appearance: textfield;
  -moz-appearance: textfield;
}

input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
  margin: 0;
  appearance: none;
  -webkit-appearance: none;
}

input[type="date"] {
  font-family: var(--font-data);
  font-variant-numeric: tabular-nums;
}

input::placeholder,
textarea::placeholder {
  color: var(--text-faint);
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-fill);
}

textarea {
  min-height: 6rem;
  resize: vertical;
}

fieldset {
  margin: 0;
  padding: 0;
  border: 0;
}

legend {
  padding: 0;
  color: var(--text-strong);
  font-family: var(--font-display);
  font-size: var(--text-h3);
  font-weight: 600;
}

/* ---------- Messages ----------------------------------------------------- */

.notice {
  display: flex;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--line);
  border-left: 3px solid var(--text-faint);
  border-radius: var(--radius-md);
  color: var(--text-muted);
  background: var(--surface-inset);
  font-size: var(--text-small);
}

.notice.is-error {
  border-color: var(--danger-line);
  border-left-color: var(--danger);
  color: var(--danger);
  background: var(--danger-fill);
}

.notice.is-accent {
  border-color: var(--accent-line);
  border-left-color: var(--accent);
  color: var(--accent-text);
  background: var(--accent-fill);
}

.empty-state {
  padding: var(--space-6) var(--space-4);
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius-lg);
  color: var(--text-muted);
  background: var(--surface-inset);
  text-align: center;
}

.empty-state h3 {
  margin-bottom: var(--space-2);
}

/* ---------- Dialog ------------------------------------------------------- */

dialog {
  width: min(32rem, calc(100vw - 2rem));
  padding: var(--space-5);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  color: var(--text);
  background: var(--surface-raised);
  box-shadow: var(--shadow-lg);
}

dialog::backdrop {
  background: rgba(4, 7, 14, 0.62);
  backdrop-filter: blur(3px);
}

.dialog-close {
  position: absolute;
  top: var(--space-3);
  right: var(--space-3);
  padding: var(--space-2);
  border: 0;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  background: transparent;
  cursor: pointer;
}

.dialog-close:hover {
  color: var(--text);
  background: var(--surface-hover);
}

/* ---------- Motion hooks ------------------------------------------------- */

/* Elements the motion engine will reveal start hidden, but only when
   scripting is available and motion is welcome — otherwise content must
   never be invisible. */
html.js-motion [data-reveal] {
  opacity: 0;
}

.sr-only {
  position: absolute;
  overflow: hidden;
  clip-path: inset(50%);
  width: 1px;
  height: 1px;
  white-space: nowrap;
}

/* ---------- Odometer -----------------------------------------------------

   The signature figure treatment. Digits live in fixed-width columns and
   roll into place; the currency symbol and separators never move.
   ------------------------------------------------------------------------ */

[data-odometer] {
  display: inline-flex;
  align-items: baseline;
}

.odo-visual {
  display: inline-flex;
  align-items: stretch;
  height: 1em;
}

.odo-col {
  display: inline-block;
  overflow: hidden;
  height: 1em;
  line-height: 1;
}

.odo-strip {
  display: block;
  will-change: transform;
}

.odo-cell {
  display: block;
  height: 1em;
  line-height: 1;
  text-align: center;
}

.odo-fixed {
  display: inline-block;
  line-height: 1;
}

/* ---------- Toast -------------------------------------------------------- */

.toast-host {
  position: fixed;
  z-index: 80;
  right: var(--space-4);
  bottom: 6.5rem;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  pointer-events: none;
}

.toast {
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  color: var(--text);
  background: var(--surface-raised);
  box-shadow: var(--shadow-lg);
  font-size: var(--text-small);
}

.toast.is-gold {
  border-color: var(--gold);
  color: var(--gold);
  background: var(--gold-fill);
}

.toast.is-error {
  border-color: var(--danger-line);
  color: var(--danger);
  background: var(--danger-fill);
}

/* ---------- Shared form primitives ---------------------------------------

   These names are also produced at runtime by money.js and trading.js, so
   they live in the shared layer rather than in any one page stylesheet.
   ------------------------------------------------------------------------ */

.button.secondary {
  /* Same treatment as a plain button; the name reads clearly at the call site. */
  border-color: var(--line-strong);
  color: var(--text);
  background: var(--surface-raised);
}

.button.full-width {
  width: 100%;
  padding-top: 0.75rem;
  padding-bottom: 0.75rem;
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  justify-content: flex-end;
}

.field-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  min-width: 0;
}

.field-group > label {
  color: var(--text);
  font-size: var(--text-small);
  font-weight: 500;
  line-height: 1.4;
}

.optional {
  color: var(--text-faint);
  font-weight: 400;
}

.form-grid {
  display: grid;
  gap: var(--space-4);
  grid-template-columns: 1fr;
}

@media (min-width: 34rem) {
  .form-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

form {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

/* Rows of fields line up on a shared baseline. */
.form-grid > .field-group {
  align-self: start;
}

/* Native selects vary too much across platforms to style directly, so the
   chevron is drawn by the shell and the select itself is transparent. */
.select-shell {
  position: relative;
  display: flex;
  align-items: center;
}

.select-shell select {
  appearance: none;
  padding-right: 2.25rem;
}

.select-shell > span {
  position: absolute;
  right: 0.75rem;
  color: var(--text-faint);
  pointer-events: none;
}

/* The currency symbol sits inside the field so the figure reads as money. */
.money-input {
  position: relative;
  display: flex;
  align-items: center;
}

.money-input > span {
  position: absolute;
  left: 0.75rem;
  color: var(--text-faint);
  font-family: var(--font-data);
  pointer-events: none;
}

.money-input input {
  padding-left: 1.75rem;
}

.form-message {
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-sm);
  color: var(--danger);
  background: var(--danger-fill);
  font-size: var(--text-small);
}

.form-message.is-success {
  color: var(--up);
  background: var(--up-fill);
}

.section-heading {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-3);
  margin-bottom: var(--space-4);
}

.section-heading h2,
.section-heading h3 {
  margin-top: var(--space-1);
  font-size: var(--text-h3);
}

.inline-form {
  padding-top: var(--space-4);
  border-top: 1px solid var(--line);
}

.placeholder-message h1 {
  margin: var(--space-2) 0;
}

/* ---------- Icon buttons ------------------------------------------------- */

.icon-button {
  display: grid;
  place-items: center;
  width: 2.25rem;
  height: 2.25rem;
  padding: 0;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  color: var(--text-muted);
  background: transparent;
  cursor: pointer;
  transition:
    color var(--dur-fast) var(--ease-out),
    border-color var(--dur-fast) var(--ease-out),
    background var(--dur-fast) var(--ease-out);
}

.icon-button svg {
  width: 1.125rem;
  height: 1.125rem;
}

.icon-button:hover {
  border-color: var(--line);
  color: var(--text);
  background: var(--surface-hover);
}

.icon-button[aria-expanded="true"] {
  border-color: var(--accent-line);
  color: var(--accent-text);
  background: var(--accent-fill);
}

/* ---------- Theme toggle ------------------------------------------------- */

.theme-icon {
  display: grid;
  flex: none;
  place-items: center;
  width: 1rem;
  height: 1rem;
}

.theme-icon > svg {
  grid-area: 1 / 1;
  width: 100%;
  height: 100%;
}

.theme-toggle .icon-moon { display: none; }
.theme-toggle .icon-sun { display: block; }

html[data-theme="dark"] .theme-toggle .icon-sun { display: block; }
html[data-theme="dark"] .theme-toggle .icon-moon { display: none; }

html[data-theme="light"] .theme-toggle .icon-sun { display: none; }
html[data-theme="light"] .theme-toggle .icon-moon { display: block; }

/* ---------- Settings menu ------------------------------------------------ */

.settings-menu {
  position: relative;
}

.settings-panel {
  position: absolute;
  z-index: 70;
  top: calc(100% + var(--space-2));
  right: 0;
  width: min(18rem, calc(100vw - 2rem));
  min-width: 14rem;
  padding: var(--space-2);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-lg);
  background:
    linear-gradient(145deg, var(--edge-light), transparent 42%),
    color-mix(in srgb, var(--surface-raised) 94%, transparent);
  box-shadow:
    var(--shadow-lg),
    inset 0 1px 0 var(--edge-light);
  backdrop-filter: blur(18px) saturate(135%);
  -webkit-backdrop-filter: blur(18px) saturate(135%);
  transform-origin: top right;
  will-change: opacity, transform;
}

.settings-panel[hidden] {
  display: none;
}

.settings-panel form {
  margin: 0;
}

.settings-label {
  padding: var(--space-2) var(--space-3) var(--space-1);
  /* A second group heading needs a rule above it to read as a divider. */
  color: var(--text-faint);
  font-family: var(--font-data);
  font-size: var(--text-micro);
  letter-spacing: var(--tracking-eyebrow);
  text-transform: uppercase;
}

.settings-label + .settings-item {
  margin-bottom: var(--space-1);
}

.settings-item ~ .settings-label,
form + .settings-label {
  margin-top: var(--space-2);
  padding-top: var(--space-3);
  border-top: 1px solid var(--line);
}

.settings-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  width: 100%;
  padding: var(--space-2) var(--space-3);
  border: 0;
  border-radius: var(--radius-sm);
  color: var(--text);
  background: transparent;
  font-size: var(--text-small);
  text-align: left;
  text-decoration: none;
  cursor: pointer;
  transition:
    color var(--dur-fast) var(--ease-out),
    background var(--dur-fast) var(--ease-out),
    transform var(--dur-fast) var(--ease-out);
}

.settings-item svg {
  flex: none;
  width: 1rem;
  height: 1rem;
  color: var(--text-faint);
  transition: color var(--dur-fast) var(--ease-out);
}

.settings-item:hover {
  background: var(--surface-hover);
  transform: translateX(2px);
}

.settings-item:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

.settings-item:hover svg {
  color: var(--accent-text);
}

.settings-item.is-danger:hover {
  color: var(--danger);
  background: var(--danger-fill);
}

.settings-item.is-danger:hover svg {
  color: var(--danger);
}

/* ---------- Secret achievement guide -------------------------------------

   A small mark in the corner. Before the code is entered it opens a keypad;
   afterwards it links straight to the guide.
   ------------------------------------------------------------------------ */

.settings-footer {
  display: flex;
  justify-content: flex-end;
  padding: var(--space-1) var(--space-1) 0;
}

.secret-mark {
  display: grid;
  width: 1.5rem;
  height: 1.5rem;
  padding: 0;
  place-items: center;
  border: 0;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  background: transparent;
  font-family: var(--font-data);
  font-size: var(--text-small);
  font-weight: 600;
  line-height: 1;
  text-decoration: none;
  cursor: pointer;
  opacity: 0.75;
  transition: opacity var(--dur-fast) var(--ease-out), color var(--dur-fast) var(--ease-out),
    background var(--dur-fast) var(--ease-out);
}

.secret-mark:hover,
.secret-mark:focus-visible {
  color: var(--accent-text);
  background: var(--surface-hover);
  opacity: 1;
}

.secret-keypad-dialog {
  width: min(20rem, calc(100vw - 2rem));
  text-align: center;
}

.secret-keypad-dialog::backdrop {
  animation: secret-backdrop-in var(--dur-base) var(--ease-out) both;
}

@keyframes secret-backdrop-in {
  from {
    background: rgba(4, 7, 14, 0);
    backdrop-filter: blur(0);
  }
}

.secret-keypad-dialog h2 {
  margin-top: var(--space-1);
}

.keypad-readout {
  display: flex;
  gap: var(--space-3);
  justify-content: center;
  margin: var(--space-4) 0;
}

.keypad-dot {
  width: 0.75rem;
  height: 0.75rem;
  border: 1px solid var(--line-strong);
  border-radius: 50%;
  background: transparent;
  transition: background var(--dur-fast) var(--ease-out), border-color var(--dur-fast) var(--ease-out);
}

.keypad-dot.is-filled {
  border-color: var(--accent);
  background: var(--accent);
}

.keypad-grid {
  display: grid;
  gap: var(--space-2);
  grid-template-columns: repeat(3, 1fr);
}

.keypad-key {
  padding: var(--space-3) 0;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  color: var(--text-strong);
  background: var(--surface-inset);
  font-family: var(--font-data);
  font-size: var(--text-h3);
  font-variant-numeric: tabular-nums;
  cursor: pointer;
  transition: background var(--dur-fast) var(--ease-out), border-color var(--dur-fast) var(--ease-out);
}

.keypad-key:hover {
  border-color: var(--accent-line);
  background: var(--surface-hover);
}

.keypad-key:active {
  background: var(--accent-fill);
}

.keypad-key.is-muted {
  color: var(--text-muted);
  font-size: var(--text-body);
}

.secret-keypad-dialog .form-message {
  margin-top: var(--space-4);
}

/* The whole dialog shakes once when a code is refused. */
.secret-keypad-dialog.is-refused {
  animation: keypad-refuse 320ms var(--ease-out);
}

@keyframes keypad-refuse {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-0.5rem); }
  45% { transform: translateX(0.4rem); }
  70% { transform: translateX(-0.25rem); }
}

/* ---------- Disclaimers --------------------------------------------------

   Any page showing information from outside the app explains itself the
   same way: a first-visit dialog, an optional pinned banner, and a chip
   that reopens the notice.
   ------------------------------------------------------------------------ */

.disclaimer-chip {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: 0.4375rem 0.75rem;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-md);
  color: var(--text-muted);
  background: var(--surface-raised);
  font-size: var(--text-small);
  cursor: pointer;
  transition:
    color var(--dur-fast) var(--ease-out),
    border-color var(--dur-fast) var(--ease-out),
    background var(--dur-fast) var(--ease-out);
}

.disclaimer-chip:hover {
  border-color: var(--accent-line);
  color: var(--accent-text);
  background: var(--accent-fill);
}

.trading-disclaimer,
.news-banner {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-3);
  margin-bottom: var(--space-5);
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius-md);
  color: var(--text-muted);
  background: var(--surface-inset);
  font-size: var(--text-small);
}

.disclaimer-dialog {
  width: min(30rem, calc(100vw - 2rem));
}

.dialog-icon {
  margin-bottom: var(--space-2);
  color: var(--accent-text);
  font-family: var(--font-data);
  font-size: var(--text-h2);
}

.dialog-text {
  margin: var(--space-3) 0 var(--space-5);
  color: var(--text-muted);
  font-size: var(--text-small);
}

.dialog-actions {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

/* ==========================================================================
   Interaction
   Hover and focus states for everything that responds to a pointer. Motion
   here is short and small — these fire constantly, so they must never get
   in the way of reading a number.
   ========================================================================== */

.card {
  transition:
    border-color var(--dur-base) var(--ease-out),
    background var(--dur-base) var(--ease-out),
    box-shadow var(--dur-base) var(--ease-out),
    transform var(--dur-base) var(--ease-out);
}

/* Cards that lead somewhere lift; cards that only report a number do not,
   so movement always means "this is clickable". */
.card:has(.card-link):hover,
.card:has(a[href]):hover,
a.card:hover {
  border-color: var(--line-strong);
  background: var(--surface-raised);
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

/* The pointer lights up the card's edge rather than washing over its face,
   so the effect never sits between you and a number. */
.card::after {
  position: absolute;
  inset: 0;
  padding: 1px;
  border-radius: inherit;
  background: radial-gradient(
    14rem circle at var(--pointer-x, 50%) var(--pointer-y, 0%),
    var(--accent),
    transparent 65%
  );
  content: "";
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--dur-slow) var(--ease-out);
  -webkit-mask:
    linear-gradient(#000 0 0) content-box,
    linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask:
    linear-gradient(#000 0 0) content-box,
    linear-gradient(#000 0 0);
  mask-composite: exclude;
}

.card.is-tracking::after {
  opacity: 0.9;
}


.button {
  position: relative;
  overflow: hidden;
  transition:
    background var(--dur-fast) var(--ease-out),
    border-color var(--dur-fast) var(--ease-out),
    color var(--dur-fast) var(--ease-out),
    box-shadow var(--dur-fast) var(--ease-out),
    transform var(--dur-fast) var(--ease-out);
}

.button:hover {
  transform: translateY(-1px);
}

.button:active {
  transform: translateY(0);
}

.button.primary:hover {
  box-shadow: 0 10px 30px -8px var(--accent-glow);
}

/* A light sweep across the primary action on hover. */
.button.primary::after {
  position: absolute;
  top: 0;
  bottom: 0;
  left: -60%;
  width: 40%;
  background: linear-gradient(
    100deg,
    transparent,
    color-mix(in srgb, var(--text-on-accent) 22%, transparent),
    transparent
  );
  content: "";
  pointer-events: none;
  transform: skewX(-18deg);
  transition: left var(--dur-slow) var(--ease-out);
}

.button.primary:hover::after {
  left: 120%;
}

.stat-value,
.figure-xl {
  transition: color var(--dur-base) var(--ease-out);
}

.chip {
  transition:
    color var(--dur-fast) var(--ease-out),
    border-color var(--dur-fast) var(--ease-out),
    background var(--dur-fast) var(--ease-out),
    transform var(--dur-fast) var(--ease-out);
}

a.chip:hover {
  border-color: var(--accent-line);
  color: var(--accent-text);
  background: var(--accent-fill);
  transform: translateY(-1px);
}

.card-icon {
  transition:
    color var(--dur-base) var(--ease-out),
    border-color var(--dur-base) var(--ease-out),
    background var(--dur-base) var(--ease-out),
    transform var(--dur-base) var(--ease-spring);
}

.card:hover .card-icon {
  transform: rotate(-6deg) scale(1.1);
}

.progress-track {
  transition: background var(--dur-fast) var(--ease-out);
}

.card:hover .progress-fill {
  filter: brightness(1.12);
}

.progress-fill {
  transition: filter var(--dur-base) var(--ease-out);
}

.notice,
.empty-state {
  transition: border-color var(--dur-base) var(--ease-out), background var(--dur-base) var(--ease-out);
}

.empty-state:hover {
  border-color: var(--accent-line);
}

/* Rows in a list highlight edge to edge, so the whole row reads as one
   target rather than just the text in it. */
.transaction-item,
.holding-item,
.trade-item,
.leaderboard-item,
.review-list a {
  position: relative;
  transition: background var(--dur-fast) var(--ease-out);
}

.transaction-item:hover,
.holding-item:hover,
.trade-item:hover,
.leaderboard-item:hover,
.review-list a:hover {
  background: var(--surface-hover);
  box-shadow: 0 0 0 var(--space-3) var(--surface-hover);
}

input,
select,
textarea {
  transition:
    border-color var(--dur-fast) var(--ease-out),
    background var(--dur-fast) var(--ease-out),
    box-shadow var(--dur-fast) var(--ease-out);
}

input:hover:not(:focus),
select:hover:not(:focus),
textarea:hover:not(:focus) {
  border-color: var(--line-strong);
}

@media (prefers-reduced-motion: reduce) {

  .secret-keypad-dialog::backdrop,
  .secret-keypad-dialog.is-refused {
    animation: none;
  }
  .card:hover,
  .button:hover,
  a.chip:hover {
    transform: none;
  }

  .card:hover .card-icon {
    transform: none;
  }

  .button.primary::after {
    display: none;
  }

  .card::after {
    display: none;
  }
}
