/* =========================================================================
   OpenClassroomTool — the one stylesheet every page loads.

   1. Fonts and tokens (light, dark)      6. Tool page: head, shell, stage
   2. Base, layout, utilities             7. Present mode
   3. Header, menus, search               8. Settings controls
   4. Buttons, forms, dialogs, toast      9. Stage primitives shared by tools
   5. Home, category, cards, content     10. Footer, print

   Tools that need more bring their own sheet (assets/css/tools/<slug>.css).
   Sizes inside a tool's stage use container units (cqmin), so one tool
   lays itself out the same in a small Board widget and on a projector.
   ========================================================================= */

/* ---- 1. Fonts and tokens ------------------------------------------------ */

@font-face {
  font-family: "Lexend";
  src: url("../fonts/lexend-latin.woff2") format("woff2");
  font-weight: 300 800;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Lexend";
  src: url("../fonts/lexend-latin-ext.woff2") format("woff2");
  font-weight: 300 800;
  font-display: swap;
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

:root {
  --brand: #12324a;
  --brand-600: #1a4466;
  --brand-700: #0d2638;
  --accent: #1f9d76;
  --accent-600: #17835f;

  --ink: #18212d;
  --ink-soft: #465263;
  --muted: #6b7686;
  --line: #e1e6ed;
  --line-soft: #edf1f6;
  --bg: #f3f6fa;
  --bg-deep: #e9eef5;
  --card: #ffffff;
  --card-alt: #f7f9fc;
  --field: #ffffff;
  --header-bg: #12324a;
  --header-ink: #ffffff;
  --stage-bg: #ffffff;
  --stage-ink: #18212d;
  --ring: rgba(47, 116, 208, .4);
  --danger: #d64545;
  --warn: #e39a05;
  --ok: #1f9d76;

  --c-time: #2f74d0;
  --c-random: #e8710a;
  --c-manage: #14936b;
  --c-teach: #7c4ddb;
  --cat: var(--accent);

  --radius: 14px;
  --radius-sm: 10px;
  --radius-lg: 22px;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, .06);
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 8px 24px rgba(16, 24, 40, .07);
  --shadow-lg: 0 2px 6px rgba(16, 24, 40, .08), 0 22px 48px rgba(16, 24, 40, .16);

  --font: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-display: "Lexend", var(--font);
  --header-h: 64px;
  --maxw: 1480px;
  --gutter: 28px;
  color-scheme: light;
}

:root[data-theme="dark"] {
  --brand: #8fc3ff;
  --brand-600: #a9d1ff;
  --brand-700: #c9e2ff;
  --ink: #e6ebf2;
  --ink-soft: #b4bfcd;
  --muted: #8a96a7;
  --line: #2a3442;
  --line-soft: #222b37;
  --bg: #0e141c;
  --bg-deep: #0a0f15;
  --card: #161e29;
  --card-alt: #1b2431;
  --field: #111821;
  --header-bg: #0b1119;
  --stage-bg: #121a24;
  --stage-ink: #edf1f6;
  --ring: rgba(120, 170, 255, .5);
  --c-time: #5b9bf0;
  --c-random: #ff9440;
  --c-manage: #33bb8d;
  --c-teach: #a07cf5;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
  --shadow: 0 1px 2px rgba(0, 0, 0, .35), 0 8px 24px rgba(0, 0, 0, .35);
  --shadow-lg: 0 2px 6px rgba(0, 0, 0, .4), 0 22px 48px rgba(0, 0, 0, .55);
  color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --brand: #8fc3ff;
    --brand-600: #a9d1ff;
    --brand-700: #c9e2ff;
    --ink: #e6ebf2;
    --ink-soft: #b4bfcd;
    --muted: #8a96a7;
    --line: #2a3442;
    --line-soft: #222b37;
    --bg: #0e141c;
    --bg-deep: #0a0f15;
    --card: #161e29;
    --card-alt: #1b2431;
    --field: #111821;
    --header-bg: #0b1119;
    --stage-bg: #121a24;
    --stage-ink: #edf1f6;
    --ring: rgba(120, 170, 255, .5);
    --c-time: #5b9bf0;
    --c-random: #ff9440;
    --c-manage: #33bb8d;
    --c-teach: #a07cf5;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
    --shadow: 0 1px 2px rgba(0, 0, 0, .35), 0 8px 24px rgba(0, 0, 0, .35);
    --shadow-lg: 0 2px 6px rgba(0, 0, 0, .4), 0 22px 48px rgba(0, 0, 0, .55);
    color-scheme: dark;
  }
}

.cat-time   { --cat: var(--c-time); }
.cat-random { --cat: var(--c-random); }
.cat-manage { --cat: var(--c-manage); }
.cat-teach  { --cat: var(--c-teach); }

/* ---- 2. Base, layout, utilities ------------------------------------------- */

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: calc(var(--header-h) + 12px); }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.55 var(--font);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
main { flex: 1 0 auto; outline: none; }
img, svg, canvas { display: block; max-width: 100%; }
svg.icon { display: inline-block; flex: none; vertical-align: middle; }
a { color: var(--c-time); text-decoration-thickness: 1px; text-underline-offset: 2px; }
a:hover { text-decoration-thickness: 2px; }
h1, h2, h3, h4 { font-family: var(--font-display); line-height: 1.2; margin: 0 0 .5em; letter-spacing: -.01em; font-weight: 650; }
h1 { font-size: clamp(1.7rem, 2.6vw, 2.35rem); }
h2 { font-size: clamp(1.3rem, 1.8vw, 1.65rem); }
h3 { font-size: 1.15rem; }
p { margin: 0 0 1em; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid var(--ring); outline-offset: 2px; }
::selection { background: color-mix(in srgb, var(--c-time) 30%, transparent); }
[hidden] { display: none !important; }
kbd {
  font: 600 .78em/1 var(--font);
  padding: .25em .5em;
  border-radius: 6px;
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  background: var(--card-alt);
  color: var(--ink-soft);
}

.wrap { width: 100%; max-width: var(--maxw); margin: 0 auto; padding: 0 var(--gutter); }
.muted { color: var(--muted); }
.sr-only {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}
.skip-link {
  position: absolute; left: 12px; top: -60px; z-index: 2000;
  background: var(--card); color: var(--ink); padding: 10px 16px; border-radius: var(--radius-sm);
  box-shadow: var(--shadow); transition: top .15s;
}
.skip-link:focus { top: 12px; }
.noscript { padding: 16px; background: #fff4d6; color: #5b4300; border-radius: var(--radius-sm); }

/* ---- 3. Header, menus, search --------------------------------------------- */

.site-header {
  position: sticky; top: 0; z-index: 500;
  background: var(--header-bg);
  color: var(--header-ink);
  box-shadow: 0 1px 0 rgba(255, 255, 255, .06), 0 6px 20px rgba(5, 15, 30, .18);
}
.header-inner { height: var(--header-h); display: flex; align-items: center; gap: 14px; }
.brand { display: flex; align-items: center; gap: 10px; color: inherit; text-decoration: none; flex: none; }
.brand .logo { width: 34px; height: 34px; border-radius: 8px; box-shadow: 0 0 0 1px rgba(255, 255, 255, .14); }
.brand-name { font: 600 1.18rem/1 var(--font-display); letter-spacing: -.02em; white-space: nowrap; }
.brand-name b { font-weight: 700; color: #ffc24a; }

.main-nav { flex: 1 1 auto; min-width: 0; }
.nav-list { list-style: none; margin: 0; padding: 0; display: flex; gap: 2px; }
.nav-menu { position: relative; }
.nav-menu > summary { list-style: none; }
.nav-menu > summary::-webkit-details-marker { display: none; }
.nav-link {
  display: flex; align-items: center; gap: 7px;
  height: 40px; padding: 0 12px; border-radius: 10px;
  color: rgba(255, 255, 255, .9); font-weight: 600; font-size: .95rem; white-space: nowrap;
  cursor: pointer; user-select: none; transition: background .15s;
}
.nav-link .icon:first-child { color: color-mix(in srgb, var(--cat) 55%, white); }
.nav-link .chev { opacity: .6; transition: transform .2s; }
.nav-link:hover, .nav-menu[open] > .nav-link { background: rgba(255, 255, 255, .1); }
.nav-menu[open] > .nav-link .chev { transform: rotate(180deg); }
.nav-link.is-active { background: rgba(255, 255, 255, .12); box-shadow: inset 0 -3px 0 var(--cat); }

.menu-panel {
  position: absolute; top: calc(100% + 10px); left: 0; z-index: 10;
  width: min(680px, calc(100vw - 40px));
  padding: 18px; border-radius: var(--radius-lg);
  background: var(--card); color: var(--ink);
  box-shadow: var(--shadow-lg); border: 1px solid var(--line);
  border-top: 4px solid var(--cat);
  animation: menu-in .16s ease-out;
}
/* The last menu opens leftwards so it never runs off a 1366px screen. */
.nav-menu:last-of-type .menu-panel { left: auto; right: 0; }
@keyframes menu-in { from { opacity: 0; transform: translateY(-6px); } }
.menu-blurb { color: var(--muted); font-size: .9rem; margin: 0 4px 12px; }
.menu-grid { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 4px; }
.menu-item {
  display: flex; gap: 12px; align-items: flex-start; padding: 10px; border-radius: 12px;
  color: var(--ink); text-decoration: none; transition: background .12s;
}
.menu-item:hover { background: var(--card-alt); }
.menu-item b { display: block; font-weight: 600; font-size: .95rem; line-height: 1.25; }
.menu-item small { display: block; color: var(--muted); font-size: .8rem; line-height: 1.35; margin-top: 2px; }
.menu-all {
  display: inline-flex; align-items: center; gap: 6px; margin: 12px 4px 0;
  font-weight: 600; font-size: .9rem; color: var(--cat); text-decoration: none;
}

.tile-icon {
  flex: none; display: grid; place-items: center;
  width: 40px; height: 40px; border-radius: 11px;
  color: #fff;
  background: linear-gradient(145deg, color-mix(in srgb, var(--cat) 78%, white), var(--cat) 55%, color-mix(in srgb, var(--cat) 80%, black));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .35), inset 0 -2px 0 rgba(0, 0, 0, .15), 0 3px 8px color-mix(in srgb, var(--cat) 35%, transparent);
}

.header-search { position: relative; flex: 0 1 240px; min-width: 150px; }
.header-search input {
  width: 100%; height: 40px; padding: 0 34px 0 38px;
  border-radius: 999px; border: 1px solid rgba(255, 255, 255, .16);
  background: rgba(255, 255, 255, .09); color: #fff; outline: none;
  transition: background .15s, border-color .15s;
}
.header-search input::placeholder { color: rgba(255, 255, 255, .62); }
.header-search input:focus { background: rgba(255, 255, 255, .16); border-color: rgba(255, 255, 255, .4); }
.header-search .search-icon { position: absolute; left: 13px; top: 11px; opacity: .7; pointer-events: none; }
.search-kbd {
  position: absolute; right: 10px; top: 10px; background: rgba(255, 255, 255, .12);
  border-color: rgba(255, 255, 255, .2); color: rgba(255, 255, 255, .75); pointer-events: none;
}
.header-search input:focus ~ .search-kbd, .header-search input:not(:placeholder-shown) ~ .search-kbd { display: none; }
.search-results {
  position: absolute; top: calc(100% + 8px); right: 0; width: min(420px, 92vw); max-height: 70vh; overflow: auto;
  background: var(--card); color: var(--ink); border-radius: var(--radius); border: 1px solid var(--line);
  box-shadow: var(--shadow-lg); padding: 6px;
}
.search-hit {
  display: flex; gap: 12px; align-items: center; padding: 8px 10px; border-radius: 10px;
  color: var(--ink); text-decoration: none;
}
.search-hit .tile-icon { width: 34px; height: 34px; border-radius: 9px; }
.search-hit b { display: block; font-weight: 600; font-size: .95rem; }
.search-hit small { display: block; color: var(--muted); font-size: .8rem; line-height: 1.3; }
.search-hit[aria-selected="true"], .search-hit:hover { background: var(--card-alt); }
.search-none { padding: 14px; color: var(--muted); font-size: .92rem; }

.btn-board { flex: none; }
.site-header .btn-board {
  background: #ffc24a; color: #2a1d00; border-color: transparent; box-shadow: 0 2px 0 #c9901b;
}
.site-header .btn-board:hover { background: #ffd06e; }
.site-header .btn-board.is-active { box-shadow: 0 0 0 3px rgba(255, 194, 74, .35); }

.icon-btn {
  flex: none; display: inline-grid; place-items: center; width: 40px; height: 40px;
  border-radius: 10px; border: 0; background: transparent; color: inherit;
}
.icon-btn:hover { background: rgba(127, 140, 160, .16); }
.theme-toggle .i-sun { display: none; }
:root[data-theme="dark"] .theme-toggle .i-sun { display: block; }
:root[data-theme="dark"] .theme-toggle .i-moon { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle .i-sun { display: block; }
  :root:not([data-theme="light"]) .theme-toggle .i-moon { display: none; }
}
.nav-toggle { display: none; }

@media (max-width: 1480px) {
  .nav-link .icon:first-child { display: none; }
}
@media (max-width: 1340px) {
  .header-inner { gap: 10px; }
  .nav-link { padding: 0 8px; font-size: .9rem; gap: 5px; }
  .header-search { flex-basis: 170px; min-width: 120px; }
}
@media (max-width: 1240px) {
  .site-header .btn-board { padding: 0 11px; }
  .btn-board span { display: none; }
}
@media (max-width: 980px) {
  :root { --gutter: 16px; }
  .nav-toggle { display: inline-grid; }
  .main-nav {
    display: none; position: absolute; top: var(--header-h); left: 0; right: 0;
    background: var(--header-bg); padding: 8px 16px 16px; box-shadow: 0 12px 24px rgba(0, 0, 0, .25);
  }
  .main-nav.is-open { display: block; }
  .nav-list { flex-direction: column; }
  .menu-panel { position: static; width: auto; margin: 6px 0 10px; animation: none; }
  .menu-grid { grid-template-columns: 1fr; }
  .header-search { flex: 1 1 auto; }
  .brand-name { display: none; }
}

.breadcrumbs ol { list-style: none; margin: 0; padding: 14px 0 0; display: flex; flex-wrap: wrap; gap: 6px; font-size: .88rem; color: var(--muted); }
.breadcrumbs li + li::before { content: "›"; margin-right: 6px; opacity: .6; }
.breadcrumbs a { color: var(--ink-soft); text-decoration: none; }
.breadcrumbs a:hover { color: var(--ink); text-decoration: underline; }

/* ---- 4. Buttons, forms, dialogs, toast ------------------------------------- */

.btn {
  --b: var(--card);
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 42px; padding: 0 16px; border-radius: 11px;
  border: 1px solid var(--line); background: var(--b); color: var(--ink);
  font-weight: 600; font-size: .95rem; text-decoration: none; white-space: nowrap;
  box-shadow: var(--shadow-sm); transition: background .12s, border-color .12s, transform .06s, box-shadow .12s;
}
.btn:hover { border-color: color-mix(in srgb, var(--ink) 25%, var(--line)); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary {
  background: var(--cat); border-color: transparent; color: #fff;
  box-shadow: 0 2px 0 color-mix(in srgb, var(--cat) 70%, black), 0 6px 16px color-mix(in srgb, var(--cat) 30%, transparent);
}
.btn-primary:hover { background: color-mix(in srgb, var(--cat) 88%, white); }
.btn-ghost { background: transparent; box-shadow: none; border-color: transparent; color: var(--ink-soft); }
.btn-ghost:hover { background: color-mix(in srgb, var(--ink) 7%, transparent); color: var(--ink); }
.btn-danger { color: var(--danger); }
.btn-sm { min-height: 34px; padding: 0 11px; font-size: .86rem; border-radius: 9px; }
.btn-lg { min-height: 52px; padding: 0 22px; font-size: 1.05rem; border-radius: 13px; }
.btn.is-on { background: color-mix(in srgb, var(--cat) 14%, var(--card)); border-color: color-mix(in srgb, var(--cat) 50%, var(--line)); color: var(--ink); }

input[type="text"], input[type="number"], input[type="url"], input[type="search"]:not([data-search-input]), input[type="time"], select, textarea {
  width: 100%; min-height: 40px; padding: 8px 11px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--field); color: var(--ink);
  transition: border-color .12s, box-shadow .12s;
}
textarea { min-height: 120px; resize: vertical; line-height: 1.45; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--c-time); box-shadow: 0 0 0 3px var(--ring); }
input[type="range"] { width: 100%; accent-color: var(--cat); }
input[type="checkbox"], input[type="radio"] { accent-color: var(--cat); width: 18px; height: 18px; }
input[type="color"] { width: 40px; height: 34px; padding: 2px; border-radius: 8px; border: 1px solid var(--line); background: var(--field); }

.modal {
  border: 0; padding: 0; border-radius: var(--radius-lg); width: min(560px, calc(100vw - 32px));
  background: var(--card); color: var(--ink); box-shadow: var(--shadow-lg);
}
.modal::backdrop { background: rgba(8, 15, 25, .55); backdrop-filter: blur(3px); }
.modal-head { display: flex; align-items: center; gap: 12px; padding: 18px 20px 6px; }
.modal-head h2 { flex: 1; margin: 0; font-size: 1.25rem; }
.modal-body { padding: 8px 20px 4px; }
.modal-foot { display: flex; gap: 10px; justify-content: flex-end; padding: 14px 20px 18px; flex-wrap: wrap; }
.modal-foot .spacer { flex: 1; }
.modal .help { font-size: .86rem; color: var(--muted); margin: 6px 0 0; }
.keys-table { width: 100%; border-collapse: collapse; }
.keys-table td { padding: 8px 4px; border-bottom: 1px solid var(--line-soft); }
.keys-table td:first-child { width: 130px; white-space: nowrap; }

.toast {
  position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%); z-index: 3000;
  display: flex; align-items: center; gap: 14px;
  background: #18212d; color: #fff; padding: 12px 18px; border-radius: 12px; box-shadow: var(--shadow-lg);
  font-weight: 500; max-width: calc(100vw - 32px);
  animation: toast-in .2s ease-out;
}
.toast a { color: #ffd06e; font-weight: 600; }
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 10px); } }

/* ---- 5. Home, category, cards, content ------------------------------------ */

.hero { padding-block: 44px 26px; position: relative; overflow: hidden; }
.hero::before {
  content: ""; position: absolute; inset: -40% -10% auto; height: 560px; z-index: -1;
  background:
    radial-gradient(520px 260px at 12% 30%, color-mix(in srgb, var(--c-time) 16%, transparent), transparent 70%),
    radial-gradient(460px 260px at 52% 10%, color-mix(in srgb, var(--c-random) 13%, transparent), transparent 70%),
    radial-gradient(520px 300px at 88% 40%, color-mix(in srgb, var(--c-teach) 15%, transparent), transparent 70%);
}
.hero-grid { display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, .95fr); gap: 40px; align-items: center; }
.hero h1 { font-size: clamp(2rem, 3.6vw, 3.1rem); line-height: 1.08; letter-spacing: -.025em; margin-bottom: .4em; }
.hero h1 em { font-style: normal; background: linear-gradient(90deg, var(--c-time), var(--c-teach)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.hero-lead { font-size: 1.15rem; color: var(--ink-soft); max-width: 40em; }
.hero-search { position: relative; max-width: 560px; margin: 22px 0 16px; }
.hero-search input[data-home-filter] {
  width: 100%; height: 58px; padding: 0 20px 0 54px; border-radius: 16px; font-size: 1.08rem;
  border: 1px solid var(--line); background: var(--card); color: var(--ink); box-shadow: var(--shadow);
}
.hero-search input[data-home-filter]:focus { outline: none; border-color: var(--c-time); box-shadow: 0 0 0 4px var(--ring), var(--shadow); }
.hero-search .icon { position: absolute; left: 19px; top: 19px; color: var(--muted); pointer-events: none; }
.quick-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  display: inline-flex; align-items: center; gap: 7px; padding: 7px 13px 7px 9px; border-radius: 999px;
  background: var(--card); border: 1px solid var(--line); color: var(--ink); text-decoration: none;
  font-weight: 600; font-size: .9rem; box-shadow: var(--shadow-sm); transition: transform .12s, box-shadow .12s;
}
.chip .icon { color: var(--cat); }
.chip:hover { transform: translateY(-1px); box-shadow: var(--shadow); }
.hero-art { position: relative; }
.hero-art svg { width: 100%; height: auto; filter: drop-shadow(0 24px 40px rgba(16, 24, 40, .18)); }
.hero-trust { display: flex; flex-wrap: wrap; gap: 18px; margin-top: 20px; color: var(--muted); font-size: .9rem; }
.hero-trust span { display: inline-flex; gap: 6px; align-items: center; }

.section { padding-block: 26px; }
.section-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 16px; }
.section-head h2 { margin: 0; display: flex; align-items: center; gap: 12px; }
.section-head p { margin: 4px 0 0; color: var(--muted); }
.section-head .tile-icon { width: 38px; height: 38px; }
.section-link { font-weight: 600; text-decoration: none; color: var(--cat); display: inline-flex; gap: 6px; align-items: center; white-space: nowrap; }

.tool-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 16px; }
.tool-card {
  position: relative; display: flex; flex-direction: column; gap: 10px;
  padding: 18px; border-radius: var(--radius-lg); background: var(--card);
  border: 1px solid var(--line); color: var(--ink); text-decoration: none;
  box-shadow: var(--shadow-sm); transition: transform .16s, box-shadow .16s, border-color .16s;
  overflow: hidden;
}
.tool-card::after {
  content: ""; position: absolute; inset: auto -30% -60% auto; width: 180px; height: 180px; border-radius: 50%;
  background: radial-gradient(circle, color-mix(in srgb, var(--cat) 14%, transparent), transparent 70%);
  pointer-events: none; transition: transform .3s;
}
.tool-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); border-color: color-mix(in srgb, var(--cat) 40%, var(--line)); }
.tool-card:hover::after { transform: scale(1.25); }
.tool-card .tile-icon { width: 50px; height: 50px; border-radius: 14px; }
.tool-card h3 { margin: 4px 0 0; font-size: 1.08rem; }
.tool-card p { margin: 0; color: var(--ink-soft); font-size: .92rem; line-height: 1.45; }
.badges { display: flex; gap: 6px; margin-top: auto; padding-top: 4px; }
.badge {
  font: 700 .68rem/1 var(--font); letter-spacing: .04em; text-transform: uppercase;
  padding: 5px 7px; border-radius: 6px; background: var(--card-alt); color: var(--muted); border: 1px solid var(--line-soft);
}
.badge-3d { background: linear-gradient(135deg, #7c4ddb, #2f74d0); color: #fff; border-color: transparent; }

.recent-row { display: flex; flex-wrap: wrap; gap: 8px; }

.board-cta {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 24px; align-items: center;
  padding: 26px 30px; border-radius: var(--radius-lg); color: #fff;
  background: radial-gradient(600px 220px at 85% 0%, rgba(255, 194, 74, .35), transparent 60%), linear-gradient(120deg, #12324a, #1f4f7a 60%, #2a5d8f);
  box-shadow: var(--shadow-lg);
}
.board-cta h2 { color: #fff; margin-bottom: 6px; }
.board-cta p { color: rgba(255, 255, 255, .82); margin: 0; }
.tpl-row { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 16px; }
.tpl-chip {
  display: inline-flex; align-items: center; gap: 8px; padding: 9px 14px; border-radius: 12px;
  background: rgba(255, 255, 255, .12); border: 1px solid rgba(255, 255, 255, .2); color: #fff; text-decoration: none; font-weight: 600; font-size: .92rem;
}
.tpl-chip:hover { background: rgba(255, 255, 255, .2); }
.board-cta .btn-lg { background: #ffc24a; color: #2a1d00; border: 0; box-shadow: 0 3px 0 #c9901b; }

.page-head { padding-block: 22px 6px; }
.page-head p { color: var(--ink-soft); font-size: 1.08rem; max-width: 52em; }

.prose { max-width: 820px; }
.prose h2 { margin-top: 1.4em; }
.prose ul, .prose ol { padding-left: 1.3em; }
.prose li { margin: .3em 0; }

.content-grid { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 40px; padding-block: 36px 20px; align-items: start; }
.content-main > section { margin-bottom: 34px; }
.steps { list-style: none; counter-reset: step; padding: 0; margin: 0; display: grid; gap: 12px; }
.steps li { counter-increment: step; display: grid; grid-template-columns: 36px 1fr; gap: 12px; align-items: start; }
.steps li::before {
  content: counter(step); display: grid; place-items: center; width: 32px; height: 32px; border-radius: 50%;
  background: color-mix(in srgb, var(--cat) 14%, var(--card)); color: var(--cat); font: 700 .95rem/1 var(--font-display);
}
.steps b { display: block; }
.ideas { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; list-style: none; padding: 0; margin: 0; }
.ideas li { padding: 14px 16px; border-radius: var(--radius); background: var(--card); border: 1px solid var(--line); line-height: 1.45; }
.ideas li::before { content: "💡"; margin-right: 6px; }
.faq details { border-bottom: 1px solid var(--line); padding: 4px 0; }
.faq summary { cursor: pointer; padding: 12px 28px 12px 0; font-weight: 600; position: relative; list-style: none; }
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after { content: "+"; position: absolute; right: 4px; top: 8px; font-size: 1.4rem; color: var(--muted); }
.faq details[open] summary::after { content: "–"; }
.faq .answer { padding: 0 0 14px; color: var(--ink-soft); }
.side-card { padding: 18px; border-radius: var(--radius-lg); background: var(--card); border: 1px solid var(--line); box-shadow: var(--shadow-sm); position: sticky; top: calc(var(--header-h) + 20px); }
.side-card h2 { font-size: 1.05rem; }
.side-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 2px; }
.side-list a { display: flex; gap: 10px; align-items: center; padding: 7px 8px; border-radius: 10px; color: var(--ink); text-decoration: none; font-weight: 500; font-size: .94rem; }
.side-list a:hover { background: var(--card-alt); }
.side-list .tile-icon { width: 30px; height: 30px; border-radius: 8px; }
.updated { font-size: .85rem; color: var(--muted); }

/* ---- 6. Tool page: head, shell, stage ------------------------------------- */

.tool-head { display: flex; align-items: center; gap: 20px; padding-block: 12px 14px; }
.tool-title { display: flex; align-items: center; gap: 14px; flex: 1; min-width: 0; }
.tool-title .tile-icon { width: 48px; height: 48px; border-radius: 14px; }
.tool-title h1 { margin: 0; font-size: clamp(1.45rem, 2vw, 1.9rem); }
.tool-title p { margin: 2px 0 0; color: var(--muted); font-size: .95rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tool-actions { display: flex; gap: 8px; flex: none; }
.tool-actions .btn { min-height: 40px; }
.tool-actions .i-mute { display: none; }
.is-muted .tool-actions .i-sound, .is-muted .present-bar .i-sound { display: none; }
.is-muted .tool-actions .i-mute, .is-muted .present-bar .i-mute { display: inline-block; }
.present-bar .i-mute { display: none; }

.tool-shell {
  display: grid; grid-template-columns: minmax(0, 1fr) 330px; gap: 18px;
  height: clamp(460px, calc(100vh - var(--header-h) - 140px), 980px);
}
.tool-shell.no-settings { grid-template-columns: minmax(0, 1fr); }
.stage {
  position: relative; container-type: size; overflow: hidden; min-width: 0;
  border-radius: var(--radius-lg); background: var(--stage-bg); color: var(--stage-ink);
  border: 1px solid var(--line); box-shadow: var(--shadow), inset 0 4px 0 var(--cat);
  isolation: isolate;
}
.stage-loading { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); }
.stage-loading::before {
  content: ""; width: 44px; height: 44px; border-radius: 50%; border: 4px solid var(--line); border-top-color: var(--cat);
  animation: spin 1s linear infinite; margin-bottom: 70px;
}
@keyframes spin { to { transform: rotate(360deg); } }
.stage noscript p { margin: 30px; }

.settings-panel {
  min-width: 0; overflow: auto; border-radius: var(--radius-lg);
  background: var(--card); border: 1px solid var(--line); box-shadow: var(--shadow-sm);
  padding: 4px 18px 18px;
}
.settings-panel > h2 {
  position: sticky; top: 0; z-index: 1; margin: 0 -18px 4px; padding: 16px 18px 10px; background: var(--card);
  font-size: 1rem; display: flex; align-items: center; gap: 8px; color: var(--ink-soft);
}

@media (max-width: 1100px) {
  .tool-shell { grid-template-columns: minmax(0, 1fr); height: auto; }
  .tool-shell .stage { height: clamp(420px, 70vh, 760px); }
  .settings-panel { max-height: none; }
  .tool-head { flex-wrap: wrap; }
  .content-grid { grid-template-columns: 1fr; }
  .hero-grid { grid-template-columns: 1fr; }
  .hero-art { display: none; }
}
@media (max-width: 640px) {
  .tool-actions .btn span { display: none; }
  .tool-title p { white-space: normal; }
}

/* ---- 7. Present mode ------------------------------------------------------- */

.present-bar { display: none; }
body.is-present { overflow: hidden; }
body.is-present .tool-shell {
  position: fixed; inset: 0; z-index: 1500; height: auto; gap: 0; padding: 0;
  grid-template-columns: minmax(0, 1fr); background: var(--stage-bg);
}
body.is-present .stage { border-radius: 0; border: 0; box-shadow: inset 0 5px 0 var(--cat); }
body.is-present .settings-panel {
  position: fixed; top: 70px; right: 16px; bottom: 16px; width: 340px; z-index: 2; display: none;
  box-shadow: var(--shadow-lg);
}
body.is-present.show-settings .settings-panel { display: block; }
body.is-present .present-bar {
  display: flex; gap: 6px; position: fixed; top: 14px; right: 16px; z-index: 3;
  padding: 6px; border-radius: 14px; background: color-mix(in srgb, var(--card) 88%, transparent);
  border: 1px solid var(--line); box-shadow: var(--shadow); backdrop-filter: blur(8px);
  transition: opacity .3s, transform .3s;
}
.present-bar .btn { min-height: 40px; }
body.is-present.is-idle .present-bar { opacity: 0; transform: translateY(-8px); pointer-events: none; }
body.is-present.is-idle, body.is-present.is-idle .stage { cursor: none; }

/* ---- 8. Settings controls (built by core/ui.js) --------------------------- */

.set-group { padding: 12px 0; border-bottom: 1px solid var(--line-soft); }
.set-group:last-child { border-bottom: 0; }
.set-label { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-weight: 600; font-size: .9rem; margin-bottom: 8px; color: var(--ink); }
.set-label output, .set-label .val { font-weight: 600; color: var(--muted); font-variant-numeric: tabular-nums; }
.set-help { font-size: .82rem; color: var(--muted); margin: 6px 0 0; line-height: 1.4; }
.set-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.set-row > * { flex: 1 1 auto; }
.set-row .btn { flex: 0 0 auto; }

.seg {
  display: flex; flex-wrap: wrap; gap: 4px; padding: 4px; border-radius: 12px; background: var(--card-alt); border: 1px solid var(--line);
}
.seg button {
  flex: 1 1 auto; min-height: 34px; padding: 0 10px; border: 0; border-radius: 9px; background: transparent;
  font-weight: 600; font-size: .86rem; color: var(--ink-soft); display: inline-flex; align-items: center; justify-content: center; gap: 6px;
}
.seg button:hover { color: var(--ink); background: color-mix(in srgb, var(--ink) 6%, transparent); }
.seg button[aria-pressed="true"] { background: var(--card); color: var(--ink); box-shadow: var(--shadow-sm), inset 0 0 0 1px color-mix(in srgb, var(--cat) 45%, transparent); }

.switch { display: flex; align-items: center; justify-content: space-between; gap: 12px; cursor: pointer; font-weight: 600; font-size: .9rem; }
.switch input { appearance: none; -webkit-appearance: none; width: 42px; height: 24px; border-radius: 999px; background: var(--line); position: relative; transition: background .15s; flex: none; margin: 0; cursor: pointer; }
.switch input::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .3); transition: transform .15s; }
.switch input:checked { background: var(--cat); }
.switch input:checked::after { transform: translateX(18px); }

.swatches { display: flex; flex-wrap: wrap; gap: 8px; }
.swatch {
  width: 32px; height: 32px; border-radius: 50%; border: 2px solid var(--card); box-shadow: 0 0 0 1px var(--line);
  padding: 0; background: var(--sw, #ccc);
}
.swatch[aria-pressed="true"] { box-shadow: 0 0 0 2px var(--card), 0 0 0 4px var(--cat); }

.stepper { display: flex; align-items: center; gap: 6px; }
.stepper input { text-align: center; font-weight: 600; font-variant-numeric: tabular-nums; }
.stepper .btn { width: 40px; padding: 0; flex: none; }

.class-picker { display: flex; gap: 8px; }
.class-picker select { flex: 1; }

/* ---- 9. Stage primitives shared by tools ---------------------------------- */

.t-fill { position: absolute; inset: 0; }
.t-center { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3cqmin; padding: 4cqmin; text-align: center; }
.t-canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
.t-big {
  font-family: var(--font-display); font-weight: 600; line-height: 1; letter-spacing: -.02em;
  font-variant-numeric: tabular-nums; font-size: clamp(28px, 22cqmin, 520px);
}
.t-title { font-family: var(--font-display); font-weight: 600; font-size: clamp(16px, 6cqmin, 110px); line-height: 1.1; }
.t-sub { color: color-mix(in srgb, var(--stage-ink) 62%, transparent); font-size: clamp(12px, 3.2cqmin, 40px); }
.t-controls {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 5;
  display: flex; justify-content: center; align-items: center; flex-wrap: wrap; gap: clamp(6px, 1.6cqmin, 18px);
  padding: clamp(8px, 2.6cqmin, 28px); pointer-events: none;
}
.t-controls > * { pointer-events: auto; }
.t-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .45em;
  min-height: clamp(36px, 8.4cqmin, 84px); padding: 0 clamp(12px, 3cqmin, 34px);
  border-radius: clamp(10px, 2.2cqmin, 22px); font-weight: 650; font-size: clamp(13px, 3cqmin, 30px);
  border: 1px solid var(--line); background: var(--card); color: var(--ink); box-shadow: var(--shadow-sm);
  transition: transform .06s, background .12s, box-shadow .12s; white-space: nowrap; user-select: none;
}
.t-btn:hover { background: var(--card-alt); }
.t-btn:active { transform: translateY(2px); }
.t-btn .icon { width: 1.2em; height: 1.2em; }
.t-btn-primary {
  background: var(--cat); color: #fff; border-color: transparent;
  box-shadow: 0 3px 0 color-mix(in srgb, var(--cat) 65%, black), 0 8px 20px color-mix(in srgb, var(--cat) 35%, transparent);
  min-width: clamp(90px, 22cqmin, 260px);
}
.t-btn-primary:hover { background: color-mix(in srgb, var(--cat) 88%, white); }
.t-btn-primary:active { box-shadow: 0 1px 0 color-mix(in srgb, var(--cat) 65%, black); }
.t-btn-round { width: clamp(36px, 8.4cqmin, 84px); padding: 0; }
.t-btn:disabled { opacity: .45; cursor: not-allowed; }
.t-chip {
  display: inline-flex; align-items: center; gap: .4em; padding: .35em .8em; border-radius: 999px;
  background: color-mix(in srgb, var(--cat) 14%, var(--stage-bg)); color: var(--stage-ink);
  font-weight: 650; font-size: clamp(12px, 3cqmin, 30px); border: 1px solid color-mix(in srgb, var(--cat) 30%, transparent);
}
.t-result {
  position: absolute; top: clamp(8px, 3cqmin, 30px); left: 50%; transform: translateX(-50%); z-index: 4;
  padding: .35em .9em; border-radius: 999px; font: 650 clamp(14px, 4.6cqmin, 54px)/1.2 var(--font-display);
  background: color-mix(in srgb, var(--stage-bg) 82%, transparent); color: var(--stage-ink);
  border: 1px solid var(--line); box-shadow: var(--shadow); backdrop-filter: blur(6px);
  white-space: nowrap; max-width: 94%; overflow: hidden; text-overflow: ellipsis;
}
.t-note { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); max-width: 80%; text-align: center; color: var(--muted); font-size: clamp(13px, 3cqmin, 24px); }
.t-pop { animation: t-pop .45s cubic-bezier(.2, 1.6, .4, 1); }
@keyframes t-pop { 0% { transform: scale(.6); opacity: 0; } 100% { transform: scale(1); opacity: 1; } }
.t-flash { animation: t-flash 1s ease-in-out infinite; }
@keyframes t-flash { 50% { opacity: .25; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

/* ---- 10. Footer, print ---------------------------------------------------- */

.site-footer { margin-top: 56px; background: var(--card); border-top: 1px solid var(--line); padding: 40px 0 20px; font-size: .92rem; }
.footer-grid { display: grid; grid-template-columns: 1.4fr repeat(4, 1fr); gap: 28px; }
.footer-brand .brand { color: var(--ink); margin-bottom: 12px; }
.footer-brand .brand-name b { color: var(--c-random); }
.footer-brand p { color: var(--ink-soft); }
.footer-badges { list-style: none; padding: 0; margin: 0; display: grid; gap: 6px; color: var(--muted); }
.footer-badges li { display: flex; gap: 8px; align-items: center; }
.footer-col h2 { font-size: .95rem; margin-bottom: 10px; }
.footer-col h2 a { color: var(--ink); text-decoration: none; }
.footer-col ul { list-style: none; padding: 0; margin: 0; display: grid; gap: 6px; }
.footer-col a { color: var(--ink-soft); text-decoration: none; }
.footer-col a:hover { color: var(--ink); text-decoration: underline; }
.footer-family { margin-top: 26px; padding-top: 18px; border-top: 1px solid var(--line-soft); display: flex; gap: 16px; align-items: baseline; flex-wrap: wrap; }
.footer-family h2 { font-size: .85rem; margin: 0; color: var(--muted); font-family: var(--font); font-weight: 600; }
.footer-family ul { list-style: none; display: flex; flex-wrap: wrap; gap: 6px 16px; margin: 0; padding: 0; }
.footer-family a { color: var(--ink-soft); }
.footer-bottom { margin-top: 18px; display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; color: var(--ink-soft); }
.footer-bottom a { color: var(--ink-soft); }
.footer-bottom p { margin: 0; }
@media (max-width: 1100px) { .footer-grid { grid-template-columns: 1fr 1fr; } }

@media print {
  .site-header, .site-footer, .breadcrumbs, .tool-actions, .settings-panel, .t-controls, .content-grid, .toast { display: none !important; }
  body { background: #fff; }
  .tool-shell { display: block; height: auto; }
  .stage { box-shadow: none; border: 0; height: auto; min-height: 90vh; }
}
