/* Shared design system for internal pages (sahaj://settings etc.).
   Same "Sahaj Dawn" tokens as the chrome; grouped-list layout,
   iOS Settings discipline. Fonts are self-hosted (flat woff2 beside
   this file so both file:// and sahaj:// resolve them). */

@font-face {
  font-family: 'Sora Variable';
  src: url('sora-latin-wght-normal.woff2') format('woff2');
  font-weight: 100 800;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Bricolage Grotesque Variable';
  src: url('bricolage-grotesque-latin-opsz-normal.woff2') format('woff2');
  font-weight: 200 800;
  font-style: normal;
  font-display: swap;
}

:root {
  --surface: #f3f2ee;
  --surface-raised: #fcfbf8;
  --surface-hover: rgba(252, 251, 248, 0.8);
  --ink: #231c12;
  --ink-soft: #5f5545;
  --ink-faint: #6e6250;
  --line: rgba(35, 28, 18, 0.1);
  --accent: #e8890c;
  --accent-strong: color-mix(in srgb, var(--accent) 64%, #1a1206);
  --accent-soft: color-mix(in srgb, var(--accent) 12%, transparent);
  --accent-ink: #ffffff;
  --danger: #c93a3a;
  --ok: #3d9a50;
  --radius-s: 10px;
  --radius-m: 14px;
  --radius-l: 20px;
  --shadow-card: 0 1px 2px rgba(46, 34, 18, 0.05), 0 4px 16px rgba(46, 34, 18, 0.07);
  --ease: cubic-bezier(0.23, 1, 0.32, 1);
  --font-ui: 'Sora Variable', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-display: 'Bricolage Grotesque Variable', 'Sora Variable', -apple-system, sans-serif;
  --glow: radial-gradient(120% 70% at 50% -10%, color-mix(in srgb, var(--accent) 9%, transparent), transparent 60%);
}

[data-theme="dark"] {
  --surface: #16130e;
  --surface-raised: #262019;
  --surface-hover: rgba(255, 244, 228, 0.07);
  --ink: #f3ead9;
  --ink-soft: #bcae97;
  --ink-faint: #a2957e;
  --line: rgba(243, 234, 217, 0.1);
  --accent-strong: color-mix(in srgb, var(--accent) 84%, #ffffff);
  --accent-soft: color-mix(in srgb, var(--accent) 18%, transparent);
  --shadow-card: 0 1px 2px rgba(0, 0, 0, 0.35), 0 4px 16px rgba(0, 0, 0, 0.4);
  --glow: radial-gradient(120% 70% at 50% -10%, color-mix(in srgb, var(--accent) 7%, transparent), transparent 60%);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: var(--font-ui);
  font-size: 14px;
  color: var(--ink);
  background: var(--glow), var(--surface);
  background-repeat: no-repeat;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

button { font-family: inherit; }
[hidden] { display: none !important; }

.page {
  max-width: 760px;
  margin: 0 auto;
  padding: 28px 20px 64px;
}

.page-head { margin-bottom: 22px; }
.page-head h1 { font-family: var(--font-display); font-size: 30px; font-weight: 640; font-stretch: 94%; letter-spacing: -0.025em; }
.page-head .sub { color: var(--ink-soft); font-size: 13px; margin-top: 4px; }

.group {
  background: var(--surface-raised);
  border: 1px solid var(--line);
  border-radius: var(--radius-l);
  box-shadow: var(--shadow-card);
  overflow: hidden;
  margin-bottom: 20px;
}
.group-title {
  font-size: 11.5px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--ink-faint);
  margin: 0 4px 8px;
}
.row {
  display: flex; align-items: center; gap: 12px;
  padding: 13px 16px;
  min-height: 48px;
}
.row + .row { border-top: 1px solid color-mix(in srgb, var(--line) 60%, transparent); }
.row .r-main { flex: 1; min-width: 0; }
.row .r-label { font-size: 14px; }
.row .r-sub { font-size: 12px; color: var(--ink-soft); margin-top: 2px; }
.row .r-control { flex: none; }

select.input, input.input[type="text"], input.input[type="number"] {
  height: 34px;
  border: 1px solid var(--line);
  border-radius: var(--radius-s);
  background: var(--surface);
  color: var(--ink);
  font-size: 13px;
  padding: 0 12px;
  outline: none;
  transition: border-color 140ms var(--ease), box-shadow 140ms var(--ease);
}
input.input::placeholder { color: var(--ink-faint); }
select.input:focus, input.input:focus {
  border-color: var(--accent-strong);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 16%, transparent);
}

.switch {
  position: relative;
  width: 44px; height: 26px; flex: none;
  border-radius: 999px;
  background: color-mix(in srgb, var(--ink-faint) 35%, transparent);
  border: none; cursor: pointer;
  transition: background-color 180ms var(--ease);
}
.switch[aria-checked="true"] { background: var(--accent); }
.switch::after {
  content: '';
  position: absolute; top: 2px; left: 2px;
  width: 22px; height: 22px; border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
  transition: transform 180ms var(--ease);
}
.switch[aria-checked="true"]::after { transform: translateX(18px); }

.btn {
  border: 1px solid var(--line);
  background: var(--surface-raised);
  color: var(--ink);
  height: 34px;
  padding: 0 16px;
  border-radius: var(--radius-s);
  font-size: 13px;
  cursor: pointer;
  transition: background-color 130ms var(--ease), transform 110ms var(--ease);
}
.btn:hover { background: var(--surface); }
.btn:active { transform: scale(0.97); }
.btn.accent { background: var(--accent); border-color: transparent; color: var(--accent-ink); }
.btn.accent:hover { background: color-mix(in srgb, var(--accent) 88%, #000); }
.btn.danger { color: var(--danger); }
.btn.text { border: none; background: none; color: var(--accent-strong); height: auto; padding: 4px 8px; }
.btn.text.danger { color: var(--danger); }

.swatches { display: flex; gap: 10px; }
.swatch {
  width: 30px; height: 30px; border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  transition: transform 130ms var(--ease), border-color 130ms var(--ease);
}
.swatch:hover { transform: scale(1.08); }
.swatch.selected { border-color: var(--ink); }

.seg {
  display: flex;
  background: transparent;
  border: none;
  border-radius: var(--radius-s);
  padding: 0;
  gap: 2px;
}
.seg button {
  border: none; background: none;
  padding: 6px 14px;
  border-radius: 7px;
  font-size: 12.5px;
  color: var(--ink-soft);
  cursor: pointer;
  transition: background-color 130ms var(--ease), color 130ms var(--ease);
}
.seg button.on { background: var(--surface); color: var(--ink); }

.search-line { margin-bottom: 16px; }
.search-line input { width: 100%; height: 40px; border-radius: 999px; padding: 0 18px; }

.list-row {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 16px;
  cursor: pointer;
}
.list-row + .list-row { border-top: 1px solid color-mix(in srgb, var(--line) 60%, transparent); }
.list-row:hover { background: var(--surface); }
.list-row .lr-icon {
  width: 32px; height: 32px; flex: none;
  border-radius: 9px;
  background: var(--surface);
  border: 1px solid var(--line);
  display: grid; place-items: center;
  color: var(--ink-soft);
  overflow: hidden;
}
.list-row .lr-icon img { width: 16px; height: 16px; }
.list-row .lr-icon svg { width: 15px; height: 15px; }
.list-row .lr-main { flex: 1; min-width: 0; }
.list-row .lr-title { font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-row .lr-sub { font-size: 12px; color: var(--ink-faint); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-top: 1px; }
.list-row .lr-side { flex: none; font-size: 12px; color: var(--ink-faint); }
.list-row .lr-actions { flex: none; display: flex; gap: 4px; }
.list-row .lr-actions button {
  border: none; background: none; color: var(--ink-faint);
  width: 26px; height: 26px; border-radius: 7px; cursor: pointer;
  display: grid; place-items: center;
}
.list-row .lr-actions button:hover { background: var(--line); color: var(--ink); }
.list-row .lr-actions svg { width: 13px; height: 13px; }

.bar { height: 4px; border-radius: 2px; background: var(--line); overflow: hidden; margin-top: 6px; }
.bar i { display: block; height: 100%; background: var(--accent); border-radius: 2px; transition: width 200ms linear; }

.empty {
  padding: 40px 16px;
  text-align: center;
  color: var(--ink-faint);
  font-size: 13px;
}
.day-head {
  font-size: 12px; font-weight: 600;
  color: var(--ink-faint);
  padding: 14px 16px 6px;
  text-transform: uppercase; letter-spacing: 0.05em;
}

.chip-row { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  display: inline-flex; align-items: center; gap: 7px;
  border: 1px solid var(--line);
  background: var(--surface-raised);
  border-radius: 999px;
  padding: 7px 13px;
  font-size: 12.5px; color: var(--ink);
  cursor: pointer;
  transition: background-color 130ms var(--ease), transform 110ms var(--ease), border-color 130ms var(--ease);
}
.chip:hover { background: var(--surface); border-color: color-mix(in srgb, var(--accent) 40%, var(--line)); }
.chip:active { transform: scale(0.97); }
.chip img { width: 14px; height: 14px; border-radius: 4px; }

.note {
  font-size: 12px; color: var(--ink-soft);
  background: color-mix(in srgb, var(--accent) 7%, transparent);
  border: 1px solid color-mix(in srgb, var(--accent) 22%, transparent);
  border-radius: var(--radius-m);
  padding: 12px 14px;
  margin-bottom: 20px;
  line-height: 1.55;
}

.stats-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 20px; }
.stat-card {
  background: var(--surface-raised);
  border: 1px solid var(--line);
  border-radius: var(--radius-l);
  box-shadow: var(--shadow-card);
  padding: 16px;
}
.stat-card .n { font-size: 26px; font-weight: 650; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.stat-card .l { font-size: 11.5px; color: var(--ink-soft); margin-top: 3px; }

@media (max-width: 560px) {
  .stats-grid { grid-template-columns: 1fr 1fr; }
}

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