/* ==========================================================================
   skin.css - "ChessRecaps" visual skin (owner: C25). Loads AFTER css/app.css.
   Warm-charcoal game-app look (dark default) + matching light mode, with
   our own twist: violet XP accent, per-tab accent colours, glowing hero
   cards, glassy chips and tactile 3D buttons. Rules: see DESIGN.md.
   Only tokens + generic component classes live here; tab modules keep
   their own prefixed CSS and should consume these tokens/classes.
   ========================================================================== */
/* Nunito is loaded by index.html (non-blocking, optional); --font below falls back to the system rounded font. */

/* ------------------------------------------------------------ dark (default)
   Selector trio = equal-or-higher specificity than every app.css token block,
   so the skin always wins regardless of system scheme / manual toggle.       */
:root,
:root[data-theme="dark"],
:root:not([data-theme="light"]),
[data-theme="dark"] {
  /* surfaces: warm charcoal, lighter = higher */
  --bg: #302e2b;
  --bg-deep: #262421;            /* nav rail, tab bar */
  --well: #262421;               /* recessed tracks: segmented, subtabs, bars */
  --bg-glow-1: rgba(129, 182, 76, .09);
  --bg-glow-2: rgba(164, 123, 255, .10);
  --surface: #3b3835;
  --surface-2: #46423e;
  --surface-3: #534e49;
  --surface-glass: rgba(255, 255, 255, .07);
  --text: #ffffff;
  --text-2: #c2bdb6;
  --text-3: #8f8982;
  --border: rgba(255, 255, 255, .07);
  --border-strong: rgba(255, 255, 255, .14);
  --edge: rgba(0, 0, 0, .32);    /* the darker "lip" under raised things */
  --btn-2-bg: #57524c;           /* secondary button face / lip */
  --btn-2-edge: #2a2724;

  /* brand + status */
  --accent: #81b64c;
  --accent-2: #9ccf63;
  --accent-deep: #45753c;
  --accent-ink: #ffffff;
  --accent-text: #9ccf63;        /* accent used AS text on surfaces */
  --accent-soft: rgba(129, 182, 76, .18);
  --good: #81b64c;
  --bad: #f0584b;
  --warn: #f7c045;
  --info: #5fa8ff;
  --gold: #ffc23d;
  --gold-deep: #c98a12;
  --purple: #a47bff;

  /* our twist: XP violet */
  --xp: #a47bff;
  --xp-2: #c3a6ff;
  --xp-deep: #6c45e0;
  --xp-soft: rgba(164, 123, 255, .18);
  --xp-ink: #ffffff;

  /* per-tab accents */
  --c-openings: #81b64c;   --c-openings-deep: #45753c;
  --c-middlegame: #ff7a45; --c-middlegame-deep: #b8461c;
  --c-endgame: #34c3e6;    --c-endgame-deep: #13809c;
  --c-profile: #a47bff;    --c-profile-deep: #6c45e0;

  --shadow-1: 0 1px 0 rgba(255, 255, 255, .04) inset, 0 2px 0 rgba(0, 0, 0, .18), 0 4px 14px rgba(0, 0, 0, .18);
  --shadow-2: 0 14px 34px rgba(0, 0, 0, .40), 0 3px 8px rgba(0, 0, 0, .28);
  --shadow-3: 0 26px 70px rgba(0, 0, 0, .58);
  --hero-ink: #ffffff;
  color-scheme: dark;
}

/* ------------------------------------------------------------ light */
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg: #f2efe9; --bg-deep: #ffffff; --well: #ebe7e0;
    --bg-glow-1: rgba(129, 182, 76, .14); --bg-glow-2: rgba(124, 77, 255, .08);
    --surface: #ffffff; --surface-2: #f4f1ec; --surface-3: #e6e1d9; --surface-glass: rgba(255, 255, 255, .6);
    --text: #262421; --text-2: #69635c; --text-3: #9b958d;
    --border: rgba(38, 36, 33, .08); --border-strong: rgba(38, 36, 33, .15); --edge: rgba(38, 36, 33, .14); --btn-2-bg: #ffffff; --btn-2-edge: #d6d0c6;
    --accent: #7cb147; --accent-2: #91c65a; --accent-deep: #4b7d33; --accent-ink: #ffffff; --accent-text: #4b8a26; --accent-soft: rgba(124, 177, 71, .16);
    --good: #5f9d2f; --bad: #dc3d31; --warn: #d18f0b; --info: #2f78e0; --gold: #f5b021; --gold-deep: #b97a06; --purple: #7c4dff;
    --xp: #7c4dff; --xp-2: #9d78ff; --xp-deep: #5631d1; --xp-soft: rgba(124, 77, 255, .12); --xp-ink: #ffffff;
    --c-openings: #6fa83c; --c-openings-deep: #4b7d33;
    --c-middlegame: #f2652d; --c-middlegame-deep: #b8461c;
    --c-endgame: #1aa7cc; --c-endgame-deep: #0f7591;
    --c-profile: #7c4dff; --c-profile-deep: #5631d1;
    --shadow-1: 0 1px 0 rgba(38, 36, 33, .04), 0 2px 0 rgba(38, 36, 33, .05), 0 6px 18px rgba(38, 36, 33, .06);
    --shadow-2: 0 14px 34px rgba(38, 36, 33, .12), 0 3px 8px rgba(38, 36, 33, .06);
    --shadow-3: 0 26px 70px rgba(38, 36, 33, .22);
    color-scheme: light;
  }
}
:root[data-theme="light"],
[data-theme="light"] {
  --bg: #f2efe9; --bg-deep: #ffffff; --well: #ebe7e0;
  --bg-glow-1: rgba(129, 182, 76, .14); --bg-glow-2: rgba(124, 77, 255, .08);
  --surface: #ffffff; --surface-2: #f4f1ec; --surface-3: #e6e1d9; --surface-glass: rgba(255, 255, 255, .6);
  --text: #262421; --text-2: #69635c; --text-3: #9b958d;
  --border: rgba(38, 36, 33, .08); --border-strong: rgba(38, 36, 33, .15); --edge: rgba(38, 36, 33, .14); --btn-2-bg: #ffffff; --btn-2-edge: #d6d0c6;
  --accent: #7cb147; --accent-2: #91c65a; --accent-deep: #4b7d33; --accent-ink: #ffffff; --accent-text: #4b8a26; --accent-soft: rgba(124, 177, 71, .16);
  --good: #5f9d2f; --bad: #dc3d31; --warn: #d18f0b; --info: #2f78e0; --gold: #f5b021; --gold-deep: #b97a06; --purple: #7c4dff;
  --xp: #7c4dff; --xp-2: #9d78ff; --xp-deep: #5631d1; --xp-soft: rgba(124, 77, 255, .12); --xp-ink: #ffffff;
  --c-openings: #6fa83c; --c-openings-deep: #4b7d33;
  --c-middlegame: #f2652d; --c-middlegame-deep: #b8461c;
  --c-endgame: #1aa7cc; --c-endgame-deep: #0f7591;
  --c-profile: #7c4dff; --c-profile-deep: #5631d1;
  --shadow-1: 0 1px 0 rgba(38, 36, 33, .04), 0 2px 0 rgba(38, 36, 33, .05), 0 6px 18px rgba(38, 36, 33, .06);
  --shadow-2: 0 14px 34px rgba(38, 36, 33, .12), 0 3px 8px rgba(38, 36, 33, .06);
  --shadow-3: 0 26px 70px rgba(38, 36, 33, .22);
  color-scheme: light;
}

/* ------------------------------------------------------------ scheme-independent tokens */
:root {
  --font: "Nunito", ui-rounded, system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --radius: 16px;
  --radius-sm: 12px;
  --radius-xs: 8px;
  --radius-lg: 22px;
  --radius-pill: 999px;
  /* spacing (4px grid) */
  --sp-1: 4px; --sp-2: 8px; --sp-3: 12px; --sp-4: 16px; --sp-5: 20px; --sp-6: 24px; --sp-7: 32px; --sp-8: 40px;
  /* type scale */
  --fs-xs: 12px; --fs-sm: 13.5px; --fs-base: 15.5px; --fs-md: 18px; --fs-lg: 22px; --fs-xl: 28px; --fs-2xl: 36px; --fs-display: 48px;
  --fw-body: 600; --fw-strong: 800; --fw-heavy: 900;
  /* 3D press depth */
  --press: 4px;
  --ease: cubic-bezier(.2, .8, .2, 1);
  --spring: cubic-bezier(.34, 1.56, .64, 1);
  /* default tab accent (overridden per tab below) */
  --tab-accent: var(--accent);
  --tab-accent-deep: var(--accent-deep);
}

/* per-tab accent scopes: the panel, its nav item, or any [data-accent] wrapper */
#panel-openings, [data-accent="openings"], .app-nav-item[data-tab="openings"] { --tab-accent: var(--c-openings); --tab-accent-deep: var(--c-openings-deep); }
#panel-middlegame, [data-accent="middlegame"], .app-nav-item[data-tab="middlegame"] { --tab-accent: var(--c-middlegame); --tab-accent-deep: var(--c-middlegame-deep); }
#panel-endgame, [data-accent="endgame"], .app-nav-item[data-tab="endgame"] { --tab-accent: var(--c-endgame); --tab-accent-deep: var(--c-endgame-deep); }
#panel-profile, [data-accent="profile"], .app-nav-item[data-tab="profile"] { --tab-accent: var(--c-profile); --tab-accent-deep: var(--c-profile-deep); }
/* C82 Home: the brand green (the hero) with a violet glow; area cards inside it carry their own tab colour via data-accent */
#panel-home, [data-accent="home"], .app-nav-item[data-tab="home"] { --tab-accent: var(--accent); --tab-accent-deep: var(--accent-deep); }
[data-accent], #panel-home, #panel-openings, #panel-middlegame, #panel-endgame, #panel-profile, .app-nav-item[data-tab] {
  --tab-accent-soft: color-mix(in srgb, var(--tab-accent) 18%, transparent);
}

/* ------------------------------------------------------------ base */
body {
  background-color: var(--bg);
  background-image:
    radial-gradient(900px 480px at 0% -10%, var(--bg-glow-1), transparent 60%),
    radial-gradient(800px 480px at 110% 0%, var(--bg-glow-2), transparent 60%);
  color: var(--text);
  font-family: var(--font);
  font-weight: var(--fw-body);
}
a { color: var(--accent-text); }
h1, h2, h3, h4 { font-weight: var(--fw-heavy); letter-spacing: -.015em; }
::selection { background: color-mix(in srgb, var(--xp) 40%, transparent); }
:focus-visible { outline: 3px solid color-mix(in srgb, var(--tab-accent, var(--accent)) 75%, transparent); outline-offset: 2px; }

/* type helpers */
.t-display { font-size: clamp(34px, 9vw, var(--fs-display)); font-weight: var(--fw-heavy); line-height: 1.02; letter-spacing: -.03em; }
.t-h1 { font-size: clamp(26px, 6.4vw, var(--fs-2xl)); font-weight: var(--fw-heavy); line-height: 1.08; letter-spacing: -.02em; }
.t-h2 { font-size: var(--fs-lg); font-weight: var(--fw-heavy); line-height: 1.15; }
.t-h3 { font-size: var(--fs-md); font-weight: var(--fw-strong); line-height: 1.2; }
.t-body { font-size: var(--fs-base); font-weight: var(--fw-body); }
.t-small { font-size: var(--fs-sm); font-weight: 700; color: var(--text-2); }
.t-eyebrow { font-size: var(--fs-xs); font-weight: var(--fw-heavy); letter-spacing: .09em; text-transform: uppercase; color: var(--text-2); }
.t-num { font-weight: var(--fw-heavy); font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.text-xp { color: var(--xp); }
.text-accent { color: var(--accent-text); }

/* ------------------------------------------------------------ brand */
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--text); text-decoration: none; }
.brand-mark { flex: none; width: 36px; height: 36px; display: block; border-radius: 11px; box-shadow: 0 3px 0 var(--edge); }
.brand-wordmark { font-weight: var(--fw-heavy); font-size: 21px; letter-spacing: -.03em; line-height: 1; }
.brand-wordmark b {
  font-weight: inherit;
  background: linear-gradient(100deg, var(--accent-2), var(--xp) 85%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}

/* The shell renders a glyph inside .app-logo/.boot-logo; the skin swaps in our mark (C114: the ChessRecaps mark = a rook inside a replay arrow, same as assets/logo.svg). */
.app-logo, .boot-logo {
  font-size: 0 !important; color: transparent !important;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 64 64'%3E%3Cdefs%3E%3ClinearGradient id='t' x1='0' y1='0' x2='1' y2='1'%3E%3Cstop offset='0' stop-color='%233a3632'/%3E%3Cstop offset='1' stop-color='%231f1d1b'/%3E%3C/linearGradient%3E%3ClinearGradient id='r' x1='0' y1='0' x2='0' y2='1'%3E%3Cstop offset='0' stop-color='%23a6da6e'/%3E%3Cstop offset='1' stop-color='%236fa83c'/%3E%3C/linearGradient%3E%3C/defs%3E%3Crect width='64' height='64' rx='16' fill='url(%23t)'/%3E%3Cpath d='M19.4 14A22 22 0 1 0 44.6 14' fill='none' stroke='%23ffc23d' stroke-width='4.5' stroke-linecap='round'/%3E%3Cpath d='M48.1 9.1L41.2 18.9L38.9 10Z' fill='%23ffc23d' stroke='%23ffc23d' stroke-width='2' stroke-linejoin='round'/%3E%3Cg transform='translate(32 33) scale(.58) translate(-32 -33.5)'%3E%3Cpath d='M18 14H24V19H28V14H36V19H40V14H46V24L42 28V42L46 46H18L22 42V28L18 24Z' fill='url(%23r)' stroke='url(%23r)' stroke-width='2' stroke-linejoin='round'/%3E%3Cpath d='M23 28H41' stroke='%231f1d1b' stroke-opacity='.35' stroke-width='2' stroke-linecap='round'/%3E%3Crect x='15' y='47' width='34' height='6' rx='3' fill='%236fa83c'/%3E%3C/g%3E%3C/svg%3E") center / cover no-repeat !important;
  box-shadow: 0 3px 0 var(--edge), 0 6px 16px rgba(0, 0, 0, .18) !important;
}
.boot-logo { box-shadow: 0 6px 0 var(--edge), var(--shadow-2) !important; }

/* ------------------------------------------------------------ shell chrome (visual only) */
.app-topbar { background: color-mix(in srgb, var(--bg-deep) 88%, transparent); border-bottom-color: var(--border); }
.app-brand-name { font-weight: var(--fw-heavy); letter-spacing: -.03em; }
.app-iconbtn, .app-userchip { background: var(--surface); border-color: var(--border); box-shadow: 0 2px 0 var(--edge); }
.app-iconbtn:hover { background: var(--surface-2); }
.app-nav {
  background: color-mix(in srgb, var(--bg-deep) 94%, transparent);
  border-top-color: var(--border);
  box-shadow: 0 -10px 30px rgba(0, 0, 0, .14);
}
.app-nav-item { color: var(--text-3); font-weight: var(--fw-heavy); }
.app-nav-item:hover { color: var(--text); }
.app-nav-item[aria-current="page"] { color: var(--tab-accent); }
.app-nav-item[aria-current="page"] .app-nav-ico svg { stroke-width: 2.4; filter: drop-shadow(0 2px 6px color-mix(in srgb, var(--tab-accent) 45%, transparent)); }
.app-nav-ind { background: color-mix(in srgb, var(--text) 7%, transparent); }
@media (min-width: 900px) {
  .app-nav { background: var(--bg-deep); border-right-color: var(--border); }
  .app-nav-item { color: var(--text-2); }
  .app-nav-item[aria-current="page"] { color: var(--text); }
  .app-nav-item[aria-current="page"] .app-nav-ico { color: var(--tab-accent); }
}

/* ------------------------------------------------------------ buttons (3D press) */
.btn {
  --btn-bg: var(--surface-3);
  --btn-fg: var(--text);
  --btn-sh: var(--edge);
  position: relative;
  min-height: 46px; padding: 10px 20px; border: 0; border-radius: 12px;
  font-family: var(--font); font-weight: var(--fw-heavy); font-size: 16px; letter-spacing: .005em;
  color: var(--btn-fg);
  background: linear-gradient(180deg, color-mix(in srgb, var(--btn-bg), #fff 7%) 0%, var(--btn-bg) 55%, color-mix(in srgb, var(--btn-bg), #000 6%) 100%);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, .16),
    0 var(--press) 0 var(--btn-sh),
    0 calc(var(--press) + 3px) 10px rgba(0, 0, 0, .16);
  transform: translateY(0);
  transition: transform calc(.09s * var(--motion, 1)) ease-out, box-shadow calc(.09s * var(--motion, 1)) ease-out, filter .18s;
}
.btn:hover { filter: brightness(1.07) saturate(1.04); }
.btn:active {
  transform: translateY(calc(var(--press) - 1px));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .12), 0 1px 0 var(--btn-sh), 0 2px 4px rgba(0, 0, 0, .14);
}
.btn[disabled], .btn.is-disabled { opacity: .5; filter: saturate(.3); transform: none; box-shadow: 0 var(--press) 0 var(--btn-sh); }

.btn-primary {
  --btn-bg: var(--accent); --btn-fg: var(--accent-ink); --btn-sh: var(--accent-deep);
  text-shadow: 0 1px 1px rgba(0, 0, 0, .22);
}
.btn-secondary { --btn-bg: var(--btn-2-bg); --btn-fg: var(--text); --btn-sh: var(--btn-2-edge); }
.btn-xp { --btn-bg: var(--xp); --btn-fg: var(--xp-ink); --btn-sh: var(--xp-deep); text-shadow: 0 1px 1px rgba(0, 0, 0, .25); }
.btn-tab { --btn-bg: var(--tab-accent); --btn-fg: #fff; --btn-sh: var(--tab-accent-deep); text-shadow: 0 1px 1px rgba(0, 0, 0, .22); }
.btn-gold { --btn-bg: var(--gold); --btn-fg: #3a2606; --btn-sh: var(--gold-deep); }
.btn-danger { --btn-bg: var(--bad); --btn-fg: #fff; --btn-sh: color-mix(in srgb, var(--bad) 62%, #000); }
.btn-ghost {
  --btn-sh: transparent;
  background: transparent; box-shadow: none; color: var(--text-2); text-shadow: none;
}
.btn-ghost:hover { background: color-mix(in srgb, var(--text) 7%, transparent); color: var(--text); filter: none; }
.btn-ghost:active { transform: scale(.97); box-shadow: none; }
.btn-sm { --press: 3px; min-height: 36px; padding: 7px 14px; font-size: 14px; border-radius: 10px; }
.btn-lg { --press: 5px; min-height: 58px; padding: 14px 26px; font-size: 19px; border-radius: 14px; }
.btn-block { width: 100%; }
.btn-icon { width: 46px; padding: 0; }
.btn-icon.btn-sm { width: 36px; }

/* ------------------------------------------------------------ cards */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-1);
  padding: var(--sp-4);
}
.card-head h2, .card-title { font-size: var(--fs-md); font-weight: var(--fw-heavy); }
.card-ico { background: linear-gradient(150deg, color-mix(in srgb, var(--tab-accent), #fff 18%), var(--tab-accent-deep)); box-shadow: 0 3px 0 color-mix(in srgb, var(--tab-accent-deep), #000 25%); }
.card-ico.is-xp { background: linear-gradient(150deg, var(--xp-2), var(--xp-deep)); box-shadow: 0 3px 0 color-mix(in srgb, var(--xp-deep), #000 25%); }
.card-ico.is-gold { box-shadow: 0 3px 0 color-mix(in srgb, var(--gold-deep), #000 25%); }
.card-ico.is-red { box-shadow: 0 3px 0 #8f241e; }
.card-ico.is-blue { box-shadow: 0 3px 0 #1f3f8a; }
.card-ico.is-purple { box-shadow: 0 3px 0 #3d2a99; }
.card-flat { box-shadow: none; background: var(--surface-2); border-color: transparent; }
.card-lift { transition: transform calc(.22s * var(--motion, 1)) var(--spring), box-shadow .22s; }
.card-lift:hover { transform: translateY(-3px); box-shadow: var(--shadow-2); }
.card-lift:active { transform: translateY(0) scale(.99); }

/* hero card: tab-accent gradient + slow animated glow ring (our twist) */
@property --spin { syntax: "<angle>"; inherits: false; initial-value: 0deg; }
.card-hero {
  position: relative; isolation: isolate; overflow: hidden;
  border-radius: var(--radius-lg);
  padding: var(--sp-5);
  color: var(--hero-ink);
  border: 0;
  background:
    radial-gradient(70% 90% at 108% -10%, color-mix(in srgb, var(--xp) 42%, transparent) 0%, transparent 70%),
    radial-gradient(80% 100% at 0% 0%, color-mix(in srgb, var(--tab-accent), #fff 22%) 0%, transparent 70%),
    linear-gradient(150deg, var(--tab-accent) 0%, color-mix(in srgb, var(--tab-accent-deep), #000 12%) 100%);
  box-shadow: 0 5px 0 color-mix(in srgb, var(--tab-accent-deep), #000 40%), var(--shadow-2);
}
.card-hero::before { /* rotating glow edge */
  content: ""; position: absolute; inset: 0; z-index: -1; border-radius: inherit; padding: 2px;
  background: conic-gradient(from var(--spin), transparent 0 55%, rgba(255, 255, 255, .85) 70%, color-mix(in srgb, var(--xp-2) 90%, transparent) 78%, transparent 90%);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor; mask-composite: exclude;
  animation: skin-spin calc(6s * var(--motion, 1)) linear infinite;
  opacity: .7;
}
.card-hero::after { /* soft sheen */
  content: ""; position: absolute; inset: 0; z-index: -1; pointer-events: none;
  background: linear-gradient(180deg, rgba(255, 255, 255, .12), transparent 40%);
}
.card-hero h1, .card-hero h2, .card-hero h3 { color: var(--hero-ink); }
.card-hero p, .card-hero .muted { color: rgba(255, 255, 255, .84); }
.card-hero .btn-primary { --btn-bg: #ffffff; --btn-fg: color-mix(in srgb, var(--tab-accent-deep), #000 15%); --btn-sh: rgba(0, 0, 0, .28); text-shadow: none; }
/* The ONE main button of each tab's hero (Openings, Middlegame, Endgame): identical everywhere, the signature green primary
   (C30, SIMPLIFY.md rule 1), large and full width, with a light ring so it also stands out on the green Openings hero. */
.card-hero .btn-primary.hero-go {
  --btn-bg: var(--accent); --btn-fg: var(--accent-ink); --btn-sh: var(--accent-deep); --press: 5px;
  width: 100%; min-height: 56px; padding: 12px 22px; font-size: 18px; border-radius: 14px;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  text-shadow: 0 1px 1px rgba(0, 0, 0, .22);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .16), 0 0 0 2px rgba(255, 255, 255, .72), 0 var(--press) 0 2px var(--btn-sh), 0 calc(var(--press) + 4px) 12px rgba(0, 0, 0, .2);
}
.card-hero .btn-primary.hero-go:active { box-shadow: inset 0 1px 0 rgba(255, 255, 255, .12), 0 0 0 2px rgba(255, 255, 255, .72), 0 1px 0 2px var(--btn-sh); }
.card-hero .btn-primary.hero-go svg { width: 20px; height: 20px; flex: none; }
.card-hero .btn-secondary { --btn-bg: rgba(255, 255, 255, .18); --btn-fg: #fff; --btn-sh: rgba(0, 0, 0, .25); border-color: rgba(255, 255, 255, .18); }
.card-hero-art { position: absolute; right: -8px; bottom: -14px; width: 46%; max-width: 190px; opacity: .22; z-index: -1; pointer-events: none; color: #fff; }
@keyframes skin-spin { to { --spin: 360deg; } }

/* ------------------------------------------------------------ chips + badges */
.chip {
  min-height: 32px; padding: 5px 12px; gap: 6px;
  border: 1.5px solid var(--border-strong); border-radius: var(--radius-pill);
  background: var(--surface-2); color: var(--text-2);
  font-weight: var(--fw-strong); font-size: 13.5px; line-height: 1;
}
.chip:is(button):hover { color: var(--text); border-color: color-mix(in srgb, var(--text) 25%, transparent); }
.chip[aria-pressed="true"] { border-color: var(--tab-accent); background: var(--tab-accent-soft, var(--accent-soft)); color: var(--text); }
.chip svg { width: 15px; height: 15px; flex: none; }
/* glassy XP / level / streak chips (our twist) */
.chip-glass, .chip-xp, .chip-level, .chip-streak {
  border: 1px solid rgba(255, 255, 255, .22);
  background: linear-gradient(180deg, rgba(255, 255, 255, .20), rgba(255, 255, 255, .06));
  -webkit-backdrop-filter: blur(10px) saturate(1.4); backdrop-filter: blur(10px) saturate(1.4);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .28), 0 2px 8px rgba(0, 0, 0, .14);
  color: var(--text);
}
.chip-xp { background: linear-gradient(180deg, color-mix(in srgb, var(--xp-2) 88%, transparent), color-mix(in srgb, var(--xp-deep) 92%, transparent)); text-shadow: 0 1px 1px rgba(0, 0, 0, .25); color: #fff; border-color: color-mix(in srgb, var(--xp-2) 60%, transparent); }
.chip-level { background: linear-gradient(180deg, color-mix(in srgb, #ffd76a 92%, transparent), color-mix(in srgb, var(--gold-deep) 92%, transparent)); color: #fff; border-color: color-mix(in srgb, var(--gold) 70%, transparent); text-shadow: 0 1px 1px rgba(0, 0, 0, .25); }
.chip-streak { background: linear-gradient(180deg, rgba(255, 140, 90, .92), rgba(200, 76, 30, .92)); text-shadow: 0 1px 1px rgba(0, 0, 0, .25); color: #fff; border-color: rgba(255, 160, 120, .6); }
.card-hero .chip-glass { color: #fff; }

.badge, .badge-positional, .badge-tactical, .badge-good, .badge-bad, .badge-new {
  display: inline-flex; align-items: center; gap: 5px; height: 24px; padding: 0 9px; border-radius: 7px;
  font-weight: var(--fw-heavy); font-size: 11.5px; letter-spacing: .06em; text-transform: uppercase; white-space: nowrap;
  background: var(--surface-3); color: var(--text-2);
}
.badge-positional { background: color-mix(in srgb, var(--c-endgame) 18%, transparent); color: color-mix(in srgb, var(--c-endgame), var(--text) 25%); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--c-endgame) 35%, transparent); }
.badge-tactical { background: color-mix(in srgb, var(--c-middlegame) 18%, transparent); color: color-mix(in srgb, var(--c-middlegame), var(--text) 20%); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--c-middlegame) 35%, transparent); }
.badge-good { background: color-mix(in srgb, var(--good) 18%, transparent); color: var(--good); }
.badge-bad { background: color-mix(in srgb, var(--bad) 16%, transparent); color: var(--bad); }
.badge-new { background: var(--xp); color: #fff; box-shadow: 0 2px 0 var(--xp-deep); }
.badge-positional::before, .badge-tactical::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

/* ------------------------------------------------------------ list rows (icon-led) */
.list { display: grid; gap: var(--sp-2); }
.list-row {
  display: flex; align-items: center; gap: var(--sp-3); width: 100%; min-width: 0;
  padding: 10px 12px; border-radius: 14px; border: 0;
  background: var(--surface); color: var(--text); text-align: left; text-decoration: none;
  box-shadow: 0 2px 0 var(--edge);
  font: inherit;
  transition: transform calc(.18s * var(--motion, 1)) var(--spring), background .18s;
}
.list-row:is(a, button):hover { background: var(--surface-2); transform: translateX(2px); }
:is(.card, .modal, .sheet, .app-modal-card) .list-row { background: var(--surface-2); box-shadow: none; }
:is(.card, .modal, .sheet, .app-modal-card) .list-row:is(a, button):hover { background: var(--surface-3); }
.list-row:is(a, button):active { transform: scale(.985); }
.list-row-ico {
  flex: none; width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center; color: #fff;
  background: linear-gradient(150deg, color-mix(in srgb, var(--tab-accent), #fff 15%), var(--tab-accent-deep));
  box-shadow: 0 3px 0 color-mix(in srgb, var(--tab-accent-deep), #000 30%);
}
.list-row-ico svg { width: 22px; height: 22px; }
.list-row-ico.is-xp { background: linear-gradient(150deg, var(--xp-2), var(--xp-deep)); box-shadow: 0 3px 0 color-mix(in srgb, var(--xp-deep), #000 30%); }
.list-row-ico.is-quiet { background: var(--surface); color: var(--text-2); box-shadow: 0 2px 0 var(--edge); }
.list-row-main { flex: 1; min-width: 0; }
.list-row-title { display: block; font-weight: var(--fw-strong); font-size: 15.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-row-sub { display: block; font-weight: 700; font-size: 12.5px; color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-row-end { flex: none; display: flex; align-items: center; gap: 6px; color: var(--text-3); font-weight: var(--fw-heavy); font-size: 13.5px; }
.list-row-end svg { width: 18px; height: 18px; }

/* ------------------------------------------------------------ stats */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(96px, 1fr)); gap: var(--sp-2); }
.stat {
  min-width: 0; padding: 12px 12px 10px; border-radius: 14px; background: var(--surface-2);
  display: grid; gap: 2px;
}
.stat-value { font-size: 26px; font-weight: var(--fw-heavy); line-height: 1.05; letter-spacing: -.03em; font-variant-numeric: tabular-nums; }
.stat-label { font-size: 11.5px; font-weight: var(--fw-heavy); text-transform: uppercase; letter-spacing: .07em; color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stat-delta { font-size: 12.5px; font-weight: var(--fw-heavy); color: var(--good); }
.stat-delta.is-down { color: var(--bad); }
.card-hero .stat { background: rgba(0, 0, 0, .2); }
.card-hero .stat-label { color: rgba(255, 255, 255, .78); }

/* progress ring: set --p (0-100) and optionally --ring (colour) */
.progress-ring {
  --p: 0; --ring: var(--tab-accent); --track: var(--surface-3); --size: 72px; --thick: 8px;
  position: relative; flex: none; width: var(--size); height: var(--size); border-radius: 50%;
  display: grid; place-items: center;
  background: conic-gradient(var(--ring) calc(var(--p) * 1%), var(--track) 0);
}
.progress-ring::before { content: ""; position: absolute; inset: var(--thick); border-radius: 50%; background: var(--ring-hole, var(--surface)); }
.progress-ring > * { position: relative; font-weight: var(--fw-heavy); font-size: calc(var(--size) * .26); letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.progress-ring.is-xp { --ring: var(--xp); }
.card-hero .progress-ring { --track: rgba(0, 0, 0, .25); --ring: #fff; --ring-hole: color-mix(in srgb, var(--tab-accent-deep), #000 20%); }
.progress-bar { height: 12px; border-radius: 999px; background: var(--surface-3); overflow: hidden; box-shadow: inset 0 2px 3px rgba(0, 0, 0, .12); }
.progress-bar > i { display: block; height: 100%; width: calc(var(--p, 0) * 1%); border-radius: inherit; background: linear-gradient(90deg, var(--tab-accent), color-mix(in srgb, var(--tab-accent), #fff 22%)); box-shadow: inset 0 -2px 0 rgba(0, 0, 0, .15); transition: width calc(.8s * var(--motion, 1)) var(--ease); }
.progress-bar.is-xp > i { background: linear-gradient(90deg, var(--xp-deep), var(--xp), var(--xp-2)); }
.card-hero .progress-bar { background: rgba(0, 0, 0, .25); }
.card-hero .progress-bar > i { background: linear-gradient(90deg, #ffe08a, var(--gold)); }

/* ------------------------------------------------------------ tab bar (generic) */
.tabbar {
  display: flex; align-items: stretch; justify-content: space-around; gap: 4px;
  padding: 6px 8px calc(6px + var(--safe-b, 0px));
  background: var(--bg-deep); border-top: 1px solid var(--border);
}
.tab {
  flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  padding: 6px 4px; border: 0; border-radius: 14px; background: none; color: var(--text-3);
  font-weight: var(--fw-heavy); font-size: 11.5px; text-decoration: none;
  transition: color .18s, background .18s;
}
.tab svg { width: 26px; height: 26px; transition: transform calc(.3s * var(--motion, 1)) var(--spring); }
.tab:hover { color: var(--text); }
.tab--active { color: var(--tab-accent); background: color-mix(in srgb, var(--text) 6%, transparent); }
.tab--active svg { transform: translateY(-1px) scale(1.1); filter: drop-shadow(0 2px 6px color-mix(in srgb, var(--tab-accent) 50%, transparent)); }
/* segmented sub-tabs inside a screen */
.subtabs { display: flex; gap: 4px; padding: 4px; border-radius: 14px; background: var(--well); overflow-x: auto; scrollbar-width: none; }
.subtabs > * { flex: 1 0 auto; border: 0; background: none; color: var(--text-2); min-height: 36px; padding: 6px 14px; border-radius: 10px; font-weight: var(--fw-heavy); font-size: 14px; white-space: nowrap; }
.subtabs > [aria-selected="true"], .subtabs > .tab--active { background: var(--surface); color: var(--text); box-shadow: 0 2px 0 var(--edge); }
.seg { background: var(--well); }
.seg button[aria-pressed="true"], .seg button[aria-checked="true"] { background: var(--surface); box-shadow: 0 2px 0 var(--edge); }

/* ------------------------------------------------------------ section title */
.section-title {
  display: flex; align-items: center; gap: 10px; margin: var(--sp-6) 0 var(--sp-3);
  font-size: var(--fs-md); font-weight: var(--fw-heavy); letter-spacing: -.01em;
}
.section-title::before { content: ""; flex: none; width: 5px; height: 20px; border-radius: 3px; background: linear-gradient(180deg, var(--tab-accent), var(--xp)); }
.section-title .section-more { margin-left: auto; font-size: 13.5px; font-weight: var(--fw-heavy); color: var(--accent-text); text-decoration: none; }
.section-title:first-child { margin-top: 0; }

/* ------------------------------------------------------------ empty state */
.empty-state { display: grid; justify-items: center; text-align: center; gap: var(--sp-2); padding: var(--sp-7) var(--sp-4); }
.empty-state-art {
  width: 88px; height: 88px; border-radius: 28px; display: grid; place-items: center; margin-bottom: var(--sp-2); color: #fff;
  background: linear-gradient(150deg, color-mix(in srgb, var(--tab-accent), #fff 15%), var(--tab-accent-deep));
  box-shadow: 0 6px 0 color-mix(in srgb, var(--tab-accent-deep), #000 30%), 0 16px 36px color-mix(in srgb, var(--tab-accent) 30%, transparent);
  animation: skin-float calc(3.2s * var(--motion, 1)) ease-in-out infinite;
}
.empty-state-art svg { width: 44px; height: 44px; }
.empty-state h3 { font-size: var(--fs-lg); }
.empty-state p { color: var(--text-2); font-weight: 600; max-width: 34ch; }
.empty-state .btn { margin-top: var(--sp-3); }

/* ------------------------------------------------------------ modal / bottom sheet */
.modal-backdrop, .app-modal { background: rgba(14, 12, 10, .62); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); }
.modal-backdrop { position: fixed; inset: 0; z-index: 100005; display: grid; place-items: center; padding: 16px; animation: app-fade calc(.2s * var(--motion, 1)) ease-out both; }
.modal, .app-modal-card {
  width: min(440px, 100%); max-height: calc(100dvh - 32px); overflow: auto;
  background: var(--surface); color: var(--text); border: 1px solid var(--border);
  border-radius: 24px; padding: var(--sp-6); box-shadow: 0 6px 0 var(--edge), var(--shadow-3);
  animation: skin-pop calc(.34s * var(--motion, 1)) var(--spring) both;
}
.modal h3, .app-modal-card h3 { font-size: var(--fs-lg); margin-bottom: 8px; }
.modal-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 10px; margin-top: var(--sp-5); }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 100006; max-height: 88dvh; overflow: auto;
  background: var(--surface); color: var(--text); border-radius: 26px 26px 0 0;
  padding: 10px var(--sp-4) calc(var(--sp-5) + var(--safe-b, 0px));
  box-shadow: 0 -20px 60px rgba(0, 0, 0, .4); border-top: 1px solid var(--border);
  animation: skin-sheet calc(.36s * var(--motion, 1)) var(--ease) both;
}
.sheet::before { content: ""; display: block; width: 44px; height: 5px; border-radius: 3px; background: var(--surface-3); margin: 0 auto 14px; }
@media (min-width: 640px) { .sheet { left: 50%; right: auto; width: 520px; transform: translateX(-50%); bottom: 24px; border-radius: 26px; animation-name: skin-pop; } }

/* ------------------------------------------------------------ inputs */
.input { background: var(--bg-deep); border: 2px solid var(--border-strong); border-radius: 12px; font-weight: 700; }
.input:focus { border-color: var(--tab-accent); box-shadow: 0 0 0 4px var(--tab-accent-soft, var(--accent-soft)); }
.switch { background: var(--surface-3); box-shadow: inset 0 2px 3px rgba(0, 0, 0, .18); }
.switch[aria-checked="true"] { background: var(--accent); }

/* ------------------------------------------------------------ board area */
.board-frame {
  position: relative; border-radius: 10px; overflow: hidden;
  box-shadow: 0 6px 0 rgba(0, 0, 0, .28), 0 18px 40px rgba(0, 0, 0, .28);
}
.board-stage { display: grid; grid-template-columns: 18px minmax(0, 1fr); gap: 8px; align-items: stretch; }
.eval-bar { position: relative; border-radius: 0; overflow: hidden; background: #403d39; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .25); }
.eval-bar > i { position: absolute; left: 0; right: 0; bottom: 0; height: calc(var(--white, 50) * 1%); background: #f4f2ee; will-change: height; transition: height calc(.9s * var(--motion, 1)) cubic-bezier(.22,.61,.36,1); }
.eval-bar > b { position: absolute; left: 0; right: 0; bottom: 4px; text-align: center; font-size: 8.5px; letter-spacing: -.04em; font-weight: var(--fw-heavy); color: #403d39; z-index: 1; }
.player-strip { display: flex; align-items: center; gap: 10px; padding: 8px 2px; min-width: 0; }
.player-strip .avatar { flex: none; width: 36px; height: 36px; border-radius: 8px; display: grid; place-items: center; background: var(--surface-3); font-weight: var(--fw-heavy); }
.player-strip b { font-weight: var(--fw-heavy); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.player-strip small { color: var(--text-3); font-weight: 700; }
.player-strip .clock { margin-left: auto; padding: 6px 12px; border-radius: 8px; background: var(--surface-2); font-weight: var(--fw-heavy); font-variant-numeric: tabular-nums; font-size: 18px; }
.player-strip .clock.is-on { background: #f4f2ee; color: #262421; }
.move-feedback { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-radius: 14px; font-weight: var(--fw-strong); background: var(--surface-2); }
.move-feedback.is-good { background: color-mix(in srgb, var(--good) 18%, var(--surface)); }
.move-feedback.is-bad { background: color-mix(in srgb, var(--bad) 16%, var(--surface)); }
.move-feedback .mf-ico { flex: none; width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; color: #fff; font-weight: 900; background: var(--good); box-shadow: 0 2px 0 rgba(0, 0, 0, .25); }
.move-feedback.is-bad .mf-ico { background: var(--bad); }

/* ------------------------------------------------------------ micro-interactions */
.lift { transition: transform calc(.22s * var(--motion, 1)) var(--spring), box-shadow .22s; }
.lift:hover { transform: translateY(-3px); }
.press:active { transform: scale(.97); }
.pop-in { animation: skin-pop calc(.38s * var(--motion, 1)) var(--spring) both; }
.glow-xp { box-shadow: 0 0 0 2px color-mix(in srgb, var(--xp) 50%, transparent), 0 0 24px color-mix(in srgb, var(--xp) 45%, transparent); }

/* success burst: add .is-bursting to any positioned element (remove after 700ms) */
.burst { position: relative; }
.burst.is-bursting { animation: skin-bump calc(.45s * var(--motion, 1)) var(--spring); }
.burst.is-bursting::after {
  content: ""; position: absolute; left: 50%; top: 50%; width: 8px; height: 8px; margin: -4px 0 0 -4px; border-radius: 50%;
  pointer-events: none; z-index: 5;
  box-shadow:
    0 -34px 0 0 var(--gold), 24px -24px 0 0 var(--xp), 34px 0 0 0 var(--accent), 24px 24px 0 0 var(--c-endgame),
    0 34px 0 0 var(--gold), -24px 24px 0 0 var(--c-middlegame), -34px 0 0 0 var(--xp), -24px -24px 0 0 var(--accent);
  animation: skin-burst calc(.65s * var(--motion, 1)) var(--ease) forwards;
}
.burst.is-bursting::before {
  content: ""; position: absolute; inset: -6px; border-radius: inherit; pointer-events: none; z-index: 4;
  border: 3px solid var(--good); animation: skin-ring calc(.6s * var(--motion, 1)) var(--ease) forwards;
}
.xp-float { position: absolute; font-weight: 900; color: var(--xp); text-shadow: 0 2px 0 rgba(0, 0, 0, .25); animation: skin-xp-float calc(1s * var(--motion, 1)) var(--ease) forwards; pointer-events: none; }

@keyframes skin-pop   { 0% { transform: scale(.85); opacity: 0; } 70% { transform: scale(1.03); opacity: 1; } 100% { transform: scale(1); } }
@keyframes skin-sheet { from { transform: translateY(100%); } to { transform: none; } }
@keyframes skin-float { 0%, 100% { transform: translateY(0) rotate(-2deg); } 50% { transform: translateY(-8px) rotate(2deg); } }
@keyframes skin-bump  { 0% { transform: scale(1); } 40% { transform: scale(1.06); } 100% { transform: scale(1); } }
@keyframes skin-burst { 0% { transform: scale(.2); opacity: 1; } 100% { transform: scale(1.6); opacity: 0; } }
@keyframes skin-ring  { 0% { transform: scale(.9); opacity: .9; } 100% { transform: scale(1.18); opacity: 0; } }
@keyframes skin-xp-float { 0% { transform: translateY(0) scale(.8); opacity: 0; } 20% { opacity: 1; transform: translateY(-6px) scale(1.1); } 100% { transform: translateY(-36px) scale(1); opacity: 0; } }

/* ------------------------------------------------------------ calm feedback (no zoom on a right answer)
   Feedback after a move/puzzle/lesson only fades in. Nothing scales, so the screen never seems to zoom.
   These override the per-tab pop animations (op-pop, mg-pop, eg-pop), which the tabs inject at runtime. */
@keyframes calm-fade { from { opacity: 0; } to { opacity: 1; } }
.op-pop, .op-fb.op-pop, .op-card.op-pop, .op-plan.op-pop, .mg-reveal, .eg-big .eg-star.on { animation: calm-fade .25s ease both !important; }

/* ------------------------------------------------------------ motion preferences */
:root[data-motion="off"] .card-hero::before,
:root[data-motion="off"] .empty-state-art { animation: none !important; }
@media (prefers-reduced-motion: reduce) {
  .card-hero::before, .empty-state-art { animation: none !important; }
  .card-lift:hover, .lift:hover, .list-row:is(a, button):hover { transform: none; }
  .burst.is-bursting::after, .xp-float { display: none; }
  .btn, .btn:active { transition: none; }
}

/* ------------------------------------------------------------ integration (C21): shared pieces used by several modules */
.card-hero .stat-label { white-space: normal; line-height: 1.15; }
.card-hero .t-eyebrow { color: rgba(255, 255, 255, .82); }
/* floating "Analyze" launcher (analysis.js): 3D green pill, icon-only on phones so it never hides content */
body .an-fab {
  background: linear-gradient(180deg, color-mix(in srgb, var(--accent), #fff 8%), var(--accent));
  color: var(--accent-ink); text-shadow: 0 1px 1px rgba(0, 0, 0, .22);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .2), 0 4px 0 var(--accent-deep), 0 10px 26px rgba(0, 0, 0, .35);
}
body .an-fab:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--accent-deep), 0 4px 10px rgba(0, 0, 0, .3); }
body .an-fab { transition: transform calc(.22s * var(--motion, 1)) var(--spring, ease), opacity calc(.22s * var(--motion, 1)) ease; }
@media (max-width: 599px) {
  body .an-fab { width: 50px; height: 50px; min-height: 50px; padding: 0; justify-content: center; border-radius: 16px; }
  body .an-fab span { display: none; }
  /* tucked away while the user scrolls down (analysis.js), so it never covers text */
  body .an-fab.is-tucked { transform: translateY(calc(100% + 90px)); opacity: 0; pointer-events: none; }
}
/* the analysis overlay picks up the brand accent */
.an-root { --tab-accent: var(--accent); --tab-accent-deep: var(--accent-deep); }
/* Progress line (C44, shell.js): one slim line of real progress under the header: rating + change over the period ·
   Today's plan x/3 · day streak. Each part is a 44px tap target that opens the matching part of Profile. No levels, no XP. */
.pl { display: flex; align-items: stretch; gap: 2px; min-width: 0; padding: 0 4px; border-radius: 14px; background: var(--surface); border: 1px solid var(--border); box-shadow: 0 2px 0 var(--edge); }
.pl-item { flex: 0 1 auto; min-width: 0; min-height: 44px; display: inline-flex; align-items: center; gap: 6px; padding: 0 10px; border: 0; border-radius: 11px; background: none; color: var(--text); font: inherit; font-size: 14px; font-weight: 800; white-space: nowrap; cursor: pointer; font-variant-numeric: tabular-nums; }
.pl-item:hover { background: var(--surface-2); }
.pl-item:focus-visible { outline: 3px solid var(--accent); outline-offset: -3px; }
.pl-item + .pl-item { position: relative; }
.pl-item + .pl-item::before { content: ""; position: absolute; left: -1px; top: 12px; bottom: 12px; width: 1px; background: var(--border-strong, var(--border)); }
.pl-rating { flex: 1 1 auto; overflow: hidden; }
.pl-rating .pl-txt { overflow: hidden; text-overflow: ellipsis; }
.pl-k { color: var(--text-2); font-weight: 700; }
.pl-sep { color: var(--text-3, var(--text-2)); font-weight: 700; }
.pl-ch { font-weight: 900; }
.pl-ch.is-up { color: var(--good); }
.pl-ch.is-down { color: var(--bad); }
.pl-ch.is-flat { color: var(--text-2); }
.pl-ico { flex: none; width: 18px; height: 18px; display: grid; place-items: center; color: var(--text-2); }
.pl-ico svg { width: 18px; height: 18px; }
.pl-plan.is-done .pl-ico { color: var(--good); }
.pl-streak .pl-ico { color: var(--warn, #d18f0b); }
.pl-streak.is-open .pl-ico { color: var(--text-3, var(--text-2)); }
@media (max-width: 420px) {
  .pl { padding: 0 2px; }
  .pl-item { padding: 0 7px; gap: 4px; font-size: 13.5px; }
  /* labels stay visible (CLARITY: no bare numbers); the period is explained when the rating is tapped */
  .pl-rating .pl-per { display: none; }
}
@media (max-width: 360px) { .pl-rating .pl-k { display: none; } }
@media (max-width: 340px) { .pl-streak .pl-k { display: none; } }
/* Fun toasts (session done, milestones): short and above the tab bar, never over the board controls */
.fun-layer .fun-toasts { bottom: calc(var(--nav-h, 66px) + var(--safe-b, 0px) + 74px); }
@media (min-width: 900px) { .fun-layer .fun-toasts { bottom: 84px; left: calc(50% + var(--rail-w, 0px) / 2); } }
/* Profile: incremental update + collapsible full re-analysis */
.pf-an-note { margin: 8px 2px 2px; font-size: 13px; font-weight: 700; color: var(--text-3); }
.pf-an-more { margin-top: 10px; border-top: 1px solid var(--border); padding-top: 6px; }
.pf-an-more > summary { cursor: pointer; list-style: none; display: flex; align-items: center; gap: 8px; min-height: 40px; font-weight: 800; font-size: 14px; color: var(--text-2); }
.pf-an-more > summary::-webkit-details-marker { display: none; }
.pf-an-more > summary::before { content: ""; width: 7px; height: 7px; border-right: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: rotate(-45deg); transition: transform .2s; }
.pf-an-more[open] > summary::before { transform: rotate(45deg); }
.pf-an-more > summary:hover { color: var(--text); }
.pf-an-more[open] > summary { margin-bottom: 8px; }
/* ---- Import: scope picker (quick / full), background-progress chip, "keep training" links ---- */
.pf-scope { display: grid; gap: 8px; grid-template-columns: 1fr; }
@media (min-width: 440px) { .pf-scope { grid-template-columns: 1fr 1fr; } }
.pf-scope-opt {
  display: grid; gap: 3px; text-align: left; align-content: start; min-height: 44px; padding: 12px 14px;
  border-radius: var(--radius-sm); border: 2px solid var(--border-strong); background: var(--surface-2); color: var(--text);
  font: inherit; cursor: pointer; transition: border-color .15s, background-color .15s;
}
.pf-scope-opt:hover { border-color: var(--tab-accent, var(--accent)); }
.pf-scope-opt[aria-checked="true"] { border-color: var(--tab-accent, var(--accent)); background: color-mix(in srgb, var(--tab-accent, var(--accent)) 14%, var(--surface-2)); }
.pf-scope-opt:focus-visible { outline: 3px solid var(--info); outline-offset: 2px; }
.pf-scope-top { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 15.5px; font-weight: 900; }
.pf-scope-sub { font-size: 13.5px; font-weight: 700; color: var(--text-2); }
.pf-scope-eta { display: inline-flex; align-items: center; gap: 6px; margin-top: 2px; font-size: 13px; font-weight: 800; color: var(--text-3); }
.pf-scope-opt[aria-checked="true"] .pf-scope-eta { color: var(--text-2); }
.pf-net { background: color-mix(in srgb, var(--warn) 16%, var(--surface-2)); color: var(--text); align-items: flex-start; line-height: 1.4; }
.pf-train { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 13px; font-weight: 800; color: var(--text-2); }
.pf-train > span { flex: 1 1 100%; }

.app-importchip {
  position: sticky; top: calc(var(--topbar-h) + 8px); z-index: 30; display: flex; align-items: center; gap: 10px;
  width: 100%; min-height: 40px; margin: 0 0 10px; padding: 6px 14px 6px 10px; border-radius: var(--radius-pill, 999px);
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); font: inherit; font-weight: 800; font-size: 14px;
  box-shadow: var(--shadow-2, 0 4px 14px rgba(0,0,0,.25)); cursor: pointer; text-align: left; position: sticky; overflow: hidden;
}
.app-importchip[hidden] { display: none; }
.app-importchip::after { content: ""; position: absolute; left: 0; bottom: 0; height: 3px; width: calc(var(--p, 0) * 1%); background: var(--xp, var(--accent)); transition: width .4s ease; }
.app-importchip-ring { flex: none; width: 20px; height: 20px; border-radius: 50%; border: 3px solid var(--surface-3); border-top-color: var(--xp, var(--accent)); animation: app-importspin 1s linear infinite; }
.app-importchip-txt { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@keyframes app-importspin { to { transform: rotate(360deg); } }
@media (min-width: 900px) { .app-importchip { top: 8px; width: auto; max-width: 320px; } }
@media (prefers-reduced-motion: reduce) { .app-importchip-ring { animation: none; } }
html[data-motion="off"] .app-importchip-ring { animation: none; }

/* A switched-to player's games being analysed (Shell.importProgressHTML): tab heroes and empty states */
.app-imp { width: 100%; margin: 10px 0 4px; text-align: left; color: inherit; }
.app-imp-t { margin: 0 0 8px; font-size: 15px; line-height: 1.35; font-weight: 700; }
.app-imp-t b { font-weight: 900; }
.app-imp-t span { opacity: .85; }
.app-imp-bar { height: 10px; border-radius: 999px; background: color-mix(in srgb, currentColor 18%, transparent); overflow: hidden; }
.app-imp-bar i { display: block; height: 100%; border-radius: inherit; background: var(--xp, var(--accent)); transition: width .4s ease; }
.app-imp-row { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 12px; margin-top: 8px; }
.app-imp-eta { flex: 1 1 200px; font-size: 13px; font-weight: 700; line-height: 1.35; opacity: .85; }
.app-imp-x { flex: none; min-height: 44px; padding: 0 16px; border-radius: 12px; border: 1px solid color-mix(in srgb, currentColor 30%, transparent); background: transparent; color: inherit; font: inherit; font-size: 14px; font-weight: 800; cursor: pointer; }
.app-imp-x:hover { background: color-mix(in srgb, currentColor 10%, transparent); }
.app-imp-x:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { .app-imp-bar i { transition: none; } }
/* Profile: "Back to <your name>" while another player is active */
.pf-backhome { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 12px; margin: 12px 0 2px; padding: 10px 12px; border-radius: 12px; background: var(--surface-2); color: var(--text-2); font-size: 13.5px; font-weight: 700; line-height: 1.35; }
.pf-backhome > span { flex: 1 1 200px; min-width: 0; }
.pf-backhome .btn { min-height: 44px; }
.pf-backhome .btn svg { width: 16px; height: 16px; }
/* web version: "Find a player" explains that search needs the desktop version */
.app-webcard-note { margin: 8px 0 0; font-size: 13.5px; font-weight: 700; color: var(--text-2); }

/* ==========================================================================
   C88 polish (named Rookwise then, ChessRecaps since C114). One consistency pass, kept simple:
   tokens for spacing/type/status colours, one heading style, card hierarchy
   (hero > section cards > rows), framed boards + eval bars, a calmer tab bar,
   loading skeletons, and NO scale/zoom animations anywhere.
   Overrides of styles that tabs inject at runtime use a :root prefix so they
   win regardless of load order.
   ========================================================================== */
:root {
  --gap-card: var(--sp-4);          /* between cards */
  --gap-section: var(--sp-6);       /* above a section title */
  --fs-title: 18px;                 /* section + card titles */
  --good-soft: color-mix(in srgb, var(--good) 16%, transparent);
  --bad-soft: color-mix(in srgb, var(--bad) 15%, transparent);
  --neutral-soft: color-mix(in srgb, var(--text) 8%, transparent);
  --skel: color-mix(in srgb, var(--text) 10%, transparent);
  --frame-shadow: 0 3px 0 var(--edge), 0 12px 28px rgba(0, 0, 0, .22);
}

/* ---- status chips: one look for good / bad / neutral everywhere */
.chip-good, .chip-bad, .chip-neutral {
  display: inline-flex; align-items: center; gap: 5px; min-height: 24px; padding: 2px 9px; border-radius: var(--radius-pill);
  font-size: var(--fs-xs); font-weight: var(--fw-heavy); white-space: nowrap; line-height: 1.2;
}
.chip-good { background: var(--good-soft); color: var(--good); }
.chip-bad { background: var(--bad-soft); color: var(--bad); }
.chip-neutral { background: var(--neutral-soft); color: var(--text-2); }
/* results bars: draws are neutral grey everywhere (Endgame used yellow, every other bar grey) */
:root .eg-wdl .d { background: var(--text-3); }
:root .eg-wdl-l .d { color: var(--text-2); }

/* ---- one section-title style: tab-colour bar + 18px heavy title (Home, Endgame match Openings) */
:root .hm-sec > .hm-h2, :root .eg-sec {
  display: flex; align-items: center; gap: 10px; margin: var(--sp-2) 2px var(--sp-3);
  font-size: var(--fs-title); font-weight: var(--fw-heavy); letter-spacing: -.01em; line-height: 1.2;
  text-transform: none; color: var(--text);
}
:root .eg-sec { margin-top: var(--gap-section); }
:root .hm-sec > .hm-h2::before, :root .eg-sec::before {
  content: ""; flex: none; width: 5px; height: 20px; border-radius: 3px; background: linear-gradient(180deg, var(--tab-accent), var(--xp));
}
/* titles inside a section card: sentence case, full-strength text (was a grey uppercase eyebrow) */
:root .mg-card h2 { font-size: 17px; font-weight: var(--fw-heavy); letter-spacing: -.01em; text-transform: none; color: var(--text); line-height: 1.25; }
:root .hm-recent .hm-h2 { font-size: 17px; }

/* ---- card hierarchy: section cards share one surface/radius/shadow; rows inside cards are flat */
:root .mg-card, :root .hm-recent { border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-1); }
:root .hm-recent { padding: var(--sp-4); }

/* ---- Home: the three area cards line up (status grows, number + button sit at the bottom) */
:root .hm-area-num { min-height: 62px; align-content: center; align-items: center; }
:root .hm-area-go { margin-top: auto; }
/* Today's plan: two roomy columns on desktop instead of three cramped ones */
@media (min-width: 900px) {
  :root .st-plan-list { grid-template-columns: repeat(auto-fill, minmax(min(100%, 340px), 1fr)); }
}
:root .st-task { padding: 10px 10px 10px 12px; }
:root .st-task-ico { border-radius: 11px; }

/* ---- the same content width on every tab at desktop sizes (Middlegame / Endgame were much narrower than Home / Openings) */
@media (min-width: 900px) {
  :root .mg-root, :root .eg-root { max-width: 880px; }
}

/* ---- boards and eval bars: one frame everywhere (rounded 6px, the same lip + soft shadow) */
:root .cb-wrap .cb-board { border-radius: 6px; box-shadow: var(--frame-shadow); }
:root .cb-wrap .cb-board.cb-kbd:focus { box-shadow: 0 0 0 3px var(--accent), var(--frame-shadow); }
:root .an-eval, :root .lg-eval, :root .qz-eval, :root .eb-bar, .eval-bar { border-radius: 0; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .25), 0 3px 0 var(--edge); }
.board-frame { border-radius: 6px; box-shadow: var(--frame-shadow); }
/* the shared eval bar (js/evalbar.js) sits inside the board's own wrap: frame the board and the bar separately, not the pair */
:root .board-frame:has(.eb-bar), :root .op-board:has(.eb-bar) { box-shadow: none; overflow: visible; background: none; }
/* Profile piece-set previews: the Profiles card class (.pf-pc) also styled these tiny piece cells (padding, border, background) */
:root .pf-pieceset-row .pf-pc, :root .pf-mini .pf-pc { padding: 0; border: 0; border-radius: 0; background: none; gap: 0; }
:root .pf-pieceset-row .pf-pc:not([style*="grid"]), :root .pf-mini .pf-pc:not([style*="grid"]) { display: block; }
:root .pf-theme-sw .pf-pc { border: 0; border-radius: 0; background: none; gap: 0; display: block; }

/* ---- tab bar: the active tab shows its own colour (soft pill + a short bar on top on phones), no icon zoom */
.app-nav-item .app-nav-ico svg { stroke-width: 2; }
.app-nav-item[aria-current="page"] .app-nav-ico svg { stroke-width: 2.4; }
.app-nav-item[aria-current="page"] .app-nav-ico { transform: none; }
.app-nav:has(.app-nav-item[data-tab="home"][aria-current="page"]) .app-nav-ind { background: color-mix(in srgb, var(--accent) 16%, transparent); }
.app-nav:has(.app-nav-item[data-tab="openings"][aria-current="page"]) .app-nav-ind { background: color-mix(in srgb, var(--c-openings) 16%, transparent); }
.app-nav:has(.app-nav-item[data-tab="middlegame"][aria-current="page"]) .app-nav-ind { background: color-mix(in srgb, var(--c-middlegame) 16%, transparent); }
.app-nav:has(.app-nav-item[data-tab="endgame"][aria-current="page"]) .app-nav-ind { background: color-mix(in srgb, var(--c-endgame) 16%, transparent); }
.app-nav:has(.app-nav-item[data-tab="profile"][aria-current="page"]) .app-nav-ind { background: color-mix(in srgb, var(--c-profile) 16%, transparent); }
@media (max-width: 899px) {
  .app-nav-item[aria-current="page"]::before {
    content: ""; position: absolute; top: -6px; left: 50%; width: 28px; height: 3px; margin-left: -14px;
    border-radius: 0 0 3px 3px; background: var(--tab-accent);
  }
  .app-nav-label { font-size: 11.5px; }
}
@media (min-width: 900px) {
  .app-nav-item[aria-current="page"] { color: var(--text); }
}

/* ---- icons: one stroke weight inside every icon tile and button */
.card-ico svg, .list-row-ico svg, .btn > svg, :root .hm-area-ico svg, :root .st-task-ico svg, :root .pf-row-ico svg, .empty-state-art svg { stroke-width: 2; }

/* ---- toasts: a raised warm surface in both themes (was pure white on dark, pure black on light) */
.app-toast { background: var(--surface-3); color: var(--text); border: 1px solid var(--border-strong); }

/* ---- loading skeletons (used instead of spinners where data loads): calm opacity pulse, no movement */
.skel { display: block; height: 14px; border-radius: 7px; background: var(--skel); animation: skel-pulse calc(1.4s * var(--motion, 1)) ease-in-out infinite; }
.skel + .skel { margin-top: var(--sp-2); }
.skel-title { height: 26px; width: 70%; border-radius: 9px; }
.skel-short { width: 45%; }
.skel-btn { height: 52px; border-radius: 14px; margin-top: var(--sp-4) !important; }
.skel-row { height: 56px; border-radius: 14px; }
.skel-board { width: min(100%, 320px); aspect-ratio: 1 / 1; height: auto; border-radius: 6px; margin: var(--sp-3) auto 0; }
.card-hero .skel { background: rgba(255, 255, 255, .22); }
.skel-stack { display: grid; gap: var(--sp-2); margin-top: var(--sp-3); }
.skel-stack > .skel + .skel { margin-top: 0; }
@keyframes skel-pulse { 0%, 100% { opacity: 1; } 50% { opacity: .45; } }
:root[data-motion="off"] .skel { animation: none; }
@media (prefers-reduced-motion: reduce) { .skel { animation: none; } }
/* the old in-line spinners next to "loading" text are replaced by the skeleton under the text */
:root .lg-wait .lg-spin, :root .pp-wait .pp-spin { display: none; }

/* ---- calm motion: presses sink 1px instead of shrinking; dialogs fade/slide in instead of zooming */
.btn-ghost:active, .list-row:is(a, button):active, .app-iconbtn:active { transform: translateY(1px); }
.card-lift:active { transform: translateY(0); }
:root .st-task.is-done .st-task-check { transform: none; }
.tab--active svg { transform: translateY(-1px); }
@keyframes skin-pop { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes skin-bump { 0%, 100% { filter: none; } 40% { filter: brightness(1.12); } }
@keyframes skin-xp-float { 0% { transform: translateY(0); opacity: 0; } 20% { opacity: 1; transform: translateY(-6px); } 100% { transform: translateY(-36px); opacity: 0; } }

/* ---- brand wordmark: a touch larger in the desktop rail */
@media (min-width: 1081px) { .app-rail-head .brand-wordmark { font-size: 22px; } }

/* ---- Openings "Your openings" cards: the status chip drops under the name when space is short, so names no longer wrap word by word */
:root .op-rep-hd { flex-wrap: wrap; row-gap: 8px; }
:root .op-rep-hd > div[style*="flex:1"] { flex: 1 1 9em !important; }   /* the inline style says flex:1 / min-width:0 */
:root .op-rep-hd > .op-chip { margin-left: auto; }

/* ================================================================ C85 (FRESH_EYES_2) */
/* #2: on desktop the training boards leave room for the buttons under them (js/board.js reads --cb-below) */
@media (min-width: 900px) {
  #panel-openings, #panel-middlegame, #panel-endgame { --cb-below: 130px; }
}
/* #13: phone header: the 1M / 3M / 6M pill keeps its size and never runs under the search button */
.app-topbar .app-period { flex: none; }
@media (max-width: 420px) {
  .app-topbar { gap: 6px; }
  .app-topbar .app-period-seg button { min-width: 30px; padding: 0 4px; }
  .app-topbar .app-anbtn-top { padding: 0 8px; }
}
@media (max-width: 400px) { .app-topbar { padding-left: 12px; padding-right: 12px; } }
/* C107: the header logo never gets squeezed (at 375px it shrank to ~3px and the 1M/3M/6M pill ran over it) */
.app-topbar .app-brand { flex-shrink: 0; min-width: 36px; }
@media (max-width: 400px) {
  .app-topbar { gap: 4px; padding-left: 10px; padding-right: 10px; }
  .app-topbar .app-brand { min-width: 32px; }
  .app-topbar .app-logo { width: 32px; height: 32px; border-radius: 10px; }
  .app-topbar .app-period-seg button { min-width: 28px; padding: 0 3px; }
  .app-topbar .app-anbtn-top { padding: 0 6px; gap: 5px; }
  .app-topbar .app-helpbtn { width: 36px; }
}
/* #9: Today's plan: the two optional cards are labelled as extras (the plan is 3 tasks) */
.st-plan-extra-h { margin: 14px 2px 8px; font-size: var(--fs-xs, 12px); font-weight: 800; letter-spacing: .02em; color: var(--text-3); }
/* #15: Profile: "Settings" names the right-hand group */
.pf-col > .pf-group-h { margin: 4px 2px 0; }/* #6: Endgame "Quiz me": one board at a time (the lesson board and its buttons fold away while the quiz runs) */
.eg-quizzing > .eg-meta, .eg-quizzing > .eg-boardwrap, .eg-quizzing > .eg-eval, .eg-quizzing > .eg-fb, .eg-quizzing > .eg-ctl,
.eg-quizzing > [data-r="result"], .eg-quizzing > [data-r="review"] > :not(.eg-qzslot) { display: none !important; }
/* C95: the player's board + tools sit in a .bt-split (board | side column): same rule one level down, quiz gets the full width */
.eg-quizzing > .bt-split .bt-main, .eg-quizzing > .bt-split [data-r="tools"], .eg-quizzing > .bt-split .eg-eval, .eg-quizzing > .bt-split .eg-fb,
.eg-quizzing > .bt-split .eg-ctl, .eg-quizzing > .bt-split [data-r="result"], .eg-quizzing > .bt-split [data-r="review"] > :not(.eg-qzslot) { display: none !important; }
.eg-quizzing > .bt-split .bt-grid { display: block !important; }
.eg-quizzing .eg-qzslot { margin-top: 0 !important; scroll-margin-top: 72px; }
@media (min-width: 900px) { .eg-quizzing .eg-qzslot { scroll-margin-top: 16px; } }/* #2: a board sized to the window height is narrower than its column: frame the board itself, not the whole column */
:root .mg-boardwrap:has(.eb-bar), :root .eg-boardwrap:has(.eb-bar) { box-shadow: none; background: none; }
/* ------------------------------------------------------------ C99 release QA */
/* a very long player name never pushes a card wider than the phone: full-width buttons wrap, names break */
.btn-block { white-space: normal; overflow-wrap: anywhere; line-height: 1.2; }
.pf-addconf { grid-template-columns: minmax(0, 1fr); }
.pf-addconf-who, .pf-addconf-who b { overflow-wrap: anywhere; }
/* "Skip to content" shows itself when a keyboard user tabs onto it */
.app-skip:focus, .app-skip:focus-visible { position: fixed !important; left: 12px; top: 12px; width: auto; height: auto; margin: 0; padding: 10px 16px; clip: auto; overflow: visible; z-index: 10000;
  background: var(--surface, #fff); color: var(--text, #222); border-radius: 10px; font-weight: 800; box-shadow: 0 4px 16px rgba(0,0,0,.25); outline: 3px solid var(--accent, #81b64c); }
#app-main:focus { outline: none; }
/* desktop has no top bar (the rail replaces it): sticky things (section chips, import chip) stick to the very top, so the page
   no longer shows through a 58px gap above the chips while you scroll */
@media (min-width: 900px) { :root { --topbar-h: 0px; } }

/* ================================================================ C120 (BOARD_SIZE_REVIEW_SPEC 1): bigger boards */
/* desktop: a board screen (Middlegame puzzle, Endgame lesson / drill / review) uses the whole content width instead of the
   880px reading column, so the board (js/board.js: column width and window height decide) can be 560-800px; the side column
   keeps its fixed width. Lists and stats keep the reading width. */
@media (min-width: 900px) {
  :root #panel-middlegame .sbt-content:has(.mg-play) { max-width: 1240px; }
  :root .eg-root:has(.eg-split) { max-width: 1240px; }
  /* while a board session runs, the area's one-line intro steps aside (it is back on the end card / start screens) */
  html.drill-focus #panel-middlegame .sbt-line, html.drill-focus #panel-endgame .sbt-line { display: none; }
}
/* short desktop windows (1280x800, 1366x768): the rating / plan strip steps aside during a live board session, like on phones */
@media (min-width: 900px) and (max-height: 940px) {
  html.drill-focus .app-hud-slot { display: none !important; }
}
/* phones: a board screen uses the page's own 16px gutter only (Middlegame / Endgame added a second 16px, so the board was 296px
   instead of ~328px on a 390px phone) */
@media (max-width: 899px) {
  :root #panel-middlegame .sbt-content:has(.mg-play) { padding-left: 0; padding-right: 0; }
  :root .eg-root:has(.eg-split) { padding-left: 0; padding-right: 0; }
}
/* very wide windows: during a board session the page column may grow (1120 -> 1280px) so the board can reach ~800px */
@media (min-width: 1500px) {
  html.drill-focus .app-main-inner:has(.mg-play), html.drill-focus .app-main-inner:has(.eg-split) { max-width: 1280px; }
}
