:root {
  --bg: #0E0F12;
  --card: #17191E;
  --card-2: #1E2127;
  --line: #2A2E36;
  --text: #ECEDEF;
  --muted: #8B9099;
  --faint: #5C616B;
  --accent: #F2A33A;
  --accent-ink: #1A1206;
  --accent-soft: rgba(242, 163, 58, 0.12);
  --green: #4CC38A;
  --red: #E5534B;
  --radius: 16px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font: 17px/1.4 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; padding: 0; }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.error-text { color: var(--red); font-size: 15px; }

/* ---------- вход ---------- */
.login {
  min-height: 100dvh; display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 24px; text-align: center; gap: 6px;
}
.login h1 { margin: 18px 0 0; font-size: 28px; letter-spacing: -0.02em; }
.login form { width: 100%; max-width: 320px; display: flex; flex-direction: column; gap: 12px; margin-top: 18px; }
.login-mark { width: 76px; height: 76px; border-radius: 50%; border: 2px solid var(--accent); display: grid; place-items: center; }
.login-mark span { width: 22px; height: 22px; border-radius: 50%; background: var(--accent); }

input[type=password], input[type=search], input[type=text], textarea {
  width: 100%; background: var(--card); border: 1px solid var(--line); border-radius: 14px;
  padding: 14px 16px; outline: none; font-size: 17px;
}
input:focus, textarea:focus { border-color: #3B414C; }
textarea { resize: none; min-height: 110px; line-height: 1.45; }

/* ---------- каркас ---------- */
.app { max-width: 600px; margin: 0 auto; min-height: 100dvh; }
.topbar {
  position: sticky; top: 0; z-index: 5; display: flex; align-items: flex-end; justify-content: space-between;
  padding: calc(var(--safe-t) + 14px) 20px 10px; background: linear-gradient(var(--bg) 75%, rgba(14,15,18,0));
}
.topbar h1 { margin: 0; font-size: 30px; font-weight: 700; letter-spacing: -0.025em; }
.topdate { color: var(--muted); font-size: 14px; }
.icon-btn { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; color: var(--muted); background: var(--card); font-weight: 700; font-size: 16px; }
.view { padding: 4px 16px calc(120px + var(--safe-b)); }

/* ---------- нижняя панель ---------- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  display: grid; grid-template-columns: 1fr 1fr 92px 1fr 1fr; align-items: end;
  max-width: 600px; margin: 0 auto;
  padding: 6px 6px calc(var(--safe-b) + 6px);
  background: rgba(14, 15, 18, 0.92); backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px);
  border-top: 1px solid #1B1E24;
}
.tab { display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 6px 0 2px; color: var(--faint); font-size: 11px; }
.tab svg { width: 24px; height: 24px; }
.tab.active { color: var(--text); }
.mic-slot { display: flex; justify-content: center; }
.mic {
  width: 72px; height: 72px; margin-top: -30px; border-radius: 50%;
  background: var(--accent); color: var(--accent-ink); display: grid; place-items: center;
  box-shadow: 0 0 0 6px var(--bg);
  transition: transform .15s ease;
}
.mic:active { transform: scale(0.94); }

/* ---------- карточки ---------- */
.section-title { font-size: 13px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); margin: 22px 4px 10px; font-weight: 600; }
.card { background: var(--card); border-radius: var(--radius); padding: 16px; margin-bottom: 10px; }
.card.accent { background: linear-gradient(var(--accent-soft), var(--accent-soft)), var(--card); box-shadow: inset 0 0 0 1px rgba(242,163,58,.35); }
.card h3 { margin: 0 0 6px; font-size: 17px; font-weight: 600; }
.card p { margin: 0; }
.card .meta { font-size: 13px; color: var(--muted); margin-bottom: 6px; display: flex; gap: 8px; align-items: center; }
.label { font-size: 12px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--accent); margin-bottom: 8px; display: block; }
.row-actions { display: flex; gap: 8px; margin-top: 14px; flex-wrap: wrap; }
.btn { height: 40px; padding: 0 16px; border-radius: 12px; background: var(--card-2); font-size: 15px; font-weight: 600; }
.btn.primary { background: var(--accent); color: var(--accent-ink); }
.btn.ghost { background: transparent; color: var(--muted); }
.btn.danger { background: transparent; color: var(--red); }
.btn.wide { width: 100%; height: 50px; font-size: 17px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.chip { background: var(--card-2); border-radius: 999px; padding: 5px 11px; font-size: 14px; }
.chip.link { color: var(--text); }
.chip.warn { box-shadow: inset 0 0 0 1px rgba(242,163,58,.5); }

.understood { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line); display: grid; gap: 8px; font-size: 15px; }
.understood .line { display: flex; gap: 10px; }
.understood .tag { flex: 0 0 auto; font-size: 12px; font-weight: 700; color: var(--muted); width: 86px; padding-top: 2px; text-transform: uppercase; letter-spacing: .04em; }
.tag.need { color: #7DB3FF; } .tag.offer { color: var(--green); } .tag.task { color: var(--accent); }

.match-line { display: flex; gap: 10px; align-items: flex-start; margin: 6px 0; }
.match-line .when { font-size: 13px; color: var(--muted); width: 64px; flex: 0 0 auto; padding-top: 2px; }
.match-arrow { height: 14px; margin-left: 74px; border-left: 1px dashed rgba(242,163,58,.6); }
.reason { font-size: 14px; color: var(--muted); margin-top: 10px; }

.task { display: flex; gap: 12px; align-items: flex-start; padding: 12px 4px; border-bottom: 1px solid #1C1F25; }
.task:last-child { border-bottom: 0; }
.check { width: 24px; height: 24px; border-radius: 50%; border: 2px solid #3A3F49; flex: 0 0 auto; margin-top: 1px; display: grid; place-items: center; }
.check.done { background: var(--green); border-color: var(--green); }
.task-body { flex: 1; min-width: 0; cursor: pointer; }
.task .due { font-size: 13px; color: var(--muted); }
.task .due.late { color: var(--red); }

.processing { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: 15px; }
.spinner { width: 18px; height: 18px; border-radius: 50%; border: 2px solid #343842; border-top-color: var(--accent); animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.empty { text-align: center; padding: 56px 20px 20px; }
.empty .clock { font-size: 64px; font-weight: 200; letter-spacing: -0.04em; font-variant-numeric: tabular-nums; }
.empty p { color: var(--muted); margin: 8px 0 0; }

/* ---------- лента и поиск ---------- */
.search { position: relative; margin-bottom: 6px; }
.search input { padding-left: 44px; }
.search svg { position: absolute; left: 15px; top: 50%; transform: translateY(-50%); color: var(--faint); }
.search input[type=search] { padding-right: 48px; }
.search .ask-mic { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); width: 40px; height: 40px; border-radius: 50%; display: flex; align-items: center; justify-content: center; color: var(--muted); }
.search .ask-mic svg { position: static; transform: none; color: inherit; }
.search .ask-mic.on { background: var(--accent); color: var(--accent-ink); animation: pulse 1.2s ease-in-out infinite; }
.answer { white-space: pre-wrap; line-height: 1.5; }
a.feed-item { color: inherit; text-decoration: none; }
.answer a.ref { text-decoration: none; }
.answer .ref { color: var(--accent); font-weight: 600; font-size: 14px; }
.day { font-size: 13px; color: var(--muted); margin: 22px 4px 8px; font-weight: 600; }
.feed-item { display: flex; gap: 12px; padding: 14px 16px; background: var(--card); border-radius: 14px; margin-bottom: 8px; width: 100%; text-align: left; }
.feed-item .time { font-size: 13px; color: var(--muted); width: 40px; flex: 0 0 auto; padding-top: 2px; font-variant-numeric: tabular-nums; }
.feed-item .body { min-width: 0; flex: 1; }
.feed-item .t { font-weight: 600; font-size: 16px; }
.feed-item .s { color: var(--muted); font-size: 14px; margin-top: 2px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.kind { display: inline-block; width: 7px; height: 7px; border-radius: 50%; margin-right: 6px; vertical-align: 2px; background: var(--faint); }
.kind.meeting { background: #7DB3FF; } .kind.site_visit { background: var(--accent); } .kind.diary { background: #B48CF2; }
.kind.idea { background: var(--green); } .kind.task { background: #E8E36C; } .kind.bx { background: #2FC6F6; }

/* ---------- люди ---------- */
.person-row { display: flex; gap: 12px; align-items: center; padding: 12px 14px; background: var(--card); border-radius: 14px; margin-bottom: 8px; width: 100%; text-align: left; }
.avatar { width: 42px; height: 42px; border-radius: 50%; background: var(--card-2); display: grid; place-items: center; font-weight: 700; color: var(--muted); flex: 0 0 auto; font-size: 15px; }
.person-row .name { font-weight: 600; }
.person-row .sub { color: var(--muted); font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.person-row .right { margin-left: auto; text-align: right; font-size: 13px; color: var(--faint); flex: 0 0 auto; }
.dot-accent { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); margin-left: 6px; }

/* ---------- неделя ---------- */
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.stat { background: var(--card); border-radius: var(--radius); padding: 16px; }
.stat .n { font-size: 34px; font-weight: 700; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; }
.stat .l { color: var(--muted); font-size: 14px; }
.goal-row { display: flex; align-items: center; gap: 12px; padding: 11px 0; border-bottom: 1px solid #1C1F25; font-size: 15px; }
.goal-row:last-child { border-bottom: 0; }

/* ---------- шторка ---------- */
.backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.55); z-index: 30; animation: fade .2s ease; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 31; max-width: 600px; margin: 0 auto;
  max-height: 92dvh; overflow-y: auto; background: #121418; border-radius: 22px 22px 0 0;
  padding: 10px 18px calc(var(--safe-b) + 24px); animation: up .25s cubic-bezier(.2,.8,.2,1);
  -webkit-overflow-scrolling: touch;
}
.grabber { width: 38px; height: 5px; border-radius: 3px; background: #3A3F49; margin: 0 auto 14px; }
.sheet h2 { margin: 0 0 4px; font-size: 24px; letter-spacing: -0.02em; }
.sheet audio { width: 100%; margin: 14px 0 4px; height: 40px; }
.sheet .block { margin-top: 18px; }
.sheet .block-title { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 600; margin-bottom: 8px; }
details summary { color: var(--muted); font-size: 15px; cursor: pointer; list-style: none; }
details summary::-webkit-details-marker { display: none; }
.transcript { color: #C7CAD0; font-size: 15px; line-height: 1.55; margin-top: 8px; white-space: pre-wrap; }
@keyframes up { from { transform: translateY(40px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

/* ---------- запись ---------- */
.recorder { position: fixed; inset: 0; z-index: 40; background: var(--bg); display: flex; flex-direction: column; align-items: center;
  padding: calc(var(--safe-t) + 20px) 24px calc(var(--safe-b) + 28px); animation: fade .15s ease; }
.recorder .top { width: 100%; display: flex; justify-content: space-between; align-items: center; }
.recorder .hint { color: var(--muted); font-size: 15px; margin-top: 36px; text-align: center; max-width: 300px; }
.recorder .timer { font-size: 56px; font-weight: 200; font-variant-numeric: tabular-nums; margin-top: 6vh; letter-spacing: -0.03em; }
.recorder canvas { width: 100%; max-width: 420px; height: 96px; margin-top: 4vh; }
.recorder .stop { margin-top: auto; width: 88px; height: 88px; border-radius: 50%; background: var(--accent); display: grid; place-items: center; color: var(--accent-ink); }
.recorder .stop span { width: 28px; height: 28px; border-radius: 7px; background: var(--accent-ink); }
.recorder .pulse { animation: pulse 1.6s ease-out infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(242,163,58,.45); } 100% { box-shadow: 0 0 0 26px rgba(242,163,58,0); } }
.recorder .text-mode { width: 100%; max-width: 520px; margin-top: 24px; display: flex; flex-direction: column; gap: 12px; flex: 1; }
.recorder .text-mode textarea { flex: 1; min-height: 180px; }

.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--safe-b) + 108px); z-index: 50;
  background: #262A31; color: var(--text); padding: 12px 18px; border-radius: 14px; font-size: 15px; max-width: 88vw;
  box-shadow: 0 8px 30px rgba(0,0,0,.4); animation: up .2s ease; }

.setting { display: flex; justify-content: space-between; align-items: center; padding: 14px 0; border-bottom: 1px solid #1C1F25; gap: 12px; }
.setting:last-child { border-bottom: 0; }
.setting .s-sub { color: var(--muted); font-size: 14px; }
.bx-line { margin-top: 8px; padding: 10px 12px; border-radius: 12px; background: rgba(47, 198, 246, 0.10); color: var(--text); font-size: 14px; }
.bx-line.done { color: #2FC6F6; background: none; padding: 4px 0 0; }
.bx-line .row-actions { margin-top: 8px; }

/* ---- покупки */
.top-actions { display: flex; gap: 10px; align-items: center; }
.shop-btn { position: relative; color: var(--muted); }
.shop-btn .badge { position: absolute; top: -2px; right: -2px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--accent); color: var(--accent-ink); font-size: 11px; font-weight: 700; display: grid; place-items: center; }
.shop-add { display: flex; gap: 8px; margin: 14px 0 6px; }
.shop-add input { flex: 1; min-width: 0; background: var(--card-2); border: 1px solid var(--line); border-radius: 12px; color: var(--text); font-size: 17px; padding: 12px 14px; }
.shop-cats { display: flex; gap: 6px; overflow-x: auto; padding: 4px 0 8px; scrollbar-width: none; }
.shop-cats::-webkit-scrollbar { display: none; }
.shop-cats .chip { white-space: nowrap; }
.shop-cats .chip.on { background: var(--accent-soft); color: var(--accent); border-color: var(--accent); }
.shop-sec { margin-top: 18px; }
.shop-sec h3 { margin: 0 0 4px; font-size: 13px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); font-weight: 700; }
.buy { display: flex; width: 100%; gap: 14px; align-items: center; padding: 14px 4px; background: none; border: 0; border-bottom: 1px solid #1C1F25; color: var(--text); font: inherit; font-size: 18px; text-align: left; }
.buy .check { width: 28px; height: 28px; }
.buy .qty { color: var(--muted); font-size: 15px; margin-left: 6px; }
.buy.bought { color: var(--faint); }
.buy.bought .name { text-decoration: line-through; }
.buy.bought .check { background: var(--green); border-color: var(--green); }
.shop-empty { color: var(--muted); margin: 26px 4px; }

/* ---- план недели */
.plan-card { font-size: 15px; line-height: 1.4; }
.plan-day { display: flex; gap: 12px; padding: 8px 0; border-bottom: 1px solid #1C1F25; }
.plan-day .dn { width: 26px; flex: 0 0 auto; color: var(--accent); font-weight: 700; }
.plan-sub { margin-top: 14px; font-size: 12px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); font-weight: 700; }
.plan-sub.warn, .plan-li.warn { color: var(--accent); }
.plan-li { margin-top: 6px; }
.plan-q { display: grid; gap: 10px; margin: 10px 0 4px; font-size: 15px; }
.plan-q > div { display: flex; gap: 10px; }
.plan-q span { color: var(--accent); font-weight: 700; width: 16px; flex: 0 0 auto; }
.plan-actions { flex-wrap: wrap; }
.btn.rec { background: var(--red); color: #fff; }
