/* IMT Library Guide: the reading theme. Built for phones first.
   Same structure as before (jobs open in place, tools open under them); the look is calm and easy to read:
   white cards on a light grey page, 1px lines, square corners, one colour per job, large clear type, no tiny mono labels.
   Tokens come from variables.css. Light only: the guide has no dark mode. */

*, *::before, *::after { box-sizing: border-box; }
:root {
  --topbar: 58px; --content: 860px;
  --line: 1px solid var(--color-ash-divider);
  --ink-line: 1.5px solid var(--color-portrait-ink);
  --display: 'Bricolage Grotesque', var(--font-head);
  --color-gold: #f5c518;
  --r: 4px;
}
html { scroll-padding-top: calc(var(--topbar) + 12px); -webkit-text-size-adjust: 100%; color-scheme: light; }
/* no double-tap zoom anywhere (pinch zoom still works) */
html, body, a, button, input, label, summary { touch-action: manipulation; }
body { margin: 0; background: var(--color-page); color: var(--color-portrait-ink); font-family: var(--font-body); font-weight: 500; font-size: 16px; line-height: 1.6; -webkit-font-smoothing: antialiased; }
a { color: inherit; text-decoration: none; -webkit-tap-highlight-color: transparent; }
button { font: inherit; color: inherit; -webkit-tap-highlight-color: transparent; }
:focus-visible { outline: 3px solid var(--color-accent); outline-offset: 2px; }
h1, h2, h3 { font-family: var(--font-head); text-wrap: balance; }

/* a section label: plain words, readable size */
.label { margin: 0; font: 800 13px/1.3 var(--font-body); letter-spacing: .02em; color: var(--color-accent); }

/* ---------- Top bar ---------- */
.topbar { position: sticky; z-index: 30; top: 0; padding-top: env(safe-area-inset-top, 0px); background: var(--color-white-canvas); border-bottom: var(--line); }
.topbar-inner { max-width: var(--content); margin: 0 auto; height: var(--topbar); display: flex; align-items: center; gap: 10px; padding: 0 max(16px, env(safe-area-inset-right, 0px)) 0 max(16px, env(safe-area-inset-left, 0px)); }
.brand { display: inline-flex; align-items: center; gap: 9px; flex: none; margin-right: auto; }
.brand-name { font: 800 17px var(--display); letter-spacing: -.01em; white-space: nowrap; }
.hd-link { flex: none; font-weight: 700; font-size: 15px; padding: 8px 6px; white-space: nowrap; }
.hd-link:hover { color: var(--color-accent); }
.back-link { flex: none; height: 40px; display: inline-flex; align-items: center; gap: 4px; padding: 0 14px 0 10px; border-radius: var(--r); font-weight: 700; font-size: 14.5px; background: var(--color-imt-navy); color: #fff; }
.back-link:hover { filter: brightness(1.08); }


/* ---------- Search: its own bar under the navbar, the first thing on the page ---------- */
.searchbar { max-width: var(--content); margin: 0 auto; padding: 14px max(16px, env(safe-area-inset-right, 0px)) 0 max(16px, env(safe-area-inset-left, 0px)); }
.search { display: flex; align-items: center; gap: 10px; height: 50px; padding: 0 14px; border: var(--ink-line); border-radius: var(--r); background: var(--color-white-canvas); color: var(--color-slate-helper); }
.search:focus-within { border-color: var(--color-accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--color-accent) 25%, transparent); color: var(--color-accent); }
.search input { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; color: var(--color-portrait-ink); font: 600 16px var(--font-body); }
.search input::placeholder { color: var(--color-slate-helper); font-weight: 500; }
.search kbd { font: 700 12px ui-monospace, Menlo, monospace; padding: 1px 7px; border: var(--line); border-radius: 3px; }

/* ---------- Page ---------- */
.main { outline: none; }
.page { max-width: var(--content); margin: 0 auto; padding: 22px max(16px, env(safe-area-inset-right, 0px)) 32px max(16px, env(safe-area-inset-left, 0px)); }
.intro { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; padding-bottom: 20px; }
.chip { margin: 0; display: inline-block; padding: 3px 10px; border-radius: 3px; background: var(--color-gold); color: #1a1a1a; font-weight: 800; font-size: 13px; }
.display, .title { margin: 0; font-family: var(--display); font-weight: 800; letter-spacing: -.03em; line-height: 1.05; }
.display { font-size: clamp(32px, 8.5vw, 56px); }
.title { font-size: clamp(28px, 6vw, 42px); }
.lead { margin: 0; font-size: 17px; color: var(--color-graphite-body); max-width: 52ch; }
.back { display: inline-flex; align-items: center; gap: 4px; margin-bottom: 12px; font-weight: 700; font-size: 15px; color: var(--color-accent); }
.back:hover { text-decoration: underline; text-underline-offset: 3px; }
.btn { flex: none; display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 48px; padding: 0 20px; border-radius: var(--r); background: var(--color-imt-navy); color: #fff; font: 800 16px var(--font-head); box-shadow: 0 3px 0 var(--color-portrait-ink); transition: transform .1s ease, box-shadow .1s ease; }
.btn:hover { filter: brightness(1.08); }
.btn:active { transform: translateY(3px); box-shadow: 0 0 0 var(--color-portrait-ink); }

/* ---------- Tags ---------- */
.tag { display: inline-block; white-space: nowrap; padding: 3px 9px; border: var(--line); border-radius: 3px; font: 700 12.5px/1.3 var(--font-body); color: var(--color-graphite-body); background: var(--color-white-canvas); }
.tag.acc-library { color: var(--color-ok-ink); background: var(--color-mint-wash); border-color: transparent; }
.tag.acc-register { color: var(--color-sun-ink); background: var(--color-peach-wash); border-color: transparent; }
.tag.ai-builtin { color: #fff; background: var(--color-imt-navy); border-color: transparent; }
.tag.ai-mcp-claude, .tag.ai-mcp-other, .tag.ai-api { color: var(--color-accent); border-color: currentColor; }

/* ---------- Jobs: each one opens under itself ---------- */
.jobs { display: flex; flex-direction: column; gap: 10px; }
.job { --c: hsl(var(--h) 75% 50%); --soft: hsl(var(--h) 85% 95%); border: var(--line); border-left: 6px solid var(--c); border-radius: var(--r); background: var(--color-white-canvas); overflow: hidden; animation: rise .4s cubic-bezier(.2,.8,.2,1) both; animation-delay: calc(var(--i) * 35ms); transition: border-color .15s ease, box-shadow .15s ease; }
.job.open { border-color: var(--color-portrait-ink); border-left-color: var(--c); box-shadow: 0 10px 28px -14px rgba(0,0,0,.4); }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } }
.job-head { width: 100%; display: grid; grid-template-columns: 46px 28px minmax(0, 1fr) auto 32px; align-items: center; gap: 14px; padding: 14px 14px 14px 12px; border: 0; background: transparent; cursor: pointer; text-align: left; }
.job.open > .job-head { background: var(--soft); border-bottom: var(--line); }
.job-n { width: 46px; height: 46px; display: grid; place-items: center; border-radius: var(--r); background: var(--c); color: #fff; font: 800 18px var(--display); text-shadow: 0 1px 1px rgba(0,0,0,.25); }
.job-ic { color: var(--c); display: inline-flex; }
.job-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.3; }
.job-text b { font: 800 19px/1.25 var(--display); letter-spacing: -.01em; }
.job-text span { font-size: 15px; color: var(--color-slate-helper); margin-top: 3px; }
.job-count { font-weight: 700; font-size: 13.5px; color: var(--color-slate-helper); white-space: nowrap; }

/* plus that turns into a minus */
.chev { position: relative; width: 32px; height: 32px; border-radius: 50%; background: var(--color-page); border: var(--line); flex: none; transition: background .15s ease, border-color .15s; }
.chev::before, .chev::after { content: ""; position: absolute; left: 50%; top: 50%; width: 12px; height: 2.5px; margin: -1.25px 0 0 -6px; border-radius: 2px; background: var(--color-portrait-ink); transition: transform .2s ease, background .15s; }
.chev::after { transform: rotate(90deg); }
[aria-expanded="true"] > .chev { background: var(--color-portrait-ink); border-color: var(--color-portrait-ink); }
[aria-expanded="true"] > .chev::after { transform: rotate(0); }
[aria-expanded="true"] > .chev::before, [aria-expanded="true"] > .chev::after { background: var(--color-page); }

/* the part that slides open */
.pane { display: grid; grid-template-rows: 0fr; visibility: hidden; transition: grid-template-rows .28s ease, visibility 0s linear .28s; }
.open > .pane { grid-template-rows: 1fr; visibility: visible; transition: grid-template-rows .28s ease, visibility 0s; }
.pane-in { min-height: 0; overflow: hidden; }

/* ---------- Tools under a job ---------- */
.tools { list-style: none; margin: 0; padding: 12px; display: flex; flex-direction: column; gap: 10px; background: var(--color-page); }
.tools.flat { padding: 0; gap: 8px; background: transparent; }
.tool { --c: var(--color-accent); border: var(--line); border-radius: var(--r); background: var(--color-white-canvas); overflow: hidden; transition: box-shadow .15s ease; }
.job .tool { --c: inherit; }
.tool-head { width: 100%; display: grid; grid-template-columns: 96px minmax(0, 1fr) auto 32px; align-items: center; gap: 14px; padding: 13px 14px; border: 0; background: transparent; cursor: pointer; text-align: left; }
.flat .tool-head { grid-template-columns: 150px minmax(0, 1fr) auto 32px; }
.rank { justify-self: start; padding: 3px 9px; border-radius: 3px; border: var(--line); font-weight: 800; font-size: 12.5px; white-space: nowrap; color: var(--color-graphite-body); }
.rank.first { background: var(--c); border-color: transparent; color: #fff; text-shadow: 0 1px 1px rgba(0,0,0,.2); }
.flat .rank { border: 0; padding: 0; font-weight: 700; color: var(--color-accent); }
.tool-main { display: flex; flex-direction: column; min-width: 0; line-height: 1.3; }
.tool-main b { font: 800 18px/1.25 var(--display); letter-spacing: -.01em; }
.tool-main span { font-size: 15px; color: var(--color-slate-helper); margin-top: 2px; }
.flat .tool-main span { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

/* an opened tool stands apart from the next one */
.tool.open { border: 2px solid var(--color-portrait-ink); box-shadow: 0 10px 26px -14px rgba(0,0,0,.45); }
.tool.open > .tool-head { background: color-mix(in srgb, var(--c) 12%, var(--color-white-canvas)); border-bottom: var(--line); }
.tool.open + .tool { margin-top: 8px; }
.tool.open + .tool::before { content: "Next tool"; display: block; padding: 6px 14px; font-weight: 800; font-size: 12.5px; color: var(--color-slate-helper); background: var(--color-page); border-bottom: var(--line); }

/* ---------- The guide inside an opened tool ---------- */
.guide { padding: 18px 16px; display: flex; flex-direction: column; gap: 20px; }
.guide-top { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.guide-what { margin: 0; font-size: 17px; line-height: 1.55; color: var(--color-graphite-body); max-width: 58ch; }
.facts { margin: 0; display: grid; grid-template-columns: repeat(3, 1fr); border: var(--line); border-radius: var(--r); background: var(--color-page); }
.facts > div { padding: 11px 14px 13px; display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.facts > div + div { border-left: var(--line); }
.facts dt { font-weight: 800; font-size: 13px; color: var(--color-slate-helper); }
.facts dd { margin: 0; display: flex; flex-direction: column; align-items: flex-start; gap: 6px; font-size: 15px; line-height: 1.45; color: var(--color-graphite-body); }
.guide-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 28px; }
.guide .label { padding-bottom: 8px; border-bottom: var(--line); margin-bottom: 6px; }
.guide .label.gap { margin-top: 18px; }
.steps { list-style: none; margin: 0; padding: 0; }
.steps li { display: grid; grid-template-columns: 30px 1fr; gap: 8px; padding: 8px 0; font-size: 16px; line-height: 1.5; color: var(--color-graphite-body); }
.steps b { width: 26px; height: 26px; display: grid; place-items: center; border-radius: 50%; background: var(--color-sky-wash); color: var(--color-accent); font-weight: 800; font-size: 13px; }
.bul { margin: 0; padding: 0; list-style: none; }
.bul li { position: relative; padding: 6px 0 6px 20px; font-size: 16px; line-height: 1.5; color: var(--color-graphite-body); }
.bul li::before { content: ""; position: absolute; left: 3px; top: 15px; width: 7px; height: 7px; border-radius: 50%; background: var(--color-accent); }
.callout { margin: 0 0 10px; padding: 11px 13px; border-left: 4px solid var(--color-accent); background: var(--color-white-canvas); font-size: 15.5px; line-height: 1.5; }
.guide-ai { padding: 16px; border-radius: var(--r); background: var(--color-sky-wash); }
.guide-ai .label { border-color: color-mix(in srgb, var(--color-accent) 30%, transparent); }
.tagrow { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 14px; }
.tagrow .label { margin: 0 4px 0 0; padding: 0; border: 0; color: var(--color-slate-helper); }
.fine { margin: 12px 0 0; font-size: 14px; line-height: 1.5; color: var(--color-slate-helper); }
.fine a { color: var(--color-accent); font-weight: 700; text-decoration: underline; text-underline-offset: 2px; }
.code { display: flex; align-items: stretch; border: var(--line); border-radius: var(--r); background: var(--color-white-canvas); margin-top: 10px; overflow: hidden; }
.code code { flex: 1; min-width: 0; padding: 12px 14px; font: 500 15.5px/1.5 var(--font-body); color: var(--color-portrait-ink); white-space: pre-wrap; }
.copy { flex: none; display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 0 16px; border: 0; border-left: var(--line); background: var(--color-white-canvas); cursor: pointer; font-weight: 800; font-size: 14px; color: var(--color-accent); }
.copy:hover { background: var(--color-accent); color: var(--color-white-canvas); }
.guide-close { display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; min-height: 48px; padding: 0 12px; border: var(--line); border-radius: var(--r); background: var(--color-page); color: var(--color-portrait-ink); cursor: pointer; font-weight: 800; font-size: 15px; }
.guide-close:hover { background: var(--color-portrait-ink); color: var(--color-page); }

/* ---------- AI strip on Home ---------- */
.ai { margin-top: 26px; padding: 22px 18px; border-radius: var(--r); background: var(--color-portrait-ink); color: var(--color-page); }
.ai-title { margin: 0 0 14px; font: 800 clamp(22px, 5vw, 28px)/1.15 var(--display); letter-spacing: -.02em; }
.ai-steps { list-style: none; margin: 0 0 14px; padding: 0; display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.ai-steps li { display: flex; gap: 12px; font-size: 16px; line-height: 1.5; align-items: flex-start; }
.ai-steps b { flex: none; width: 28px; height: 28px; display: grid; place-items: center; border-radius: 50%; background: var(--color-gold); color: #111; font-weight: 800; font-size: 14px; }
.ai .code { background: rgba(255,255,255,.08); border-color: rgba(255,255,255,.22); }
.ai .code code { color: var(--color-page); }
.ai .copy { background: transparent; border-color: rgba(255,255,255,.22); color: var(--color-gold); }
.ai .copy:hover { background: var(--color-gold); color: #111; }
.ai .fine { color: color-mix(in srgb, var(--color-page) 78%, transparent); }
.ai .fine a { color: var(--color-gold); }

/* ---------- All tools ---------- */
.seg { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 16px; }
.seg button { padding: 8px 14px; border: var(--line); border-radius: 999px; background: var(--color-white-canvas); cursor: pointer; font-weight: 700; font-size: 14.5px; }
.seg button[aria-pressed="true"] { background: var(--color-portrait-ink); color: var(--color-page); border-color: var(--color-portrait-ink); }
.count { margin: 0 0 8px; font-weight: 700; font-size: 14px; color: var(--color-slate-helper); }
.empty { padding: 30px 0; font-size: 16px; color: var(--color-slate-helper); }

/* ---------- Footer, toast ---------- */
.foot { margin-top: 36px; border: var(--line); border-radius: var(--r); background: var(--color-white-canvas); overflow: hidden; }
.foot-grid { display: grid; grid-template-columns: 1fr 1fr; }
.foot-grid section { padding: 16px 18px; }
.foot-grid section + section { border-left: var(--line); }
.foot-h { margin: 0 0 10px; font: 800 15px var(--font-body); color: var(--color-portrait-ink); }
.foot-dl { margin: 0; display: grid; grid-template-columns: 96px 1fr; gap: 8px 12px; font-size: 15px; line-height: 1.45; }
.foot-dl dt { font-weight: 700; color: var(--color-slate-helper); }
.foot-dl dd { margin: 0; color: var(--color-graphite-body); font-weight: 600; min-width: 0; overflow-wrap: anywhere; }
.foot-dl a { color: var(--color-accent); font-weight: 700; }
.foot-note { display: block; margin-top: 2px; font-size: 13px; font-weight: 500; color: var(--color-slate-helper); }
.foot-base { padding: 12px 18px 14px; border-top: var(--line); background: var(--color-page); }
.foot-base p { margin: 0; font-size: 14px; line-height: 1.55; color: var(--color-slate-helper); }
.foot-base p:first-child { font-weight: 700; color: var(--color-portrait-ink); }
.foot-base a { color: var(--color-accent); font-weight: 800; text-decoration: underline; text-underline-offset: 2px; }
@media (max-width: 640px) { .foot-grid { grid-template-columns: 1fr; } .foot-grid section + section { border-left: 0; border-top: var(--line); } .foot-dl { grid-template-columns: 88px 1fr; } }
.toast { position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); padding: 11px 18px; border-radius: var(--r); background: var(--color-portrait-ink); color: var(--color-page); font-weight: 700; font-size: 15px; opacity: 0; pointer-events: none; transition: opacity .15s ease; z-index: 60; max-width: calc(100vw - 32px); }
.toast.show { opacity: 1; }

/* ---------- Hover only where there is a mouse (no stuck colours after a tap) ---------- */
@media (hover: hover) {
  .job:hover { box-shadow: 0 6px 18px -10px rgba(0,0,0,.35); }
  .tool-head:hover { background: var(--color-page); }
  button:hover > .chev { border-color: var(--color-portrait-ink); }
  .seg button:hover { border-color: var(--color-portrait-ink); }
}

/* ---------- Tablets and phones ---------- */
@media (max-width: 760px) {
  .guide-cols { grid-template-columns: 1fr; gap: 20px; }
  .ai-steps { grid-template-columns: 1fr; gap: 12px; }
  .job-ic, .job-count { display: none; }
  .job-head { grid-template-columns: 44px minmax(0, 1fr) 32px; gap: 12px; padding: 14px 12px; }
  .job-n { width: 44px; height: 44px; font-size: 17px; }
  .tool-head, .flat .tool-head { grid-template-columns: minmax(0, 1fr) 32px; row-gap: 6px; padding: 13px 12px 13px 14px; }
  .tool-head .rank, .tool-head .tool-main { grid-column: 1; }
  .tool-head .chev { grid-column: 2; grid-row: 1 / span 2; }
  .tool-tags { display: none; }
  .guide-top { flex-direction: column; align-items: stretch; }
  .facts { grid-template-columns: 1fr; }
  .facts > div + div { border-left: 0; border-top: var(--line); }
  .facts dd { flex-direction: row; flex-wrap: wrap; align-items: center; }
}
@media (max-width: 560px) {
  :root { --topbar: 56px; }
  .hd-link { padding: 0 12px; height: 40px; display: inline-flex; align-items: center; border: var(--line); border-radius: var(--r); font-size: 14.5px; }
  .brand-name { font-size: 16px; }
  .back-link span { display: none; }
  .back-link { width: 40px; padding: 0; justify-content: center; }
  .search kbd { display: none; }
  .searchbar { padding-top: 12px; }
  .page { padding-top: 18px; }
  .tools { padding: 10px 8px; }
  .guide { padding: 16px 14px; gap: 18px; }
  .code { flex-direction: column; }
  .copy { border-left: 0; border-top: var(--line); min-height: 44px; }
}
@media (max-width: 370px) { .brand-name { display: none; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition: none !important; animation: none !important; } }
@media print { .topbar, .searchbar, .toast { display: none !important; } .pane { visibility: visible; grid-template-rows: 1fr; } }
