@import url("https://fonts.googleapis.com/css2?family=Caveat:wght@500;700&family=Patrick+Hand&display=swap");

/* ------------------------------------------------------------------ design tokens
   Override any of these with `colors:` in the spec, a theme preset, or your own CSS file. */
:root {
  --ink: #2b2b2b;          /* text and lines */
  --paper: #fdfcf8;        /* page background */
  --muted: #8a8a85;        /* secondary text, outlines of placeholders */
  --line: #cfcfc8;         /* dashed dividers */
  --accent: #c2410c;       /* pins, sliders, active states */
  --note: #fff3b0;         /* sticky notes */
  --card-bg: #ffffff;      /* cards and dialogs */
  --ok: #15803d;           /* "on" badges, success */
  --gap: 1rem;

  /* used by hand-drawn shapes (placeholders, charts) */
  --oi-stroke: var(--muted);
  --oi-fill: #f3f1ea;
  --oi-line: var(--line);
  --oi-chart: var(--accent);
  --tone-bg: #f1efe8;      /* background used by `fill: true` without a tone */

  --wired-item-selected-bg: #eee;
  --wired-toggle-on-color: var(--ink);
  --wired-toggle-off-color: var(--muted);
  --wired-slider-knob-color: var(--accent);
  --wired-slider-bar-color: var(--ink);
  --wired-radio-icon-color: var(--ink);
  --wired-checkbox-icon-color: var(--ink);
  --wired-progress-color: var(--accent);
  --wired-progress-label-color: var(--ink);
  --wired-progress-label-background: var(--card-bg);

  /* tone palette: strong colour + light tint */
  --blue: #1d4ed8;   --blue-bg: #dbeafe;
  --green: #15803d;  --green-bg: #dcfce7;
  --yellow: #a16207; --yellow-bg: #fef3c7;
  --red: #b91c1c;    --red-bg: #fee2e2;
  --purple: #7e22ce; --purple-bg: #f3e8ff;
  --pink: #be185d;   --pink-bg: #fce7f3;
  --orange: #c2410c; --orange-bg: #ffedd5;
  --teal: #0f766e;   --teal-bg: #ccfbf1;
  --gray: #475569;   --gray-bg: #e2e8f0;
}

/* ------------------------------------------------------------------ tones
   `tone: blue` on a block (or screen) recolours it and everything inside it. */
[data-tone="blue"]   { --tone: var(--blue);   --tone-bg: var(--blue-bg); }
[data-tone="green"]  { --tone: var(--green);  --tone-bg: var(--green-bg); }
[data-tone="yellow"] { --tone: var(--yellow); --tone-bg: var(--yellow-bg); }
[data-tone="red"]    { --tone: var(--red);    --tone-bg: var(--red-bg); }
[data-tone="purple"] { --tone: var(--purple); --tone-bg: var(--purple-bg); }
[data-tone="pink"]   { --tone: var(--pink);   --tone-bg: var(--pink-bg); }
[data-tone="orange"] { --tone: var(--orange); --tone-bg: var(--orange-bg); }
[data-tone="teal"]   { --tone: var(--teal);   --tone-bg: var(--teal-bg); }
[data-tone="gray"]   { --tone: var(--gray);   --tone-bg: var(--gray-bg); }
[data-tone] {
  color: var(--tone);
  --ink: var(--tone);
  --muted: color-mix(in srgb, var(--tone) 65%, white);
  --line: color-mix(in srgb, var(--tone) 35%, white);
  --accent: var(--tone);
  --ok: var(--tone);
  --oi-stroke: var(--tone);
  --oi-fill: var(--tone-bg);
  --oi-line: color-mix(in srgb, var(--tone) 30%, white);
  --oi-chart: var(--tone);
  --wired-toggle-on-color: var(--tone);
  --wired-slider-knob-color: var(--tone);
  --wired-slider-bar-color: var(--tone);
  --wired-radio-icon-color: var(--tone);
  --wired-checkbox-icon-color: var(--tone);
  --wired-progress-color: var(--tone);
  --wired-progress-label-background: color-mix(in srgb, var(--tone-bg) 55%, white);
}
[data-tone] .card, [data-tone].card { background: color-mix(in srgb, var(--tone-bg) 55%, white); }
[data-tone] wired-button { background: color-mix(in srgb, var(--tone-bg) 45%, white); }
[data-tone] wired-button[elevation="3"] { background: var(--tone); color: #fff; }
.screen[data-tone] { background: color-mix(in srgb, var(--tone-bg) 40%, var(--paper)); padding: 1rem; border-radius: 12px; }
/* the wrapper the renderer puts around any block with `tone` / `fill` */
.tone { display: contents; }
.tone[data-fill] { display: block; background: var(--tone-bg); padding: .75rem .9rem; border-radius: 6px 14px 8px 12px; }

/* ------------------------------------------------------------------ base */
* { box-sizing: border-box; }
body { margin: 0; font-family: "Patrick Hand", "Caveat", cursive; font-size: 1.1rem; color: var(--ink); background: var(--paper); }
h1, h2, h3 { font-family: "Caveat", cursive; margin: 0 0 .4rem; line-height: 1.1; }
h1 { font-size: 2.4rem; } h2 { font-size: 1.9rem; } h3 { font-size: 1.4rem; }
p { margin: 0; }
.bold { font-weight: 700; }
.lead { font-size: 1.15rem; }
.muted { color: var(--muted); font-size: .95rem; }
.center { text-align: center; }
[data-go], [data-open], .click { cursor: pointer; }

.shell { max-width: 1000px; margin: 0 auto; padding: var(--gap); }

/* layout blocks */
.stack { display: grid; gap: var(--gap); align-content: start; }
.stack.tight { gap: .2rem; }
.row { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.row.center { justify-content: center; }
/* placeholders and charts have no content width, so in a row they are a 4:3 thumbnail (--oi-w is set from their height) */
.row > oi-placeholder:not([round]), .row > oi-chart { flex: none; width: var(--oi-w); max-width: 100%; }
.grid { display: grid; grid-template-columns: repeat(var(--cols), 1fr); gap: var(--gap); align-items: start; }
@media (max-width: 720px) { html:not(.oi-print) .grid { grid-template-columns: 1fr; } }
.card { display: block; padding: 1rem; background: var(--card-bg); }
.card.dash { background: transparent; }
.center-items { justify-items: center; text-align: center; }
.center-items > * { justify-self: center; }
.field { display: grid; gap: .2rem; }
.fl { font-size: .9rem; color: var(--muted); }
wired-input, wired-textarea, wired-combo, wired-search-input, wired-progress { width: 100%; }
wired-progress { display: block; }
wired-textarea { display: block; min-height: 6rem; }
wired-combo { display: block; border: 2px solid var(--muted); border-radius: 255px 8px 225px 8px/8px 225px 8px 255px; padding: .1rem .3rem; }
wired-button oi-icon + .btn-label { margin-left: .4rem; }
/* a button is as wide as its label, not as wide as the column (matters once themes give buttons a background) */
.stack > wired-button, .stack > .tone > wired-button { justify-self: start; }
.oi-list { margin: 0; padding-left: 1.2rem; display: grid; gap: .25rem; }
.oi-link { color: var(--accent); text-decoration: underline wavy; text-underline-offset: 4px; }

/* header */
.oi-bar { display: flex; align-items: center; gap: .75rem; flex-wrap: wrap; padding: .5rem 0 1rem; border-bottom: 2px dashed var(--line); margin-bottom: var(--gap); }
.oi-bar .brand { font-family: "Caveat", cursive; font-size: 1.9rem; font-weight: 700; margin-right: auto; }
.oi-bar nav { display: flex; gap: .4rem; flex-wrap: wrap; }
.oi-bar nav[hidden] { display: none; }
.lang { display: flex; gap: .2rem; }
[data-lang].on { --wired-item-selected-bg: #eee; font-weight: 700; }

/* screens */
.screen { display: none; }
.screen.on { display: block; }
.screen > * + * { margin-top: var(--gap); }
.screen-title { display: none; }
.screen[data-width="narrow"] { max-width: 520px; margin-inline: auto; }
.screen[data-width="medium"] { max-width: 760px; margin-inline: auto; }
main { min-height: 40vh; }
footer { margin-top: 2.5rem; }

/* sticky-note annotations */
.note { background: var(--note); color: #2b2b2b; padding: .55rem .8rem; transform: rotate(-.4deg); box-shadow: 2px 3px 0 rgba(0,0,0,.08); font-size: .98rem; max-width: 60ch; }

/* next bar */
.nextbar { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; border-top: 2px dashed var(--line); padding-top: var(--gap); margin-top: 1.5rem; }

/* table */
.oi-table { width: 100%; border-collapse: collapse; }
.oi-table th, .oi-table td { text-align: left; padding: .45rem .5rem; border-bottom: 1px dashed var(--line); }
.oi-table th { font-family: "Caveat", cursive; font-size: 1.25rem; }
.oi-table tr.click:hover { background: color-mix(in srgb, var(--ink) 6%, transparent); }
/* a column that only holds an avatar shrinks to the avatar */
.oi-table td:has(> oi-placeholder[round]) { width: 1%; white-space: nowrap; }

/* badge */
.badge { display: inline-block; padding: .05rem .55rem; border: 2px solid var(--muted); border-radius: 255px 15px 225px 15px/15px 225px 15px 255px; font-size: .9rem; }
.badge.on { border-color: var(--ok); color: var(--ok); }
.badge.wait { border-color: var(--accent); color: var(--accent); }
.badge.off { border-color: var(--muted); color: var(--muted); }
.stack > .badge { justify-self: start; }

/* placeholder / chart labels */
.ph-label { position: absolute; inset: 0; margin: auto; width: max-content; height: max-content; padding: 0 .5rem; color: var(--muted); background: color-mix(in srgb, var(--oi-fill) 60%, var(--paper)); }
oi-placeholder[pin] .ph-label, oi-placeholder[play] .ph-label { inset: auto 0 10px 0; }
oi-placeholder[dots] .ph-label { inset: 12px 0 auto 0; }
oi-placeholder[upload] .ph-label { inset: auto 0 22px 0; }
.ph-corner { inset: 4px auto auto 40px; margin: 0; background: transparent; }

/* tabs */
.tab-panel { display: none; margin-top: var(--gap); }
.tab-panel.on { display: block; }

/* ------------------------------------------------------------------ content blocks */
.avatar { display: flex; align-items: center; gap: .6rem; }
.avatar-text { display: grid; line-height: 1.15; }
.hero { text-align: center; padding: 2.5rem 1rem; display: grid; gap: .8rem; justify-items: center; }
.hero.left { text-align: left; justify-items: start; padding-inline: 0; }
.hero h1 { font-size: 3.2rem; margin: 0; }
.hero .lead { max-width: 48ch; color: var(--muted); font-size: 1.25rem; }
.hero-body { justify-items: inherit; width: 100%; }
.stat-value { font-family: "Caveat", cursive; font-size: 2.6rem; line-height: 1; }
.rating { gap: .1rem; }
.rating oi-icon { color: var(--accent); }
.rating .muted { margin-left: .4rem; }

/* feedback */
.alert { --k: #1d4ed8; display: flex; gap: .7rem; align-items: flex-start; padding: .7rem .9rem; border: 2px solid var(--k);
  border-radius: 255px 15px 225px 15px/15px 225px 15px 255px; background: color-mix(in srgb, var(--k) 10%, var(--paper)); }
.alert oi-icon { color: var(--k); flex: none; }
.alert-success { --k: #15803d; } .alert-warning { --k: #b45309; } .alert-error { --k: #b91c1c; }

/* navigation */
.crumbs { display: flex; gap: .4rem; flex-wrap: wrap; color: var(--muted); }
.crumbs .current { color: var(--ink); font-weight: 700; }
.crumbs .sep { opacity: .6; }
.steps { list-style: none; display: flex; padding: 0; margin: 0; }
.steps li { flex: 1; display: flex; align-items: center; gap: .5rem; color: var(--muted); }
.steps li:not(:last-child)::after { content: ""; flex: 1; border-top: 2px dashed var(--line); margin: 0 .6rem; }
.steps li:last-child { flex: none; }
.steps .dot { width: 28px; height: 28px; border: 2px solid currentColor; border-radius: 50%; display: grid; place-items: center; font-size: .85rem; flex: none; }
.steps .on { color: var(--ink); font-weight: 700; }
.steps .on .dot { background: var(--accent); border-color: var(--accent); color: #fff; }
.steps .done { color: var(--ink); }
.steps .done .dot { background: var(--ink); color: var(--paper); }
.tabbar { display: flex; justify-content: space-around; gap: .25rem; border-top: 2px dashed var(--line); padding-top: .6rem; }
.tabbar wired-button { display: inline-flex; }
.tab-label { display: block; font-size: .72rem; line-height: 1; margin-top: .15rem; }

/* accordion */
.accordion details { border: 2px dashed var(--line); border-radius: 10px; padding: .1rem .9rem; margin-bottom: .5rem; }
.accordion summary { cursor: pointer; display: flex; justify-content: space-between; align-items: center; padding: .5rem 0; font-family: "Caveat", cursive; font-size: 1.4rem; list-style: none; }
.accordion summary::-webkit-details-marker { display: none; }
.accordion details[open] summary oi-icon { transform: rotate(180deg); }
.accordion details > .stack { padding: .3rem 0 .9rem; }

/* device frames */
.device { margin-inline: auto; width: 100%; }
.device-phone { max-width: 390px; }
.device-tablet { max-width: 720px; }
.device-frame { display: block; background: var(--card-bg); padding: 0; }
.device-body { padding: .9rem; }
.device-phone .device-body { min-height: 520px; }
.device-tablet .device-body { min-height: 420px; }
.device-notch { width: 90px; height: 8px; border-radius: 8px; background: var(--line); margin: 12px auto 0; }
.device-bar { display: flex; align-items: center; gap: 6px; padding: .55rem .9rem; border-bottom: 2px dashed var(--line); }
.device-bar i { width: 10px; height: 10px; border: 2px solid var(--muted); border-radius: 50%; display: block; }
.device-bar span { margin-left: .6rem; flex: 1; border: 2px solid var(--line); border-radius: 12px; padding: 0 .8rem; font-size: .9rem; color: var(--muted); }

/* modal */
.modal { position: fixed; inset: 0; display: none; place-items: center; z-index: 50; padding: 1rem; margin: 0 !important; }
.modal.on { display: grid; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(0, 0, 0, .4); }
.modal-card { position: relative; display: block; background: var(--card-bg); width: min(100%, 560px); max-height: 88vh; overflow: auto; padding: 1rem; }
.modal[data-width="narrow"] .modal-card { width: min(100%, 380px); }
.modal[data-width="wide"] .modal-card { width: min(100%, 820px); }

/* language switching rules ([data-l]) are generated per spec into the page <style> */

.toast { position: fixed; bottom: 1rem; left: 50%; transform: translateX(-50%); background: var(--ink); color: var(--paper); padding: .5rem 1rem; border-radius: 6px; opacity: 0; transition: opacity .2s; pointer-events: none; z-index: 100; }
.toast.show { opacity: 1; }

/* print / PDF: every screen on its own page. The runtime adds .oi-print before printing (and removes
   it after) so it can measure the print layout and shrink screens too tall for one page; the layout
   width is the @page's printable width. */
@page { size: A4 landscape; margin: 10mm; }
@media print {
  body { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}
html.oi-print { width: 277mm; }
.oi-print .oi-bar nav, .oi-print .lang, .oi-print .print-btn, .oi-print .toast, .oi-print .nextbar, .oi-print .modal { display: none !important; }
.oi-print .screen, .oi-print .screen.on { display: block !important; break-after: page; }
.oi-print .screen:last-of-type { break-after: auto; }
.oi-print .screen-title { display: block; font-family: "Caveat", cursive; font-size: 1.3rem; color: var(--muted); border-bottom: 2px dashed var(--line); }
.oi-print .tab-panel { display: block; }
