:root {
  --bg: #f1f5f9; --card: #ffffff; --text: #0f172a; --muted: #64748b; --line: #e2e8f0;
  --brand: #1e3a8a; --brand2: #2563eb; --accent: #f59e0b; --ok: #16a34a; --danger: #dc2626;
  --radius: 14px; --shadow: 0 1px 3px rgba(15, 23, 42, .08), 0 4px 14px rgba(15, 23, 42, .06);
  --font: 'Noto Sans Devanagari', 'Nirmala UI', 'Mangal', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); font-family: var(--font); font-size: 16px; }
body { min-height: 100vh; padding-bottom: env(safe-area-inset-bottom); }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--brand2); }

/* App bar */
.bar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 8px; padding: 10px 12px;
  padding-top: calc(10px + env(safe-area-inset-top)); background: var(--brand); color: #fff; box-shadow: 0 2px 8px rgba(0,0,0,.15); }
.bar h1 { flex: 1; margin: 0; font-size: 18px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar .sub { display: block; font-size: 12px; font-weight: 400; opacity: .85; }
.icon-btn { border: 0; background: transparent; color: inherit; width: 42px; height: 42px; border-radius: 50%; font-size: 21px; display: grid; place-items: center; cursor: pointer; flex: none; }
.icon-btn:active { background: rgba(255,255,255,.18); }

main { max-width: 860px; margin: 0 auto; padding: 14px 12px 110px; }
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px; margin-bottom: 12px; }
.card h2 { margin: 0 0 10px; font-size: 16px; }
.muted { color: var(--muted); font-size: 13px; }
.row { display: flex; gap: 10px; align-items: center; }
.row > * { min-width: 0; }
.grow { flex: 1; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
@media (max-width: 520px) { .grid2 { grid-template-columns: 1fr; } }

/* Buttons */
.btn { border: 0; border-radius: 12px; padding: 12px 16px; font-weight: 600; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 46px; }
.btn.primary { background: var(--brand2); color: #fff; }
.btn.dark { background: var(--brand); color: #fff; }
.btn.ghost { background: #e8eefc; color: var(--brand); }
.btn.warn { background: #fff7ed; color: #9a3412; }
.btn.danger { background: #fee2e2; color: var(--danger); }
.btn.ai { background: linear-gradient(135deg, #7c3aed, #2563eb); color: #fff; }
.btn.small { min-height: 36px; padding: 6px 12px; font-size: 14px; border-radius: 10px; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .5; }
.btns { display: flex; flex-wrap: wrap; gap: 8px; }
.fab { position: fixed; right: 16px; bottom: calc(18px + env(safe-area-inset-bottom)); z-index: 30; border-radius: 30px; padding: 14px 20px; box-shadow: 0 6px 18px rgba(37,99,235,.4); }

/* Forms */
label.f { display: block; margin-bottom: 12px; }
label.f > span { display: block; font-size: 13px; color: var(--muted); margin-bottom: 4px; font-weight: 600; }
.inp { width: 100%; border: 1.5px solid var(--line); border-radius: 12px; padding: 11px 12px; background: #fff; outline: none; min-height: 46px; }
.inp:focus { border-color: var(--brand2); box-shadow: 0 0 0 3px rgba(37,99,235,.15); }
textarea.inp { min-height: 120px; resize: vertical; line-height: 1.6; }
.mic-wrap { position: relative; }
.mic-wrap .inp { padding-right: 54px; }
.mic { position: absolute; right: 6px; top: 6px; width: 40px; height: 40px; border-radius: 50%; border: 0; background: #e8eefc; color: var(--brand); font-size: 19px; cursor: pointer; display: grid; place-items: center; }
.mic.on { background: var(--danger); color: #fff; animation: pulse 1.2s infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(220,38,38,.5); } 70% { box-shadow: 0 0 0 12px rgba(220,38,38,0); } 100% { box-shadow: 0 0 0 0 rgba(220,38,38,0); } }
.tools { display: flex; gap: 6px; margin-top: 6px; flex-wrap: wrap; }

/* Lists */
.list-item { display: flex; gap: 12px; align-items: center; padding: 12px; background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 10px; cursor: pointer; }
.list-item:active { transform: scale(.995); }
.list-item .ic { width: 44px; height: 44px; border-radius: 12px; background: #e8eefc; display: grid; place-items: center; font-size: 22px; flex: none; }
.list-item .t { font-weight: 700; }
.list-item .m { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chip { display: inline-block; font-size: 12px; padding: 2px 8px; border-radius: 20px; background: #eef2ff; color: var(--brand); font-weight: 600; }
.empty { text-align: center; color: var(--muted); padding: 40px 10px; }
.empty .big { font-size: 48px; }
.section-title { font-size: 13px; color: var(--muted); font-weight: 700; margin: 18px 4px 8px; text-transform: uppercase; letter-spacing: .02em; }

/* Entry cards in zimni editor */
.entry { border: 1.5px solid var(--line); border-radius: 12px; padding: 10px; margin-bottom: 10px; background: #fbfdff; }
.entry .no { width: 30px; height: 30px; border-radius: 50%; background: var(--brand); color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 14px; flex: none; }

/* Bottom action bar */
.actionbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 25; background: #fff; border-top: 1px solid var(--line); padding: 10px 12px calc(10px + env(safe-area-inset-bottom)); display: flex; gap: 8px; justify-content: center; }
.actionbar .btn { flex: 1; max-width: 260px; }

/* Sheet / modal */
.overlay { position: fixed; inset: 0; background: rgba(15,23,42,.45); z-index: 50; display: flex; align-items: flex-end; justify-content: center; }
.sheet-modal { background: #fff; width: 100%; max-width: 640px; border-radius: 20px 20px 0 0; padding: 16px 14px calc(16px + env(safe-area-inset-bottom)); max-height: 88vh; overflow: auto; animation: up .2s ease-out; }
@media (min-width: 700px) { .overlay { align-items: center; } .sheet-modal { border-radius: 20px; } }
@keyframes up { from { transform: translateY(30px); opacity: .5; } to { transform: none; opacity: 1; } }
.sheet-modal h3 { margin: 0 0 12px; }

/* Toast */
.toast { position: fixed; left: 50%; bottom: 90px; transform: translateX(-50%); background: #0f172a; color: #fff; padding: 10px 16px; border-radius: 12px; z-index: 80; font-size: 14px; max-width: 90vw; box-shadow: var(--shadow); }

/* Live speech panel */
.live { position: fixed; left: 10px; right: 10px; bottom: calc(80px + env(safe-area-inset-bottom)); z-index: 60; background: #111827; color: #fff; border-radius: 14px; padding: 12px 14px; box-shadow: 0 8px 24px rgba(0,0,0,.3); }
.live .lv-head { display: flex; align-items: center; gap: 8px; font-size: 13px; opacity: .9; }
.live .dot { width: 10px; height: 10px; border-radius: 50%; background: #ef4444; animation: pulse 1.2s infinite; }
.live .lv-text { margin-top: 6px; font-size: 17px; min-height: 24px; }
.live .lv-text i { opacity: .6; }

/* Preview */
.preview-wrap { overflow: auto; background: #cbd5e1; padding: 12px; border-radius: var(--radius); }
.preview-scale { transform-origin: top left; }
.preview-wrap .sheet { box-shadow: 0 4px 16px rgba(0,0,0,.2); margin-bottom: 12px; }

/* Chat */
.chat { display: flex; flex-direction: column; gap: 10px; }
.msg { max-width: 88%; padding: 10px 12px; border-radius: 14px; line-height: 1.55; white-space: pre-wrap; word-wrap: break-word; }
.msg.me { align-self: flex-end; background: var(--brand2); color: #fff; border-bottom-right-radius: 4px; }
.msg.ai { align-self: flex-start; background: #fff; box-shadow: var(--shadow); border-bottom-left-radius: 4px; }
.chat-input { position: fixed; left: 0; right: 0; bottom: 0; background: #fff; border-top: 1px solid var(--line); padding: 8px 10px calc(8px + env(safe-area-inset-bottom)); z-index: 25; }
.chat-input .row { max-width: 860px; margin: 0 auto; }
.chat-input textarea { min-height: 46px; max-height: 140px; }
.typing { opacity: .7; font-style: italic; }

/* Lock */
.lock { min-height: 100vh; display: grid; place-items: center; background: var(--brand); color: #fff; padding: 20px; }
.lock .box { text-align: center; width: 100%; max-width: 320px; }
.lock input { text-align: center; font-size: 28px; letter-spacing: 10px; }

.notice { background: #fffbeb; border: 1px solid #fde68a; color: #78350f; border-radius: 12px; padding: 10px 12px; font-size: 14px; }
.ok-note { background: #ecfdf5; border: 1px solid #a7f3d0; color: #065f46; border-radius: 12px; padding: 10px 12px; font-size: 14px; }
hr.sep { border: 0; border-top: 1px solid var(--line); margin: 14px 0; }
