:root {
  --bg: #f6f1e7;
  --panel: #fffdf8;
  --ink: #2b2620;
  --muted: #7d7365;
  --line: #e7dfd0;
  --accent: #d9771f;
  --accent-ink: #fff;
  --danger: #c0392b;
  --ok: #4f8a5b;
  --shadow: 0 1px 2px rgba(60, 45, 20, .06), 0 4px 14px rgba(60, 45, 20, .06);
  --radius: 16px;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", "Noto Sans Gujarati", "Gujarati Sangam MN", Roboto, sans-serif;
  color-scheme: light;
}
body.night {
  --bg: #15130f;
  --panel: #1f1c17;
  --ink: #ece4d6;
  --muted: #9c917f;
  --line: #34302a;
  --shadow: none;
  color-scheme: dark;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--ink); font-family: var(--font); font-size: 16px; }
body { overscroll-behavior: none; -webkit-font-smoothing: antialiased; }
[hidden] { display: none !important; }
button, input, select, textarea { font: inherit; color: inherit; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.err { color: var(--danger); }

/* buttons */
.btn { border: 1px solid var(--line); background: var(--panel); border-radius: 999px; padding: .5rem 1rem; cursor: pointer; min-height: 40px; display: inline-flex; align-items: center; gap: .35rem; justify-content: center; }
.btn:active { transform: scale(.97); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.btn.danger { color: var(--danger); border-color: transparent; background: transparent; }
.btn.ghost { background: transparent; }
.btn.icon { width: 44px; padding: 0; font-size: 1.2rem; }
.btn.big { font-size: 1.1rem; padding: .8rem 1.4rem; }
.btn.small { min-height: 32px; padding: .25rem .75rem; font-size: .85rem; }
.btn.full { width: 100%; margin-top: .5rem; }

/* boot + sign-in */
.boot { position: fixed; inset: 0; display: grid; place-items: center; }
.boot-logo { width: 72px; height: 72px; border-radius: 20px; background: var(--accent); color: #fff; font-size: 40px; font-weight: 700; display: grid; place-items: center; animation: pulse 1.2s infinite ease-in-out; }
@keyframes pulse { 50% { transform: scale(.92); opacity: .7; } }
.signin { min-height: 100%; display: grid; place-items: center; padding: 24px; }
.signin-card { background: var(--panel); border-radius: 24px; box-shadow: var(--shadow); padding: 32px; max-width: 420px; width: 100%; text-align: center; }
.signin-logo { width: 84px; height: 84px; border-radius: 22px; }
.signin-card h1 { margin: .4rem 0 0; font-size: 2rem; letter-spacing: -.02em; }
.signin-card h2 { font-size: 1.15rem; margin: 1.5rem 0 .25rem; }
.denied { background: #fbeaea; color: var(--danger); border-radius: 12px; padding: .75rem; }
.g { font-weight: 800; background: #fff; color: #4285f4; border-radius: 50%; width: 24px; height: 24px; display: inline-grid; place-items: center; }
.linkish { border: 0; background: none; color: var(--muted); text-decoration: underline; margin-top: 14px; cursor: pointer; font-size: .9rem; }
.code-box { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
.code-box input { border: 1px solid var(--line); border-radius: 10px; padding: 10px; background: var(--bg); font-size: 1rem; width: 100%; }
#codeStep2 { display: flex; gap: 8px; }
.lang-switch { margin-top: 1.25rem; display: flex; gap: .5rem; justify-content: center; }
.lang-switch button, .seg button { border: 1px solid var(--line); background: transparent; border-radius: 999px; padding: .35rem .9rem; cursor: pointer; }
.lang-switch button.on, .seg button.on { background: var(--ink); color: var(--bg); border-color: var(--ink); }

/* layout */
.app { height: 100%; display: grid; grid-template-columns: 330px 1fr; }
.aside { padding: 20px 16px 20px 20px; overflow-y: auto; display: flex; flex-direction: column; gap: 14px; padding-top: max(20px, env(safe-area-inset-top)); }
.main { display: flex; flex-direction: column; min-width: 0; height: 100%; padding-top: env(safe-area-inset-top); }
.card { background: var(--panel); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px 16px; }

.clock { padding: 4px 4px 0; }
.clock-time { font-size: 4.2rem; font-weight: 300; letter-spacing: -.04em; line-height: 1; font-variant-numeric: tabular-nums; }
.clock-date { font-size: 1.15rem; color: var(--muted); margin-top: 4px; }

.weather .wx-now { display: flex; align-items: center; gap: 12px; }
.wx-icon { font-size: 2.6rem; line-height: 1; }
.wx-temp { font-size: 2.2rem; font-weight: 600; }
.wx-label { color: var(--muted); font-size: .9rem; }
.wx-days { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-top: 10px; text-align: center; font-size: .85rem; }
.wx-days div { background: var(--bg); border-radius: 10px; padding: 6px 2px; }
.wx-days b { display: block; font-size: 1.2rem; }
.wx-place { font-size: .75rem; color: var(--muted); }

.today-box { margin-bottom: 8px; }
.today-box .tag { display: inline-block; font-size: .8rem; padding: 3px 9px; border-radius: 999px; margin: 2px 4px 2px 0; }
.tag.nz { background: #e3eefb; color: #2d5d9a; }
.tag.guj { background: #fdeedd; color: #a7560f; }
.tag.fam { background: #e6f2e8; color: #3d7148; }
body.night .tag.nz { background: #20324a; color: #a9c7ef; }
body.night .tag.guj { background: #43301a; color: #f2c08d; }
body.night .tag.fam { background: #1f3524; color: #a9d9b3; }

.mini-cal .mc-head { display: flex; align-items: center; justify-content: space-between; font-weight: 600; margin-bottom: 6px; }
.mini-cal .mc-head button { border: 0; background: transparent; font-size: 1.2rem; width: 36px; height: 36px; cursor: pointer; border-radius: 50%; }
.mc-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; text-align: center; font-size: .85rem; }
.mc-grid .dow { color: var(--muted); font-size: .7rem; padding-bottom: 2px; }
.mc-day { position: relative; border: 0; background: transparent; aspect-ratio: 1; border-radius: 50%; cursor: pointer; padding: 0; font-variant-numeric: tabular-nums; }
.mc-day.other { color: var(--muted); opacity: .45; }
.mc-day.today { background: var(--accent); color: #fff; font-weight: 700; }
.mc-day .dots { position: absolute; bottom: 3px; left: 0; right: 0; display: flex; gap: 2px; justify-content: center; }
.mc-day .dots i { width: 4px; height: 4px; border-radius: 50%; }
.dots .nz { background: #3c78c8; } .dots .guj { background: #e0811c; } .dots .fam { background: #4f8a5b; }

.section-h { font-size: .8rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 14px 0 6px; }
.upcoming { list-style: none; padding: 0; margin: 0; }
.upcoming li { display: flex; gap: 10px; padding: 7px 0; border-top: 1px solid var(--line); align-items: center; cursor: pointer; }
.upcoming li:first-child { border-top: 0; }
.upcoming .when { min-width: 52px; text-align: center; font-size: .75rem; color: var(--muted); line-height: 1.1; }
.upcoming .when b { display: block; font-size: 1.1rem; color: var(--ink); }
.upcoming .what { flex: 1; font-size: .95rem; }
.upcoming .bar { width: 4px; align-self: stretch; border-radius: 4px; }
.bar.nz { background: #3c78c8; } .bar.guj { background: #e0811c; } .bar.fam { background: #4f8a5b; }

/* top bar */
.topbar { display: flex; align-items: center; gap: 12px; padding: 14px 20px 10px; }
.brand { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; }
.brand-logo { width: 40px; height: 40px; border-radius: 11px; }
.brand-name { font-weight: 700; font-size: 1.35rem; letter-spacing: -.02em; }
.brand-tag { color: var(--muted); font-size: .8rem; }
.top-actions { display: flex; gap: 6px; }
.pill { font-size: .8rem; border-radius: 999px; padding: 4px 10px; }
.pill.warn { background: #fff3d6; color: #8a5a00; }

/* board */
.board { flex: 1; display: grid; grid-auto-flow: column; grid-auto-columns: minmax(270px, 1fr); gap: 14px; padding: 4px 20px 20px; overflow-x: auto; overflow-y: hidden; scroll-snap-type: x proximity; }
.col { background: var(--panel); border-radius: var(--radius); box-shadow: var(--shadow); display: flex; flex-direction: column; min-height: 0; scroll-snap-align: start; border-top: 5px solid var(--c, var(--accent)); }
.col-head { display: flex; align-items: center; gap: 8px; padding: 12px 14px 6px; }
.col-head h2 { font-size: 1.15rem; margin: 0; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.col-head .count { background: var(--bg); border-radius: 999px; font-size: .8rem; padding: 2px 9px; color: var(--muted); }
.col-head button { border: 0; background: transparent; font-size: 1.2rem; width: 36px; height: 36px; border-radius: 50%; cursor: pointer; color: var(--muted); }
.add-row { display: flex; align-items: center; gap: 8px; margin: 4px 10px 6px; padding: 4px 8px; border-radius: 12px; background: var(--bg); }
.add-row span { color: var(--muted); font-size: 1.3rem; width: 28px; text-align: center; }
.add-row input { flex: 1; border: 0; background: transparent; padding: 8px 0; outline: none; font-size: 1rem; }
.items { list-style: none; margin: 0; padding: 0 6px 12px; overflow-y: auto; flex: 1; -webkit-overflow-scrolling: touch; }
.item { display: flex; gap: 10px; align-items: flex-start; padding: 8px 8px; border-radius: 10px; }
.item:active { background: var(--bg); }
.item.fresh { animation: fresh 2.5s ease-out; }
@keyframes fresh { from { background: #fde7c9; } to { background: transparent; } }
.cb { flex: none; width: 28px; height: 28px; border-radius: 7px; border: 2px solid #b9ad98; background: transparent; cursor: pointer; display: grid; place-items: center; padding: 0; margin-top: 1px; }
.cb.on { background: var(--ok); border-color: var(--ok); color: #fff; }
.cb.on::after { content: "✓"; font-weight: 700; font-size: 18px; }
.item-body { flex: 1; min-width: 0; cursor: pointer; }
.item-text { font-size: 1.05rem; line-height: 1.35; word-wrap: break-word; }
.item.done .item-text { text-decoration: line-through; color: var(--muted); }
.meta { display: flex; flex-wrap: wrap; gap: 4px 8px; margin-top: 3px; font-size: .75rem; color: var(--muted); align-items: center; }
.meta .chip { background: var(--bg); border-radius: 6px; padding: 1px 6px; }
.meta .late { background: #fbe1dd; color: var(--danger); }
.meta .hi { color: var(--danger); font-weight: 700; }
body.night .meta .late { background: #4a1f1a; color: #f2a69c; }
.done-h { display: flex; align-items: center; gap: 6px; margin: 10px 8px 2px; font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); cursor: pointer; border: 0; background: transparent; padding: 4px 0; }
.empty { text-align: center; color: var(--muted); padding: 18px 8px; font-size: .9rem; }
.board-empty { display: grid; place-items: center; text-align: center; color: var(--muted); grid-column: 1 / -1; }

.chips, .tabbar, .phone-cal { display: none; }

/* dialogs */
.dlg { border: 0; border-radius: 20px; padding: 20px; width: min(520px, calc(100vw - 24px)); background: var(--panel); color: var(--ink); box-shadow: 0 20px 60px rgba(0, 0, 0, .25); max-height: calc(100vh - 40px); }
.dlg.wide { width: min(720px, calc(100vw - 24px)); }
.dlg::backdrop { background: rgba(30, 22, 10, .4); }
.dlg h2 { margin: 0 0 12px; font-size: 1.25rem; }
.dlg label { display: flex; flex-direction: column; gap: 4px; font-size: .85rem; color: var(--muted); margin-bottom: 10px; }
.dlg input:not([type=checkbox]):not([type=file]), .dlg select, .dlg textarea { border: 1px solid var(--line); border-radius: 10px; padding: 9px 10px; background: var(--bg); font-size: 1rem; width: 100%; }
.dlg textarea#fText { font-size: 1.1rem; margin-bottom: 10px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
.dlg-actions { display: flex; align-items: center; gap: 8px; margin-top: 12px; }
.spacer { flex: 1; }
.dlg-head { display: flex; gap: 12px; align-items: center; margin-bottom: 8px; }
.dlg-head h2 { margin: 0; flex: 1; }
.dlg-head input { max-width: 240px; border: 1px solid var(--line); border-radius: 999px; padding: 8px 14px; background: var(--bg); }
.photo-row { display: flex; gap: 6px; }
.photo-prev { max-width: 100%; max-height: 220px; border-radius: 12px; margin-bottom: 10px; display: block; }
.swatches { display: flex; gap: 10px; flex-wrap: wrap; margin: 6px 0; }
.swatches button { width: 38px; height: 38px; border-radius: 50%; border: 3px solid transparent; cursor: pointer; }
.swatches button.on { border-color: var(--ink); }
.arch-body { overflow-y: auto; max-height: 60vh; }
.arch-day { font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 14px 0 4px; }
.arch-item { display: flex; gap: 10px; align-items: center; padding: 8px 4px; border-top: 1px solid var(--line); }
.arch-item .t { flex: 1; text-decoration: line-through; }
.arch-item .m { font-size: .75rem; color: var(--muted); }
.set-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 0; border-top: 1px solid var(--line); flex-wrap: wrap; }
.dlg label.check { flex-direction: row; align-items: center; gap: 8px; color: var(--ink); font-size: 1rem; margin: 0; }
.check input { width: 22px; height: 22px; accent-color: var(--accent); }
.times { display: flex; align-items: center; gap: 6px; font-size: .9rem; }
.times input { width: auto !important; padding: 5px 8px !important; }
.seg { display: flex; gap: 6px; }
.set-block { border-top: 1px solid var(--line); padding: 10px 0; }
.set-block summary { cursor: pointer; font-weight: 600; padding: 4px 0; }
.siri-vals .sv { margin: 8px 0; }
.siri-vals .sv b { display: block; font-size: .8rem; color: var(--muted); font-weight: 500; }
.siri-vals .sv div { display: flex; gap: 6px; align-items: center; }
.siri-vals code { flex: 1; background: var(--bg); border-radius: 8px; padding: 7px 9px; font-size: .78rem; word-break: break-all; }

/* night veil + toast */
.night-veil { position: fixed; inset: 0; background: rgba(0, 0, 0, .78); z-index: 50; display: grid; place-items: center; }
.night-clock { color: rgba(255, 235, 200, .35); font-size: 7rem; font-weight: 200; font-variant-numeric: tabular-nums; }
.toast { position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: 12px 18px; border-radius: 999px; z-index: 60; box-shadow: var(--shadow); max-width: 90vw; }

/* ---------- phone / portrait narrow ---------- */
@media (max-width: 899px) {
  .app { grid-template-columns: 1fr; grid-template-rows: 1fr auto; }
  .aside { display: none; }
  .hide-sm { display: none; }
  .topbar { padding: 10px 14px 6px; }
  .top-actions #btnArchive, .top-actions #btnSettings { display: none; }
  .chips { display: flex; gap: 8px; overflow-x: auto; padding: 4px 14px 8px; scrollbar-width: none; }
  .chips::-webkit-scrollbar { display: none; }
  .chips button { flex: none; border: 1px solid var(--line); background: var(--panel); border-radius: 999px; padding: 7px 14px; cursor: pointer; display: flex; gap: 6px; align-items: center; }
  .chips button i { width: 9px; height: 9px; border-radius: 50%; }
  .chips button.on { background: var(--ink); color: var(--bg); border-color: var(--ink); }
  .chips button small { opacity: .7; }
  .board { display: block; padding: 0 10px 10px; overflow-y: auto; }
  .board .col { display: none; height: 100%; }
  .board .col.current { display: flex; }
  .tabbar { display: flex; border-top: 1px solid var(--line); background: var(--panel); padding-bottom: env(safe-area-inset-bottom); }
  .tabbar button { flex: 1; border: 0; background: transparent; padding: 8px 0 6px; display: flex; flex-direction: column; align-items: center; gap: 2px; cursor: pointer; color: var(--muted); }
  .tabbar button span { font-size: 1.3rem; }
  .tabbar button.active { color: var(--accent); }
  .app.tab-calendar .board, .app.tab-calendar .chips { display: none; }
  .app.tab-calendar .phone-cal { display: flex; flex-direction: column; gap: 12px; padding: 0 12px 12px; overflow-y: auto; flex: 1; }
  .clock-time { font-size: 3rem; }
  .dlg { padding: 16px; }
  .grid2 { grid-template-columns: 1fr; }
  .night-clock { font-size: 4.5rem; }
}
