/* ui.css – fælles designsystem for Dråber og Todo.
   Appens egen styles.css overskriver kun --accent-tokens og lægger layout ovenpå. */

@font-face {
  font-family: "Instrument Serif";
  src: url("/fonts/instrument-serif.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Instrument Serif";
  src: url("/fonts/instrument-serif-italic.woff2") format("woff2");
  font-weight: 400;
  font-style: italic;
  font-display: swap;
}

:root {
  --bg: #eef1f5;
  --surface: #ffffff;
  --surface-2: #f4f6f9;
  --ink: #1a1f27;
  --muted: #5c6673;
  --line: #d5dbe3;
  --accent: #2563eb;
  --accent-ink: #ffffff;
  --accent-soft: color-mix(in srgb, var(--accent) 12%, var(--surface));
  --ok: #1f7a4d;
  --warn: #c56a32;
  --danger: #b42318;
  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 16px;
  --font-ui: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-display: "Instrument Serif", ui-serif, Georgia, "Times New Roman", serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --page-x: 16px;
  --tab-h: 58px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --tab-space: calc(var(--tab-h) + var(--safe-b));
  --focus: color-mix(in srgb, var(--accent) 40%, transparent);
}

html[data-theme="dark"] {
  color-scheme: dark;
  --bg: #121417;
  --surface: #1c2128;
  --surface-2: #232932;
  --ink: #e8edf4;
  --muted: #9aa3b2;
  --line: #2a313c;
  --accent: #4d8aff;
  --accent-ink: #0b1220;
  --ok: #5dbe84;
  --warn: #e08a4d;
  --danger: #e06a62;
}

/* ---------- Basis ---------- */
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; min-height: 100dvh; }
body {
  font-family: var(--font-ui);
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}
button { cursor: pointer; font: inherit; color: inherit; }
input, button { font-family: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
[hidden], .hidden { display: none !important; }
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
svg.ic { width: 22px; height: 22px; flex: 0 0 auto; }

.app {
  max-width: 430px;
  margin: 0 auto;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding-right: calc(var(--page-x) + env(safe-area-inset-right, 0px));
  padding-left: calc(var(--page-x) + env(safe-area-inset-left, 0px));
}

/* ---------- Typografi ---------- */
h1 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 2rem;
  font-weight: 400;
  line-height: 1;
  letter-spacing: -0.01em;
}
h2 { margin: 0 0 12px; font-size: 1.05rem; font-weight: 650; }
.display { font-family: var(--font-display); font-weight: 400; letter-spacing: -0.01em; }
.muted { color: var(--muted); margin: 2px 0 0; font-size: 0.88rem; }
.num { font-variant-numeric: tabular-nums; }
.group-title {
  margin: 20px 4px 8px;
  font-size: 0.78rem;
  font-weight: 650;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.group-title:first-child { margin-top: 8px; }

/* ---------- Header ---------- */
.top {
  position: sticky;
  top: 0;
  z-index: 8;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 12px;
  margin: 0 calc(-1 * var(--page-x)) 6px;
  padding: calc(12px + env(safe-area-inset-top, 0px)) var(--page-x) 10px;
  background: var(--bg);
}
.title-block { min-width: 0; }
body.is-locked .top, body.is-locked .tabbar { display: none; }

/* ---------- Flader og lister ---------- */
.surface {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}
.surface + .surface { margin-top: 10px; }
.set-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 50px;
  margin: 0;
  padding: 11px 14px;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  text-align: left;
}
.set-row .ic { color: var(--muted); }
.set-row .lead { display: flex; align-items: center; gap: 12px; min-width: 0; flex: 1; }
.set-row .lead .ic { color: var(--accent); }
.set-row .value { color: var(--muted); font-variant-numeric: tabular-nums; }
.set-row .sub { display: block; color: var(--muted); font-size: 0.82rem; margin-top: 2px; }
button.set-row:active { background: var(--surface-2); }
.settings-list > :not([hidden]):not(.hidden) ~ :not([hidden]):not(.hidden) { border-top: 1px solid var(--line); }
.set-row.chevron::after {
  content: "";
  flex: 0 0 8px;
  width: 8px;
  height: 8px;
  border-right: 1.8px solid var(--muted);
  border-top: 1.8px solid var(--muted);
  transform: rotate(45deg);
  margin-right: 2px;
}
.set-row.danger { color: var(--danger); }
.set-row.static { color: var(--muted); font-size: 0.88rem; line-height: 1.4; }
.set-row.static:empty { display: none; }
.set-row input[type="time"], .set-row input[type="number"] {
  width: auto; max-width: 8rem; margin: 0; padding: 8px 10px;
  border-radius: var(--radius-sm); border: 1px solid var(--line);
  background: var(--surface-2); color: var(--ink); font-size: 1rem; text-align: right;
}

/* Toggle */
.switch {
  appearance: none; -webkit-appearance: none;
  flex: 0 0 auto; width: 50px; height: 30px; margin: 0;
  border-radius: 15px; background: var(--line); position: relative;
  transition: background 0.2s ease;
}
.switch::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px;
  border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
  transition: transform 0.2s cubic-bezier(0.22, 1, 0.36, 1);
}
.switch:checked { background: var(--accent); }
.switch:checked::after { transform: translateX(20px); }

/* Stepper */
.stepper { display: flex; align-items: center; gap: 4px; }
.stepper button {
  width: 36px; height: 36px; border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--surface-2); color: var(--ink); font-size: 1.2rem; line-height: 1;
}
.stepper input { width: 3rem; text-align: center; max-width: 3rem; }

/* ---------- Knapper ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 50px; padding: 12px 18px;
  border: 1px solid transparent; border-radius: var(--radius-lg);
  font-size: 1.02rem; font-weight: 650; line-height: 1.2;
  transition: transform 120ms ease, background 120ms ease, opacity 120ms ease;
}
.btn.primary { background: var(--accent); color: var(--accent-ink); }
.btn.secondary { background: var(--surface); color: var(--accent); border-color: var(--line); }
.btn.ghost { background: none; color: var(--muted); min-height: 44px; font-weight: 550; font-size: 0.92rem; }
.btn.ghost.accent { color: var(--accent); }
.btn.danger { background: var(--danger); color: #fff; }
.btn.sm { min-height: 36px; padding: 6px 12px; font-size: 0.88rem; border-radius: 10px; }
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.45; transform: none; }
.btn-block { display: flex; width: 100%; }
.btn + .btn { margin-top: 8px; }

.icon-btn {
  width: 44px; height: 44px; border: 0; border-radius: var(--radius-sm);
  background: transparent; color: var(--accent); padding: 0;
  display: inline-grid; place-items: center; flex: 0 0 auto;
}
.icon-btn svg { width: 22px; height: 22px; }
.icon-btn.subtle { color: var(--muted); }
.icon-btn:active { background: var(--surface-2); }

/* ---------- Tabbar og dock ---------- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: flex; justify-content: space-around; align-items: stretch;
  max-width: 430px; margin: 0 auto;
  height: var(--tab-space);
  padding: 0 8px var(--safe-b);
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  -webkit-backdrop-filter: blur(18px) saturate(1.4);
  backdrop-filter: blur(18px) saturate(1.4);
  border-top: 1px solid var(--line);
}
.tab {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  border: 0; background: none; color: var(--muted); padding: 6px 0 4px;
  font-size: 0.68rem; font-weight: 600; letter-spacing: 0.01em;
  border-radius: var(--radius-sm);
}
.tab svg { width: 24px; height: 24px; }
.tab[aria-current="page"] { color: var(--accent); }
.tab:active { color: var(--ink); }
.view { animation: fade-in 180ms ease; padding-bottom: calc(var(--tab-space) + 16px); }
.dock {
  position: sticky; bottom: var(--tab-space);
  padding: 10px 0 8px;
  background: linear-gradient(to top, var(--bg) 70%, transparent);
}

/* ---------- Kontroller ---------- */
.segmented {
  display: flex; padding: 3px;
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 11px;
}
.segmented button {
  flex: 1; border: 0; background: none; padding: 8px 10px; border-radius: 8px;
  font-size: 0.9rem; font-weight: 600; color: var(--muted);
}
.segmented button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1); }

.input-group {
  display: flex; align-items: center; gap: 8px;
  padding: 5px 5px 5px 14px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg);
}
.input-group input {
  flex: 1; min-width: 0; border: 0; background: none; outline: none;
  font-size: 1rem; color: var(--ink); padding: 9px 0;
}
.input-group input::placeholder { color: var(--muted); }
.input-group .icon-btn { width: 40px; height: 40px; border-radius: 12px; background: var(--accent); color: var(--accent-ink); }
.input-group:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--focus); }

.field {
  display: block; width: 100%; padding: 13px 14px;
  border-radius: var(--radius); border: 1px solid var(--line);
  background: var(--surface); color: var(--ink); font-size: 1rem;
}
.field:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--focus); }
.field.code { letter-spacing: 0.28em; font-variant-numeric: tabular-nums; font-size: 1.3rem; text-align: center; }
label.stack { display: block; font-size: 0.85rem; font-weight: 600; color: var(--muted); }
label.stack .field { margin-top: 6px; }

.check {
  flex: 0 0 26px; width: 26px; height: 26px; border-radius: 50%;
  border: 2px solid var(--line); background: transparent; color: var(--accent-ink);
  display: grid; place-items: center; padding: 0;
  transition: background 150ms ease, border-color 150ms ease;
}
.check svg { width: 15px; height: 15px; opacity: 0; transform: scale(0.6); transition: opacity 150ms ease, transform 150ms cubic-bezier(0.22, 1, 0.36, 1); }
.check.on { background: var(--accent); border-color: var(--accent); }
.check.on svg { opacity: 1; transform: none; }
.check.dot { border-style: dashed; opacity: 0.7; }

.progress { display: block; height: 4px; border-radius: 2px; background: var(--line); overflow: hidden; }
.progress > i { display: block; height: 100%; width: 0; background: var(--accent); border-radius: 2px; transition: width 300ms ease; }

.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 9px; border-radius: 999px;
  background: var(--accent-soft); color: var(--accent);
  font-size: 0.74rem; font-weight: 650; letter-spacing: 0.01em;
}
.chip.warn { background: color-mix(in srgb, var(--warn) 14%, var(--surface)); color: var(--warn); }
.chip.neutral { background: var(--surface-2); color: var(--muted); }

.stat-strip { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 14px; }
.stat-tile { padding: 12px 12px 10px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.stat-tile strong { display: block; font-family: var(--font-display); font-size: 1.7rem; font-weight: 400; line-height: 1; font-variant-numeric: tabular-nums; }
.stat-tile span { display: block; margin-top: 4px; color: var(--muted); font-size: 0.72rem; }

.empty-state { padding: 36px 18px; text-align: center; color: var(--muted); }
.empty-state svg { width: 36px; height: 36px; color: var(--accent); margin-bottom: 8px; }
.empty-state strong { display: block; font-family: var(--font-display); font-size: 1.6rem; font-weight: 400; color: var(--ink); margin-bottom: 4px; }

.backup { list-style: none; padding: 0 14px; margin: 0; font-family: var(--font-mono); font-size: 0.98rem; letter-spacing: 0.04em; }
.backup li { padding: 10px 0; border-top: 1px solid var(--line); }
.backup li:first-child { border-top: 0; }
.qr { margin: 12px auto; text-align: center; }
.qr svg { width: 220px; height: 220px; background: white; padding: 8px; border-radius: var(--radius); }

.footer-hint { color: var(--muted); font-size: 0.8rem; margin: 8px 4px 0; line-height: 1.4; }

/* ---------- Toast og inline-bekræftelse ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(var(--tab-space) + 16px); z-index: 40;
  max-width: min(92vw, 400px); padding: 12px 16px;
  background: var(--ink); color: var(--bg);
  border-radius: 12px; font-size: 0.92rem; line-height: 1.35;
  opacity: 0; transform: translate(-50%, 8px); pointer-events: none;
  transition: opacity 180ms ease, transform 180ms ease;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error { background: var(--danger); color: #fff; }
body.is-locked .toast { bottom: 24px; }
.inline-confirm {
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
  min-height: 50px; padding: 7px 8px 7px 14px;
  background: color-mix(in srgb, var(--danger) 7%, var(--surface));
  font-size: 0.95rem;
}
.inline-confirm .ic-actions { display: flex; gap: 6px; }

/* ---------- Auth ---------- */
.view-auth {
  display: flex; flex-direction: column; justify-content: center;
  flex: 1; padding: calc(24px + env(safe-area-inset-top, 0px)) 0 calc(24px + var(--safe-b));
  min-height: 100dvh;
}
.auth-card { padding: 6px 2px; }
.wordmark { font-family: var(--font-display); font-size: 2.6rem; font-weight: 400; line-height: 1; margin: 0 0 6px; letter-spacing: -0.01em; }
.wordmark .ic { width: 28px; height: 28px; vertical-align: -3px; margin-right: 6px; color: var(--accent); }
.auth-card h2 { font-size: 1.15rem; margin: 18px 0 4px; }
.auth-card .muted { margin-bottom: 18px; }
.auth-card .btn-block + .btn-block { margin-top: 10px; }
.auth-status { min-height: 1.4em; margin-top: 14px; }
body.auth-locked .auth-form { opacity: 0.4; pointer-events: none; }

/* ---------- Bevægelse ---------- */
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .btn:active { transform: none; }
}
