/* ============ шрифт ============ */
@font-face { font-family: 'Onest'; font-weight: 100 900; font-display: swap; src: url('/static/fonts/onest-cyrillic-ext-wght-normal.woff2') format('woff2'); unicode-range: U+0460-052F, U+1C80-1C8A, U+20B4, U+2DE0-2DFF, U+A640-A69F, U+FE2E-FE2F; }
@font-face { font-family: 'Onest'; font-weight: 100 900; font-display: swap; src: url('/static/fonts/onest-cyrillic-wght-normal.woff2') format('woff2'); unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: 'Onest'; font-weight: 100 900; font-display: swap; src: url('/static/fonts/onest-latin-ext-wght-normal.woff2') format('woff2'); unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: 'Onest'; font-weight: 100 900; font-display: swap; src: url('/static/fonts/onest-latin-wght-normal.woff2') format('woff2'); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }

/* ============ палитры: бумажный ежедневник с синими чернилами ============ */
:root {
  --font: 'Onest', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --serif: 'Iowan Old Style', 'Palatino Linotype', Palatino, Georgia, 'Times New Roman', serif;
  --bg: #f5f3ee;
  --surface: #fffefb;
  --surface-2: #efece4;
  --sunken: #ebe8df;
  --line: #e0dcd0;
  --line-strong: #c9c4b6;
  --text: #25231f;
  --text-2: #5f5b52;
  --text-3: #8b867a;
  --accent: #2f4d8c;
  --accent-hover: #243d72;
  --on-accent: #ffffff;
  --accent-soft: #e7ecf5;
  --now: #c8372d;
  --hi: #a8620a;
  --ok: #3c7a47;
  --danger: #b3342a;
  --danger-soft: #f8e7e4;
  --shadow: 0 1px 2px rgba(37, 35, 31, 0.08), 0 8px 20px rgba(37, 35, 31, 0.1);
  --overlay: rgba(37, 35, 31, 0.4);
  --r: 6px;
  --r-lg: 8px;
  --gutter: 46px;
  --sidebar: 224px;
  --tabbar: 58px;
  color-scheme: light;
}

:root[data-theme='dark'] {
  --bg: #161513;
  --surface: #1e1c19;
  --surface-2: #27241f;
  --sunken: #12110f;
  --line: #312e28;
  --line-strong: #46413a;
  --text: #ece8df;
  --text-2: #a8a297;
  --text-3: #7a756b;
  --accent: #8ea7dc;
  --accent-hover: #adc0e8;
  --on-accent: #101828;
  --accent-soft: #212a3f;
  --now: #ff6b5e;
  --hi: #e0a14d;
  --ok: #7ab98a;
  --danger: #f0786d;
  --danger-soft: #3a1f1c;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 10px 26px rgba(0, 0, 0, 0.5);
  --overlay: rgba(0, 0, 0, 0.62);
  color-scheme: dark;
}

/* ============ база ============ */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font: 14.5px/1.45 var(--font);
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  font-feature-settings: 'tnum' 1;
  overflow: hidden;
}
body.modal-open { overscroll-behavior: contain; }
h1, h2, h3, p { margin: 0; }
h1 { font: 500 28px/1.15 var(--serif); letter-spacing: -0.01em; }
h2 { font-size: 15px; font-weight: 600; }
h3 { font-size: 14px; font-weight: 600; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
code { font-family: ui-monospace, 'SF Mono', Menlo, monospace; font-size: 0.88em; }
.muted { color: var(--text-2); }
.icon { display: block; flex: none; }
/* цвета логотипа заданы классами, а не style="…": строгая CSP запрещает inline-стили */
.lg-lines { stroke: var(--on-accent); }
.lg-mark { stroke: var(--now); }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
.input:focus-visible, .chat-input:focus-visible { outline: none; }

.stack { display: flex; flex-direction: column; gap: 14px; }
.row { display: flex; align-items: center; gap: 10px; }
.row.end { justify-content: flex-end; }
.row.between { justify-content: space-between; }
.row.wrap { flex-wrap: wrap; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.divider { height: 1px; background: var(--line); margin: 4px 0; }

.brand { display: flex; align-items: center; gap: 9px; padding: 0 8px 18px; color: var(--accent); font: 600 20px/1 var(--serif); letter-spacing: -0.01em; }
.brand span { color: var(--text); }
.brand-logo { flex: none; box-sizing: border-box; padding: 4px; border-radius: 9px; background: #081314; object-fit: contain; }
.brand-logo-lg { padding: 6px; border-radius: 13px; }
.brand:hover { text-decoration: none; }

/* ============ кнопки и поля ============ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 34px; padding: 0 13px; border-radius: var(--r); border: 1px solid transparent;
  background: transparent; font-weight: 500; white-space: nowrap;
  transition: background 0.1s, border-color 0.1s, color 0.1s;
}
.btn:disabled { opacity: 0.5; cursor: default; }
.btn-ghost { border-color: var(--line-strong); background: var(--surface); }
.btn-ghost:hover:not(:disabled) { background: var(--surface-2); }
.btn-ghost.is-current { color: var(--accent); border-color: var(--accent); }
.btn-primary { background: var(--accent); color: var(--on-accent); }
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover:not(:disabled) { filter: brightness(0.92); }
.btn-danger-ghost { color: var(--danger); }
.btn-danger-ghost:hover:not(:disabled) { background: var(--danger-soft); }
.btn-sm { height: 28px; padding: 0 9px; font-size: 13px; }
.btn-block { width: 100%; height: 40px; }

.icon-btn {
  display: inline-grid; place-items: center; width: 34px; height: 34px; flex: none;
  border-radius: var(--r); border: 1px solid transparent; background: transparent; color: var(--text-2);
  transition: background 0.1s, color 0.1s;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }

.input {
  width: 100%; height: 36px; padding: 0 10px; border-radius: var(--r);
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--text);
  transition: border-color 0.1s, box-shadow 0.1s;
}
textarea.input { height: auto; padding: 8px 10px; resize: vertical; line-height: 1.45; }
select.input { appearance: none; padding-right: 30px; 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='%238b867a' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='M6 9.5l6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 9px center; }
.input:hover:not(:disabled) { border-color: var(--text-3); }
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
.input:disabled { background: var(--surface-2); color: var(--text-2); }
.input::placeholder, .chat-input::placeholder { color: var(--text-3); }
input[type='date'].input, input[type='time'].input { min-width: 0; }

.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field-label { font-size: 13px; font-weight: 500; color: var(--text-2); }
.field-hint { font-size: 12.5px; color: var(--text-3); }
.input-group { display: flex; gap: 8px; align-items: center; }
.input-group .input { flex: 1; }

.segmented { display: inline-flex; padding: 2px; gap: 2px; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r); max-width: 100%; }
.seg {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 28px; padding: 0 11px;
  border: 0; border-radius: 4px; background: transparent; color: var(--text-2); font-weight: 500; white-space: nowrap;
}
.seg:hover:not(.is-active) { color: var(--text); }
.seg.is-active { background: var(--surface); color: var(--text); box-shadow: 0 0 0 1px var(--line-strong); }

.switch { display: inline-flex; align-items: center; gap: 9px; cursor: pointer; user-select: none; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch-track { position: relative; width: 34px; height: 20px; border-radius: 4px; background: var(--line-strong); transition: background 0.12s; flex: none; }
.switch-track::after { content: ''; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 3px; background: #fff; transition: transform 0.12s; }
.switch input:checked + .switch-track { background: var(--accent); }
.switch input:checked + .switch-track::after { transform: translateX(14px); }
.switch input:focus-visible + .switch-track { outline: 2px solid var(--accent); outline-offset: 2px; }
.switch-sm { font-size: 13px; color: var(--text-2); }

.swatches { display: flex; flex-wrap: wrap; gap: 8px; }
.swatch { width: 26px; height: 26px; border-radius: 4px; border: 2px solid transparent; background: var(--c); padding: 0; box-shadow: inset 0 0 0 2px var(--surface); }
.swatch.is-on { border-color: var(--text); }
.swatch-auto { background: repeating-linear-gradient(45deg, var(--line-strong) 0 4px, var(--surface) 4px 8px); }

.chip { display: inline-flex; align-items: center; gap: 4px; height: 20px; padding: 0 6px; border-radius: 4px; background: var(--surface-2); color: var(--text-2); font-size: 12px; line-height: 1; white-space: nowrap; max-width: 100%; }
.chip .icon { opacity: 0.85; }
.chip-project { background: color-mix(in srgb, var(--c) 13%, transparent); color: var(--text); overflow: hidden; text-overflow: ellipsis; }
.chip-late { background: var(--danger-soft); color: var(--danger); }
.chip-high { color: var(--hi); background: color-mix(in srgb, var(--hi) 14%, transparent); padding: 0 4px; }
.chip-quiet { padding: 0 4px; background: transparent; }
.chip-ok { background: color-mix(in srgb, var(--ok) 14%, transparent); color: var(--ok); }
.chip-accent { background: var(--accent-soft); color: var(--accent); }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 2px; background: var(--c, var(--accent)); flex: none; }
.dot-lg { width: 12px; height: 12px; }
.count { display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 5px; border-radius: 4px; background: var(--sunken); color: var(--text-2); font-size: 12px; font-weight: 500; }

.notice { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 9px 12px; margin-bottom: 10px; border-radius: var(--r); border: 1px solid var(--line); border-left: 3px solid var(--accent); background: var(--surface); font-size: 14px; }
.notice span { flex: 1; min-width: 160px; }
.form-error { padding: 9px 12px; border-radius: var(--r); background: var(--danger-soft); color: var(--danger); font-size: 14px; }
.link { border: 0; background: none; padding: 0; color: var(--accent); font-weight: 500; }
.link:hover { text-decoration: underline; }

.empty { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 6px; padding: 48px 20px; color: var(--text-2); }
.empty strong { color: var(--text); font: 500 19px/1.2 var(--serif); }
.empty p { max-width: 40ch; margin-bottom: 8px; }
.empty-icon { display: grid; place-items: center; color: var(--text-3); margin-bottom: 4px; }

/* ============ уведомления и окна ============ */
#toasts { position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; z-index: 100; width: min(440px, calc(100vw - 24px)); pointer-events: none; }
.toast { padding: 10px 14px; border-radius: var(--r); background: var(--text); color: var(--bg); box-shadow: var(--shadow); font-size: 14px; animation: toast-in 0.16s ease-out; pointer-events: auto; }
.toast-error { background: var(--danger); color: #fff; }
.toast.is-leaving { opacity: 0; transition: opacity 0.2s; }
@keyframes toast-in { from { transform: translateY(6px); opacity: 0; } }

.overlay { position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; padding: 20px; background: var(--overlay); animation: fade-in 0.12s ease-out; overflow-y: auto; }
.overlay.is-leaving { opacity: 0; transition: opacity 0.12s; }
.modal { width: min(480px, 100%); max-height: calc(100dvh - 40px); display: flex; flex-direction: column; background: var(--surface); border-radius: var(--r-lg); border: 1px solid var(--line-strong); box-shadow: var(--shadow); animation: pop-in 0.14s ease-out; }
.modal-wide { width: min(660px, 100%); }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 12px 4px 18px; }
.modal-head h2 { font: 500 19px/1.2 var(--serif); }
.modal-body { padding: 8px 18px 18px; overflow-y: auto; }
@keyframes fade-in { from { opacity: 0; } }
@keyframes pop-in { from { opacity: 0; transform: translateY(6px); } }

/* ============ полосы прокрутки ============ */
/* На компьютере: тонкие и в цвет темы. На телефоне и сенсорных экранах полос нет, прокрутка пальцем. */
* { scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb { border: 3px solid transparent; border-radius: 6px; background: var(--line-strong); background-clip: content-box; }
*::-webkit-scrollbar-thumb:hover { background: var(--text-3); background-clip: content-box; }
*::-webkit-scrollbar-corner { background: transparent; }

@media (max-width: 860px), (pointer: coarse) {
  * { scrollbar-width: none; }
  *::-webkit-scrollbar { display: none; width: 0; height: 0; }
  html, body { overflow-x: hidden; }
  /* 16 px в полях ввода: иначе iOS приближает страницу при фокусе */
  .input, .chat-input, textarea.input, select.input { font-size: 16px; }
  .input { height: 40px; }
  textarea.input { height: auto; }
  .btn { height: 38px; }
  .btn-sm { height: 32px; }
  .icon-btn { width: 38px; height: 38px; }
  .seg { height: 32px; }
}

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