/* KoNote, in the Kohu Labs design system (tokens, type and components from the Kohu Labs brand book). */

/* ---------- Fonts ---------- */
@font-face { font-family: "Bricolage Grotesque"; src: url("fonts/bricolage-grotesque-latin-wght-normal.woff2") format("woff2"); font-weight: 200 800; font-style: normal; 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: "Bricolage Grotesque"; src: url("fonts/bricolage-grotesque-latin-ext-wght-normal.woff2") format("woff2"); font-weight: 200 800; font-style: normal; font-display: swap; unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: "DM Mono"; src: url("fonts/dm-mono-latin-400-normal.woff2") format("woff2"); font-weight: 400; font-style: normal; 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: "DM Mono"; src: url("fonts/dm-mono-latin-ext-400-normal.woff2") format("woff2"); font-weight: 400; font-style: normal; font-display: swap; unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: "DM Mono"; src: url("fonts/dm-mono-latin-500-normal.woff2") format("woff2"); font-weight: 500; font-style: normal; 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: "DM Mono"; src: url("fonts/dm-mono-latin-ext-500-normal.woff2") format("woff2"); font-weight: 500; font-style: normal; font-display: swap; unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }

/* ---------- Tokens ---------- */
:root, [data-theme="light"] {
  --bg: #f4f1e8; --bg-2: #ebe7da; --surface: #faf8f2;
  --ink: #0c0e14; --muted: #566073; --line: rgba(12, 14, 20, 0.17);
  --accent: #1c3dff; --accent-ink: #ffffff; --accent-hover: #0c0e14;
  --acid: #c6ee00; --highlight: var(--accent);
  --err: #b42318;   /* KoNote addition: error text, 5.6:1 on bg-2 */
  --shadow-float: 0 18px 50px rgba(0, 0, 0, 0.28);
  color-scheme: light;
}
[data-theme="dark"] {
  --bg: #090b11; --bg-2: #0f121b; --surface: #0f131d;
  --ink: #eeeae0; --muted: #98a3b8; --line: rgba(238, 234, 224, 0.17);
  --accent: #5b7bff; --accent-ink: #090b11; --accent-hover: #eeeae0;
  --acid: #d4ff3a; --highlight: var(--acid);
  --err: #ff8a7a;   /* KoNote addition: error text, 8:1 on bg-2 */
  color-scheme: dark;
}
:root {
  --space-4: 4px; --space-6: 6px; --space-10: 10px; --space-14: 14px; --space-16: 16px;
  --space-20: 20px; --space-22: 22px; --space-28: 28px; --space-32: 32px;
  --radius-sharp: 2px; --radius-pill: 99px; --radius-round: 50%;
  --font-sans: "Bricolage Grotesque", "Helvetica Neue", Arial, sans-serif;
  --font-mono: "DM Mono", ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
}

/* ---------- Base ---------- */
* { box-sizing: border-box; }
html { background: var(--bg); }
body { margin: 0; min-height: 100vh; background: var(--bg); color: var(--ink);
  font-family: var(--font-sans); font-size: 16px; line-height: 1.55; -webkit-font-smoothing: antialiased;
  padding: 0 0 env(safe-area-inset-bottom); }
.hidden { display: none !important; }
a { color: var(--accent); }
.k-mono { font-family: var(--font-mono); font-size: 0.72rem; letter-spacing: 0.1em; text-transform: uppercase; font-weight: 400; }
.k-arrow { width: 16px; height: 16px; flex: none; transition: transform 0.2s ease; }
.hl { color: var(--highlight); }

/* ---------- Header ---------- */
header { position: sticky; top: 0; z-index: 5; background: var(--bg); border-bottom: 1px solid var(--line);
  padding-top: env(safe-area-inset-top); }
.top { display: flex; align-items: center; justify-content: space-between; gap: 12px;
  max-width: 720px; margin: 0 auto; padding: 12px 16px 6px; }
.brand { display: flex; align-items: baseline; gap: 10px; min-width: 0; }
.brand b { font-size: 1.6rem; font-weight: 800; letter-spacing: -0.045em; line-height: 1; font-variation-settings: 'opsz' 96; }
.brand .k-mono { color: var(--muted); white-space: nowrap; }
.toggle { display: inline-flex; align-items: center; gap: 10px; min-height: 44px; padding: 0 16px; border: 1px solid var(--line);
  border-radius: var(--radius-pill); background: transparent; color: var(--ink); cursor: pointer; flex: none; }
.toggle:hover, .toggle:focus-visible { border-color: var(--accent); outline: none; }
.theme-dot { width: 10px; height: 10px; border-radius: var(--radius-round); background: var(--accent); border: 1px solid var(--accent); box-shadow: inset -4px 0 0 0 var(--bg); }
[data-theme="dark"] .theme-dot { box-shadow: inset 4px 0 0 0 var(--bg); }

.tabs { display: flex; gap: 4px; max-width: 720px; margin: 0 auto; padding: 0 8px; overflow-x: auto; }
.tabs button { display: flex; align-items: center; min-height: 48px; padding: 0 12px; background: none; border: 0;
  border-bottom: 2px solid transparent; color: var(--muted); font: 500 1rem var(--font-sans); cursor: pointer; }
.tabs button:hover { color: var(--ink); }
.tabs button:focus-visible { outline: 2px solid var(--accent); outline-offset: -4px; }
.tabs button[aria-current="page"] { color: var(--ink); border-bottom-color: var(--accent); }

/* ---------- Layout ---------- */
main { max-width: 720px; margin: 0 auto; padding: 0 16px 24px; }
.hero { padding: 36px 0 28px; }
.eyebrow { display: flex; align-items: center; gap: var(--space-10); margin: 0 0 14px; color: var(--muted); }
.eyebrow .num { color: var(--accent); }
.status-dot { width: 8px; height: 8px; border-radius: var(--radius-round); background: var(--acid); box-shadow: 0 0 0 1px var(--ink); flex: none; }
.page-title { margin: 0; font-size: clamp(2.5rem, 11vw, 4.4rem); line-height: 0.95; font-weight: 800; letter-spacing: -0.045em; font-variation-settings: 'opsz' 96; }
.lede { margin: 18px 0 0; max-width: 31rem; color: var(--muted); font-size: 1.1rem; line-height: 1.5; }

.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sharp); padding: var(--space-20); margin-bottom: var(--space-20); }
.panel > .eyebrow { margin-bottom: 4px; }
.panel h2 { margin: 0 0 6px; font-size: 1.5rem; line-height: 1.1; font-weight: 700; letter-spacing: -0.03em; }

/* ---------- Form ---------- */
label.field { display: flex; align-items: center; gap: 8px; margin: 18px 0 8px; font-size: 0.95rem; font-weight: 600; color: var(--ink); }
.opt { color: var(--muted); font-size: 0.66rem; }
input[type=text], input[type=password], input[type=url], select, textarea {
  width: 100%; min-height: 48px; padding: 12px; background: var(--bg); color: var(--ink);
  border: 1px solid var(--line); border-radius: var(--radius-sharp); font: inherit; font-size: 16px; }
input::placeholder, textarea::placeholder { color: var(--muted); opacity: 0.85; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
textarea { min-height: 96px; resize: vertical; }
textarea.md { min-height: 55vh; font-family: var(--font-mono); font-size: 13px; line-height: 1.6; }

.or { display: flex; align-items: center; gap: 12px; margin: 14px 0; color: var(--muted); }
.or::before, .or::after { content: ""; flex: 1; border-top: 1px solid var(--line); }

.file-pick { display: flex; align-items: center; gap: 12px; min-height: 56px; padding: 14px; margin: 0;
  border: 1px dashed var(--line); border-radius: var(--radius-sharp); color: var(--muted); cursor: pointer; background: var(--bg); }
.file-pick:hover, .file-pick:focus-within { border-color: var(--accent); }
.file-pick input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.file-pick svg { width: 18px; height: 18px; flex: none; color: var(--accent); }
.file-pick.has { border-style: solid; color: var(--ink); }

.modes { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-10); }
.mode { position: relative; display: block; margin: 0; padding: 14px 14px 16px; background: var(--bg);
  border: 1px solid var(--line); border-radius: var(--radius-sharp); cursor: pointer; transition: border-color 0.2s ease; }
.mode:hover { border-color: var(--accent); }
.mode input { position: absolute; opacity: 0; pointer-events: none; }
.mode svg { display: block; width: 22px; height: 22px; color: var(--muted); margin-bottom: 12px; }
.mode b { display: block; font-size: 1.05rem; font-weight: 700; letter-spacing: -0.02em; line-height: 1.2; }
.mode span.d { display: block; margin-top: 4px; color: var(--muted); font-size: 0.85rem; line-height: 1.45; }
.mode .tick { position: absolute; top: 14px; right: 14px; width: 12px; height: 12px; border-radius: var(--radius-round); border: 1px solid var(--line); }
.mode:has(input:checked) { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset; }
.mode:has(input:checked) svg { color: var(--accent); }
.mode:has(input:checked) .tick { background: var(--acid); border-color: var(--ink); }
.mode:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }

.check { display: flex; align-items: center; gap: 12px; min-height: 44px; margin: 10px 0 0; font-size: 0.95rem; color: var(--ink); cursor: pointer; }
.check input { width: 20px; height: 20px; margin: 0; accent-color: var(--accent); flex: none; }

.hint { margin: 10px 0 0; color: var(--muted); font-size: 0.85rem; line-height: 1.5; }
.hint b { color: var(--ink); font-weight: 600; }

/* ---------- Buttons ---------- */
.row { display: flex; gap: var(--space-14); flex-wrap: wrap; margin-top: var(--space-20); }
.row > .btn { flex: 1 1 auto; }
.btn { display: inline-flex; align-items: center; justify-content: space-between; gap: 18px; min-height: 52px; padding: 0 var(--space-22);
  border: 1px solid var(--accent); border-radius: var(--radius-sharp); font: 600 1rem/1.2 var(--font-sans); cursor: pointer;
  transition: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease; }
.btn-primary { background: var(--accent); color: var(--accent-ink); }
.btn-primary:hover, .btn-primary:focus-visible { background: var(--accent-hover); border-color: var(--accent-hover); color: var(--bg); outline: none; }
.btn-primary:hover .k-arrow { transform: translate(2px, -2px); }
.btn-ghost { background: transparent; color: var(--ink); border-color: var(--line); justify-content: center; }
.btn-ghost:hover, .btn-ghost:focus-visible { border-color: var(--accent); color: var(--accent); outline: none; }
.btn-sm { min-height: 40px; padding: 0 14px; font-size: 0.9rem; gap: 12px; flex: none; }
.btn:disabled { opacity: 0.5; cursor: progress; }

/* ---------- Status ---------- */
.status { display: none; align-items: center; gap: 12px; margin-top: var(--space-14); padding: 14px 16px;
  background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--radius-sharp); font-size: 0.95rem; }
.status.show { display: flex; }
.status .noise { font-family: var(--font-mono); color: var(--accent); min-width: 6ch; letter-spacing: 0.06em; flex: none; }
.status .tag { display: none; flex: none; }
.status.err { border-color: var(--err); }
.status.err .noise, .status.warn .noise { display: none; }
.status.err .tag, .status.warn .tag { display: inline; }
.status.err .tag { color: var(--err); }
.status.warn .tag { color: var(--accent); }

/* ---------- Result ---------- */
.result-title { margin: 0 0 14px; font-size: 1.6rem; line-height: 1.08; font-weight: 700; letter-spacing: -0.03em; overflow-wrap: anywhere; }

/* ---------- History ---------- */
.hist-item { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 14px 0; border-bottom: 1px solid var(--line); cursor: pointer; }
.hist-item:last-child { border-bottom: 0; padding-bottom: 0; }
.hist-item:hover .t { color: var(--accent); }
.hist-item .t { font-weight: 600; font-size: 1rem; line-height: 1.3; overflow-wrap: anywhere; }
.hist-item .d { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 6px; color: var(--muted); font-size: 0.66rem; }
.pill { display: inline-flex; align-items: center; gap: 7px; padding: 3px 10px 3px 8px; border: 1px solid var(--line); border-radius: var(--radius-pill);
  font: 400 0.66rem var(--font-mono); letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink); }
.pill i { width: 7px; height: 7px; border-radius: var(--radius-round); background: var(--muted); }
.pill.visual i { background: var(--accent); }

/* ---------- Footer & toast ---------- */
footer { display: flex; justify-content: center; align-items: center; gap: 10px; padding: 8px 16px 32px; color: var(--muted); }
footer svg { width: 14px; height: 14px; }
footer .plus { stroke: var(--muted); stroke-width: 1.4; }
footer .dot { fill: var(--acid); stroke: var(--ink); stroke-width: 0.8; }

.toast { position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom)); transform: translateX(-50%) translateY(20px);
  max-width: calc(100% - 32px); padding: 12px 16px; background: var(--ink); color: var(--bg); border-radius: var(--radius-sharp);
  box-shadow: var(--shadow-float); font-size: 0.95rem; opacity: 0; transition: 0.2s; pointer-events: none; z-index: 20; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

@media (max-width: 380px) {
  .brand .k-mono { display: none; }
  .modes { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}
