/* ===== Помодоро — «swiss spa» minimal, единая нейтральная палитра ===== */
:root {
  --bg: #F4F2ED;
  --surface: #FCFBF8;
  --surface-2: #ECE9E1;
  --line: #E5E1D7;
  --line-2: #EDEAE2;
  --ink: #22211D;
  --ink-2: #6C685F;
  --ink-3: #9E988C;
  --radius: 16px;
  --radius-sm: 11px;
  --shadow: 0 1px 2px rgba(40,35,25,.04), 0 14px 36px -20px rgba(40,35,25,.20);
  --shadow-sm: 0 1px 2px rgba(40,35,25,.04), 0 8px 22px -16px rgba(40,35,25,.16);
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 24px; --s6: 32px; --s7: 40px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #15140F;
    --surface: #1D1B16;
    --surface-2: #26241E;
    --line: #322F28;
    --line-2: #2A2821;
    --ink: #ECE8DF;
    --ink-2: #A7A194;
    --ink-3: #726C61;
    --shadow: 0 1px 2px rgba(0,0,0,.45), 0 16px 40px -22px rgba(0,0,0,.65);
    --shadow-sm: 0 1px 2px rgba(0,0,0,.4), 0 10px 24px -16px rgba(0,0,0,.55);
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: 'Inter', system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 15px; line-height: 1.55; letter-spacing: -.006em;
  -webkit-font-smoothing: antialiased;
  font-feature-settings: "cv11" 1;
}
.ic { width: 18px; height: 18px; display: inline-block; flex: 0 0 auto; }
.ic-sm { width: 16px; height: 16px; }
.ic-xl { width: 30px; height: 30px; }

.app { max-width: 1060px; margin: 0 auto; padding: clamp(20px, 3.4vw, 44px) clamp(16px, 3vw, 32px) clamp(28px, 4vw, 52px); }

/* ===== topbar ===== */
.topbar { display: flex; align-items: baseline; justify-content: space-between; gap: var(--s4); margin-bottom: clamp(20px, 3vw, 36px); padding-bottom: var(--s4); border-bottom: 1px solid var(--line); }
.brand { display: inline-flex; align-items: center; gap: 10px; }
.brand-mark { display: inline-flex; color: var(--ink); }
.brand-mark .ic { width: 20px; height: 20px; }
.brand-name { font-size: 19px; font-weight: 600; letter-spacing: -.01em; }
.brand-tag { font-size: 12px; color: var(--ink-3); text-transform: uppercase; letter-spacing: .14em; }

/* ===== layout ===== */
.layout { display: grid; grid-template-columns: minmax(0, 1fr); gap: clamp(16px, 2.2vw, 24px); align-items: start; }
.col-left, .col-right { display: flex; flex-direction: column; gap: clamp(16px, 2.2vw, 24px); min-width: 0; }
@media (min-width: 920px) {
  .layout { grid-template-columns: minmax(330px, 380px) minmax(0, 1fr); }
  .col-left { position: sticky; top: 28px; }
}

/* ===== panels ===== */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm); padding: clamp(20px, 2.6vw, 30px); }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); margin-bottom: var(--s5); }
.panel-title { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .13em; color: var(--ink-3); }

/* ===== stats ===== */
.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); padding: clamp(18px, 2.4vw, 26px) 0; }
.stat { text-align: center; padding: 0 var(--s3); min-width: 0; }
.stat + .stat { border-left: 1px solid var(--line); }
.stat-num { font-size: clamp(20px, 3vw, 28px); font-weight: 300; letter-spacing: -.03em; line-height: 1.1; font-variant-numeric: tabular-nums; white-space: nowrap; }
@media (max-width: 380px) { .stat { padding: 0 7px; } .stat-num { font-size: 18px; } }
.stat-label { font-size: 11px; font-weight: 500; text-transform: uppercase; letter-spacing: .1em; color: var(--ink-3); margin-top: 6px; }

/* ===== timer ===== */
.timer-panel { display: flex; flex-direction: column; align-items: center; padding: clamp(26px, 3vw, 34px); }
.ring-box { position: relative; width: clamp(210px, 56vw, 248px); aspect-ratio: 1; }
.ring { width: 100%; height: 100%; display: block; }
.ring-track { fill: none; stroke: var(--line); stroke-width: 6; }
.ring-prog { fill: none; stroke: var(--ink); stroke-width: 6; stroke-linecap: round; stroke-dasharray: 691.15; stroke-dashoffset: 691.15; transition: stroke-dashoffset .35s linear; }
.ring-center { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.time { font-size: clamp(46px, 11vw, 62px); font-weight: 300; letter-spacing: -.04em; line-height: 1; font-variant-numeric: tabular-nums; padding: 2px 12px; border-radius: 14px; transition: background .12s; }
.time.editable { cursor: pointer; }
.time.editable:hover { background: color-mix(in srgb, var(--ink) 7%, transparent); }
.time-input { font: inherit; width: 3.2ch; text-align: center; background: transparent; border: 0; color: var(--ink); padding: 0; -moz-appearance: textfield; }
.time-input::-webkit-outer-spin-button, .time-input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.time-input:focus { outline: none; }
.phase { font-size: 11px; font-weight: 500; text-transform: uppercase; letter-spacing: .16em; color: var(--ink-3); margin-top: 12px; }

.setup { width: 100%; margin-top: clamp(22px, 3vw, 30px); }

/* ===== fields ===== */
.field + .field { margin-top: var(--s4); }
.label { display: block; font-size: 12px; font-weight: 500; color: var(--ink-2); margin-bottom: 7px; letter-spacing: -.005em; }
.input, .select, .stepper-input {
  width: 100%; min-width: 0; padding: 11px 13px; border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--bg); color: var(--ink); font: inherit; font-size: 14.5px;
  transition: border-color .14s, box-shadow .14s; appearance: none;
}
.select { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%239E988C' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 11px center; padding-right: 34px; }
.input::placeholder { color: var(--ink-3); }
.input:focus, .select:focus, .stepper-input:focus { outline: none; border-color: var(--ink); box-shadow: 0 0 0 3px color-mix(in srgb, var(--ink) 10%, transparent); }
.control-row { display: flex; gap: var(--s2); }
.icon-btn { flex: 0 0 auto; width: 42px; border: 1px solid var(--line); background: var(--bg); color: var(--ink-2); border-radius: var(--radius-sm); cursor: pointer; display: grid; place-items: center; transition: .14s; }
.icon-btn:hover { color: var(--ink); border-color: var(--ink-3); }

/* ===== buttons ===== */
.actions { display: flex; gap: var(--s2); margin-top: var(--s5); }
.actions-end { justify-content: flex-end; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 12px 18px; border-radius: var(--radius-sm); border: 1px solid transparent; font: inherit; font-size: 14.5px; font-weight: 500; cursor: pointer; transition: transform .04s, background .14s, border-color .14s, color .14s; white-space: nowrap; }
.btn:active { transform: translateY(.5px); }
.btn:disabled { opacity: .4; cursor: default; }
.btn-primary { flex: 1; background: var(--ink); color: var(--bg); }
.btn-primary:not(:disabled):hover { background: color-mix(in srgb, var(--ink) 86%, var(--bg)); }
.btn-ghost { background: transparent; border-color: var(--line); color: var(--ink-2); }
.btn-ghost:not(:disabled):hover { color: var(--ink); border-color: var(--ink-3); }
.btn-icon { flex: 0 0 auto; width: 46px; padding: 12px; }
.btn-sm { padding: 8px 13px; font-size: 13.5px; border-radius: 9px; }

/* ===== настройки (список с разделителями) ===== */
.opts { margin-top: var(--s5); border-top: 1px solid var(--line-2); }
.opt { display: flex; align-items: center; justify-content: space-between; gap: var(--s4); padding: 13px 0; border-bottom: 1px solid var(--line-2); }
.opt:last-child { border-bottom: 0; }
.opt-label { display: inline-flex; align-items: center; gap: 9px; font-size: 13.5px; color: var(--ink-2); }
.opt-label .ic { color: var(--ink-3); }
.stepper-box { display: inline-flex; align-items: center; gap: 7px; }
.stepper-input { width: 56px; padding: 6px 8px; text-align: center; border-radius: 8px; font-size: 14px; }
.stepper-unit { font-size: 13px; color: var(--ink-3); }

/* switch */
.switch { display: inline-flex; cursor: pointer; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.sw-track { width: 38px; height: 22px; border-radius: 999px; background: var(--line); position: relative; transition: background .18s; }
.sw-thumb { position: absolute; top: 2px; left: 2px; width: 18px; height: 18px; border-radius: 50%; background: var(--surface); box-shadow: 0 1px 2px rgba(0,0,0,.25); transition: transform .2s cubic-bezier(.3,.7,.4,1); }
.switch input:checked + .sw-track { background: var(--ink); }
.switch input:checked + .sw-track .sw-thumb { transform: translateX(16px); }
.switch input:focus-visible + .sw-track { box-shadow: 0 0 0 3px color-mix(in srgb, var(--ink) 14%, transparent); }

/* ===== segmented (range) ===== */
.seg { display: inline-flex; background: var(--surface-2); border-radius: 999px; padding: 3px; gap: 2px; }
.seg button { border: 0; background: transparent; color: var(--ink-3); font: inherit; font-size: 12.5px; font-weight: 500; padding: 6px 13px; border-radius: 999px; cursor: pointer; transition: .14s; }
.seg button:hover { color: var(--ink-2); }
.seg button.active { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-sm); }

/* ===== chart ===== */
.chart-wrap { position: relative; height: 300px; }
@media (max-width: 560px) { .chart-wrap { height: 240px; } }
.empty { display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 52px 0; color: var(--ink-3); font-size: 13.5px; }
.empty .ic { color: var(--line); }

/* ===== журнал ===== */
.log-empty { text-align: center; color: var(--ink-3); padding: 28px 0; font-size: 13.5px; }
.log-day { display: flex; align-items: baseline; gap: var(--s2); padding: 16px 2px 7px; font-size: 11px; }
.log-day:first-child { padding-top: 0; }
.log-day .d { font-weight: 600; text-transform: uppercase; letter-spacing: .1em; color: var(--ink-2); }
.log-day .t { color: var(--ink-3); letter-spacing: .04em; }
.log-row { display: flex; align-items: center; gap: var(--s3); padding: 11px 10px; margin: 0 -10px; border-radius: var(--radius-sm); transition: background .12s; }
.log-row + .log-row { box-shadow: 0 -1px 0 var(--line-2); }
.log-row:hover { background: var(--surface-2); }
.log-row:hover + .log-row, .log-row:hover { box-shadow: none; }
.dot { width: 9px; height: 9px; border-radius: 2px; flex: 0 0 auto; }
.log-time { width: 42px; flex: 0 0 auto; color: var(--ink-3); font-size: 13px; font-variant-numeric: tabular-nums; }
.log-body { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; }
.log-cat { font-weight: 500; }
.log-cmt { color: var(--ink-3); }
.log-dur { flex: 0 0 auto; color: var(--ink-2); font-size: 13px; font-variant-numeric: tabular-nums; }
.badge-partial { font-size: 10.5px; font-weight: 500; text-transform: uppercase; letter-spacing: .06em; padding: 2px 7px; border-radius: 999px; color: var(--ink-3); border: 1px solid var(--line); }
.log-acts { display: inline-flex; gap: 2px; flex: 0 0 auto; opacity: 0; transition: opacity .12s; }
.log-row:hover .log-acts { opacity: 1; }
@media (hover: none) { .log-acts { opacity: 1; } }
.log-acts button { border: 0; background: transparent; color: var(--ink-3); cursor: pointer; padding: 5px; border-radius: 7px; display: grid; place-items: center; transition: .12s; }
.log-acts button:hover { color: var(--ink); background: var(--bg); }

.edit-row { display: flex; gap: var(--s2); align-items: center; flex-wrap: wrap; padding: 4px 0; }
.edit-row .select { width: auto; min-width: 130px; }
.edit-row .input { flex: 1; min-width: 150px; }

/* ===== ручное добавление ===== */
.manual { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: var(--s4); margin-bottom: var(--s4); background: var(--bg); }
.manual-grid { display: grid; grid-template-columns: 1fr 96px 1fr; gap: var(--s3); }
.manual-cmt { grid-column: 1 / -1; }
.manual .actions { margin-top: var(--s4); }
@media (max-width: 560px) { .manual-grid { grid-template-columns: 1fr; } }

/* ===== footer ===== */
.foot { display: flex; align-items: center; justify-content: space-between; gap: var(--s4); flex-wrap: wrap; margin-top: clamp(20px, 3vw, 32px); padding-top: var(--s4); border-top: 1px solid var(--line); color: var(--ink-3); font-size: 12.5px; }
.link { display: inline-flex; align-items: center; gap: 7px; background: none; border: 0; color: var(--ink-2); cursor: pointer; font: inherit; font-size: 12.5px; padding: 0; transition: color .12s; }
.link:hover { color: var(--ink); }
@media (max-width: 480px) { .brand-tag { display: none; } }

.hidden { display: none !important; }

/* подстраховка от горизонтальной прокрутки на мобильном (sticky-колонка только >=920px) */
@media (max-width: 919px) { html, body { overflow-x: hidden; } }

/* ===== login gate ===== */
.gate { position: fixed; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center; padding: 24px; background: var(--bg); }
.gate-card { width: 100%; max-width: 320px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: clamp(26px, 4vw, 34px); text-align: center; }
.gate-mark { display: inline-flex; color: var(--ink); margin-bottom: 14px; }
.gate-mark .ic { width: 26px; height: 26px; }
.gate-title { font-size: 20px; font-weight: 600; letter-spacing: -.01em; }
.gate-sub { font-size: 13px; color: var(--ink-3); margin-top: 4px; margin-bottom: 22px; }
.gate .input { text-align: center; letter-spacing: .28em; font-size: 16px; }
.gate-err { min-height: 17px; font-size: 12.5px; color: var(--ink-2); margin: 10px 0 12px; }
.gate .btn { width: 100%; }

/* ===== toast ===== */
.toast { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 14px); background: var(--ink); color: var(--bg); font-size: 13.5px; padding: 11px 16px; border-radius: 10px; box-shadow: var(--shadow); opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 50; max-width: calc(100vw - 32px); }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
