/* Drishti — calm, high-legibility interface. Sizes scale with --text-scale and --button-scale,
   which the adaptive UI engine sets from the saved interface configuration. */
:root {
  --text-scale: 1; --button-scale: 1;
  --navy: #101b2d; --ink: #172338; --muted: #66738a; --line: #e3e7ee; --bg: #f4f6fa; --panel: #fff; --soft: #f3f6f9;
  --accent: #315e4b; --accent-soft: #c6e7d3; --accent-ink: #173528; --warn: #94711f; --warn-soft: #fbf3df; --red: #9d3434; --red-soft: #fce9e9;
  --shadow: 0 8px 30px rgba(17, 31, 51, .06); --radius: 16px;
  --tap: calc(44px * var(--button-scale));
  font-family: 'Noto Sans', 'Noto Sans Devanagari', 'Noto Sans Gujarati', system-ui, -apple-system, 'Segoe UI', sans-serif;
  font-size: calc(16px * var(--text-scale)); color: var(--ink); background: var(--bg); -webkit-text-size-adjust: 100%;
}
:root[data-accent="blue"] { --accent: #2c5a8c; --accent-soft: #cfe2f7; --accent-ink: #12304f; }
:root[data-accent="orange"] { --accent: #9a5517; --accent-soft: #fbe0c7; --accent-ink: #4a2706; }
:root[data-accent="purple"] { --accent: #5d4590; --accent-soft: #e2d8f5; --accent-ink: #2d1d51; }
:root[data-accent="red"] { --accent: #9b3a3a; --accent-soft: #f6d6d6; --accent-ink: #4b1414; }
.dark { --ink: #e9eef5; --muted: #a6b1c0; --line: #33425a; --bg: #0f1826; --panel: #182437; --soft: #1f2d43; --shadow: 0 8px 30px rgba(0, 0, 0, .25); --accent-soft: #2c5a45; --accent-ink: #e7f6ec; --warn-soft: #3b3220; --red-soft: #452222; }
.high-contrast { --muted: #2b3445; --line: #5b6578; --ink: #000; --panel: #fff; --bg: #fff; --accent: #0b4a2e; }
.dark.high-contrast { --ink: #fff; --muted: #e1e6ee; --line: #c5cdd9; --panel: #000; --bg: #000; --soft: #111; }
.high-contrast .card, .high-contrast .stat { border-width: 2px; }
* { box-sizing: border-box; }
body { margin: 0; min-width: 300px; background: var(--bg); color: var(--ink); line-height: 1.45; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid #4f8cff; outline-offset: 2px; }
.skip { position: absolute; left: -999px; } .skip:focus { left: 8px; top: 8px; z-index: 99; background: #fff; padding: 8px; }
[hidden] { display: none !important; }

.app-shell { max-width: 1500px; margin: auto; min-height: 100dvh; display: grid; grid-template-columns: 260px minmax(0, 1fr); }
.sidebar { background: var(--navy); color: #fff; padding: 26px 16px 16px; display: flex; flex-direction: column; position: sticky; top: 0; height: 100dvh; overflow-y: auto; }
.brand { color: #fff; display: flex; align-items: center; gap: 12px; text-decoration: none; padding: 0 10px 26px; }
.brand-mark { display: inline-grid; place-items: center; width: 44px; height: 44px; border: 1px solid #668878; border-radius: 14px; background: #213d34; color: #b8e2cb; font-weight: 800; font-size: 22px; }
.brand b { display: block; font-size: 1.15rem; } .brand small { display: block; font-size: .72rem; color: #aab5c4; }
#nav { display: grid; gap: 3px; }
.nav-label { font-size: .65rem; letter-spacing: 1.3px; color: #8392a8; padding: 14px 12px 6px; }
.nav-item { border: 0; background: transparent; color: #c3cbd8; text-align: left; border-radius: 10px; padding: 0 12px; min-height: var(--tap); display: flex; gap: 12px; align-items: center; font-size: .9rem; }
.nav-item:hover, .nav-item.active { background: #233246; color: #fff; }
.nav-item.active { box-shadow: inset 3px 0 0 #b8e2cb; }
.nav-icon { width: 22px; text-align: center; }
.badge { margin-left: auto; background: #e9b44c; color: #2a1d00; border-radius: 99px; padding: 1px 8px; font-size: .72rem; font-weight: 700; }
.simple-nav .nav-item { font-size: 1.05rem; min-height: calc(var(--tap) * 1.2); }
.sidebar-bottom { margin-top: auto; border-top: 1px solid #2a3748; padding-top: 14px; }
.profile { width: 100%; border: 0; background: transparent; color: #fff; display: flex; align-items: center; gap: 10px; text-align: left; padding: 6px; }
.profile b, .profile small { display: block; } .profile small { color: #aab5c4; font-size: .72rem; }
.avatar { display: grid; place-items: center; border-radius: 50%; width: 36px; height: 36px; background: #d9eee1; color: #315e4b; font-weight: 700; flex: none; }
.avatar.big { width: 56px; height: 56px; font-size: 1.4rem; }
.chevron { margin-left: auto; color: #8793a5; font-size: 20px; }
.conn-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: #7fd49e; vertical-align: middle; } .conn-dot.off { background: #e0a14a; }

.main { padding: 28px clamp(16px, 4vw, 56px) 160px; min-width: 0; }
.topbar { display: flex; align-items: center; gap: 12px; margin-bottom: 20px; }
.topbar h1 { margin: 4px 0 0; font-size: 1.7rem; letter-spacing: -.5px; }
.eyebrow { display: block; color: var(--muted); font-weight: 700; font-size: .68rem; letter-spacing: 1.4px; }
.icon-button { border: 1px solid var(--line); background: var(--panel); border-radius: 10px; width: var(--tap); height: var(--tap); display: grid; place-items: center; font-size: 1.1rem; }
.mobile-only { display: none; }
.banner { border-radius: 12px; padding: 12px 16px; margin-bottom: 16px; background: var(--soft); border: 1px solid var(--line); font-size: .9rem; }
.banner.warn { background: var(--warn-soft); color: var(--warn); }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); min-width: 0; margin-bottom: 16px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.card-head h2 { font-size: 1.05rem; margin: 0; } .card-head p { font-size: .8rem; color: var(--muted); margin: 4px 0 0; }
.card.emphasis { border: 2px solid var(--accent); }
.dashboard { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 16px; align-items: start; }
.dashboard > .full, .dashboard > .greeting, .dashboard > .stats { grid-column: 1 / -1; }
.greeting { background: linear-gradient(115deg, #142339, #27434a); border: 0; color: #fff; }
.greeting .eyebrow { color: #abc2b4; } .greeting h2 { font-size: 1.6rem; margin: 10px 0 6px; } .greeting p { color: #d1d8de; margin: 0; max-width: 520px; }
.greeting-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 18px; }
.greeting .secondary { background: #ffffff22; color: #fff; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 16px; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 14px; text-align: left; min-height: var(--tap); }
.stat strong { display: block; font-size: 1.6rem; } .stat span { font-size: .8rem; color: var(--muted); }

.primary, .secondary, .danger, .as-button { border: 0; border-radius: 10px; padding: 0 16px; min-height: var(--tap); font-weight: 700; font-size: .9rem; display: inline-flex; align-items: center; justify-content: center; gap: 6px; text-decoration: none; }
.primary { background: var(--accent-soft); color: var(--accent-ink); } .primary:hover { filter: brightness(1.04); }
.secondary, .as-button { background: var(--soft); color: var(--ink); border: 1px solid var(--line); }
.danger { background: var(--red-soft); color: var(--red); }
.text-link { background: none; border: 0; color: var(--accent); font-weight: 700; font-size: .82rem; padding: 6px; min-height: 36px; }
.dark .text-link { color: #9fd8b5; }
button:disabled { opacity: .55; cursor: wait; }

.list { display: grid; }
.list-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; border-top: 1px solid var(--line); padding: 10px 6px; min-width: 0; border-radius: 10px; cursor: default; }
.list-row:first-child { border-top: 0; }
.list-row.selected { background: var(--accent-soft); outline: 2px solid var(--accent); }
.list-row.is-done b { text-decoration: line-through; color: var(--muted); }
.list-row.unread b::before { content: '● '; color: #e0a14a; }
.row-main { min-width: 0; flex: 1 1 150px; } .row-main b { font-weight: 600; display: block; overflow-wrap: anywhere; }
.row-main small { font-size: .8rem; color: var(--muted); display: block; margin-top: 2px; }
.row-icon { width: 36px; height: 36px; flex: none; border-radius: 11px; background: var(--soft); display: grid; place-items: center; }
.row-actions { display: flex; gap: 2px; flex-wrap: wrap; justify-content: flex-end; margin-left: auto; }
.mini-button { border: 0; background: transparent; padding: 0; border-radius: 9px; min-width: var(--tap); min-height: var(--tap); font-size: 1rem; }
.mini-button:hover { background: var(--soft); }
.subtasks { margin-left: 30px; border-left: 2px solid var(--line); padding-left: 8px; }
.pill { border-radius: 99px; padding: 4px 10px; background: var(--accent-soft); color: var(--accent-ink); font-weight: 700; font-size: .7rem; white-space: nowrap; }
.pill.amber { background: var(--warn-soft); color: var(--warn); } .pill.red { background: var(--red-soft); color: var(--red); }
.empty { border: 1px dashed var(--line); border-radius: 12px; padding: 18px; text-align: center; color: var(--muted); font-size: .9rem; }
.hint, .muted-p, .info-line { color: var(--muted); font-size: .85rem; }
.big-number { font-size: 2rem; font-weight: 800; margin: 4px 0 10px; }

.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; }
.contact-tile { border: 1px solid var(--line); border-radius: 14px; padding: 14px; display: grid; justify-items: center; gap: 4px; text-align: center; }
.contact-tile.selected { outline: 2px solid var(--accent); background: var(--accent-soft); }
.contact-tile small { color: var(--muted); font-size: .8rem; }
.tile-actions { display: flex; gap: 6px; } .tile-actions .mini-button { background: var(--accent-soft); font-size: 1.2rem; }
.quick-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.quick { border: 1px solid var(--line); background: var(--soft); border-radius: 14px; min-height: calc(var(--tap) * 1.6); font-weight: 700; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; padding: 10px; }
.quick span { font-size: 1.5rem; }
.week { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.day-cell { border: 1px solid var(--line); background: var(--soft); border-radius: 10px; padding: 8px 4px; min-height: 70px; display: grid; gap: 4px; font-size: .75rem; }
.day-cell.today { border-color: var(--accent); background: var(--accent-soft); }
.bars { display: grid; gap: 8px; } .bar-row { display: grid; grid-template-columns: 90px 1fr auto; gap: 10px; align-items: center; font-size: .85rem; }
.bar { background: var(--soft); border-radius: 6px; height: 12px; overflow: hidden; } .bar i { display: block; height: 100%; background: var(--accent); border-radius: 6px; }
.note-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.note-card p { white-space: pre-wrap; color: var(--muted); } .note-card footer { font-size: .75rem; color: var(--muted); }
.note-card.selected { outline: 2px solid var(--accent); }
details summary { cursor: pointer; font-weight: 700; min-height: var(--tap); display: flex; align-items: center; }

.screen-toolbar { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.screen-toolbar p { color: var(--muted); margin: 0; flex: 1; min-width: 160px; }
.search { border: 1px solid var(--line); background: var(--panel); border-radius: 10px; padding: 0 12px; min-height: var(--tap); min-width: min(240px, 100%); }
.settings-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 16px; align-items: start; }
.setting-row { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 10px 0; border-top: 1px solid var(--line); }
.setting-row:first-of-type { border-top: 0; } .setting-row small { display: block; color: var(--muted); font-size: .78rem; }
.switch { width: calc(24px * var(--button-scale)); height: calc(24px * var(--button-scale)); accent-color: var(--accent); }
input[type=range] { accent-color: var(--accent); width: 160px; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
.lang-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 14px; }
.lang { border: 2px solid var(--line); background: var(--panel); border-radius: 12px; min-height: calc(var(--tap) * 1.2); font-size: 1.1rem; font-weight: 700; }
.lang.active { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-ink); }
.lang-grid.big .lang { min-height: 72px; font-size: 1.35rem; }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
.field { display: grid; gap: 6px; margin-bottom: 12px; } .field.full, .checkbox-line.full { grid-column: 1 / -1; }
.field label { font-size: .8rem; font-weight: 700; color: var(--muted); }
.field input, .field select, .field textarea { border: 1px solid var(--line); background: var(--panel); border-radius: 10px; padding: 0 12px; min-height: var(--tap); width: 100%; }
.field textarea { min-height: 90px; padding: 10px 12px; resize: vertical; }
.checkbox-line { display: flex; gap: 10px; align-items: center; font-size: .9rem; min-height: var(--tap); }
.checkbox-line input { width: 22px; height: 22px; accent-color: var(--accent); }

/* toast */
.toast { position: fixed; z-index: 60; left: 50%; top: 18px; transform: translate(-50%, -20px); opacity: 0; background: #19283b; color: #fff; padding: 12px 18px; border-radius: 12px; box-shadow: var(--shadow); font-size: .9rem; transition: .2s; pointer-events: none; max-width: min(560px, 92vw); }
.toast.show { opacity: 1; transform: translate(-50%, 0); } .toast.warn { background: #6b3d12; }

/* voice */
.voice-fab { position: fixed; right: 24px; bottom: 24px; z-index: 30; border: 0; background: var(--navy); color: #fff; border-radius: 999px; min-height: calc(56px * var(--button-scale)); padding: 0 22px; display: flex; align-items: center; gap: 10px; box-shadow: 0 10px 28px #13213750; font-weight: 700; }
.voice-fab:hover { background: #22364c; } .mic-icon { font-size: 1.3rem; }
.voice-panel { position: fixed; z-index: 30; right: 20px; bottom: 20px; width: min(420px, calc(100vw - 24px)); max-height: 70dvh; display: flex; flex-direction: column; gap: 8px; border-radius: 20px; background: #132236; color: #fff; padding: 12px; box-shadow: 0 14px 50px #0b142466; }
.voice-top { display: flex; align-items: center; gap: 10px; }
.voice-wave { width: 74px; height: 40px; color: #8cdbab; flex: none; }
.voice-panel[data-state="speaking"] .voice-wave { color: #9cc7ff; }
.voice-panel[data-state="processing"] .voice-wave, .voice-panel[data-state="executing"] .voice-wave { color: #f1c66a; }
.voice-panel[data-state="error"] .voice-wave, .voice-panel[data-state="disconnected"] .voice-wave, .voice-panel.muted .voice-wave { color: #6f7c8e; }
.voice-status { min-width: 0; flex: 1; } .voice-status b { display: block; font-size: .95rem; }
.voice-status small { display: block; color: #c0cad6; font-size: .8rem; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.voice-panel[data-state="processing"] #voice-state::after, .voice-panel[data-state="executing"] #voice-state::after { content: ''; display: inline-block; width: 10px; height: 10px; margin-left: 8px; border: 2px solid #f1c66a; border-top-color: transparent; border-radius: 50%; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
.voice-controls { display: flex; gap: 6px; }
.voice-control { width: calc(42px * var(--button-scale)); height: calc(42px * var(--button-scale)); border-radius: 50%; border: 1px solid #405065; background: #26384c; color: #fff; font-size: 1rem; }
.voice-control.stop { background: #914747; border-color: #914747; }
.voice-panel.muted #voice-mute { background: #6b3d12; }
.voice-pending:empty, .voice-actions-out:empty { display: none; }
.pending-card { background: #213248; border: 1px solid #f1c66a; border-radius: 12px; padding: 10px; display: grid; gap: 8px; font-size: .9rem; }
.pending-card.high { border-color: #ff9c8a; } .pending-card div { display: flex; gap: 8px; }
.voice-actions-out { display: grid; gap: 4px; } .voice-actions-out small { color: #c0cad6; font-size: .75rem; }
.big-action { min-height: calc(52px * var(--button-scale)); font-size: 1.05rem; }
.voice-log { display: none; overflow-y: auto; max-height: 34dvh; font-size: .85rem; padding: 4px; }
.voice-panel.expanded .voice-log { display: block; }
.voice-log p { margin: 6px 0; padding: 8px 10px; border-radius: 10px; background: #1e2f45; } .voice-log p.user { background: #2b4a3c; margin-left: 30px; }
.voice-form { display: flex; gap: 6px; } .voice-form input { flex: 1; min-width: 0; border-radius: 10px; border: 1px solid #405065; background: #0f1b2b; color: #fff; padding: 0 12px; min-height: var(--tap); }

/* dialog */
dialog { border: 1px solid var(--line); border-radius: 18px; padding: 0; width: min(560px, calc(100vw - 24px)); max-height: 90dvh; background: var(--panel); color: var(--ink); box-shadow: 0 25px 80px #10203c44; }
dialog::backdrop { background: #101b2d88; }
#modal-form { padding: 22px; } .modal-head { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 16px; }
.modal-head h2 { margin: 6px 0 0; font-size: 1.3rem; } .modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 10px; }

/* onboarding */
.onboarding { position: fixed; inset: 0; z-index: 50; background: var(--bg); display: grid; place-items: center; padding: 16px; overflow-y: auto; }
.ob-card { width: min(560px, 100%); background: var(--panel); border: 1px solid var(--line); border-radius: 24px; padding: 28px; box-shadow: var(--shadow); }
.ob-card h1 { font-size: 1.6rem; margin: 14px 0 10px; } .ob-card p { color: var(--muted); }
.ob-progress { display: flex; gap: 6px; margin-bottom: 18px; } .ob-progress i { flex: 1; height: 5px; border-radius: 4px; background: var(--line); } .ob-progress i.on { background: var(--accent); }
.ob-actions { display: flex; justify-content: space-between; align-items: center; margin-top: 20px; gap: 10px; } .ob-actions > div { display: flex; gap: 8px; align-items: center; }
.big-input { font-size: 1.4rem !important; min-height: 60px !important; }
.choice-list { display: grid; gap: 10px; margin-bottom: 12px; }
.choice { display: flex; align-items: center; gap: 14px; border: 2px solid var(--line); background: var(--panel); border-radius: 14px; min-height: 64px; padding: 0 16px; font-size: 1.05rem; font-weight: 600; text-align: left; }
.choice span { font-size: 1.4rem; width: 30px; } .choice.active { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-ink); }
.ob-person { border-top: 1px solid var(--line); padding-top: 10px; grid-template-columns: 1fr 1fr 1fr; }

.bottom-nav { display: none; }

@media (max-width: 900px) { .app-shell { grid-template-columns: 220px 1fr; } .settings-grid { grid-template-columns: 1fr; } }
@media (max-width: 700px) {
  .app-shell { display: block; }
  .sidebar { position: fixed; z-index: 35; left: 0; top: 0; width: 280px; transform: translateX(-105%); transition: transform .2s; }
  .sidebar.open { transform: none; box-shadow: 15px 0 40px #101b2d44; }
  .mobile-only { display: grid; }
  .main { padding: 16px 14px 190px; }
  .topbar h1 { font-size: 1.4rem; }
  .dashboard, .form-grid, .ob-person { grid-template-columns: 1fr; }
  .card { padding: 16px; }
  .stats { gap: 8px; } .stat { padding: 10px; } .stat strong { font-size: 1.3rem; }
  .bottom-nav { display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 25; background: var(--panel); border-top: 1px solid var(--line); padding: 4px 4px calc(4px + env(safe-area-inset-bottom)); }
  .bottom-nav button { flex: 1; border: 0; background: none; display: grid; justify-items: center; gap: 2px; font-size: .68rem; min-height: calc(52px * var(--button-scale)); color: var(--muted); }
  .bottom-nav button span { font-size: 1.15rem; } .bottom-nav button.active { color: var(--accent); font-weight: 700; }
  .voice-fab { right: 14px; bottom: calc(70px * var(--button-scale)); padding: 0; width: calc(60px * var(--button-scale)); justify-content: center; }
  .voice-fab .fab-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .voice-fab .mic-icon { font-size: 1.6rem; }
  .voice-panel { right: 8px; left: 8px; width: auto; bottom: calc(68px * var(--button-scale)); }
  .week { grid-template-columns: repeat(4, 1fr); }
  .bar-row { grid-template-columns: 70px 1fr auto; }
}
@media (min-width: 701px) { .sidebar { transform: none !important; } }
