/* СУТКИ — тихий интерфейс вокруг одного яркого элемента, циферблата. */

:root {
  --bg: #E8EBEE;
  --bg-2: #F2F4F6;
  --text: #1B2230;
  --muted: #5B6474;
  --line: #C9CED6;
  --accent: #2F5BFF;
  --accent-ink: #FFFFFF;
  --danger: #B3261E;
  --sleep: #0B0F1A;
  --dim: #E8EBEE;
  --gutter: 16px;
  --dock-h: 128px;
  --radius: 12px;
  --font: 'Golos Text', system-ui, -apple-system, sans-serif;
  --display: 'Unbounded', 'Golos Text', system-ui, sans-serif;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121722;
    --bg-2: #1A2130;
    --text: #E6E9EF;
    --muted: #98A1B1;
    --line: #2B3343;
    --accent: #5A7DFF;
    --danger: #FF8A80;
    --dim: #121722;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; background: var(--bg); }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 400 16px/1.4 var(--font);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
:focus { outline: none; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
code { font-size: .9em; background: var(--bg-2); padding: 1px 5px; border-radius: 4px; }

.display { font-family: var(--display); font-weight: 700; letter-spacing: -.01em; margin: 0; }
.kicker { margin: 0 0 2px; color: var(--muted); font-weight: 500; font-size: 15px; }
.muted { color: var(--muted); }
.error { color: var(--danger); min-height: 1.4em; margin: 6px 0; font-size: 15px; }

/* ───────── экраны ───────── */

#screens {
  padding: calc(env(safe-area-inset-top) + 14px) calc(env(safe-area-inset-right) + var(--gutter)) calc(var(--dock-h) + env(safe-area-inset-bottom) + 24px) calc(env(safe-area-inset-left) + var(--gutter));
  max-width: 560px;
}
.screen-head { margin-bottom: 18px; }
.screen-head .display { font-size: 28px; line-height: 1.15; }
.screen-head p { margin: 6px 0 0; }

.day-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; }
.day-head .display { font-size: 30px; line-height: 1.1; }
.block { margin-top: 26px; }
.block-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin: 0 0 6px; }
.block-head h2 { font-size: 17px; font-weight: 600; margin: 0; }
.block-head .muted { font-size: 14px; }

/* ───────── неделя ───────── */

.week {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
  margin: 16px -6px 0;
  touch-action: pan-y;
  user-select: none;
  -webkit-user-select: none;
}
.week.slide-next { animation: slideNext .22s ease-out; }
.week.slide-prev { animation: slidePrev .22s ease-out; }
@keyframes slideNext { from { transform: translateX(24px); opacity: .3; } }
@keyframes slidePrev { from { transform: translateX(-24px); opacity: .3; } }
.wd {
  border: 0; background: none; padding: 6px 6px 8px;
  min-height: 64px; display: flex; flex-direction: column; align-items: flex-start; gap: 3px;
  border-radius: 10px; text-align: left;
}
.wd small { font-size: 13px; color: var(--muted); }
.wd b { font: 500 17px/1.1 var(--display); }
.wd .load { width: 100%; height: 3px; border-radius: 2px; background: var(--line); overflow: hidden; margin-top: 4px; }
.wd .load i { display: block; height: 100%; background: var(--text); opacity: .55; border-radius: 2px; }
.wd.is-today b { color: var(--accent); }
.wd[aria-pressed="true"] { background: var(--bg-2); }
.wd[aria-pressed="true"] .load i { background: var(--accent); opacity: 1; }
.wd.is-weekend small { color: var(--muted); opacity: .8; }

/* ───────── циферблат ───────── */

.dial-wrap { position: relative; width: min(100%, 360px); aspect-ratio: 1; margin: 20px 0 0; }
.dial-wrap svg { width: 100%; height: 100%; display: block; overflow: visible; }
.dial-center {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: 54%; text-align: center; pointer-events: none;
}
.dial-center .k { font-size: 14px; color: var(--muted); font-weight: 500; }
.dial-center .k.live { color: var(--accent); }
.dial-center .t {
  font: 500 19px/1.2 var(--display); margin: 6px 0 4px;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere;
}
.dial-center .t.free { font-size: 18px; }
.dial-center .s { font-size: 15px; }
.dial-center .c { font-size: 13px; color: var(--muted); margin-top: 10px; }
.dial-label { font: 500 11px var(--font); fill: var(--muted); }
.dial-tick { stroke: var(--line); stroke-width: 1.2; }
.dial-tick.major { stroke: var(--muted); stroke-width: 1.6; }
.dial-arc { cursor: pointer; }
.dial-hand { stroke: #2F5BFF; stroke-width: 3; stroke-linecap: round; }

/* ───────── списки ───────── */

.row {
  display: grid; grid-template-columns: 52px 32px 1fr; align-items: start;
  border-bottom: 1px solid var(--line); min-height: 56px;
}
.row:last-child { border-bottom: 0; }
.row .time { padding-top: 16px; font-size: 15px; font-variant-numeric: tabular-nums; }
.row .time small { display: block; color: var(--muted); font-size: 13px; }
.row .mark { padding-top: 12px; display: flex; justify-content: flex-start; }
.row .bar { width: 4px; border-radius: 2px; height: 30px; margin: 13px 0 0 4px; }
.row .main {
  border: 0; background: none; text-align: left; padding: 14px 0 12px; min-height: 56px; width: 100%;
  display: flex; flex-direction: column; gap: 2px;
}
.row .title { font-weight: 500; overflow-wrap: anywhere; }
.row .meta { font-size: 14px; color: var(--muted); }
.row.is-done .title { color: var(--muted); text-decoration: line-through; text-decoration-thickness: 1px; }
.row.is-now .title { color: var(--accent); }
.row.is-past .time { color: var(--muted); }
.row.compact { grid-template-columns: 52px 32px 1fr; }
.row.no-time { grid-template-columns: 32px 1fr; }
.row.with-actions { grid-template-columns: 32px 1fr auto; }
.row .actions { display: flex; gap: 4px; padding-top: 8px; }

.check {
  width: 44px; height: 44px; margin: -6px 0 0 -11px; border: 0; background: none; padding: 0;
  display: grid; place-items: center; border-radius: 50%;
}
.check span {
  width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--muted);
  display: grid; place-items: center; transition: background .15s, border-color .15s;
}
.check[aria-checked="true"] span { background: var(--accent); border-color: var(--accent); }
.check svg { width: 14px; height: 14px; stroke: var(--accent-ink); stroke-width: 2.5; fill: none; opacity: 0; }
.check[aria-checked="true"] svg { opacity: 1; }
.prio { color: var(--accent); font-weight: 600; }

.now-line { display: grid; grid-template-columns: 52px 1fr; align-items: center; height: 0; position: relative; }
.now-line span { font-size: 12px; color: var(--accent); font-weight: 600; background: var(--bg); padding-right: 4px; transform: translateY(-50%); font-variant-numeric: tabular-nums; }
.now-line i { height: 2px; background: var(--accent); border-radius: 1px; transform: translateY(-50%); }
.now-line i::before { content: ''; position: absolute; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); left: 48px; top: -4px; }

.empty { color: var(--muted); padding: 10px 0; margin: 0; }

.day-group { margin-top: 24px; }
.day-group h2 { font: 500 16px/1.3 var(--display); margin: 0 0 4px; }

/* ───────── кнопки ───────── */

.btn-primary, .btn-wide, .btn-secondary, .btn-danger, .btn-quiet, .btn-small {
  border-radius: var(--radius); border: 1px solid transparent; min-height: 48px; padding: 0 18px;
  font-weight: 600; display: inline-flex; align-items: center; justify-content: flex-start; gap: 8px; text-align: left;
}
.btn-primary { background: var(--accent); color: var(--accent-ink); }
.btn-secondary { background: none; border-color: var(--line); }
.btn-danger { background: none; border-color: var(--line); color: var(--danger); }
.btn-wide { width: 100%; background: none; border-color: var(--text); }
.btn-quiet { background: none; color: var(--accent); padding: 0 6px; min-height: 44px; }
.btn-small { min-height: 36px; padding: 0 12px; font-size: 14px; border-color: var(--line); background: none; font-weight: 500; border-radius: 10px; }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; }
button:disabled { opacity: .45; cursor: default; }
.btn-primary:active, .btn-secondary:active, .btn-wide:active, .btn-small:active { opacity: .7; }

/* ───────── нижняя панель ───────── */

.dock {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  background: var(--bg); border-top: 1px solid var(--line);
  padding: 8px calc(env(safe-area-inset-right) + 12px) env(safe-area-inset-bottom) calc(env(safe-area-inset-left) + 12px);
  will-change: transform;
}
.quick-row { display: flex; gap: 6px; align-items: center; }
#quick-input {
  flex: 1; min-width: 0; height: 46px; border-radius: var(--radius); border: 1px solid var(--line);
  background: var(--bg-2); padding: 0 14px; font-size: 17px;
}
#quick-input::placeholder { color: var(--muted); opacity: .8; }
#quick-input:focus-visible, #quick-input:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: transparent; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; padding: 8px 0 2px; }
.chips:empty { display: none; }
.chip {
  font-size: 13px; padding: 4px 10px; border-radius: 999px; border: 1px solid var(--line); color: var(--text);
  background: none; min-height: 28px; display: inline-flex; align-items: center;
}
.chip.k-date, .chip.k-time { border-color: var(--accent); color: var(--accent); }
.chip.k-type { color: var(--muted); }

.tabs { display: grid; grid-template-columns: repeat(4, 1fr); margin-top: 6px; }
.tabs button {
  border: 0; background: none; min-height: 52px; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px; color: var(--muted); font-size: 11px; font-weight: 500; position: relative;
}
.tabs svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.tabs [aria-current="page"] { color: var(--accent); }
.badge { position: absolute; top: 4px; left: calc(50% + 8px); font-size: 11px; font-weight: 600; background: var(--accent); color: var(--accent-ink); border-radius: 999px; padding: 0 5px; min-width: 18px; line-height: 18px; text-align: center; }
body.typing .tabs { display: none; }
body.typing .dock { padding-bottom: 8px; }

/* ───────── нижний лист ───────── */

.backdrop { position: fixed; inset: 0; background: rgba(10, 14, 22, .42); z-index: 40; animation: fade .2s; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 41; max-height: 92dvh; overflow-y: auto; overscroll-behavior: contain;
  background: var(--bg); border-radius: 18px 18px 0 0; border-top: 1px solid var(--line);
  padding: 8px calc(env(safe-area-inset-right) + var(--gutter)) calc(env(safe-area-inset-bottom) + 18px) calc(env(safe-area-inset-left) + var(--gutter));
  animation: up .24s cubic-bezier(.2, .8, .2, 1);
}
.sheet .grip { width: 40px; height: 5px; border-radius: 3px; background: var(--line); margin: 2px 0 12px; border: 0; padding: 0; display: block; }
.sheet h2 { font: 500 18px/1.2 var(--display); margin: 0 0 12px; }
@keyframes up { from { transform: translateY(40%); opacity: .4; } }
@keyframes fade { from { opacity: 0; } }

.field { margin-top: 16px; }
.field > label, .field > .lbl { display: block; font-size: 14px; color: var(--muted); margin-bottom: 6px; font-weight: 500; }
.field input[type=text], .field input[type=date], .field input[type=time], .field input[type=number], .field select, .field textarea {
  width: 100%; min-height: 46px; border-radius: var(--radius); border: 1px solid var(--line); background: var(--bg-2);
  padding: 10px 12px; font-size: 17px; -webkit-appearance: none; appearance: none; text-align: left;
}
.field input[type=date], .field input[type=time] { display: block; }
.field input::-webkit-date-and-time-value { text-align: left; }
.field textarea { min-height: 88px; resize: vertical; }
.field-title input { font-size: 19px; font-weight: 500; }
.inline { display: flex; gap: 8px; align-items: center; }
.inline > * { flex: 1; }
.inline > .btn-small, .inline > .btn-quiet { flex: 0 0 auto; }

.seg { display: flex; flex-wrap: wrap; gap: 6px; }
.seg button {
  min-height: 40px; padding: 0 14px; border-radius: 10px; border: 1px solid var(--line); background: none; font-size: 15px;
}
.seg button[aria-pressed="true"], .seg button[aria-checked="true"] { background: var(--text); color: var(--bg); border-color: var(--text); }
.sheet-actions { display: flex; flex-direction: column; gap: 8px; margin-top: 22px; }
.sheet-actions .btn-row > * { flex: 1; }

/* ───────── разбор дня ───────── */

.review {
  position: fixed; inset: 0; z-index: 50; background: var(--bg); overflow-y: auto;
  padding: calc(env(safe-area-inset-top) + 14px) calc(env(safe-area-inset-right) + var(--gutter)) calc(env(safe-area-inset-bottom) + 24px) calc(env(safe-area-inset-left) + var(--gutter));
  animation: fade .2s;
}
.review-top { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.review-top .display { font-size: 24px; }
.review-progress { height: 3px; background: var(--line); border-radius: 2px; margin: 14px 0 0; overflow: hidden; }
.review-progress i { display: block; height: 100%; background: var(--accent); transition: width .25s; }
.review-card { margin-top: 36px; }
.review-card .from { color: var(--muted); font-size: 15px; margin: 0 0 8px; }
.review-card .display { font-size: 26px; line-height: 1.2; font-weight: 500; overflow-wrap: anywhere; }
.review-card .notes { color: var(--muted); margin: 10px 0 0; white-space: pre-wrap; }
.review-actions { display: flex; flex-direction: column; gap: 10px; margin-top: 32px; }
.review-actions button { width: 100%; min-height: 54px; font-size: 17px; }
.review-sum { margin-top: 36px; }
.review-sum dl { display: grid; grid-template-columns: 1fr auto; gap: 10px 16px; margin: 24px 0; font-size: 17px; }
.review-sum dt { color: var(--muted); }
.review-sum dd { margin: 0; font: 500 17px var(--display); }

/* ───────── настройки ───────── */

.set-group { margin-top: 28px; }
.set-group > h2 { font-size: 17px; font-weight: 600; margin: 0 0 4px; }
.set-group > p { margin: 4px 0 10px; color: var(--muted); font-size: 15px; }
.set-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; min-height: 56px; border-bottom: 1px solid var(--line); }
.set-row:last-child { border-bottom: 0; }
.set-row label { flex: 1; }
.set-row input[type=time], .set-row select {
  min-height: 40px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg-2); padding: 6px 10px; font-size: 16px;
  -webkit-appearance: none; appearance: none; min-width: 96px;
}
.set-row input[type=time]:disabled { opacity: .4; }
.status { font-size: 15px; margin: 6px 0 12px; }
.status.on { color: var(--accent); }

.switch { position: relative; width: 52px; height: 32px; flex: 0 0 auto; }
.switch input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; z-index: 1; }
.switch span { position: absolute; inset: 0; border-radius: 16px; background: var(--line); transition: background .15s; }
.switch span::after { content: ''; position: absolute; top: 3px; left: 3px; width: 26px; height: 26px; border-radius: 50%; background: #fff; transition: transform .15s; }
.switch input:checked + span { background: var(--accent); }
.switch input:checked + span::after { transform: translateX(20px); }
.switch input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.script-box { width: 100%; min-height: 120px; font: 12px ui-monospace, monospace; border-radius: 10px; border: 1px solid var(--line); background: var(--bg-2); padding: 8px; margin-top: 8px; }

/* ───────── вход и уведомление ───────── */

.login { position: fixed; inset: 0; z-index: 60; background: var(--bg); overflow-y: auto; padding: calc(env(safe-area-inset-top) + 48px) var(--gutter) 32px; }
.login-box { max-width: 420px; }
.login-box .display { font-size: 34px; margin-bottom: 18px; }
.login-box label { display: block; font-weight: 500; margin: 22px 0 6px; }
.login-box input { width: 100%; min-height: 50px; border-radius: var(--radius); border: 1px solid var(--line); background: var(--bg-2); padding: 0 14px; font-size: 17px; }
.login-box .btn-primary { width: 100%; margin-top: 8px; }

.toast {
  position: fixed; z-index: 70; left: calc(env(safe-area-inset-left) + 12px); right: calc(env(safe-area-inset-right) + 12px);
  bottom: calc(var(--dock-h) + env(safe-area-inset-bottom) + 10px);
  background: var(--text); color: var(--bg); border-radius: var(--radius); padding: 10px 10px 10px 16px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px; font-size: 15px; min-height: 48px;
  animation: fade .15s;
}
.toast button { border: 0; background: none; color: inherit; font-weight: 600; min-height: 36px; padding: 0 8px; text-decoration: underline; text-underline-offset: 3px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}

@media (min-width: 600px) {
  .sheet { max-width: 560px; margin: 0 auto; border: 1px solid var(--line); border-bottom: 0; }
  .dock > * { max-width: 560px; }
  .toast { max-width: 536px; }
}
