/* Haku — design tokens + components shared by the platform, the studio sites
   and the owner panel. Studio sites override --accent with the studio colour. */
:root {
  --paper: #F1F3F2;
  --surface: #FFFFFF;
  --sunk: #E8ECEA;
  --ink: #17232D;
  --ink-2: #33414B;
  --muted: #5B6870;
  --line: #DCE1DF;
  --line-strong: #C3CAC7;
  --accent: #4B44B5;
  --accent-ink: #FFFFFF;
  --accent-soft: color-mix(in srgb, var(--accent) 11%, var(--surface));
  --accent-line: color-mix(in srgb, var(--accent) 35%, var(--surface));
  --ok: #24785A;
  --ok-soft: color-mix(in srgb, var(--ok) 12%, var(--surface));
  --warn: #A9561B;
  --warn-soft: color-mix(in srgb, var(--warn) 12%, var(--surface));
  --bad: #B3362F;
  --bad-soft: color-mix(in srgb, var(--bad) 10%, var(--surface));
  --shadow-pop: 0 18px 50px -12px rgba(23, 35, 45, .28), 0 2px 6px rgba(23, 35, 45, .08);
  --r-chip: 999px;
  --r-ctl: 10px;
  --r-panel: 16px;
  --display: "Bricolage Grotesque", "Onest", system-ui, sans-serif;
  --ui: "Onest", system-ui, -apple-system, "Segoe UI", sans-serif;
  --gutter: 16px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #0F161B; --surface: #172128; --sunk: #1D2931; --ink: #E6ECEF; --ink-2: #C5CFD4;
    --muted: #93A1A8; --line: #2A3740; --line-strong: #3A4954; --accent: #9C96F0; --accent-ink: #12102B;
    --ok: #5FC79D; --warn: #E89A5E; --bad: #F0857D;
    --shadow-pop: 0 18px 50px -12px rgba(0, 0, 0, .6), 0 2px 6px rgba(0, 0, 0, .3);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #0F161B; --surface: #172128; --sunk: #1D2931; --ink: #E6ECEF; --ink-2: #C5CFD4;
  --muted: #93A1A8; --line: #2A3740; --line-strong: #3A4954; --accent: #9C96F0; --accent-ink: #12102B;
  --ok: #5FC79D; --warn: #E89A5E; --bad: #F0857D;
  --shadow-pop: 0 18px 50px -12px rgba(0, 0, 0, .6), 0 2px 6px rgba(0, 0, 0, .3);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--paper); color: var(--ink);
  font: 400 15.5px/1.55 var(--ui); font-feature-settings: "ss01";
  -webkit-font-smoothing: antialiased;
}
img { max-width: 100%; display: block; }
a { color: inherit; text-decoration-color: var(--accent-line); text-underline-offset: 3px; }
a:hover { text-decoration-color: var(--accent); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
h1, h2, h3, h4 { font-family: var(--display); font-weight: 600; letter-spacing: -.015em; line-height: 1.12; margin: 0; }
h1 { font-size: clamp(1.9rem, 4.5vw, 2.6rem); }
h2 { font-size: 1.45rem; }
h3 { font-size: 1.12rem; }
p { margin: 0 0 .8em; }
small, .small { font-size: .86rem; }
.muted { color: var(--muted); }
.num { font-variant-numeric: tabular-nums; }
.nowrap { white-space: nowrap; }
.stack > * + * { margin-top: var(--stack, 16px); }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.grow { flex: 1 1 auto; min-width: 0; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.wrap { width: min(1120px, 100% - 2 * var(--gutter)); margin-inline: auto; }
.narrow { width: min(640px, 100% - 2 * var(--gutter)); margin-inline: auto; }

/* ---- buttons ------------------------------------------------------------ */
.btn {
  --b-bg: var(--surface); --b-fg: var(--ink); --b-line: var(--line-strong);
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 40px; padding: 8px 16px; border-radius: var(--r-ctl);
  background: var(--b-bg); color: var(--b-fg); border: 1px solid var(--b-line);
  font: 600 .93rem/1.1 var(--ui); text-decoration: none; cursor: pointer; white-space: nowrap;
  transition: background .15s, border-color .15s, transform .08s;
}
.btn:hover { border-color: var(--ink-2); }
.btn:active { transform: translateY(1px); }
.btn.primary { --b-bg: var(--accent); --b-fg: var(--accent-ink); --b-line: var(--accent); }
.btn.primary:hover { --b-bg: color-mix(in srgb, var(--accent) 88%, black); }
.btn.quiet { --b-bg: transparent; --b-line: transparent; color: var(--ink-2); }
.btn.quiet:hover { --b-bg: var(--sunk); }
.btn.danger { --b-fg: var(--bad); }
.btn.danger:hover { --b-line: var(--bad); }
.btn.ok { --b-bg: var(--ok); --b-fg: #fff; --b-line: var(--ok); }
.btn.small { min-height: 32px; padding: 5px 11px; font-size: .85rem; border-radius: 8px; }
.btn.big { min-height: 50px; padding: 12px 22px; font-size: 1rem; border-radius: 12px; }
.btn.block { width: 100%; }
.btn[disabled], .btn.disabled { opacity: .45; pointer-events: none; }
.linkbtn { background: none; border: 0; padding: 0; color: inherit; font: inherit; text-decoration: underline;
  text-decoration-color: var(--accent-line); text-underline-offset: 3px; cursor: pointer; }
form.inline { display: inline; }

/* ---- chips & badges ------------------------------------------------------ */
.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: var(--r-chip);
  font-size: .8rem; font-weight: 600; background: var(--sunk); color: var(--ink-2); white-space: nowrap;
}
.chip.ok { background: var(--ok-soft); color: var(--ok); }
.chip.warn { background: var(--warn-soft); color: var(--warn); }
.chip.bad { background: var(--bad-soft); color: var(--bad); }
.chip.accent { background: var(--accent-soft); color: var(--accent); }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--c, var(--accent)); flex: none; display: inline-block; }

/* ---- panels -------------------------------------------------------------- */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-panel); padding: 20px; }
.panel.flush { padding: 0; overflow: hidden; }
.panel > header { display: flex; align-items: center; gap: 12px; justify-content: space-between; margin-bottom: 14px; flex-wrap: wrap; }
.panel > header h2, .panel > header h3 { font-size: 1.1rem; }
.panel.tinted { background: var(--accent-soft); border-color: var(--accent-line); }
.empty { padding: 28px 20px; text-align: center; color: var(--muted); }
.empty h3 { color: var(--ink); margin-bottom: 6px; }
.divider { border: 0; border-top: 1px solid var(--line); margin: 18px 0; }

/* ---- lists & tables ------------------------------------------------------ */
.list { list-style: none; margin: 0; padding: 0; }
.list > li { display: flex; gap: 12px; align-items: center; padding: 12px 20px; border-top: 1px solid var(--line); }
.list > li:first-child { border-top: 0; }
.list a.rowlink { text-decoration: none; display: contents; }
.table { width: 100%; border-collapse: collapse; font-size: .93rem; }
.table th { text-align: left; font-weight: 600; color: var(--muted); font-size: .82rem; padding: 10px 14px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table td { padding: 11px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table td.r, .table th.r { text-align: right; }
.table tbody tr:hover { background: color-mix(in srgb, var(--sunk) 55%, transparent); }
.tablewrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }

/* ---- forms --------------------------------------------------------------- */
.field { margin-bottom: 16px; }
.field > label, .label { display: block; font-weight: 600; font-size: .9rem; margin-bottom: 6px; }
.field .help { color: var(--muted); font-size: .83rem; margin-top: 5px; }
.field .errors { color: var(--bad); font-size: .85rem; margin-top: 5px; }
.field.has-error input, .field.has-error select, .field.has-error textarea { border-color: var(--bad); }
input:not([type]), input[type=text], input[type=email], input[type=password], input[type=number], input[type=tel], input[type=url],
input[type=date], input[type=time], input[type=search], select, textarea {
  width: 100%; min-height: 42px; padding: 9px 12px; border: 1px solid var(--line-strong); border-radius: var(--r-ctl);
  background: var(--surface); color: var(--ink); font: 400 1rem/1.35 var(--ui);
}
textarea { min-height: 96px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
input[type=color] { width: 56px; height: 42px; padding: 3px; border: 1px solid var(--line-strong); border-radius: var(--r-ctl); background: var(--surface); }
input[type=file] { font: inherit; font-size: .9rem; }
.check { display: flex; gap: 10px; align-items: flex-start; font-weight: 500; font-size: .95rem; cursor: pointer; }
.check input { width: 18px; height: 18px; margin: 2px 0 0; accent-color: var(--accent); flex: none; }
.field.checkbox > label { display: flex; gap: 10px; align-items: flex-start; font-weight: 500; }
.choices { display: flex; flex-wrap: wrap; gap: 8px; }
.choices label { display: flex; gap: 8px; align-items: center; padding: 8px 14px; border: 1px solid var(--line-strong);
  border-radius: var(--r-ctl); cursor: pointer; font-weight: 500; font-size: .93rem; }
.choices label:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.choices input { accent-color: var(--accent); margin: 0; }
.choices.list-checks { flex-direction: column; gap: 4px; }
.choices.list-checks label { border: 0; padding: 4px 0; }
.choices.list-checks label:has(input:checked) { background: none; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 16px; }
.grid3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0 16px; }
@media (max-width: 640px) { .grid2, .grid3 { grid-template-columns: 1fr; } }
fieldset { border: 0; padding: 0; margin: 0 0 8px; }
legend { font-family: var(--display); font-weight: 600; font-size: 1.05rem; margin-bottom: 12px; padding: 0; }
.formactions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-top: 8px; }
.formactions .spacer { flex: 1; }

/* ---- messages ------------------------------------------------------------ */
.toasts { position: fixed; z-index: 90; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  display: grid; gap: 8px; width: min(520px, calc(100% - 32px)); pointer-events: none; }
.toast { pointer-events: auto; display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px 12px 16px;
  background: var(--ink); color: var(--paper); border-radius: 12px; box-shadow: var(--shadow-pop); font-size: .94rem;
  animation: toast-in .25s ease-out; }
.toast.error { background: var(--bad); color: #fff; }
.toast button { margin-left: auto; background: none; border: 0; color: inherit; opacity: .7; font-size: 1.2rem; line-height: 1; cursor: pointer; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

/* ---- dialogs ------------------------------------------------------------- */
dialog { border: 0; padding: 0; border-radius: 18px; background: var(--surface); color: var(--ink);
  width: min(480px, calc(100vw - 24px)); box-shadow: var(--shadow-pop); max-height: calc(100dvh - 32px); }
dialog.wide { width: min(760px, calc(100vw - 24px)); }
dialog::backdrop { background: rgba(15, 22, 27, .45); }
dialog .dlg { padding: 22px; }
dialog .dlg > h2 { font-size: 1.3rem; margin-bottom: 16px; }

/* ---- language / theme switch -------------------------------------------- */
.lang { display: inline-flex; border: 1px solid var(--line); border-radius: var(--r-chip); padding: 2px; }
.lang button { border: 0; background: none; font: 600 .78rem/1 var(--ui); padding: 5px 9px; border-radius: var(--r-chip); color: var(--muted); cursor: pointer; }
.lang button[aria-pressed="true"] { background: var(--ink); color: var(--paper); }

/* ---- avatar -------------------------------------------------------------- */
.avatar { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; flex: none;
  background: var(--accent-soft); color: var(--accent); font: 700 .8rem/1 var(--ui); overflow: hidden; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar.lg { width: 64px; height: 64px; font-size: 1.1rem; }

/* ---- time typography (the signature) ------------------------------------- */
.t-big { font-family: var(--display); font-weight: 500; font-variant-numeric: tabular-nums; letter-spacing: -.02em; line-height: 1; }

@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
