:root {
  --bg: #f6f3ee; --card: #ffffff; --ink: #1d1d1f; --muted: #6e6a64; --line: #e6e0d6;
  --accent: #2f6f5e; --accent-ink: #ffffff; --accent-soft: #e3efe9;
  --warn: #b5562b; --warn-soft: #f8e7dd; --ok: #2f7d4f; --ok-soft: #e1f2e7; --wait: #9a7a14; --wait-soft: #f6eecf;
  --shadow: 0 1px 2px rgba(40, 30, 10, .06), 0 4px 16px rgba(40, 30, 10, .05);
  --r: 16px;
  --safe-b: env(safe-area-inset-bottom, 0px); --safe-t: env(safe-area-inset-top, 0px);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #16171a; --card: #202227; --ink: #f1efe9; --muted: #a29d94; --line: #33353b;
    --accent: #5fb39a; --accent-ink: #0f1a16; --accent-soft: #23362f;
    --warn: #ef8c5d; --warn-soft: #3b2820; --ok: #6cc58f; --ok-soft: #1f3327; --wait: #e2c15a; --wait-soft: #3a3320;
    --shadow: none; color-scheme: dark;
  }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--ink); }
body { font: 16px/1.4 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif; -webkit-text-size-adjust: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
.boot { padding: 40vh 16px; text-align: center; color: var(--muted); }

/* layout */
.top { position: sticky; top: 0; z-index: 5; background: var(--bg); padding: calc(var(--safe-t) + 12px) 16px 8px; display: flex; align-items: center; gap: 8px; }
.top h1 { font-size: 28px; line-height: 1.1; margin: 0; flex: 1; letter-spacing: -.02em; }
.main { padding: 4px 16px calc(120px + var(--safe-b)); max-width: 720px; margin: 0 auto; }
.nav { position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; background: color-mix(in srgb, var(--card) 92%, transparent); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid var(--line); display: flex; padding: 6px 4px calc(6px + var(--safe-b)); }
.nav button { flex: 1; border: 0; background: none; padding: 4px 0; font-size: 11px; color: var(--muted); display: flex; flex-direction: column; align-items: center; gap: 2px; min-height: 48px; }
.nav button .i { font-size: 21px; line-height: 1; }
.nav button.on { color: var(--accent); font-weight: 600; }
.mic { position: fixed; right: 16px; bottom: calc(76px + var(--safe-b)); z-index: 11; width: 60px; height: 60px; border-radius: 50%; border: 0;
  background: var(--accent); color: var(--accent-ink); font-size: 26px; box-shadow: 0 6px 20px rgba(0, 0, 0, .22); }
.iconbtn { border: 0; background: var(--card); width: 40px; height: 40px; border-radius: 50%; font-size: 18px; box-shadow: var(--shadow); }

/* blocks */
h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 22px 4px 8px; font-weight: 600; display: flex; align-items: baseline; gap: 8px; }
h2 .sp { flex: 1; }
h2 .lnk { text-transform: none; letter-spacing: 0; font-size: 14px; color: var(--accent); background: none; border: 0; padding: 0; font-weight: 500; }
.card { background: var(--card); border-radius: var(--r); box-shadow: var(--shadow); overflow: hidden; }
.card + .card { margin-top: 10px; }
.pad { padding: 14px 16px; }
.row { display: flex; align-items: center; gap: 12px; padding: 12px 16px; min-height: 52px; border-top: 1px solid var(--line); }
.card > .row:first-child { border-top: 0; }
.row .grow { flex: 1; min-width: 0; }
.row .t { overflow-wrap: anywhere; }
.row .s { font-size: 13px; color: var(--muted); margin-top: 2px; overflow-wrap: anywhere; }
.row .amt { font-variant-numeric: tabular-nums; font-weight: 600; white-space: nowrap; }
.row.done .t { text-decoration: line-through; color: var(--muted); }
.empty { padding: 18px 16px; color: var(--muted); text-align: center; font-size: 15px; }
.chk { width: 26px; height: 26px; border-radius: 50%; border: 2px solid var(--line); background: none; flex: none; display: grid; place-items: center; font-size: 14px; color: var(--accent-ink); }
.chk.on { background: var(--accent); border-color: var(--accent); }
.badge { display: inline-block; font-size: 12px; padding: 2px 8px; border-radius: 99px; background: var(--accent-soft); color: var(--accent); font-weight: 600; white-space: nowrap; }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.wait { background: var(--wait-soft); color: var(--wait); }
.badge.gray { background: var(--line); color: var(--muted); }
.x { border: 0; background: none; color: var(--muted); font-size: 18px; width: 32px; height: 32px; flex: none; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.stat { background: var(--card); border-radius: 14px; padding: 12px; box-shadow: var(--shadow); min-width: 0; }
.stat .l { font-size: 12px; color: var(--muted); }
.stat .v { font-size: 17px; font-weight: 700; font-variant-numeric: tabular-nums; margin-top: 2px; overflow-wrap: anywhere; }
.bar { height: 8px; border-radius: 99px; background: var(--line); overflow: hidden; margin-top: 8px; }
.bar > i { display: block; height: 100%; background: var(--accent); border-radius: 99px; }
.seg { display: flex; background: var(--line); border-radius: 12px; padding: 3px; gap: 3px; margin: 4px 0 2px; }
.seg button { flex: 1; border: 0; background: none; border-radius: 9px; padding: 8px 4px; font-size: 14px; color: var(--muted); }
.seg button.on { background: var(--card); color: var(--ink); font-weight: 600; box-shadow: var(--shadow); }
.monthnav { display: flex; align-items: center; justify-content: space-between; margin: 6px 0 10px; }
.monthnav b { font-size: 17px; }
.monthnav button { border: 0; background: var(--card); border-radius: 10px; width: 40px; height: 36px; font-size: 18px; box-shadow: var(--shadow); }

/* forms */
.form { display: grid; gap: 10px; padding: 14px 16px; }
.form .two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
label.f { display: grid; gap: 4px; font-size: 13px; color: var(--muted); }
input, select, textarea { width: 100%; border: 1px solid var(--line); background: var(--bg); border-radius: 12px; padding: 11px 12px; font-size: 16px; min-height: 44px; }
textarea { resize: vertical; min-height: 120px; line-height: 1.45; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: transparent; }
.btn { border: 0; border-radius: 12px; padding: 12px 16px; font-weight: 600; background: var(--accent); color: var(--accent-ink); min-height: 46px; }
.btn.sec { background: var(--accent-soft); color: var(--accent); }
.btn.ghost { background: none; color: var(--muted); }
.btn.danger { background: var(--warn-soft); color: var(--warn); }
.btn.sm { padding: 7px 12px; min-height: 34px; font-size: 14px; border-radius: 10px; }
.btn:disabled { opacity: .5; }
.btns { display: flex; gap: 8px; flex-wrap: wrap; }
.hint { font-size: 13px; color: var(--muted); line-height: 1.45; }
.err { color: var(--warn); font-size: 14px; }

/* sheet */
.shade { position: fixed; inset: 0; background: rgba(0, 0, 0, .35); z-index: 20; display: flex; align-items: flex-end; justify-content: center; }
.sheet { background: var(--bg); width: 100%; max-width: 720px; max-height: 92vh; overflow: auto; border-radius: 20px 20px 0 0; padding: 8px 16px calc(20px + var(--safe-b)); -webkit-overflow-scrolling: touch; }
.sheet .grab { width: 40px; height: 5px; border-radius: 3px; background: var(--line); margin: 4px auto 10px; }
.sheet h3 { margin: 4px 0 12px; font-size: 20px; display: flex; align-items: center; }
.sheet h3 span { flex: 1; }

/* parsed items */
.item { display: grid; grid-template-columns: auto 1fr; gap: 10px; padding: 12px 14px; border-top: 1px solid var(--line); }
.card > .item:first-child { border-top: 0; }
.item.off { opacity: .45; }
.item .fields { display: grid; gap: 6px; min-width: 0; }
.item .fields input, .item .fields select { min-height: 38px; padding: 7px 10px; font-size: 15px; }
.item .fields .two { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }

/* auth */
.auth { max-width: 380px; margin: 0 auto; padding: calc(var(--safe-t) + 14vh) 16px 40px; }
.auth h1 { font-size: 34px; margin: 0 0 6px; letter-spacing: -.02em; }
.auth .logo { width: 64px; height: 64px; border-radius: 16px; margin-bottom: 16px; }

#toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(150px + var(--safe-b)); z-index: 40; background: var(--ink); color: var(--bg);
  padding: 10px 16px; border-radius: 12px; font-size: 15px; opacity: 0; pointer-events: none; transition: opacity .2s; max-width: calc(100% - 32px); text-align: center; }
#toast.on { opacity: .95; }
.mono { font-family: ui-monospace, Menlo, monospace; font-size: 13px; overflow-wrap: anywhere; user-select: all; -webkit-user-select: all; }
.pwbox { background: var(--wait-soft); color: var(--ink); border-radius: 12px; padding: 12px; }

/* ---------- Оформление у каждого своё ---------- */
/* Мужское: строгое, графит и тёмно-синий, острее углы */
html[data-theme="man"] {
  --bg: #eceff3; --card: #ffffff; --ink: #121a24; --muted: #5d6875; --line: #d8dee6;
  --accent: #1f4e79; --accent-ink: #ffffff; --accent-soft: #dce6f0;
  --shadow: 0 1px 2px rgba(10, 20, 35, .08); --r: 10px;
}
html[data-theme="man"] .top h1 { font-weight: 800; letter-spacing: -.01em; text-transform: uppercase; font-size: 24px; }
html[data-theme="man"] .btn, html[data-theme="man"] input, html[data-theme="man"] select, html[data-theme="man"] textarea { border-radius: 8px; }
html[data-theme="man"] .mic { border-radius: 14px; }
html[data-theme="man"] h2 { letter-spacing: .1em; }
/* Женское: мягкое, пудровая роза, круглее углы */
html[data-theme="woman"] {
  --bg: #fbf2f3; --card: #ffffff; --ink: #2d1e24; --muted: #8a6f78; --line: #f0dde2;
  --accent: #c0577a; --accent-ink: #ffffff; --accent-soft: #fbe3ea;
  --shadow: 0 2px 10px rgba(192, 87, 122, .08); --r: 22px;
}
html[data-theme="woman"] .top h1 { font-family: Georgia, "Times New Roman", serif; font-weight: 600; font-style: italic; }
html[data-theme="woman"] .btn, html[data-theme="woman"] input, html[data-theme="woman"] select, html[data-theme="woman"] textarea { border-radius: 16px; }
html[data-theme="woman"] .seg, html[data-theme="woman"] .seg button { border-radius: 16px; }
html[data-theme="woman"] .stat { border-radius: 18px; }
@media (prefers-color-scheme: dark) {
  html[data-theme="man"] {
    --bg: #0e1319; --card: #18202a; --ink: #e8edf3; --muted: #93a0ae; --line: #2a3542;
    --accent: #5b9bd5; --accent-ink: #0b1622; --accent-soft: #1c2c3d;
  }
  html[data-theme="woman"] {
    --bg: #1b1417; --card: #261c21; --ink: #f6e9ed; --muted: #c2a3ad; --line: #3a2a31;
    --accent: #e88aab; --accent-ink: #2a1019; --accent-soft: #3d2530;
  }
}

/* ассистент */
.chat { display: flex; flex-direction: column; gap: 8px; max-height: 46vh; overflow-y: auto; margin-bottom: 10px; -webkit-overflow-scrolling: touch; }
.msg { padding: 10px 14px; border-radius: 18px; max-width: 86%; white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.4; }
.msg.user { align-self: flex-end; background: var(--accent); color: var(--accent-ink); border-bottom-right-radius: 6px; }
.msg.assistant { align-self: flex-start; background: var(--card); box-shadow: var(--shadow); border-bottom-left-radius: 6px; }
