/* Versed Tools — the look (14 Nov 2026). Loaded LAST on the tools front door and every tool page, and
   nowhere else. The shared half (colour tokens, cream page, header, cards, inputs, push buttons, toast,
   the kind note) is in look.css, which Versed Study loads too; this file is what only the tools wear:
   one colour per family of tools, each tool's band and pixel icon, the tool bar, chips, the per-tool
   panels and the front door. Layout rules sit inside @media screen, so the formulas sheet still prints
   the way it always did. */

/* Each tool page wears its family's colour and its own pixel icon, worked out from its tool bar, so it is
   right from the first paint (no script needed). Keep in step with TOOLS in common.js. */
body:has(nav.toolbar[data-tools="breaker"]) { --hf: var(--amber-f); --hl: var(--amber-l); --hi: var(--amber-i); --ticon: url(/tools/img/breaker.png); }
body:has(nav.toolbar[data-tools="timetable"]) { --hf: var(--amber-f); --hl: var(--amber-l); --hi: var(--amber-i); --ticon: url(/tools/img/timetable.png); }
body:has(nav.toolbar[data-tools="reader"]) { --hf: var(--teal-f); --hl: var(--teal-l); --hi: var(--teal-i); --ticon: url(/tools/img/reader.png); }
body:has(nav.toolbar[data-tools="listen"]) { --hf: var(--teal-f); --hl: var(--teal-l); --hi: var(--teal-i); --ticon: url(/tools/img/listen.png); }
body:has(nav.toolbar[data-tools="ask"]) { --hf: var(--violet-f); --hl: var(--violet-l); --hi: var(--violet-i); --ticon: url(/tools/img/ask.png); }
body:has(nav.toolbar[data-tools="maths"]) { --hf: var(--violet-f); --hl: var(--violet-l); --hi: var(--violet-i); --ticon: url(/tools/img/maths.png); }
body:has(nav.toolbar[data-tools="calc"]) { --hf: var(--violet-f); --hl: var(--violet-l); --hi: var(--violet-i); --ticon: url(/tools/img/calc.png); }
body:has(nav.toolbar[data-tools="formulas"]) { --hf: var(--violet-f); --hl: var(--violet-l); --hi: var(--violet-i); --ticon: url(/tools/img/formulas.png); }
body:has(nav.toolbar[data-tools="write"]) { --hf: var(--pink-f); --hl: var(--pink-l); --hi: var(--pink-i); --ticon: url(/tools/img/write.png); }
body:has(nav.toolbar[data-tools="cite"]) { --hf: var(--pink-f); --hl: var(--pink-l); --hi: var(--pink-i); --ticon: url(/tools/img/cite.png); }
body:has(nav.toolbar[data-tools="pdf"]) { --hf: var(--pink-f); --hl: var(--pink-l); --hi: var(--pink-i); --ticon: url(/tools/img/pdf.png); }
body:has(nav.toolbar[data-tools="grade"]) { --hf: var(--blue-f); --hl: var(--blue-l); --hi: var(--blue-i); --ticon: url(/tools/img/grade.png); }

@media screen {
  /* ---------- the tool's own band (every tool page): its icon, its name, its colour ---------- */
  body:has(nav.toolbar[data-tools]) .hero {
    display: grid; grid-template-columns: 60px minmax(0, 1fr); column-gap: .9rem; align-items: center;
    background: var(--hf); border: 2px solid var(--hl); border-bottom-width: 6px; border-radius: 22px;
    padding: 1rem 1.1rem .95rem; margin: 0 0 1rem;
  }
  body:has(nav.toolbar[data-tools]) .hero::before {
    content: ''; width: 60px; height: 60px; border-radius: 18px; background: var(--card) var(--ticon) center / 44px 44px no-repeat;
    border: 2px solid var(--hl); box-shadow: 0 3px 0 var(--hl); image-rendering: pixelated; grid-row: 1; grid-column: 1; align-self: center;
  }
  body:has(nav.toolbar[data-tools]) .hero > * { grid-column: 1 / -1; position: relative; }
  body:has(nav.toolbar[data-tools]) .hero h1 { grid-column: 2; grid-row: 1; font-size: clamp(1.45rem, 5.6vw, 2rem); line-height: 1.1; margin: 0; color: var(--text); }
  body:has(nav.toolbar[data-tools]) .hero h1 span { color: var(--hi); }
  body:has(nav.toolbar[data-tools]) .hero p { color: var(--text); opacity: .86; font-size: .95rem; line-height: 1.5; margin: .75rem 0 0; padding-right: 0 !important; }
  body:has(nav.toolbar[data-tools]) .hero p + p { margin-top: .4rem; }
  body:has(nav.toolbar[data-tools]) .hero .why { color: var(--hi); opacity: 1; font-weight: 700; }
  body:has(nav.toolbar[data-tools]) .hero .deco { display: none; }

  /* ---------- the tool bar: one chunky chip per tool, in its family colour ---------- */
  .toolbar { gap: .45rem; margin: 0 0 1.1rem; }
  .toolbar a {
    gap: .45rem; padding: .3rem .75rem .3rem .3rem; border-radius: 14px; min-height: 44px;
    background: var(--card); border: 2px solid var(--line); box-shadow: 0 3px 0 var(--line);
    color: var(--text); font-size: .8rem; transition: transform .07s, box-shadow .07s;
  }
  .toolbar a .tbi { width: 30px; height: 30px; border-radius: 10px; background: var(--hf); display: grid; place-items: center; flex: none; }
  .toolbar a .tbi img { width: 22px; height: 22px; }
  .toolbar a:hover { border-color: var(--hl); color: var(--text); }
  .toolbar a:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--line); }
  .toolbar a[aria-current] { background: var(--hf); border-color: var(--hl); box-shadow: 0 3px 0 var(--hl); color: var(--text); }
  .toolbar a[aria-current] .tbi { background: var(--card); }
  /* Phones: one row you slide along (the tool you are in is scrolled into view), so the tool itself
     starts near the top instead of under four rows of chips. */
  @media (max-width: 600px) {
    .toolbar { flex-wrap: nowrap; overflow-x: auto; overscroll-behavior-x: contain; scrollbar-width: none; margin: 0 -1rem 1rem; padding: 2px 1rem 7px; scroll-padding-inline: 1rem;
      -webkit-mask-image: linear-gradient(90deg, transparent 0, #000 .9rem, #000 calc(100% - 1.8rem), transparent); mask-image: linear-gradient(90deg, transparent 0, #000 .9rem, #000 calc(100% - 1.8rem), transparent); }
    .toolbar::-webkit-scrollbar { display: none; }
    .toolbar a { flex: none; font-size: .78rem; padding: .25rem .7rem .25rem .25rem; gap: .4rem; }
    .toolbar a img, .toolbar a .tb { width: 22px; height: 22px; }
  }

  h2.h, .section h2 { font-size: 1.02rem; }
  .note { background: var(--soft); border: 2px dashed var(--line); border-radius: 16px; }
  .divider { background: repeating-linear-gradient(90deg, var(--hl, var(--line)) 0 8px, transparent 8px 16px); height: 4px; border-radius: 2px; opacity: .5; }
  .hard, .hard-lime { box-shadow: 0 4px 0 var(--line); }


  /* chips you pick from: presets, kinds, modes, follow-ups, subjects, tabs */
  .presets button, .types button, .quick button, .follow-chips button, .modes button, .fm-subjects button, .pf-tab, .case-btns .chip, .thumbs .thumb, .listen-btn.with-label, .msg-tools .copy-btn, .hist button, .an-tools .btn, .wr-rewrite button {
    background: var(--card); border: 2px solid var(--line); box-shadow: 0 3px 0 var(--line); color: var(--text); border-radius: 14px; min-height: 44px; transition: transform .07s, box-shadow .07s;
  }
  .presets button, .types button { padding: .45rem .9rem; font-size: .84rem; font-weight: 700; }
  .presets button:hover, .types button:hover, .quick button:hover, .follow-chips button:hover, .modes button:hover, .fm-subjects button:hover, .thumbs .thumb:hover, .case-btns .chip:hover { border-color: var(--hl, var(--violet)); color: var(--text); }
  .presets button:active, .types button:active, .quick button:active, .follow-chips button:active, .modes button:active, .fm-subjects button:active, .pf-tab:active, .thumbs .thumb:active, .listen-btn.with-label:active, .hist button:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--line); }
  .presets button[aria-pressed="true"], .types button[aria-pressed="true"], .modes button[aria-pressed="true"], .fm-subjects button[aria-pressed="true"], .pf-tab[aria-selected="true"], .wr-rewrite button[aria-pressed="true"], .an-tools .btn[aria-pressed="true"], .an-sign .btn[aria-pressed="true"] {
    background: var(--hf); border-color: var(--hl); box-shadow: 0 3px 0 var(--hl); color: var(--text);
  }
  .seg { background: var(--soft); border: 2px solid var(--line); border-radius: 16px; }
  .seg button { border-radius: 12px; color: var(--muted); min-height: 38px; }
  .seg button[aria-pressed="true"] { background: var(--card); color: var(--text); box-shadow: inset 0 0 0 2px var(--hl), 0 2px 0 var(--hl); }
  .chip { background: var(--soft); color: var(--muted); }
  .listen-btn { color: var(--muted); border-radius: 14px; }
  .listen-btn:hover { background: var(--card); border-color: var(--line); }
  .listen-btn[aria-pressed="true"], .listen-btn[aria-pressed="true"]:hover { background: var(--hf); border-color: var(--hl); color: var(--text); box-shadow: 0 3px 0 var(--hl); }
  .btn-icon.main, .ls-transport .btn-icon.main { background: var(--act); color: var(--act-ink); border: 2px solid var(--act-rim); box-shadow: 0 5px 0 var(--act-edge); border-radius: 18px; }
  .ls-transport .btn-icon.main:active { transform: translateY(4px); box-shadow: 0 1px 0 var(--act-edge); }


  /* thumbs */
  .thumbs .thumbs-done { color: var(--right-i); }


  /* ---------- per tool: where a page's own markup fought the new look ---------- */
  /* Tiny steps: the one step is a big calm card in the family colour */
  .one { background: var(--card); border: 2px solid var(--hl); border-bottom-width: 6px; box-shadow: none; border-radius: 24px; }
  .one .n { color: var(--hi); font-weight: 800; }
  .ring { background: conic-gradient(var(--hl) calc(var(--p) * 1%), var(--line) 0); width: 156px; height: 156px; }
  .ring::before { background: var(--card); inset: 11px; }
  .timer { color: var(--text); }
  .timer.running { color: var(--hi); }
  .timer.done { color: var(--right-i); }
  .step, .mytask, .exam, .week, .ref, .fm-item, .room-line { border-radius: 16px; border-width: 2px; }
  .step.done .chk { background: var(--right-l); border-color: var(--right-l); color: var(--bg); }
  .mytask.cur { border-color: var(--hl); }
  .progress { border: 0; background: var(--line); height: 12px; }
  .progress i, .mytask .mini-bar i { background: var(--hl); }
  details.drawer summary, details.card summary { min-height: 48px; border-radius: 16px; border-width: 2px; }
  details.drawer summary::after, details.card summary::after { color: var(--hi); }
  /* Grade calculator: the answer is a big soft panel, never a red one */
  .results .stat { background: var(--card); border: 2px solid var(--line); border-top: 2px solid var(--line); border-radius: 18px; box-shadow: 0 4px 0 var(--line); }
  .results .stat b { color: var(--text); }
  .results .stat.good, .results .stat.warn, .results .stat.bad { border-top-color: var(--line); }
  .results .stat.good b { color: var(--right-i); } .results .stat.warn b { color: var(--amber-i); } .results .stat.bad b { color: var(--text); }
  .need-hero { background: var(--hf); border: 2px solid var(--hl); border-bottom-width: 6px; border-radius: 22px; }
  .need-hero b { color: var(--hi); }
  .need-hero.good { background: var(--right-f); border-color: var(--right-l); } .need-hero.good b { color: var(--right-i); }
  .need-hero.warn { background: var(--amber-f); border-color: var(--amber-l); } .need-hero.warn b { color: var(--amber-i); }
  .need-hero.bad { background: var(--card); border-color: var(--rim); } .need-hero.bad b { color: var(--text); }
  .need-hero:not(.good):not(.warn):not(.bad) { background: var(--card); border-color: var(--line); }
  .work { background: var(--soft); border: 0; border-radius: 16px; }
  /* Calculator */
  .calc { background: var(--card); border: 2px solid var(--line); box-shadow: 0 5px 0 var(--line); border-radius: 24px; }
  .calc .screen { background: var(--field); border-radius: 18px; }
  .calc .res { color: var(--hi); }
  .keys button { background: var(--card2); border: 2px solid var(--line); box-shadow: 0 3px 0 var(--line); border-radius: 14px; transition: transform .06s, box-shadow .06s; }
  .keys button:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--line); background: var(--card2); }
  .keys button.fn { background: var(--card); color: var(--muted); }
  .keys button.op { background: var(--hf); color: var(--hi); border-color: var(--hl); box-shadow: 0 3px 0 var(--hl); }
  .keys button.eq { background: var(--act); color: var(--act-ink); border-color: var(--act-rim); box-shadow: 0 4px 0 var(--act-edge); }
  .keys button.eq:active { box-shadow: 0 1px 0 var(--act-edge); }
  .keys button.del { background: var(--card); color: var(--muted); }
  /* Maths steps */
  .mt-answer { background: var(--hf); border: 2px solid var(--hl); border-bottom-width: 5px; border-radius: 20px; }
  .mt-answer .mt-label { color: var(--hi); }
  .mt-answer .mt-value { color: var(--text); }
  /* Ask */
  .msg.user .bubble { background: var(--hf); color: var(--text); border: 2px solid var(--hl); }
  .msg.ai .bubble { background: var(--card); border: 2px solid var(--line); }
  .bubble h3 { color: var(--hi); }
  .bubble code { background: var(--soft); }
  .msg.ai.streaming .bubble::after { background: var(--hl); }
  .prompt-box { background: var(--field); border-radius: 16px; }
  .prompt-box .k { color: var(--hi); }
  .opens .btn, .opens .btn-primary:not(.btn-sm) { padding: .7rem .6rem; min-width: 0; font-size: .92rem; min-height: 50px; }
  .pack { border-radius: 16px; box-shadow: 0 3px 0 var(--line); }
  .pack:hover { transform: none; border-color: var(--hl); box-shadow: 0 3px 0 var(--hl); }
  .pack svg { color: var(--hi); }
  .cap { background: var(--card); border-radius: 18px; }
  .left b { color: var(--hi); }
  /* Citation maker */
  .editor { border-color: var(--hl); box-shadow: 0 4px 0 var(--hl); }
  .ref { background: var(--card); }
  .ref .num { color: var(--hi); }
  .ref-text.preview { background: var(--field); border-radius: 14px; }
  /* Exam countdown */
  .exam { border-left-width: 6px; }
  .exam .left b { color: var(--text); }
  .next-up { background: var(--hf); border: 2px solid var(--hl); border-bottom-width: 6px; border-radius: 22px; }
  .next-up .big { color: var(--text); }
  /* Easy reader, Read aloud, Writing checker: their own paper stays theirs */
  .paper, .ls-paper { border-radius: 18px; }
  .ctl label output, .ls-controls .ctl label output { color: var(--hi); }
  .wr-editor { background: var(--field); border-radius: 18px; }
  .wr-editor:focus-within { border-color: var(--focus); box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus) 30%, transparent); }
  .wr-editor textarea { caret-color: var(--text); }
  .wr-pop .fixes button, .wr-issue .fixes button { background: var(--act); color: var(--act-ink); border-radius: 10px; }
  /* Formulas */
  .fm-item { background: var(--card); }
  .fm-item .f { color: var(--hi); }
  /* PDF toolkit */
  .pf-drop { background: var(--field); border-radius: 20px; }
  .pf-drop:hover, .pf-drop:focus-visible, .pf-drop.pf-over { border-color: var(--hl); background: var(--hf); }
  .pf-tab { color: var(--text); }

  /* Cream only: things drawn for a dark page */
  html[data-theme="cream"] .msg.ai .bubble b, html[data-theme="cream"] .note b { color: var(--text); }
}
@media screen and (prefers-color-scheme: light) {
  html:not([data-theme]) .msg.ai .bubble b { color: var(--text); }
}

/* ---------- the front door ---------- */
@media screen {
  .home-hero { position: relative; display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: .2rem 1rem; align-items: end; margin: .2rem 0 1.1rem; }
  .home-hero h1 { font-size: clamp(1.9rem, 8vw, 2.7rem); font-weight: 800; line-height: 1.04; margin: 0; }
  .home-hero h1 span { color: var(--lime); }
  .home-hero p { grid-column: 1 / -1; color: var(--muted); font-size: 1rem; line-height: 1.5; margin: .55rem 0 0; }
  .home-hero p b { color: var(--text); }
  .home-pet { width: 72px; height: 83px; image-rendering: pixelated; align-self: end; transform-origin: 50% 100%; }
  .home-pet.hop { animation: pet-hop .55s cubic-bezier(.3,1.6,.5,1); }
  .promise { display: flex; flex-wrap: wrap; gap: .4rem; margin: .8rem 0 0; grid-column: 1 / -1; padding: 0; list-style: none; }
  .promise li { display: inline-flex; align-items: center; gap: .35rem; font-size: .8rem; font-weight: 700; color: var(--muted); background: var(--soft); border-radius: 999px; padding: .3rem .75rem .3rem .55rem; }
  .promise li svg { width: 15px; height: 15px; color: var(--right-i); }

  .fam { margin: 0 0 1.5rem; }
  .fam-band { display: flex; align-items: center; gap: .75rem; background: var(--hf); border: 2px solid var(--hl); border-bottom-width: 5px; border-radius: 20px; padding: .7rem .9rem; margin: 0 0 .75rem; font-size: 1.05rem; line-height: 1.25; }
  .fam-band .fam-ic { width: 44px; height: 44px; border-radius: 14px; background: var(--hl); color: var(--bg); display: grid; place-items: center; flex: none; }
  .fam-band .fam-ic svg { width: 24px; height: 24px; stroke-width: 2.2; }
  .fam-band small { display: block; font-family: var(--body); font-size: .74rem; font-weight: 700; letter-spacing: .05em; color: var(--hi); margin-bottom: .1rem; }
  .fam-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr)); gap: .9rem; padding-bottom: 4px; }
  .home .home-hero { max-width: 640px; }

  .tcard {
    position: relative; display: grid; grid-template-columns: 64px minmax(0, 1fr) 44px; align-items: center; gap: .85rem;
    padding: .85rem .85rem .85rem .85rem; min-height: 96px; border-radius: 22px; text-decoration: none; color: var(--text);
    background: var(--card); border: 2px solid var(--hl); box-shadow: 0 6px 0 var(--hl);
    transition: transform .08s ease-out, box-shadow .08s ease-out; -webkit-tap-highlight-color: transparent;
  }
  .tcard:hover { filter: brightness(1.03); }
  .tcard:active { transform: translateY(5px); box-shadow: 0 1px 0 var(--hl); }
  .tcard .ti { width: 64px; height: 64px; border-radius: 20px; background: var(--hf); display: grid; place-items: center; }
  .tcard .ti img { width: 46px; height: 46px; image-rendering: pixelated; }
  .tcard .tw { display: grid; gap: .2rem; min-width: 0; }
  .tcard .tw b { font-family: var(--display); font-size: 1.02rem; line-height: 1.22; overflow-wrap: break-word; }
  .tcard .tw span { color: var(--muted); font-size: .86rem; line-height: 1.38; }
  .tcard .tgo { width: 44px; height: 44px; border-radius: 50%; background: var(--hl); color: var(--bg); display: grid; place-items: center; box-shadow: 0 3px 0 color-mix(in srgb, var(--hl) 62%, #000); }
  .tcard .tgo svg { width: 22px; height: 22px; stroke-width: 2.5; }
  /* the one to tap first: lime, a little bigger, with "Start here" over it */
  .tcard.first { background: var(--act); color: var(--act-ink); border-color: var(--act-rim); box-shadow: 0 6px 0 var(--act-edge); min-height: 108px; margin-top: 2.1rem; }
  .tcard.first:active { box-shadow: 0 1px 0 var(--act-edge); }
  .tcard.first .tw span { color: #2B3A08; }
  .tcard.first .ti { background: #0E0D1714; }
  .tcard.first .tgo { background: var(--act-ink); color: var(--act); box-shadow: none; }
  .tcard.first .callout { position: absolute; left: 1rem; top: -2.15rem; background: var(--card); color: var(--lime); border: 2px solid var(--act-rim); border-radius: 12px; padding: .2rem .75rem; font-size: .86rem; font-weight: 800; white-space: nowrap; }
  .tcard.first .callout::after { content: ''; position: absolute; left: 22px; bottom: -7px; width: 10px; height: 10px; background: var(--card); border-right: 2px solid var(--act-rim); border-bottom: 2px solid var(--act-rim); transform: rotate(45deg); }
  .fam-more { display: block; text-align: center; color: var(--muted); font-size: .86rem; margin: .2rem 0 1rem; }

  .home-foot { text-align: center; margin-top: .4rem; }
  .home-foot .shelf { opacity: .85; }
  @media (max-width: 380px) {
    .tcard { grid-template-columns: 52px minmax(0, 1fr) 40px; gap: .65rem; padding: .75rem; }
    .tcard .ti { width: 52px; height: 52px; border-radius: 16px; }
    .tcard .ti img { width: 38px; height: 38px; }
    .tcard .tgo { width: 40px; height: 40px; }
    .fam-cards { grid-template-columns: minmax(0, 1fr); }
  }
}

@media (prefers-reduced-motion: reduce) {
  .tcard:active, .toolbar a:active, .keys button:active,
  .presets button:active, .types button:active, .quick button:active, .follow-chips button:active, .modes button:active, .fm-subjects button:active, .pf-tab:active, .thumbs .thumb:active, .listen-btn.with-label:active, .hist button:active { transform: none !important; filter: brightness(.88); }
  .home-pet.hop { animation: none !important; }
}

/* Easy reader: "Page colour" (one setting for every tool) */
@media screen {
  .pagecol { margin-top: .9rem; padding-top: .8rem; border-top: 2px dashed var(--line); }
  .pagecol-l { display: block; font-weight: 700; margin-bottom: .45rem; }
  .pagecol .seg { display: flex; flex-wrap: wrap; width: 100%; }
  .pagecol .seg button { flex: 1 1 auto; min-height: 44px; font-size: .86rem; padding: .4rem .7rem; }
  .pagecol p { margin: .45rem 0 0; }
  .everywhere { border-top-width: 2px; }
}
