/* ------------------------------------------------------------------
   kimpy — design tokens
   Type: Inter (UI) — highly legible, neutral and friendly; JetBrains Mono (code) — clear 0/O and 1/l/I, no ligatures.
   Colour: cool neutrals + ONE accent (indigo). Green = go / success, red = stop / error, amber = stars.
           Ten preset colours are used for sections and file colour-strips. Text pairs meet WCAG AA.
   Icons: Font Awesome Free (self-hosted). See icons.js for why each icon is used.
------------------------------------------------------------------- */
:root {
  --bg: #F5F6F9; --surface: #FFFFFF; --surface-2: #EFF1F6; --border: #E0E4EC;
  --text: #19202F; --muted: #566075;
  --accent: #4338CA; --accent-hover: #3730A3; --accent-soft: #ECEBFD; --on-accent: #FFFFFF;
  --run: #15803D; --run-hover: #116B33; --on-run: #FFFFFF;
  --danger: #B42318; --danger-soft: #FDECEA;
  --hint-bg: #FFF7E0; --hint-border: #F1D58A;
  --star: #D97706; --ok: #15803D; --ok-soft: #E7F6EC;
  --focus: 0 0 0 3px rgba(67, 56, 202, .38);
  --shadow: 0 10px 32px rgba(20, 28, 50, .18);
  --shadow-sm: 0 1px 3px rgba(20, 28, 50, .10);

  --code-bg: #FFFFFF; --gutter: #8A93A7; --guide: #E4E8F0; --sel: rgba(67, 56, 202, .22);
  --t-kw: #6D28D9; --t-str: #0B7A4B; --t-num: #B45309; --t-com: #6B7280;
  --t-bi: #0369A1; --t-fn: #1D4ED8; --t-def: #A21CAF; --t-self: #9A3412;

  --c-red: #E5484D; --c-orange: #F76B15; --c-yellow: #E2A700; --c-green: #30A46C; --c-teal: #12A594;
  --c-sky: #0091FF; --c-blue: #3E63DD; --c-purple: #8E4EC6; --c-pink: #D6409F; --c-gray: #8B8D98;

  --font-ui: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --font-code: 'JetBrains Mono', ui-monospace, 'Cascadia Code', Consolas, monospace;
  --code-size: 13.5px;
  --radius: 12px;
  --nav-h: 56px;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #0D111E; --surface: #151A2A; --surface-2: #1D2338; --border: #2A3250;
  --text: #E7EAF4; --muted: #A1AAC0;
  --accent: #6C70F0; --accent-hover: #8185FF; --accent-soft: #232A52; --on-accent: #FFFFFF;
  --run: #4ADE80; --run-hover: #6EE79A; --on-run: #052E16;
  --danger: #FF8A80; --danger-soft: #3A1E22;
  --hint-bg: #2B2616; --hint-border: #5C4F22;
  --star: #FBBF24; --ok: #4ADE80; --ok-soft: #14301F;
  --focus: 0 0 0 3px rgba(129, 133, 255, .5);
  --shadow: 0 10px 32px rgba(0, 0, 0, .5);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, .4);

  --code-bg: #121726; --gutter: #6E7894; --guide: #222A44; --sel: rgba(129, 133, 255, .32);
  --t-kw: #C4B5FD; --t-str: #6EE7B7; --t-num: #FCD34D; --t-com: #8E98B2;
  --t-bi: #7DD3FC; --t-fn: #93C5FD; --t-def: #F0ABFC; --t-self: #FDBA74;

  --c-red: #FF6369; --c-orange: #FF8B3E; --c-yellow: #FFD60A; --c-green: #3DD68C; --c-teal: #0BD8B6;
  --c-sky: #52A9FF; --c-blue: #849DFF; --c-purple: #BF7AF0; --c-pink: #FF74B8; --c-gray: #A0A1AB;
  color-scheme: dark;
}
.c-red { --strip: var(--c-red); } .c-orange { --strip: var(--c-orange); } .c-yellow { --strip: var(--c-yellow); }
.c-green { --strip: var(--c-green); } .c-teal { --strip: var(--c-teal); } .c-sky { --strip: var(--c-sky); }
.c-blue { --strip: var(--c-blue); } .c-purple { --strip: var(--c-purple); } .c-pink { --strip: var(--c-pink); } .c-gray { --strip: var(--c-gray); }

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font: 400 14px/1.5 var(--font-ui); background: var(--bg); color: var(--text);
  -webkit-font-smoothing: antialiased; -webkit-text-size-adjust: 100%; overflow: hidden;
}
[hidden] { display: none !important; }
h1, h2, h3, h4 { margin: 0; }
a { color: inherit; }
:focus-visible { outline: none; box-shadow: var(--focus); }
button, input, select, textarea { font: inherit; color: inherit; }
.spacer { flex: 1; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip-link { position: absolute; left: 8px; top: -60px; z-index: 200; padding: 10px 14px; border-radius: 10px; background: var(--accent); color: var(--on-accent); font-weight: 600; text-decoration: none; }
.skip-link:focus { top: 8px; }

/* icons are Font Awesome glyphs: sized with font-size, coloured with color */
.ic { flex: none; display: inline-block; width: 1.25em; text-align: center; font-size: 16px; line-height: 1; }

/* ---------- app frame & navbar ---------- */
.app { height: var(--vvh, 100dvh); display: flex; flex-direction: column; }
.navbar {
  display: flex; align-items: center; gap: 8px; min-height: var(--nav-h); padding: 6px 16px;
  background: var(--surface); border-bottom: 1px solid var(--border); z-index: 20;
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; margin-right: 14px; }
.brand-mark { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 10px; background: var(--accent); color: var(--on-accent); font-size: 16px; }
.brand-name { font-weight: 800; font-size: 19px; letter-spacing: -.03em; }
.nav { display: flex; align-items: center; gap: 4px; }
.nav-link {
  display: inline-flex; align-items: center; gap: 9px; height: 40px; padding: 0 16px; border-radius: 11px;
  color: var(--muted); font-weight: 600; font-size: 14.5px; text-decoration: none; white-space: nowrap;
}
.nav-link i { font-size: 15px; width: 1.2em; text-align: center; }
.nav-link:hover { background: var(--surface-2); color: var(--text); }
.nav-link[aria-current="page"] { background: var(--accent-soft); color: var(--accent); }
:root[data-theme="dark"] .nav-link[aria-current="page"] { color: #C7C9FF; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 38px; padding: 0 15px; border-radius: 10px; border: 1px solid transparent;
  font-weight: 600; font-size: 13.5px; line-height: 1; cursor: pointer; text-decoration: none; white-space: nowrap;
  transition: background .12s, border-color .12s, transform .06s;
}
.btn .ic { font-size: 14px; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: default; }
.btn.primary { background: var(--accent); color: var(--on-accent); }
.btn.primary:hover:not(:disabled) { background: var(--accent-hover); }
.btn.run { background: var(--run); color: var(--on-run); padding: 0 18px; min-width: 92px; font-size: 14px; }
.btn.run:hover:not(:disabled) { background: var(--run-hover); }
.btn.stop { background: var(--danger); color: #fff; padding: 0 18px; font-size: 14px; }
:root[data-theme="dark"] .btn.stop { color: #2B0B0A; }
.btn.ghost { background: transparent; border-color: var(--border); }
.btn.ghost:hover { background: var(--surface-2); }
.btn.text { background: transparent; color: var(--muted); padding: 0 10px; }
.btn.text:hover { background: var(--surface-2); color: var(--text); }
.btn.sm { height: 32px; font-size: 13px; padding: 0 10px; }
.btn.block { width: 100%; }
.btn.lg { height: 46px; font-size: 15px; }
.btn.xl { height: 52px; font-size: 16px; padding: 0 24px; border-radius: 12px; }
.btn.primary.danger-btn { background: var(--danger); }
:root[data-theme="dark"] .btn.primary.danger-btn { color: #2B0B0A; }

.icon-btn {
  display: inline-grid; place-items: center; width: 38px; height: 38px; flex: none;
  border: 0; border-radius: 10px; background: transparent; color: var(--muted); cursor: pointer;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn.sm { width: 32px; height: 32px; }
.icon-btn.sm .ic { font-size: 14px; }
.icon-btn.toggle[aria-pressed="true"] { color: var(--accent); background: var(--accent-soft); }
:root[data-theme="dark"] .icon-btn.toggle[aria-pressed="true"] { color: #C7C9FF; }
.icon-btn.txt { font-weight: 700; font-size: 13px; width: auto; padding: 0 8px; }

/* ---------- account ---------- */
.account { display: flex; align-items: center; gap: 6px; position: relative; }
.avatar {
  width: 38px; height: 38px; border-radius: 50%; border: 0; cursor: pointer;
  background: var(--accent-soft); color: var(--accent); font-weight: 700; font-size: 16px; text-transform: uppercase;
}
:root[data-theme="dark"] .avatar { color: #C7C9FF; }
.avatar, .av { overflow: hidden; display: inline-grid; place-items: center; padding: 0; flex: none; }
.avatar img, .av img { width: 100%; height: 100%; object-fit: cover; display: block; }
.av { width: 44px; height: 44px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); font-weight: 700; font-size: 19px; text-transform: uppercase; }
:root[data-theme="dark"] .av { color: #C7C9FF; }
.menu .who-row { display: flex; align-items: center; gap: 12px; padding: 8px 10px 10px; border-bottom: 1px solid var(--border); margin-bottom: 6px; }
.menu .who-row .who { padding: 0; border: 0; margin: 0; min-width: 0; }
.menu .who-row b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* profile picture dialog */
.av-crop { display: grid; place-items: center; margin: 0 0 14px; }
#av-canvas { width: 240px; height: 240px; max-width: 100%; border-radius: 14px; background: var(--surface-2); cursor: grab; touch-action: none; }
#av-canvas:active { cursor: grabbing; }
.av-defaults { margin: 0 0 14px; }
.av-defaults h3 { margin: 0 0 8px; font-size: 13px; font-weight: 600; color: var(--muted); }
.av-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; }
.av-pick { padding: 0; border: 2px solid transparent; border-radius: 50%; background: none; cursor: pointer; line-height: 0; aspect-ratio: 1; }
.av-pick canvas { width: 100%; height: 100%; border-radius: 50%; display: block; }
.av-pick:hover { border-color: var(--border); }
.av-pick[aria-pressed="true"] { border-color: var(--accent); }
.av-pick:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.av-zoom input[type="range"] { width: 100%; accent-color: var(--accent); }
.av-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.av-actions .spacer { flex: 1; }
#av-remove { color: var(--danger); }
.account-btn .ic { font-size: 22px; }
.menu {
  position: absolute; right: 0; top: 48px; z-index: 60; min-width: 230px; padding: 8px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow);
}
.menu .who { padding: 8px 10px 10px; color: var(--muted); font-size: 13px; border-bottom: 1px solid var(--border); margin-bottom: 6px; }
.menu .who b { display: block; color: var(--text); font-size: 15px; }
.menu .btn { width: 100%; justify-content: flex-start; height: 40px; }
.menu .btn .ic { width: 1.4em; }

/* ---------- views ---------- */
:root[data-boot="page"] #view-work { display: none; }
.view { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.work { min-width: 0; }
.toolbar {
  display: flex; align-items: center; gap: 8px; min-height: 52px; padding: 6px 14px;
  background: var(--surface); border-bottom: 1px solid var(--border);
}
.crumbs { min-width: 0; flex: 0 1 auto; }
.crumbs ol { display: flex; align-items: center; gap: 4px; list-style: none; margin: 0; padding: 0; min-width: 0; }
.crumbs li { display: flex; align-items: center; gap: 4px; min-width: 0; white-space: nowrap; font-size: 14px; }
.crumbs .sep .ic { font-size: 11px; width: auto; color: var(--muted); }
.crumbs .plain { display: inline-flex; align-items: center; gap: 7px; color: var(--muted); font-weight: 500; padding: 4px 6px; }
.crumbs a { display: inline-flex; align-items: center; gap: 7px; color: var(--muted); text-decoration: none; font-weight: 500; padding: 4px 6px; border-radius: 7px; }
.crumbs a:hover { background: var(--surface-2); color: var(--text); }
.crumbs .here { display: inline-flex; align-items: center; gap: 7px; font-weight: 700; min-width: 0; padding: 4px 6px; }
.crumbs .here span { overflow: hidden; text-overflow: ellipsis; }
.crumbs .ic { font-size: 14px; color: var(--muted); }
.crumbs .c-ic { color: var(--strip, var(--muted)); }
.crumbs .crumb-back { display: none; }
.crumb-tag { font-size: 11px; font-weight: 700; padding: 3px 9px; border-radius: 99px; background: var(--surface-2); color: var(--muted); } /* e.g. "Read-only" in the breadcrumb; not the achievement .badge */
.save-status { font-size: 12.5px; color: var(--muted); white-space: nowrap; }

.body { flex: 1; min-height: 0; display: flex; position: relative; outline: none; }

/* ---------- sidebar (my files) ---------- */
.sidebar {
  width: 256px; flex: none; display: flex; flex-direction: column; gap: 4px;
  background: var(--surface); border-right: 1px solid var(--border); padding: 12px 10px; overflow-y: auto;
}
.side-head { display: flex; align-items: center; gap: 4px; padding: 0 4px 6px 8px; border-radius: 10px; }
.side-head h2 { flex: 1; font-size: 12px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.file-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.file-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-card {
  margin: 12px 4px 0; padding: 14px; border-radius: var(--radius); background: var(--surface-2);
  display: flex; flex-direction: column; gap: 8px; font-size: 14px;
}
.side-card p { margin: 0; color: var(--muted); }
.side-card strong i { color: var(--accent); margin-right: 4px; }
.side-card .btn { height: auto; min-height: 38px; padding: 9px 12px; white-space: normal; text-align: center; line-height: 1.25; }

/* ---------- workspace & panes ---------- */
.workspace {
  flex: 1; min-width: 0; padding: 12px; display: grid;
  grid-template-columns: minmax(0, var(--l, 11fr)) 12px minmax(0, var(--r, 9fr));
  grid-template-rows: minmax(0, 1fr);
}
.pane {
  display: flex; flex-direction: column; min-width: 0; min-height: 0; overflow: hidden;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
}
.pane-head { display: flex; align-items: center; gap: 10px; min-height: 46px; padding: 5px 10px 5px 14px; border-bottom: 1px solid var(--border); }
.pane-title { display: flex; align-items: center; gap: 9px; font-weight: 700; font-size: 14px; }
.pane-title .ic { color: var(--muted); font-size: 14px; }
.tools { display: flex; align-items: center; gap: 2px; }
.tool-sep { width: 1px; height: 18px; background: var(--border); margin: 0 6px; }

.splitter { cursor: col-resize; position: relative; touch-action: none; border-radius: 6px; }
.splitter::after { content: ''; position: absolute; left: 50%; top: 50%; width: 4px; height: 44px; margin: -22px 0 0 -2px; border-radius: 4px; background: var(--border); transition: background .12s; }
.splitter:hover::after, .splitter:focus-visible::after, .splitter.drag::after { background: var(--accent); }

/* page differences: a mission has its instructions on the left and stacks code above output */
.work[data-page="activity"] .sidebar, .work:not([data-page="activity"]) .taskpanel { display: none; }
.work[data-page="activity"] .workspace { grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 6fr) minmax(0, 4fr); gap: 12px; }
.work[data-page="activity"] .splitter { display: none; }
.work:not([data-page="activity"]) #tab-task, .work:not([data-page="activity"]) #btn-reset, .work[data-page="activity"] #btn-menu { display: none; }
#btn-menu { display: none; }
@media (max-width: 699px), (max-height: 520px) and (pointer: coarse) { .work:not([data-page="activity"]) #btn-menu { display: inline-grid; } }
.work[data-page="share"] .keybar, .work[data-page="share"] #btn-ac { display: none !important; }

/* ---------- editor ---------- */
#editor { flex: 1; min-height: 0; }
.editor {
  position: relative; display: grid; grid-template-columns: auto minmax(0, 1fr); overflow: hidden;
  background: var(--code-bg); font-family: var(--font-code); font-size: var(--code-size); line-height: 1.7;
  font-variant-ligatures: none; font-feature-settings: 'liga' 0, 'calt' 0; tab-size: 4;
}
.ed-gutter { overflow: hidden; padding: 14px 10px 0 14px; color: var(--gutter); text-align: right; user-select: none; border-right: 1px solid var(--border); }
.ed-gutter-inner, .ed-hl, .ed-input { margin: 0; font: inherit; line-height: inherit; font-variant-ligatures: none; tab-size: 4; letter-spacing: 0; }
.ed-gutter-inner { padding-bottom: 160px; }
.ed-main { position: relative; min-width: 0; }
.ed-hl, .ed-input { position: absolute; inset: 0; padding: 14px 18px 160px 14px; white-space: pre; border: 0; }
.ed-hl { overflow: hidden; pointer-events: none; color: var(--text); }
.ed-marks { position: absolute; inset: 0; margin: 0; padding: 14px 0 160px 0; overflow: hidden; pointer-events: none; font: inherit; line-height: inherit; white-space: pre; color: transparent; }
.ed-marks code { display: block; font: inherit; min-width: 100%; width: max-content; will-change: transform; }
.ml { display: block; padding: 0 18px 0 14px; }
.ml-err { background: var(--danger-soft); box-shadow: inset 3px 0 0 var(--danger); }
.sq { text-decoration: underline wavy var(--danger); text-decoration-thickness: 1.5px; text-underline-offset: 4px; }
.gm { color: var(--danger); font-weight: 700; background: var(--danger-soft); border-radius: 4px; padding: 0 3px; margin: 0 -3px; }
/* The error note floats as a card with the same 12px gap on the left, right and bottom (clear of the scrollbar), so it never touches an edge. */
.ed-msg { position: absolute; left: 12px; right: calc(12px + var(--ed-sb-x, 0px)); bottom: calc(12px + var(--ed-sb-y, 0px)); z-index: 2; margin: 0; box-sizing: border-box; display: flex; align-items: flex-start; gap: 10px; padding: 9px 12px; border-radius: 10px; font: 500 13px/1.45 var(--font-ui); background: var(--danger-soft); color: var(--text); border: 1px solid var(--danger); box-shadow: 0 4px 14px rgba(0, 0, 0, .12); pointer-events: none; overflow-wrap: anywhere; }
.ed-msg[hidden] { display: none; }
.ed-msg > .ic { color: var(--danger); margin-top: 2px; flex: none; }
.ed-msg-text b { color: var(--danger); font-weight: 700; margin-right: 4px; }
.ed-tip { position: absolute; z-index: 4; max-width: min(320px, 90%); padding: 8px 11px; border-radius: 9px; background: #1a2036; color: #fff; border: 1px solid rgba(255, 255, 255, .14); box-shadow: 0 8px 24px rgba(0, 0, 0, .35); font: 400 13px/1.4 var(--font-ui); pointer-events: none; display: flex; flex-direction: column; gap: 3px; white-space: normal; }
.ed-tip[hidden] { display: none; }
.ed-tip strong { font-weight: 600; color: #ffb4ab; }
.ed-tip span { color: #dfe4f5; }

/* ---------- status bar: version + what's new (like the bar at the bottom of a code editor) ---------- */
.statusbar { flex: none; display: flex; align-items: center; gap: 12px; height: 28px; padding: 0 12px 0 0; font: 500 11.5px/1 var(--font-code); color: var(--muted); background: var(--surface); border-top: 1px solid var(--border); white-space: nowrap; overflow: hidden; }
.sb-brand { align-self: stretch; display: flex; align-items: center; gap: 7px; padding: 0 14px; background: var(--accent); color: var(--on-accent); font-weight: 700; letter-spacing: .01em; }
.sb-brand i { font-size: 10.5px; }
.sb-tag { font-family: var(--font-ui); font-weight: 500; }
.sb-sp { flex: 1; }
.sb-ver { padding: 3px 9px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border); color: var(--text); font-weight: 700; }
.sb-ver[hidden] { display: none; }
.sb-new { position: relative; display: inline-flex; align-items: center; gap: 6px; height: 20px; padding: 0 9px; border: 0; border-radius: 6px; background: transparent; color: var(--accent); font: 600 11.5px/1 var(--font-ui); cursor: pointer; }
.sb-new:hover { background: var(--surface-2); }
.sb-new:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.sb-new[hidden] { display: none; }
.sb-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--danger); box-shadow: 0 0 0 2px var(--surface); }
.sb-dot[hidden] { display: none; }
@media (max-width: 720px) { .sb-tag, .sb-time { display: none; } .statusbar { gap: 8px; } }
.changes-tag { margin-left: 8px; padding: 1px 7px; border-radius: 999px; background: var(--accent); color: #fff; font-size: 11px; font-weight: 600; vertical-align: 1px; }
/* ---------- Shared links page ---------- */
.shared { overflow-y: auto; padding: 28px 24px 56px; outline: none; }
.shr-wrap { max-width: 860px; width: 100%; margin: 0 auto; display: flex; flex-direction: column; gap: 18px; }
.shr-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; }
.shr-head h1 { margin: 0 0 4px; font-size: 26px; letter-spacing: -.02em; outline: none; }
.shr-lead { margin: 0; color: var(--muted); font-size: 14px; line-height: 1.5; max-width: 62ch; }
.shr-filters { display: flex; flex-wrap: wrap; gap: 8px; }
.shr-chip { display: inline-flex; align-items: center; gap: 8px; height: 34px; padding: 0 14px; border: 1px solid var(--border); border-radius: 999px; background: var(--surface); color: var(--text); font: 600 13px/1 var(--font-ui); cursor: pointer; }
.shr-chip:hover { background: var(--surface-2); }
.shr-chip[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.shr-count { min-width: 20px; padding: 2px 6px; border-radius: 999px; background: var(--surface-2); color: var(--muted); font-size: 11.5px; text-align: center; }
.shr-chip[aria-pressed="true"] .shr-count { background: rgba(255, 255, 255, .22); color: inherit; }
.shr-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 12px; }
.shr-card { display: flex; flex-direction: column; gap: 12px; padding: 16px 18px; background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--border); border-radius: 14px; box-shadow: var(--shadow-sm); }
.shr-card[data-state="active"] { border-left-color: var(--ok); }
.shr-card[data-state="expired"] { border-left-color: var(--star); }
.shr-card[data-state="revoked"] { border-left-color: var(--danger); }
.shr-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.shr-file { display: inline-flex; align-items: center; gap: 8px; min-width: 0; font-size: 15px; }
.shr-file strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.shr-pill { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px; font-size: 12px; font-weight: 700; white-space: nowrap; }
.shr-pill[data-state="active"] { background: var(--ok-soft); color: var(--ok); }
.shr-pill[data-state="expired"] { background: var(--hint-bg); color: var(--star); border: 1px solid var(--hint-border); }
.shr-pill[data-state="revoked"] { background: var(--danger-soft); color: var(--danger); }
.shr-url { display: flex; align-items: center; gap: 6px; }
.shr-url code { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding: 6px 10px; border-radius: 8px; background: var(--surface-2); font: 500 13px var(--font-code); }
.shr-card:not([data-state="active"]) .shr-url code { text-decoration: line-through; color: var(--muted); }
.shr-facts { display: flex; flex-wrap: wrap; gap: 6px 18px; color: var(--muted); font-size: 13px; }
.shr-facts span { display: inline-flex; align-items: center; gap: 6px; }
.shr-facts .ic { font-size: 12px; width: auto; }
.shr-stats { display: flex; flex-wrap: wrap; gap: 10px; }
.shr-stat { display: flex; flex-direction: column; gap: 2px; min-width: 92px; padding: 8px 14px; border-radius: 10px; background: var(--surface-2); }
.shr-stat.wide { flex: 1; min-width: 130px; justify-content: center; }
.shr-num { display: inline-flex; align-items: center; gap: 7px; font: 700 20px/1.2 var(--font-ui); }
.shr-num .ic { font-size: 13px; width: auto; color: var(--muted); }
.shr-when { font-weight: 700; font-size: 14px; }
.shr-lab { color: var(--muted); font-size: 12px; }
.shr-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.btn.danger-text { color: var(--danger); }
.shr-empty { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 36px 20px; text-align: center; color: var(--muted); border: 1px dashed var(--border); border-radius: 16px; }
.shr-empty > .ic { font-size: 26px; width: auto; color: var(--accent); }
.shr-empty p { margin: 0; }
.share-all { margin: 14px 0 0; font-size: 13px; }
.share-all a { color: var(--accent); }
.sl-file { overflow-wrap: anywhere; font-family: var(--font-code); font-size: 12.5px; }
@media (max-width: 640px) { .shared { padding: 16px 12px 40px; } .shr-head { flex-direction: column; } .shr-stat { flex: 1; } }
.changes { max-height: min(60vh, 460px); overflow: auto; padding-right: 4px; }
.changes-build { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin: 16px 0 6px; font-size: 15px; }
.changes-build:first-child { margin-top: 0; }
.changes-when { font-size: 12px; font-weight: 400; color: var(--muted); }
.changes-list { margin: 0; padding-left: 20px; font-size: 14px; line-height: 1.5; }
.changes-list li { margin: 3px 0; }
.ed-hl code { display: block; font: inherit; will-change: transform; }
.ed-input {
  overflow: auto; resize: none; background: transparent; color: transparent; caret-color: var(--text);
  outline: none; -webkit-text-fill-color: transparent; text-wrap: nowrap; overflow-wrap: normal;
}
.ed-input::selection { background: var(--sel); -webkit-text-fill-color: transparent; }
.ed-input:focus-visible { box-shadow: none; }
.editor:focus-within { box-shadow: inset 0 0 0 2px var(--accent); }
.editor.readonly .ed-input { caret-color: transparent; }
.t-kw { color: var(--t-kw); font-weight: 500; } .t-str { color: var(--t-str); } .t-num { color: var(--t-num); }
.t-com { color: var(--t-com); font-style: italic; } .t-bi { color: var(--t-bi); } .t-fn { color: var(--t-fn); }
.t-def { color: var(--t-def); font-weight: 500; } .t-const { color: var(--t-num); font-weight: 500; } .t-self { color: var(--t-self); font-style: italic; }
.ig { box-shadow: inset 1px 0 0 var(--guide); }

/* suggestion popup */
.ed-probe { position: absolute; visibility: hidden; pointer-events: none; white-space: pre; font: inherit; left: 0; top: 0; }
.ac {
  position: absolute; z-index: 6; min-width: 210px; max-width: min(340px, calc(100% - 8px)); padding: 4px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow);
  font-family: var(--font-ui); font-size: 13px; line-height: 1.3;
}
.ac-item { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 7px 9px; border-radius: 7px; cursor: pointer; }
.ac-item.sel { background: var(--accent-soft); }
.ac-label { font-family: var(--font-code); font-size: 13px; white-space: pre; overflow: hidden; text-overflow: ellipsis; }
.ac-label b { font-weight: 700; color: var(--accent); }
:root[data-theme="dark"] .ac-label b { color: #C7C9FF; }
.ac-kind { flex: none; font-size: 11px; color: var(--muted); }
.ac-foot { display: flex; gap: 10px; padding: 6px 9px 3px; margin-top: 3px; border-top: 1px solid var(--border); color: var(--muted); font-size: 11px; }
.ac-foot kbd { font: 600 10px var(--font-ui); padding: 1px 5px; border: 1px solid var(--border); border-radius: 4px; background: var(--surface-2); color: var(--text); }
.ac-tap { display: none; }

.keybar { display: none; gap: 6px; padding: 6px 8px; border-top: 1px solid var(--border); background: var(--surface); overflow-x: auto; scrollbar-width: none; }
.keybar button {
  flex: none; min-width: 44px; height: 42px; padding: 0 12px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--surface-2); font-family: var(--font-code); font-size: 18px; font-weight: 500; cursor: pointer; touch-action: manipulation;
}
.keybar button.wide { font-family: var(--font-ui); font-size: 14px; font-weight: 600; }
.keybar button:active { background: var(--accent-soft); }

/* ---------- console ---------- */
.console {
  flex: 1; min-height: 0; overflow: auto; margin: 0; padding: 14px 16px; background: var(--code-bg);
  font-family: var(--font-code); font-size: var(--code-size); line-height: 1.65; white-space: pre-wrap; overflow-wrap: anywhere; outline: none;
}
.console[data-empty="true"]::before { content: attr(data-placeholder); color: var(--muted); font-family: var(--font-ui); font-size: 14px; }
.console:focus-visible { box-shadow: inset 0 0 0 2px var(--accent); }
.game { flex: none; display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 10px 12px 12px; border-bottom: 1px solid var(--border); background: var(--surface-2); max-height: 68%; min-height: 0; }
.game-head { align-self: stretch; display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 600; color: var(--muted); }
.game-warn { padding: 1px 8px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); font-size: 12px; font-weight: 600; }
:root[data-theme="dark"] .game-warn { color: #C7C9FF; }
.game-head .game-hint { margin-left: auto; font-weight: 500; font-size: 12px; }
#game-canvas { display: block; min-height: 0; max-width: 100%; max-height: 100%; width: auto; height: auto; background: #000; border-radius: 6px; cursor: crosshair; outline: none; touch-action: none; }
#game-canvas:focus-visible { box-shadow: 0 0 0 3px var(--accent); }
@media (max-width: 520px) { .game-hint { display: none; } }
.console .err { color: var(--danger); }
.console .usr { color: var(--accent); font-weight: 500; }
:root[data-theme="dark"] .console .usr { color: #B6B9FF; }
.console .sys { color: var(--muted); font-family: var(--font-ui); font-size: 14px; }
.console .hint {
  display: block; margin-top: 12px; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--hint-border);
  background: var(--hint-bg); color: var(--text); font-family: var(--font-ui); font-size: 14px; white-space: normal;
}
.console .hint b { font-weight: 600; }
.input-row { display: flex; gap: 8px; padding: 10px; border-top: 1px solid var(--border); background: var(--surface); }
.input-row input { flex: 1; min-width: 0; height: 40px; padding: 0 12px; border-radius: 10px; border: 1px solid var(--border); background: var(--code-bg); font-family: var(--font-code); font-size: 14px; }
.input-row input:focus { outline: none; border-color: var(--accent); box-shadow: var(--focus); }
.input-row .btn { height: 40px; }

/* ---------- dialogs & forms ---------- */
dialog {
  width: min(440px, calc(100vw - 24px)); max-height: calc(100dvh - 24px); overflow-y: auto; padding: 20px 22px 22px;
  background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: 18px; box-shadow: var(--shadow);
}
dialog::backdrop { background: rgba(10, 14, 28, .55); backdrop-filter: blur(2px); }
.dlg-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 14px; }
.dlg-head h2 { font-size: 18px; letter-spacing: -.01em; }
.dlg-head .icon-btn { margin-right: -8px; }
.dlg-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
.sub { font-size: 12px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin: 22px 0 8px; }
.note { margin: 0 0 14px; font-size: 13px; color: var(--muted); }
.note.where { margin: -6px 0 12px; font-weight: 500; }
.error { margin: 0 0 14px; padding: 10px 12px; border-radius: 10px; font-size: 14px; background: var(--danger-soft); color: var(--danger); }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field > span { font-size: 13px; font-weight: 600; }
.field small { color: var(--muted); font-size: 12px; }
.field input, .field select {
  height: 40px; padding: 0 12px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface);
  font-size: 14px; width: 100%;
}
.field input[aria-invalid="true"] { border-color: var(--danger); }
.field input:focus, .field select:focus { outline: none; border-color: var(--accent); box-shadow: var(--focus); }
.check { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; font-size: 14px; cursor: pointer; min-height: 32px; }
.check input { width: 20px; height: 20px; accent-color: var(--accent); }
.seg { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 4px; margin-bottom: 16px; background: var(--surface-2); border-radius: 12px; }
.seg button { height: 38px; border: 0; border-radius: 9px; background: transparent; font-weight: 600; font-size: 14px; color: var(--muted); cursor: pointer; }
.seg button[aria-selected="true"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }

.captcha-row { display: flex; align-items: center; gap: 6px; }
.captcha-row img { display: block; max-width: calc(100% - 50px); height: auto; border: 1px solid var(--border); border-radius: 10px; background: #F3F4F8; }
#captcha-input:not(:placeholder-shown) { text-transform: uppercase; letter-spacing: .25em; font-family: var(--font-code); font-weight: 600; }
.share-new { margin-top: 16px; padding: 12px; border-radius: var(--radius); background: var(--accent-soft); display: flex; flex-direction: column; gap: 8px; font-size: 14px; }
.share-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.share-item { display: flex; align-items: center; gap: 8px; padding: 8px 8px 8px 12px; border: 1px solid var(--border); border-radius: 10px; }
.share-item .info { flex: 1; min-width: 0; display: flex; flex-direction: column; font-size: 14px; }
.share-item .url { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: var(--font-code); font-size: 13px; }
.share-item .meta { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 12px; }
.share-item .meta .ic { font-size: 11px; width: auto; }
.link-row { display: flex; gap: 8px; }
.link-row input { flex: 1; min-width: 0; height: 42px; padding: 0 12px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface); font-family: var(--font-code); font-size: 14px; }

.toast {
  position: fixed; left: 50%; bottom: 84px; z-index: 100; transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  max-width: calc(100vw - 32px); padding: 12px 18px; border-radius: 12px; background: var(--text); color: var(--bg);
  font-size: 13px; font-weight: 500; box-shadow: var(--shadow); transition: opacity .18s, transform .18s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast { display: flex; align-items: center; gap: 10px; }
.toast-ic { flex: none; width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; color: #fff; font-size: 12px; background: #2563eb; }
.toast.success .toast-ic { background: #16a34a; }
.toast.error .toast-ic { background: #dc2626; }
.toast.warn .toast-ic { background: #d97706; }
.toast.info .toast-ic { background: #2563eb; }
.toast-text { min-width: 0; overflow-wrap: anywhere; }
.empty-state { margin: auto; max-width: 360px; padding: 24px; text-align: center; color: var(--muted); }
.empty-state h2 { color: var(--text); margin-bottom: 8px; }

/* ---------- file tree: folders, colour strips, menus, drag & drop ---------- */
#file-list { flex: 1 1 auto; min-height: 90px; border-radius: 10px; }
#file-list li { list-style: none; }
.tree-children { list-style: none; margin: 0; padding: 0; }
.tree-item {
  position: relative; display: flex; align-items: center; gap: 6px; min-height: 38px; margin: 1px 0; padding: 0 4px 0 calc(8px + var(--depth, 0) * 16px);
  border-radius: 9px; cursor: pointer; font-size: 14px; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
}
.tree-item:hover { background: var(--surface-2); }
.tree-item.active { background: var(--accent-soft); font-weight: 600; color: var(--accent); }
:root[data-theme="dark"] .tree-item.active { color: #C7C9FF; }
.tree-item.target:not(.active) { background: var(--surface-2); }
.tree-item::before { content: ''; position: absolute; left: 0; top: 5px; bottom: 5px; width: 5px; border-radius: 0 4px 4px 0; background: var(--strip, transparent); }
@supports (background: color-mix(in srgb, red 10%, transparent)) {
  .tree-item[class*="c-"]:not(.active):not(.drop-over) { background: color-mix(in srgb, var(--strip) 11%, transparent); }
  .tree-item[class*="c-"]:not(.active):not(.drop-over):hover { background: color-mix(in srgb, var(--strip) 20%, transparent); }
}
.tree-chev { display: grid; place-items: center; width: 18px; flex: none; color: var(--muted); }
.tree-chev .ic { font-size: 11px; width: auto; transition: transform .12s; }
.tree-chev.open .ic { transform: rotate(90deg); }
.tree-ic { color: var(--muted); font-size: 15px; }
.tree-item.active .tree-ic { color: inherit; }
.tree-item[data-kind="folder"] .tree-ic { color: var(--strip, #E2A700); }
.tree-item .file-name { flex: 1; min-width: 0; }
.tree-more { opacity: 0; flex: none; }
.tree-item:hover .tree-more, .tree-item:focus-within .tree-more, .tree-item.active .tree-more { opacity: 1; }
.tree-item.dragging { opacity: .45; }
.tree-item.drop-over { background: var(--accent-soft); box-shadow: inset 0 0 0 2px var(--accent); }
#file-list.drop-root, .side-head.drop-root { box-shadow: inset 0 0 0 2px var(--accent); background: color-mix(in srgb, var(--accent) 7%, transparent); }
.tree-empty { padding: 4px 8px 6px calc(34px + var(--depth, 1) * 16px); font-size: 12px; color: var(--muted); font-style: italic; }
.tree-item:focus-visible { box-shadow: var(--focus); }
.tree-item.drop-over:focus-visible { box-shadow: inset 0 0 0 2px var(--accent); }

.ctx-menu {
  position: fixed; z-index: 90; min-width: 218px; padding: 6px; display: flex; flex-direction: column; gap: 1px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow);
}
.ctx-menu:focus { outline: none; }
.ctx-item { display: flex; align-items: center; gap: 10px; height: 38px; padding: 0 10px; border: 0; border-radius: 8px; background: none; font-size: 14px; text-align: left; cursor: pointer; }
.ctx-item:hover, .ctx-item:focus-visible { background: var(--surface-2); outline: none; }
.ctx-item .ic { font-size: 14px; color: var(--muted); }
.ctx-item.danger, .ctx-item.danger .ic { color: var(--danger); }
.ctx-sep { height: 1px; margin: 4px 6px; background: var(--border); }
.ctx-colors { padding: 6px 10px 8px; }
.ctx-label { display: block; margin-bottom: 8px; font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.swatches { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; }
.swatch { width: 28px; height: 28px; padding: 0; border: 2px solid transparent; border-radius: 50%; background: var(--strip); cursor: pointer; display: grid; place-items: center; }
.swatch:hover { transform: scale(1.1); }
.swatch.on { border-color: var(--text); box-shadow: 0 0 0 2px var(--surface) inset; }
.swatch.none { background: var(--surface-2); border: 1px dashed var(--muted); color: var(--muted); }
.swatch.none.on { border: 2px solid var(--text); }
.swatch .ic { font-size: 12px; width: auto; }
.swatch:focus-visible { outline: none; box-shadow: var(--focus); }

.move-list { display: flex; flex-direction: column; gap: 2px; max-height: 50vh; overflow-y: auto; }
.move-opt {
  position: relative; display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 0 12px 0 calc(14px + var(--depth, 0) * 18px);
  border: 0; border-radius: 10px; background: none; font-size: 15px; text-align: left; cursor: pointer;
}
.move-opt:hover:not(:disabled) { background: var(--surface-2); }
.move-opt:disabled { opacity: .45; cursor: default; }
.move-opt::before { content: ''; position: absolute; left: 0; top: 6px; bottom: 6px; width: 5px; border-radius: 0 4px 4px 0; background: var(--strip, transparent); }
.move-opt .ic { color: var(--muted); }
.move-opt small { margin-left: auto; color: var(--muted); font-size: 12px; }

/* ---------- stars (difficulty) ---------- */
.stars { display: inline-flex; align-items: center; gap: 2px; flex: none; }
.stars .ic { width: auto; font-size: 13px; }
.stars .ic.on { color: var(--star); }
.stars .ic.off { color: var(--border); }
:root[data-theme="dark"] .stars .ic.off { color: #46507A; }
.star-label { margin-left: 8px; font-size: 12.5px; font-weight: 600; color: var(--muted); }

/* ═══════════════ Practice hub ═══════════════ */
.hub { overflow-y: auto; padding: 28px 24px 56px; outline: none; }
.hub-inner { max-width: 1120px; margin: 0 auto; display: flex; flex-direction: column; gap: 24px; }
.hub-hero { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(300px, .85fr); gap: 20px; align-items: stretch; }
.hero-text { padding: 8px 4px; display: flex; flex-direction: column; justify-content: center; gap: 10px; }
.hero-text h1 { font-size: 34px; font-weight: 800; letter-spacing: -.03em; line-height: 1.15; }
.hero-text p { margin: 0; font-size: 17px; line-height: 1.6; color: var(--muted); max-width: 46ch; }
.hero-text .steps-inline { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 6px; }
.chip { display: inline-flex; align-items: center; gap: 8px; padding: 7px 13px; border-radius: 99px; background: var(--surface); border: 1px solid var(--border); font-size: 13.5px; font-weight: 600; }
.chip .ic { width: auto; font-size: 13px; color: var(--accent); }
.hero-card { display: flex; align-items: center; gap: 20px; padding: 22px; border-radius: 20px; background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-sm); flex-wrap: wrap; }
.ring { position: relative; width: 96px; height: 96px; flex: none; border-radius: 50%; background: conic-gradient(var(--run) calc(var(--pct, 0) * 1%), var(--border) 0); display: grid; place-items: center; }
.ring::after { content: ''; position: absolute; inset: 10px; border-radius: 50%; background: var(--surface); }
.ring b { position: relative; z-index: 1; font-size: 22px; font-weight: 800; letter-spacing: -.02em; }
.hero-stats { flex: 1; min-width: 160px; display: flex; flex-direction: column; gap: 6px; }
.hero-stats .big { font-size: 20px; font-weight: 800; letter-spacing: -.02em; }
.hero-stats .sub-line { color: var(--muted); font-size: 14px; display: flex; align-items: center; gap: 7px; }
.hero-stats .sub-line .ic { width: auto; color: var(--star); }
.hero-card .btn { width: 100%; }
.guest-note { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; padding: 14px 16px; border-radius: 14px; background: var(--accent-soft); font-size: 14.5px; }
.guest-note > .ic { color: var(--accent); font-size: 18px; }
.guest-note > span { flex: 1; min-width: 200px; }
:root[data-theme="dark"] .guest-note > .ic { color: #C7C9FF; }

.hub-bar { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.legend { display: flex; flex-wrap: wrap; gap: 8px 18px; color: var(--muted); font-size: 13.5px; }
.legend span { display: inline-flex; align-items: center; gap: 8px; }
.filters { display: inline-flex; gap: 4px; padding: 4px; border-radius: 12px; background: var(--surface-2); }
.filters button { height: 34px; padding: 0 14px; border: 0; border-radius: 9px; background: transparent; color: var(--muted); font-weight: 600; font-size: 13.5px; cursor: pointer; }
.filters button[aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }

.sections { display: flex; flex-direction: column; gap: 14px; }
.sec { border: 1px solid var(--border); border-radius: 20px; background: var(--surface); overflow: hidden; }
.sec-head {
  display: flex; align-items: center; gap: 16px; width: 100%; padding: 16px 18px; border: 0; background: none; cursor: pointer; text-align: left;
}
.sec-head:hover { background: var(--surface-2); }
.sec-badge { display: grid; place-items: center; width: 48px; height: 48px; flex: none; border-radius: 14px; background: color-mix(in srgb, var(--strip) 16%, transparent); color: var(--strip); font-size: 21px; }
.sec-badge .ic { width: auto; font-size: 21px; }
.sec-text { flex: 1; min-width: 0; }
.sec-text h2 { font-size: 18px; font-weight: 800; letter-spacing: -.02em; }
.sec-text p { margin: 2px 0 0; color: var(--muted); font-size: 14px; }
.sec-prog { display: flex; align-items: center; gap: 12px; flex: none; color: var(--muted); font-size: 13.5px; font-weight: 600; }
.sec-bar { width: 90px; height: 8px; border-radius: 8px; background: var(--border); overflow: hidden; }
.sec-bar i { display: block; height: 100%; background: var(--run); border-radius: 8px; transition: width .3s; }
.sec-chev { color: var(--muted); transition: transform .15s; }
.sec[data-open="true"] .sec-chev { transform: rotate(180deg); }
.sec-body { padding: 4px 18px 20px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(255px, 1fr)); gap: 12px; }
.tile {
  position: relative; display: flex; align-items: flex-start; gap: 13px; padding: 14px 14px 14px 16px; min-height: 92px;
  border: 1px solid var(--border); border-radius: 16px; background: var(--surface); text-decoration: none; color: inherit;
  transition: transform .12s, box-shadow .12s, border-color .12s;
}
.tile::before { content: ''; position: absolute; left: 0; top: 14px; bottom: 14px; width: 5px; border-radius: 0 4px 4px 0; background: var(--strip); }
.tile:hover { transform: translateY(-2px); box-shadow: var(--shadow); border-color: color-mix(in srgb, var(--strip) 50%, var(--border)); }
.tile.done { background: color-mix(in srgb, var(--ok) 7%, var(--surface)); }
.tile-num { display: grid; place-items: center; width: 34px; height: 34px; flex: none; border-radius: 50%; background: color-mix(in srgb, var(--strip) 16%, transparent); font-size: 13px; font-weight: 800; }
.tile.done .tile-num { background: var(--ok); color: var(--on-run); }
.tile.done .tile-num .ic { width: auto; font-size: 15px; }
.tile-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.tile-main strong { font-size: 15.5px; font-weight: 700; letter-spacing: -.01em; line-height: 1.3; }
.tile-main small { color: var(--muted); font-size: 13.5px; line-height: 1.4; }
.tile-foot { display: flex; align-items: center; gap: 10px; margin-top: 6px; }
.tile-state { margin-left: auto; font-size: 12.5px; font-weight: 700; color: var(--muted); }
.tile.done .tile-state { color: var(--ok); }
.hub-empty { padding: 26px; text-align: center; color: var(--muted); border: 1px dashed var(--border); border-radius: 16px; }

/* ═══════════════ Profile page ═══════════════ */
.profile { overflow-y: auto; padding: 28px 24px 56px; outline: none; }
.prof-inner { width: 100%; max-width: 1120px; margin: 0 auto; display: flex; flex-direction: column; gap: 20px; }
.prof-loading { color: var(--muted); }
.prof-head { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
.prof-id h1 { font-size: 30px; font-weight: 800; letter-spacing: -.03em; line-height: 1.15; overflow-wrap: anywhere; outline: none; }
.prof-id p { margin: 4px 0 0; color: var(--muted); display: flex; align-items: center; gap: 7px; }
.prof-id p .ic { width: auto; font-size: 13px; }
.prof-id p .aud { margin-left: 10px; }
.prof-priv { position: relative; }
.prof-priv summary { list-style: none; cursor: pointer; }
.prof-priv summary::-webkit-details-marker { display: none; }
.prof-priv[open] summary { background: var(--surface-2); }
.priv-panel { position: absolute; right: 0; top: calc(100% + 8px); z-index: 20; width: 300px; max-width: calc(100vw - 24px); padding: 16px; border: 1px solid var(--border); border-radius: 16px; background: var(--surface); box-shadow: 0 8px 24px rgba(0,0,0,.18); display: flex; flex-direction: column; gap: 10px; }
.priv-panel h3 { font-size: 14px; font-weight: 800; }
.priv-panel p { margin: 0; color: var(--muted); font-size: 12.5px; line-height: 1.45; }
.priv-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; font-size: 13.5px; font-weight: 600; }
.priv-row select { height: 32px; padding: 0 8px; border: 1px solid var(--border); border-radius: 9px; background: var(--surface); color: var(--text); font-size: 13px; font-weight: 600; cursor: pointer; }
/* Masonry (see masonry() in profile.js): each card goes in the shortest column, so there are no holes. */
.prof-grid { display: flex; gap: 16px; align-items: flex-start; }
.prof-col { flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; gap: 16px; }
.pcard { margin: 0; padding: 18px 20px 20px; border: 1px solid var(--border); border-radius: 20px; background: var(--surface); box-shadow: var(--shadow-sm); }
.pcard > header { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.pcard h2 { display: flex; align-items: center; gap: 10px; font-size: 17px; font-weight: 800; letter-spacing: -.02em; }
.pcard h2 .ic { width: auto; color: var(--accent); font-size: 16px; }
:root[data-theme="dark"] .pcard h2 .ic { color: #C7C9FF; }
.aud { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; font-weight: 600; }
.aud .ic { width: auto; font-size: 13px; }
.aud select { height: 32px; padding: 0 8px; border: 1px solid var(--border); border-radius: 9px; background: var(--surface); color: var(--text); font-size: 13px; font-weight: 600; cursor: pointer; }
.pcard[data-aud="me"] { border-style: dashed; }
.p-top { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
.stats { display: flex; flex-wrap: wrap; gap: 10px 26px; }
.stat { display: flex; flex-direction: column; min-width: 0; }
.stat b { font-size: 22px; font-weight: 800; letter-spacing: -.02em; line-height: 1.2; }
.stat span { color: var(--muted); font-size: 13.5px; }
.p-sub { margin: 18px 0 8px; font-size: 13px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.p-secs { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.p-secs li { display: grid; grid-template-columns: minmax(0, 14.5em) minmax(40px, 1fr) 3.2em; align-items: center; gap: 12px; font-size: 13.5px; }
.ps-name { display: flex; align-items: center; gap: 8px; min-width: 0; line-height: 1.3; } /* wraps rather than clipping long names */
.ps-name .ic { width: 1.3em; font-size: 14px; color: var(--strip); }
.p-secs .sec-bar { width: auto; }
.ps-n { text-align: right; color: var(--muted); font-weight: 600; font-variant-numeric: tabular-nums; }
.wk-chart { display: flex; align-items: flex-end; gap: 6px; height: 120px; padding-bottom: 1px; border-bottom: 1px solid var(--border); }
.wk { flex: 1; height: 100%; display: flex; align-items: flex-end; min-width: 0; }
.wk i { display: block; width: 100%; background: var(--accent); border-radius: 4px 4px 0 0; transition: opacity .12s; }
:root[data-theme="dark"] .wk i { background: var(--accent-hover); }
.wk i.zero { background: var(--border); }
.wk:hover i { opacity: .75; }
.wk-axis { display: flex; justify-content: space-between; margin-top: 6px; color: var(--muted); font-size: 12px; }
@media (max-width: 699px) {
  .profile { padding: 16px 12px 40px; }
  .prof-id h1 { font-size: 25px; }
  .pcard { padding: 16px; }
  .p-secs li { grid-template-columns: minmax(0, 1fr) 3.2em; }
  .p-secs .sec-bar { display: block; grid-column: 1 / -1; grid-row: 2; }
  .p-secs li > .ps-n { grid-column: 2; grid-row: 1; }
}

/* ═══════════════ "I'm feeling lucky" ═══════════════ */
.lucky-panel { padding: 20px 22px 22px; border: 1px solid var(--border); border-radius: 20px; background: var(--surface); box-shadow: var(--shadow-sm); display: flex; flex-direction: column; gap: 14px; }
.lucky-head { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
.lucky-text { flex: 1; min-width: 240px; }
.lucky-text h2 { display: flex; align-items: center; gap: 10px; font-size: 20px; font-weight: 800; letter-spacing: -.02em; }
.lucky-text h2 .ic { width: auto; color: var(--accent); }
:root[data-theme="dark"] .lucky-text h2 .ic { color: #C7C9FF; }
.lucky-text p { margin: 6px 0 0; color: var(--muted); font-size: 14.5px; line-height: 1.55; max-width: 62ch; }
.lucky-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.lucky-chip { cursor: pointer; color: var(--text); font-family: inherit; }
.lucky-chip .ic { color: var(--strip); }
.lucky-chip:hover { background: color-mix(in srgb, var(--strip) 14%, var(--surface)); border-color: color-mix(in srgb, var(--strip) 50%, var(--border)); }
.lucky-n { min-width: 22px; padding: 1px 7px; border-radius: 99px; background: var(--ok-soft); color: var(--ok); font-size: 12px; font-weight: 800; text-align: center; }
.lucky-count { margin: 0; display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13.5px; font-weight: 600; }
.lucky-count .ic { width: auto; color: var(--ok); }
.m-lucky { display: inline-flex; align-items: center; gap: 7px; font-weight: 700; color: var(--accent); }
.m-lucky .ic { width: auto; font-size: 14px; }
:root[data-theme="dark"] .m-lucky { color: #C7C9FF; }
.prof-none { margin: 10px 0 0; color: var(--muted); }
@media (max-width: 699px) { .lucky-panel { padding: 16px; } .lucky-head .btn { width: 100%; } }

/* ═══════════════ Mission panel ═══════════════ */
.taskpanel {
  width: 392px; flex: none; overflow-y: auto; padding: 20px 20px 32px; background: var(--surface); border-right: 1px solid var(--border);
  font-size: 15.5px; line-height: 1.65;
}
.m-head { display: flex; flex-direction: column; gap: 10px; }
.m-meta { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; font-size: 13px; color: var(--muted); font-weight: 600; }
.m-section { display: inline-flex; align-items: center; gap: 7px; padding: 4px 11px; border-radius: 99px; background: color-mix(in srgb, var(--strip) 15%, transparent); color: var(--text); font-weight: 700; font-size: 12.5px; text-decoration: none; }
.m-section .ic { width: auto; color: var(--strip); font-size: 12px; }
.m-head h1 { font-size: 25px; font-weight: 800; letter-spacing: -.03em; line-height: 1.2; }
.m-diff { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.m-done { display: inline-flex; align-items: center; gap: 7px; padding: 4px 12px; border-radius: 99px; background: var(--ok-soft); color: var(--ok); font-weight: 700; font-size: 13px; }
.m-done .ic { width: auto; }
.steps { display: flex; align-items: center; gap: 6px; margin: 16px 0 4px; flex-wrap: wrap; }
.step { display: inline-flex; align-items: center; gap: 7px; padding: 6px 11px; border-radius: 10px; background: var(--surface-2); font-size: 13px; font-weight: 700; }
.step .ic { width: auto; font-size: 13px; color: var(--accent); }
.step.s-run .ic { color: var(--run); }
.steps > .ic { width: auto; font-size: 11px; color: var(--muted); }

.m-card { margin-top: 16px; padding: 15px 16px; border-radius: 14px; background: var(--surface-2); border-left: 4px solid var(--accent); }
.m-card h3 { display: flex; align-items: center; gap: 9px; margin-bottom: 7px; font-size: 14px; font-weight: 800; letter-spacing: -.01em; }
.m-card h3 .ic { width: auto; font-size: 15px; }
.m-card p { margin: 0 0 8px; }
.m-card p:last-child { margin-bottom: 0; }
.m-goal { border-left-color: var(--accent); background: var(--accent-soft); }
.m-goal h3 .ic { color: var(--accent); }
.m-idea { border-left-color: var(--star); background: var(--hint-bg); }
.m-idea h3 .ic { color: var(--star); }
.m-example { border-left-color: var(--c-teal); }
.m-example h3 .ic { color: var(--c-teal); }
.m-card code, .checks code { padding: 1px 6px; border-radius: 6px; background: color-mix(in srgb, var(--text) 8%, transparent); font-family: var(--font-code); font-size: .9em; }
.m-card pre, .m-sol pre, .cmp pre, .fail-detail pre {
  margin: 8px 0 0; padding: 10px 12px; border-radius: 10px; background: var(--code-bg); border: 1px solid var(--border);
  font-family: var(--font-code); font-size: 13.5px; line-height: 1.55; white-space: pre-wrap; overflow-wrap: anywhere;
}
.ex-grid { display: grid; gap: 4px; }
.ex-label { display: flex; align-items: center; gap: 7px; margin-top: 8px; font-size: 12.5px; font-weight: 700; color: var(--muted); }
.ex-label:first-child { margin-top: 0; }
.ex-label .ic { width: auto; font-size: 12px; }
.ex-grid pre { margin-top: 2px; }
.ex-grid pre.none { color: var(--muted); font-family: var(--font-ui); }

.m-hints { display: flex; flex-direction: column; gap: 10px; margin-top: 16px; }
.hint-item { display: flex; gap: 11px; padding: 12px 14px; border-radius: 12px; background: var(--hint-bg); border: 1px solid var(--hint-border); }
.hint-item .ic { color: var(--star); margin-top: 4px; width: auto; }
.m-hint-actions { margin-top: 14px; display: flex; flex-wrap: wrap; gap: 8px; }
.m-sol { margin-top: 12px; }
.m-sol:empty { display: none; }
.m-sol .ex-label { margin-top: 0; }
.m-nav { display: flex; justify-content: space-between; gap: 8px; margin-top: 26px; padding-top: 18px; border-top: 1px solid var(--border); }
.m-nav .btn { flex: 1; min-width: 0; }
.m-nav .btn span { overflow: hidden; text-overflow: ellipsis; }

/* ═══════════════ Check results ═══════════════ */
.console .checks { display: block; white-space: normal; font-family: var(--font-ui); font-size: 15px; line-height: 1.55; }
.checks-head { display: flex; gap: 14px; align-items: flex-start; padding: 16px; border-radius: 16px; }
.checks-head > .ic { width: auto; font-size: 28px; margin-top: 1px; }
.checks-head.ok { background: var(--ok-soft); color: var(--ok); }
.checks-head.bad { background: var(--danger-soft); color: var(--danger); }
.checks-head strong { display: block; color: var(--text); font-size: 17px; letter-spacing: -.01em; }
.checks-sub { color: var(--muted); font-size: 14px; margin-top: 2px; }
.celebrate { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 8px; padding: 22px 16px; border-radius: 20px; background: var(--ok-soft); }
.celebrate .trophy { font-size: 46px; color: var(--star); animation: pop .5s ease-out; }
.celebrate h3 { font-size: 22px; font-weight: 800; letter-spacing: -.02em; color: var(--text); }
.celebrate p { margin: 0; color: var(--muted); }
.celebrate .earned { display: inline-flex; gap: 6px; font-size: 26px; color: var(--star); }
.celebrate .earned .ic { animation: pop .45s ease-out both; }
.celebrate .earned .ic:nth-child(2) { animation-delay: .12s; } .celebrate .earned .ic:nth-child(3) { animation-delay: .24s; }
@keyframes pop { 0% { transform: scale(.3) rotate(-12deg); opacity: 0; } 70% { transform: scale(1.18) rotate(4deg); opacity: 1; } 100% { transform: scale(1); } }
.check-list { list-style: none; margin: 14px 0 0; padding: 0; display: flex; flex-direction: column; gap: 5px; }
.check-list li { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-radius: 10px; background: var(--surface-2); font-size: 14px; }
.check-list li .ic { width: auto; font-size: 15px; }
.check-list li.pass .ic { color: var(--ok); }
.check-list li.fail .ic { color: var(--danger); }
.check-list li.skip { opacity: .65; }
.check-list li.skip .ic { color: var(--muted); }
.ck-state { margin-left: auto; color: var(--muted); font-size: 12.5px; font-weight: 600; }
.fail-detail { display: flex; flex-direction: column; gap: 12px; margin-top: 16px; padding: 14px; border: 1px solid var(--border); border-radius: 16px; }
.fail-detail h4 { font-size: 14px; font-weight: 800; display: flex; align-items: center; gap: 8px; }
.fail-detail h4 .ic { width: auto; color: var(--star); }
.fail-detail p { margin: 0; }
.fail-detail .err { color: var(--danger); font-family: var(--font-code); font-size: 13px; }
.cmp { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.cmp-col h5 { margin: 0 0 4px; font-size: 12.5px; font-weight: 700; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.cmp pre { margin: 0; }
.cmp .ln { display: block; min-height: 1.55em; padding: 0 4px; border-radius: 4px; }
.cmp .ln.bad { background: var(--danger-soft); color: var(--danger); font-weight: 600; }
.cmp .ln.good { color: var(--text); }
.checks-next { margin-top: 16px; display: flex; gap: 8px; flex-wrap: wrap; }
.checks-next .btn { flex: 1; min-width: 160px; }

/* ═══════════════ responsive ═══════════════ */
.only-compact { display: none; }
.only-narrow { display: none; }
.scrim { display: none; }
.tabbar { display: none; }
.copy-short { display: none; }
.check-short { display: none; }

/* medium screens: narrower instructions, stacked editor/output for files */
@media (max-width: 1199px) { .taskpanel { width: 340px; } }
@media (max-width: 999px) {
  .workspace { grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 6fr) minmax(0, 4fr); gap: 12px; }
  .splitter { display: none; }
  .hub-hero { grid-template-columns: 1fr; }
  #btn-reset span { display: none; }
}

/* phones (portrait or landscape) & small tablets */
@media (max-width: 699px), (max-height: 520px) and (pointer: coarse) {
  :root { --nav-h: 52px; }
  .only-compact { display: inline-grid; }
  .only-wide { display: none !important; }
  .only-narrow { display: inline-grid; }
  .menu .btn.only-compact { display: flex; }
  .navbar { padding: 5px 10px; gap: 4px; }
  .brand { margin-right: 4px; }
  .brand-name { display: none; }
  .nav-link { padding: 0 11px; gap: 7px; font-size: 14px; height: 38px; }
  .toolbar { padding: 5px 10px; gap: 6px; min-height: 48px; }
  .btn-text { display: none; }
  #btn-share { padding: 0 12px; }
  .crumbs li:not(:last-child) { display: none; }
  .crumbs li.crumb-back { display: flex; }
  .crumbs .crumb-back a { padding: 6px 10px 6px 4px; color: var(--text); font-weight: 600; }
  .crumbs .crumb-back span { display: inline; }
  /* on a mission the title is right below, so the toolbar only needs the way back */
  .work[data-page="activity"] .crumbs li:last-child { display: none; }
  .work:not([data-page="activity"]) .crumbs .crumb-back span { display: none; }
  .crumbs .here { font-size: 14.5px; }
  .save-status { display: none; }
  .sidebar {
    position: absolute; z-index: 40; inset: 0 auto 0 0; width: min(300px, 86vw); transform: translateX(-102%); transition: transform .2s ease;
  }
  .app.drawer-open .sidebar { transform: none; box-shadow: var(--shadow); }
  .app.drawer-open .scrim { display: block; position: absolute; inset: 0; z-index: 35; background: rgba(10, 14, 28, .5); }
  .workspace { padding: 8px; grid-template-rows: minmax(0, 1fr); }
  .work[data-view="code"] .pane-out, .work[data-view="out"] .pane-code { display: none; }
  .work[data-page="activity"] .workspace { grid-template-rows: minmax(0, 1fr); gap: 0; }
  /* the mission becomes its own full-screen tab on phones */
  .work[data-page="activity"] .taskpanel { display: none; width: auto; flex: 1; border-right: 0; padding: 16px 14px 24px; font-size: 16px; }
  .work[data-page="activity"][data-view="task"] .taskpanel { display: block; }
  .work[data-page="activity"][data-view="task"] .workspace { display: none; }
  .tabbar {
    display: grid; grid-template-columns: 1fr 1fr; gap: 6px; padding: 6px 10px calc(6px + env(safe-area-inset-bottom));
    background: var(--surface); border-top: 1px solid var(--border);
  }
  .work[data-page="activity"] .tabbar { grid-template-columns: 1fr 1fr 1fr; }
  .tab {
    display: flex; align-items: center; justify-content: center; gap: 8px; height: 46px; border: 0; border-radius: 12px;
    background: transparent; color: var(--muted); font-weight: 600; font-size: 14px; cursor: pointer;
  }
  .tab.active { background: var(--accent-soft); color: var(--accent); }
  :root[data-theme="dark"] .tab.active { color: #C7C9FF; }
  .tool-sep, #btn-fs-down, #btn-fs-up { display: none; }
  #btn-reset span { display: none; }
  .copy-long { display: none; }
  .copy-short { display: inline; }
  .check-long { display: none; }
  .check-short { display: inline; }
  dialog {
    margin: auto auto calc(12px + env(safe-area-inset-bottom));
    width: calc(100vw - 24px); max-width: none; border-radius: 18px;
    max-height: calc(100dvh - 24px - env(safe-area-inset-bottom));
  }
  .toast { bottom: 96px; }
}
/* narrow screens only (not phone-landscape, which is wide enough for columns) */
@media (max-width: 699px) {
  .hub { padding: 16px 12px 40px; }
  .hub-inner { gap: 18px; }
  .hero-text h1 { font-size: 27px; }
  .hero-text p { font-size: 16px; }
  .hero-card { padding: 16px; gap: 14px; }
  .ring { width: 80px; height: 80px; }
  .sec-head { padding: 14px; gap: 12px; }
  .sec-badge { width: 42px; height: 42px; }
  .sec-bar { display: none; }
  .sec-body { padding: 2px 12px 16px; }
  .grid { grid-template-columns: 1fr; }
  .cmp { grid-template-columns: 1fr; }
}
@media (max-width: 359px) { .check-short, #btn-check .check-long { display: none; } #btn-check { padding: 0 14px; } }
@media (max-width: 420px) { .nav-link span { font-size: 13.5px; } .nav-link { padding: 0 9px; } }

/* landscape phones: every pixel of height goes to the code */
@media (max-height: 520px) and (pointer: coarse) {
  .navbar { min-height: 46px; padding-block: 3px; }
  .toolbar { min-height: 42px; padding-block: 3px; }
  .tabbar { padding-block: 4px; }
  .tab { height: 38px; }
  .keybar { padding-block: 4px; }
  .keybar button { height: 36px; }
  .pane-head { min-height: 40px; padding-block: 2px; }
  .ed-gutter-inner { padding-bottom: 40px; }
  .ed-hl, .ed-input { padding-bottom: 40px; }
  .workspace { padding: 6px 8px; }
}

/* touch devices: bigger targets + quick-key bar */
@media (pointer: coarse) {
  :root { --code-size: 16px; }
  .ac-key, .ac-foot span:last-child { display: none; }
  .ac-tap { display: inline; }
  .ac-item { padding: 10px 10px; }
  .ac-label { font-size: 15px; }
  .tree-more { opacity: 1; }
  .tree-item { min-height: 44px; }
  .ctx-item { height: 44px; }
  .swatch { width: 34px; height: 34px; }
  .field input, .field select, .input-row input, #captcha-input { font-size: 16px; }
  .btn { height: 44px; }
  .btn.sm { height: 40px; }
  .btn.xl { height: 54px; }
  .icon-btn { width: 44px; height: 44px; }
  .icon-btn.sm { width: 40px; height: 40px; }
  .keybar { display: flex; }
}

@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* ═══════════════ Achievements: badges, toasts, tooltip, page ═══════════════ */
/* A badge is pure CSS: a hexagon in a metal tier ring, a face in the badge's own colour, and its own icon. */
.tier-bronze { --tier-bg: linear-gradient(145deg, #e8b184, #a8622f 55%, #6e3f1d); }
.tier-silver { --tier-bg: linear-gradient(145deg, #fafbfd, #b4bccb 55%, #7c8599); }
.tier-gold { --tier-bg: linear-gradient(145deg, #fff0a8, #f2b82e 50%, #b47a00); }
.tier-platinum { --tier-bg: linear-gradient(135deg, #f7fcff, #bda9ff 28%, #6fe0ff 55%, #f5f1ff 78%, #b9a7ff); }
.badge { --bs: 64px; position: relative; display: inline-block; flex: none; width: var(--bs); height: calc(var(--bs) * 1.1547); filter: drop-shadow(0 2px 3px rgba(10, 14, 30, .28)); }
.badge-ring, .badge-face { position: absolute; clip-path: polygon(50% 0, 100% 25%, 100% 75%, 50% 100%, 0 75%, 0 25%); }
.badge-ring { inset: 0; background: var(--tier-bg); }
.badge-face {
  inset: 7%; display: grid; place-items: center; color: #fff; text-shadow: 0 1px 2px rgba(0, 0, 0, .4);
  background: radial-gradient(circle at 30% 22%, color-mix(in srgb, var(--strip) 62%, #fff), var(--strip) 52%, color-mix(in srgb, var(--strip) 72%, #000));
}
.badge-face .ic { width: auto; font-size: calc(var(--bs) * .4); }
.badge[data-locked="true"] { filter: grayscale(1) drop-shadow(0 1px 2px rgba(10, 14, 30, .18)); opacity: .62; }
.badge[data-locked="true"] .badge-ring { background: linear-gradient(145deg, var(--border), var(--surface-2)); }
.badge[data-locked="true"] .badge-face { background: var(--surface-2); color: var(--muted); text-shadow: none; }
.badge-lock { position: absolute; right: 2%; bottom: 8%; display: grid; place-items: center; width: calc(var(--bs) * .32); height: calc(var(--bs) * .32); border-radius: 50%; background: var(--surface); color: var(--muted); border: 1px solid var(--border); }
.badge-lock .ic { width: auto; font-size: calc(var(--bs) * .15); }
.tier-chip { display: inline-flex; align-items: center; gap: 7px; }
.tier-chip::before { content: ''; width: 11px; height: 12.7px; background: var(--tier-bg); clip-path: polygon(50% 0, 100% 25%, 100% 75%, 50% 100%, 0 75%, 0 25%); }
.tier-chip .tier-dot { display: none; }

/* toasts */
.ach-toasts { position: fixed; right: 16px; bottom: 16px; z-index: 300; display: flex; flex-direction: column; gap: 10px; width: min(380px, calc(100vw - 24px)); pointer-events: none; }
.ach-toast { pointer-events: auto; display: flex; align-items: center; gap: 12px; padding: 10px 8px 10px 14px; background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--star); border-radius: 16px; box-shadow: var(--shadow); animation: ach-in .4s cubic-bezier(.2, .9, .3, 1.2); }
.ach-toast.leaving { opacity: 0; transform: translateY(8px); transition: opacity .2s, transform .2s; }
.ach-toast .badge { animation: ach-pop .6s .15s cubic-bezier(.2, 1.4, .4, 1) both; }
.ach-toast-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; text-align: left; border: 0; background: none; padding: 2px 0; cursor: pointer; border-radius: 8px; }
.ach-kicker { display: flex; align-items: center; gap: 6px; font-size: 11.5px; font-weight: 800; letter-spacing: .05em; text-transform: uppercase; color: var(--star); }
.ach-kicker .ic { width: auto; font-size: 12px; }
.ach-toast-main strong { font-size: 16px; font-weight: 800; letter-spacing: -.01em; }
.ach-sub { color: var(--muted); font-size: 13px; line-height: 1.35; }
.ach-summary-ic { display: grid; place-items: center; width: 50px; height: 50px; flex: none; border-radius: 50%; background: var(--accent-soft); color: var(--star); }
.ach-summary-ic .ic { width: auto; font-size: 22px; }
@keyframes ach-in { from { opacity: 0; transform: translateY(14px) scale(.96); } to { opacity: 1; transform: none; } }
@keyframes ach-pop { from { transform: scale(.4) rotate(-20deg); opacity: 0; } to { transform: none; opacity: 1; } }

/* tooltip (one shared element, see badge.js) */
#tip { position: fixed; z-index: 400; max-width: 260px; padding: 9px 12px; border-radius: 10px; background: #1a2036; color: #fff; font-size: 13px; line-height: 1.4; box-shadow: 0 8px 24px rgba(0, 0, 0, .35); pointer-events: none; display: flex; flex-direction: column; gap: 2px; border: 1px solid rgba(255, 255, 255, .12); }
#tip[hidden] { display: none; }
#tip strong { font-size: 13.5px; }
#tip .tip-status { margin-top: 3px; padding-top: 5px; border-top: 1px solid rgba(255, 255, 255, .18); color: #c9d1ec; font-size: 12px; font-weight: 600; }
#tip::after { content: ''; position: absolute; left: var(--arrow, 50%); width: 10px; height: 10px; background: #1a2036; transform: translateX(-50%) rotate(45deg); border: 1px solid rgba(255, 255, 255, .12); }
#tip[data-pos="above"]::after { bottom: -6px; border-top: 0; border-left: 0; }
#tip[data-pos="below"]::after { top: -6px; border-bottom: 0; border-right: 0; }

/* the page */
.achv { overflow-y: auto; padding: 28px 24px 56px; outline: none; }
.ach-inner { max-width: 1040px; margin: 0 auto; display: flex; flex-direction: column; gap: 22px; }
.ach-head { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(280px, .8fr); gap: 20px; align-items: center; }
.ach-title h1 { font-size: 34px; font-weight: 800; letter-spacing: -.03em; line-height: 1.15; outline: none; }
.ach-title p { margin: 8px 0 0; color: var(--muted); font-size: 16px; line-height: 1.55; max-width: 48ch; }
.ach-total { padding: 18px 20px; border: 1px solid var(--border); border-radius: 18px; background: var(--surface); box-shadow: var(--shadow-sm); display: flex; flex-direction: column; gap: 10px; }
.ach-count { color: var(--muted); font-size: 15px; } .ach-count b { color: var(--text); font-size: 28px; font-weight: 800; letter-spacing: -.02em; }
.ach-bar { display: block; height: 8px; border-radius: 8px; background: var(--border); overflow: hidden; }
.ach-bar i { display: block; height: 100%; border-radius: 8px; background: var(--run); transition: width .4s; }
.ach-bar.big { height: 12px; }
.ach-tiers { display: flex; flex-wrap: wrap; gap: 6px; }
.ach-tiers .chip { padding: 4px 10px; font-size: 12.5px; }
.ach-bar-row { display: flex; }
.ach-sec-head { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 12px; margin-bottom: 12px; }
.ach-sec-head h2 { display: flex; align-items: center; gap: 10px; font-size: 19px; font-weight: 800; letter-spacing: -.02em; }
.ach-sec-head h2 .ic { width: auto; color: var(--accent); font-size: 17px; }
:root[data-theme="dark"] .ach-sec-head h2 .ic { color: #C7C9FF; }
.ach-sec-n { padding: 1px 9px; border-radius: 99px; background: var(--surface-2); color: var(--muted); font-size: 12.5px; font-weight: 700; }
.ach-sec-head p { flex-basis: 100%; margin: 0; color: var(--muted); font-size: 14px; }
.ach-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; }
.ach-tile {
  display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 16px 10px 14px; text-align: center; cursor: pointer;
  border: 1px solid var(--border); border-radius: 18px; background: var(--surface); transition: transform .12s, box-shadow .12s, border-color .12s;
}
.ach-tile:hover { transform: translateY(-2px); box-shadow: var(--shadow); border-color: color-mix(in srgb, var(--accent) 40%, var(--border)); }
.ach-tile[data-state="on"] { background: color-mix(in srgb, var(--star) 6%, var(--surface)); }
.ach-name { font-weight: 700; font-size: 14px; line-height: 1.25; letter-spacing: -.01em; }
.ach-tile[data-state="off"] .ach-name { color: var(--muted); }
.ach-when { display: inline-flex; align-items: center; gap: 6px; color: var(--ok); font-size: 12.5px; font-weight: 700; }
.ach-when .ic { width: auto; font-size: 12px; }
.ach-when.off { color: var(--muted); font-weight: 600; }
.ach-prog { display: flex; align-items: center; gap: 8px; width: 100%; color: var(--muted); font-size: 12px; font-weight: 700; }
.ach-prog .ach-bar { flex: 1; height: 6px; }

/* detail dialog */
.badge-body { display: flex; flex-direction: column; gap: 16px; padding-bottom: 4px; }
.bd-top { display: flex; align-items: center; gap: 18px; }
.bd-id h2 { font-size: 24px; font-weight: 800; letter-spacing: -.02em; line-height: 1.2; }
.bd-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.bd-chips .chip { padding: 4px 10px; font-size: 12.5px; }
.badge-body h3 { font-size: 12.5px; font-weight: 800; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); margin-bottom: 4px; }
.badge-body p { margin: 0; font-size: 15.5px; line-height: 1.55; }
.bd-status { display: flex; gap: 12px; align-items: flex-start; padding: 14px 16px; border-radius: 14px; border: 1px solid var(--border); background: var(--surface-2); }
.bd-status > .ic { width: auto; font-size: 20px; margin-top: 2px; }
.bd-status > div { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1; }
.bd-status.on { background: var(--ok-soft); border-color: color-mix(in srgb, var(--ok) 35%, var(--border)); } .bd-status.on > .ic { color: var(--ok); }
.bd-status.off > .ic { color: var(--muted); } .bd-status small { color: var(--muted); }
.bd-status .ach-bar { margin-top: 8px; }

/* on profiles */
.p-badges { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.p-badge { padding: 4px 4px 2px; border: 0; background: none; border-radius: 12px; cursor: pointer; transition: transform .12s; }
.p-badge:hover { transform: translateY(-2px) scale(1.06); }
.p-more { margin-top: 10px; }

@media (max-width: 999px) { .ach-head { grid-template-columns: 1fr; } }
@media (max-width: 699px) {
  .achv { padding: 16px 12px 40px; }
  .ach-title h1 { font-size: 27px; }
  .ach-grid { grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 8px; }
  .ach-tile { padding: 12px 6px 10px; }
  #nav-achievements span { display: none; } #nav-achievements { padding: 0 11px; }
  .ach-toasts { right: 12px; left: 12px; bottom: auto; top: calc(var(--nav-h) + 8px); width: auto; }
  .bd-top { gap: 14px; }
}

/* Practice / Achievements are locked for guests (see renderNavGate in app.js) */
.nav-link.locked { opacity: .6; cursor: not-allowed; }
.nav-link.locked:hover { background: transparent; color: var(--muted); }
.nav-link .nav-lock { width: auto; font-size: 11px; margin-left: -2px; }

/* code pane tools: Clear / Undo / Redo (labels collapse to icons on narrower screens, like "Start again") */
.icon-btn:disabled { opacity: .35; cursor: default; }
.icon-btn:disabled:hover { background: transparent; color: var(--muted); }
@media (max-width: 999px) { #btn-clear-code span { display: none; } #btn-clear-code { padding: 0 8px; } }
#btn-clear-code:hover { color: var(--danger); }

/* ---- Version history of a file ---- */
#dlg-history { width: min(560px, calc(100vw - 24px)); }
.hist-list { list-style: none; margin: 12px 0 0; padding: 0; display: grid; gap: 8px; max-height: 52vh; overflow: auto; }
.hist-row { border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; display: grid; gap: 8px; }
.hist-line { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.hist-info { display: grid; gap: 2px; }
.hist-info span { font-size: 13px; color: var(--muted); }
.hist-actions { display: flex; gap: 6px; }
.hist-peek { margin: 0; max-height: 200px; overflow: auto; padding: 10px 12px; border-radius: 8px; background: var(--surface-2, var(--surface)); border: 1px solid var(--border); font: 13px/1.5 var(--font-code); white-space: pre; tab-size: 4; }
.hist-empty { color: var(--muted); padding: 8px 2px; }

/* Very narrow phones: the code toolbar has six icon buttons now, so "Clear" shows just its icon (it keeps its tooltip and label). */
@media (max-width: 420px) { #btn-clear-code span { display: none; } }

/* ---- Mission complete pop-up ---- */
#dlg-complete { width: min(460px, calc(100vw - 24px)); max-height: calc(100dvh - 24px); overflow-y: auto; }
#dlg-complete .celebrate.try-again, .celebrate.try-again { background: var(--accent-soft); }
.celebrate.try-again .trophy { color: var(--accent); animation: none; }
#dlg-complete .fail-detail { margin-top: 12px; }
#dlg-complete .cd-head { margin-bottom: 0; }
#dlg-complete .celebrate { margin-top: -8px; }
#dlg-complete .cd-progress { margin: 10px 0 0; text-align: center; font-size: 13px; color: var(--muted); }
#dlg-complete .checks-next { flex-direction: column; }
#dlg-complete .checks-next .btn { flex: none; width: 100%; }
#dlg-complete > .btn.block { margin-top: 8px; }

/* ---------- guided tour (see tour.js) ---------- */
#dlg-tour { width: min(420px, calc(100vw - 24px)); text-align: center; }
.tour-q { display: flex; flex-direction: column; align-items: center; gap: 10px; }
.tour-q .tour-q-ic { font-size: 38px; color: var(--accent); }
.tour-q h2 { font-size: 22px; font-weight: 800; letter-spacing: -.02em; }
.tour-q p { margin: 0; color: var(--muted); font-size: 14.5px; line-height: 1.5; }
.tour-q-btns { display: flex; flex-direction: column; gap: 8px; width: 100%; margin-top: 8px; }
.tour-q-btns .btn { width: 100%; justify-content: center; }
.tour-q .tour-q-note { font-size: 12.5px; }
.tour-layer { position: fixed; inset: 0; z-index: 500; }
.tour-layer[data-center] { background: rgba(10, 14, 28, .62); }
.tour-hole { position: fixed; left: var(--tx, 0); top: var(--ty, 0); width: var(--tw, 0); height: var(--th, 0); border-radius: 12px; pointer-events: none;
  box-shadow: 0 0 0 100vmax rgba(10, 14, 28, .62), 0 0 0 3px var(--accent); transition: left .25s, top .25s, width .25s, height .25s; }
.tour-layer[data-center] .tour-hole { display: none; }
.tour-card { position: fixed; left: var(--cx, 12px); top: var(--cy, 12px); width: min(350px, calc(100vw - 16px)); display: flex; flex-direction: column; gap: 8px;
  padding: 16px 18px; background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: 16px; box-shadow: var(--shadow); }
.tour-card h2 { font-size: 17px; font-weight: 800; letter-spacing: -.01em; }
.tour-card p { margin: 0; color: var(--muted); font-size: 14px; line-height: 1.5; }
.tour-foot { display: flex; align-items: center; gap: 8px; margin-top: 8px; }
.tour-count { font-size: 12.5px; font-weight: 600; color: var(--muted); white-space: nowrap; }
@media (prefers-reduced-motion: reduce) { .tour-hole { transition: none; } }
