/* Планер. Раскладка: липкая шапка с быстрым вводом; ниже «Неделя» или «Доска»; редактор — панель справа (на телефоне снизу).
   Основа — прототип v1. Шрифты системные: без внешних CDN. */
:root {
  --bg: #f5f6f4;
  --surface: #ffffff;
  --surface-2: #eceeea;
  --line: #d9ddd6;
  --fg: #1d2420;
  --muted: #5e6a63;
  --accent: #1f6f5c;
  --accent-soft: #d7ebe4;
  --p3: #c2410c;
  --p3-soft: #fbe3d6;
  --p2: #a16207;
  --p2-soft: #f8ecc8;
  --p1: #2f6f9f;
  --p1-soft: #dbe9f4;
  --p0: #7a857e;
  --p0-soft: #e6e9e5;
  --event: #6b4fa0;
  --danger: #b42318;
  --shadow: 0 1px 2px rgba(20, 30, 25, .06), 0 4px 14px rgba(20, 30, 25, .06);
  --font-ui: "Segoe UI", system-ui, -apple-system, "Roboto", "Helvetica Neue", Arial, sans-serif;
  --r: 10px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #131815; --surface: #1b211e; --surface-2: #222a26; --line: #303a35; --fg: #e6ebe7; --muted: #9aa7a0;
    --accent: #5cc3a6; --accent-soft: #1d3a31;
    --p3: #f08a5d; --p3-soft: #3d241a; --p2: #e0b54a; --p2-soft: #3a3019; --p1: #7fb4e0; --p1-soft: #1b2d3c; --p0: #8c9891; --p0-soft: #262d29;
    --event: #b39ae0; --danger: #f97066; --shadow: 0 1px 2px rgba(0,0,0,.4), 0 6px 18px rgba(0,0,0,.35);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #131815; --surface: #1b211e; --surface-2: #222a26; --line: #303a35; --fg: #e6ebe7; --muted: #9aa7a0;
  --accent: #5cc3a6; --accent-soft: #1d3a31;
  --p3: #f08a5d; --p3-soft: #3d241a; --p2: #e0b54a; --p2-soft: #3a3019; --p1: #7fb4e0; --p1-soft: #1b2d3c; --p0: #8c9891; --p0-soft: #262d29;
  --event: #b39ae0; --danger: #f97066; --shadow: 0 1px 2px rgba(0,0,0,.4), 0 6px 18px rgba(0,0,0,.35);
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--fg); font-family: var(--font-ui); font-size: 15px; line-height: 1.45; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; opacity: .55; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
[hidden] { display: none !important; }
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
body::before { content: ""; position: fixed; inset: 0 0 auto; height: env(safe-area-inset-top, 0px); z-index: 10; background: var(--surface); }

.top { position: sticky; top: env(safe-area-inset-top, 0px); z-index: 5; background: var(--surface); border-bottom: 1px solid var(--line);
  padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); padding-block: 12px; }
.top-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.brand { font-weight: 700; font-size: 18px; letter-spacing: .01em; margin: 0; }
.brand small { font-weight: 500; font-size: 12px; color: var(--muted); margin-left: 6px; letter-spacing: 0; }
.tabs { display: flex; gap: 4px; background: var(--surface-2); padding: 3px; border-radius: 999px; margin-left: auto; }
.tabs button { border: 0; background: transparent; padding: 6px 14px; border-radius: 999px; color: var(--muted); font-weight: 500; }
.tabs button[aria-selected="true"] { background: var(--surface); color: var(--fg); box-shadow: var(--shadow); }
.icon-btn { border: 1px solid var(--line); background: var(--surface); border-radius: 999px; width: 36px; height: 36px; display: grid; place-items: center; flex: none; padding: 0; }
.icon-btn svg { width: 18px; height: 18px; }

.quick { margin-top: 10px; display: flex; gap: 8px; align-items: center; }
.kind { display: flex; border: 1px solid var(--line); border-radius: 999px; overflow: hidden; flex: none; }
.kind button { border: 0; background: transparent; padding: 8px 12px; color: var(--muted); font-weight: 500; display: flex; align-items: center; gap: 6px; }
.kind button[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent); }
.kind svg { width: 15px; height: 15px; }
.quick input { flex: 1; min-width: 0; border: 1px solid var(--line); background: var(--bg); border-radius: 999px; padding: 9px 16px; }
.quick input:focus { outline: none; border-color: var(--accent); background: var(--surface); }
.add-btn { border: 0; background: var(--accent); color: var(--surface); border-radius: 999px; padding: 9px 16px; font-weight: 600; flex: none; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; min-height: 24px; align-items: center; }
.chip { font-size: 12px; padding: 3px 9px; border-radius: 999px; background: var(--surface-2); color: var(--muted); }
.chip.on { background: var(--accent-soft); color: var(--accent); }
.hint { font-size: 12px; color: var(--muted); }
.link-btn { border: 0; background: none; color: var(--accent); font-size: 13px; padding: 2px 4px; font-weight: 500; }

main { padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); padding-block: 16px 40px; }
.banner { font-size: 13px; color: var(--muted); background: var(--surface); border: 1px dashed var(--line); border-radius: var(--r); padding: 8px 12px; margin-bottom: 14px; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.banner.error { color: var(--danger); border-color: var(--danger); }

/* фокус недели */
.focus { background: var(--surface); border: 1px solid var(--line); border-left: 4px solid var(--accent); border-radius: var(--r); padding: 10px 12px; margin-bottom: 14px; }
.focus h3 { margin: 0 0 6px; font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 600; }
.focus ul { margin: 0; padding: 0; list-style: none; display: flex; gap: 8px; flex-wrap: wrap; }
.focus li button { border: 1px solid var(--line); background: var(--bg); border-radius: 999px; padding: 4px 12px; font-weight: 500; text-align: left; }

/* неделя */
.week-head { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; }
.week-head h2 { font-weight: 600; font-size: 16px; margin: 0 6px 0 0; }
.pager button { border: 1px solid var(--line); background: var(--surface); border-radius: 8px; padding: 5px 10px; }
.week-layout { display: grid; grid-template-columns: minmax(0, 1fr) 260px; gap: 16px; align-items: start; }
.days-scroll { overflow-x: auto; min-width: 0; }
.days { display: grid; grid-template-columns: repeat(7, minmax(132px, 1fr)); gap: 8px; min-width: 940px; }
.day { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); min-height: 360px; display: flex; flex-direction: column; }
.day.today { border-color: var(--accent); }
.day.drop { background: var(--accent-soft); }
.day-h { padding: 8px 10px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: baseline; }
.day-h b { font-weight: 600; }
.day-h span { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.day.today .day-h b { color: var(--accent); }
.day-body { padding: 6px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.day-empty { color: var(--muted); font-size: 12px; padding: 6px 4px; }
.item { border-radius: 8px; padding: 6px 8px 7px; background: var(--p0-soft); border: 0; border-left: 3px solid var(--p0); text-align: left; width: 100%; display: flex; flex-direction: column; gap: 2px; }
.item[data-p="3"] { background: var(--p3-soft); border-left-color: var(--p3); }
.item[data-p="2"] { background: var(--p2-soft); border-left-color: var(--p2); }
.item[data-p="1"] { background: var(--p1-soft); border-left-color: var(--p1); }
.item .time { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; display: flex; align-items: center; gap: 5px; }
.item .time svg { width: 13px; height: 13px; flex: none; }
.item .time .ev { color: var(--event); }
.item .t { font-size: 13.5px; font-weight: 500; overflow-wrap: anywhere; }
.item .meta { font-size: 12px; color: var(--muted); overflow-wrap: anywhere; }
.item.done .t { text-decoration: line-through; color: var(--muted); }
.item.flag { background: transparent; border: 1px dashed var(--line); border-left: 3px solid var(--p0); }
.item.flag[data-p="3"] { border-left-color: var(--p3); }
.item.flag[data-p="2"] { border-left-color: var(--p2); }
.item.flag[data-p="1"] { border-left-color: var(--p1); }
.side { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 10px; display: flex; flex-direction: column; gap: 6px; }
.side.drop { background: var(--accent-soft); }
.side h3, .col h3 { margin: 0 0 4px; font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 600; display: flex; justify-content: space-between; }
.legend { display: flex; gap: 12px; flex-wrap: wrap; font-size: 12px; color: var(--muted); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }
.legend .p3 { background: var(--p3); }
.legend .p2 { background: var(--p2); }
.legend .p1 { background: var(--p1); }
.legend .p0 { background: var(--p0); }

/* доска */
.board { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; align-items: start; }
.col { background: var(--surface-2); border-radius: var(--r); padding: 10px; display: flex; flex-direction: column; gap: 8px; min-height: 200px; }
.col.drop { outline: 2px dashed var(--accent); }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 9px; padding: 10px; display: flex; flex-direction: column; gap: 6px; box-shadow: var(--shadow); border-left: 4px solid var(--p0); text-align: left; width: 100%; }
.card[data-p="3"] { border-left-color: var(--p3); }
.card[data-p="2"] { border-left-color: var(--p2); }
.card[data-p="1"] { border-left-color: var(--p1); }
.card .t { font-weight: 600; overflow-wrap: anywhere; border: 0; background: none; padding: 0; text-align: left; }
.card .row { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.tag { font-size: 11.5px; padding: 2px 8px; border-radius: 999px; background: var(--surface-2); color: var(--muted); }
.tag.late { background: var(--p3-soft); color: var(--p3); }
.move { display: flex; gap: 6px; flex-wrap: wrap; }
.move button { border: 1px solid var(--line); background: var(--bg); border-radius: 7px; font-size: 12px; padding: 3px 8px; }
.more-done { font-size: 12px; color: var(--muted); padding: 4px; }

/* панель редактора и настроек */
.scrim { position: fixed; inset: 0; background: rgba(10, 15, 12, .35); z-index: 20; }
.sheet { position: fixed; z-index: 21; top: 0; right: 0; bottom: 0; width: min(440px, 100%); background: var(--surface); box-shadow: var(--shadow);
  display: flex; flex-direction: column; padding-top: env(safe-area-inset-top, 0px); padding-bottom: env(safe-area-inset-bottom, 0px); padding-right: env(safe-area-inset-right, 0px); }
.sheet-h { display: flex; align-items: center; gap: 8px; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.sheet-h h2 { margin: 0; font-size: 16px; font-weight: 600; flex: 1; }
.sheet-b { overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 14px; flex: 1; }
.sheet-f { padding: 12px 16px; border-top: 1px solid var(--line); display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.field { display: flex; flex-direction: column; gap: 5px; }
.field > span { font-size: 12px; color: var(--muted); font-weight: 500; }
.field input, .field textarea, .field select { border: 1px solid var(--line); background: var(--bg); border-radius: 8px; padding: 8px 10px; width: 100%; }
.field textarea { min-height: 70px; resize: vertical; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.seg { display: flex; flex-wrap: wrap; gap: 6px; }
.seg button { border: 1px solid var(--line); background: var(--bg); border-radius: 999px; padding: 5px 12px; font-size: 13px; }
.seg button[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.seg .dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; vertical-align: 1px; }
.seg .dot.p0 { background: var(--p0); }
.seg .dot.p1 { background: var(--p1); }
.seg .dot.p2 { background: var(--p2); }
.seg .dot.p3 { background: var(--p3); }
details.more { border: 1px solid var(--line); border-radius: var(--r); padding: 0 12px; }
details.more summary { padding: 10px 0; cursor: pointer; font-weight: 500; color: var(--accent); }
details.more[open] { padding-bottom: 12px; }
details.more .inner { display: flex; flex-direction: column; gap: 12px; }
.check-row { display: flex; gap: 8px; align-items: center; }
.check-row input[type=text] { flex: 1; min-width: 0; border: 1px solid var(--line); background: var(--bg); border-radius: 8px; padding: 6px 8px; }
.inline-check { display: flex; gap: 8px; align-items: center; font-size: 14px; }
.btn { border: 1px solid var(--line); background: var(--surface); border-radius: 8px; padding: 8px 14px; font-weight: 500; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--surface); }
.btn.danger { color: var(--danger); }
.push-right { margin-left: auto; }
.note { font-size: 12px; color: var(--muted); }
.error-text { font-size: 13px; color: var(--danger); }
.section { display: flex; flex-direction: column; gap: 8px; padding-bottom: 14px; border-bottom: 1px solid var(--line); }
.section:last-child { border-bottom: 0; }
.section h3 { margin: 0; font-size: 14px; }
.code { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: 22px; letter-spacing: .12em; background: var(--surface-2); border-radius: 8px; padding: 8px 12px; align-self: flex-start; user-select: all; }
.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(16px + env(safe-area-inset-bottom, 0px)); background: var(--fg); color: var(--bg); padding: 8px 14px; border-radius: 999px; font-size: 13px; z-index: 30; max-width: calc(100% - 32px); }
.toast.error { background: var(--danger); color: #fff; }

/* страница входа */
.login-page { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); padding: 24px; width: min(360px, 100%); display: flex; flex-direction: column; gap: 14px; }
.login-card h1 { margin: 0; font-size: 22px; }
.login-card .btn { width: 100%; padding: 10px; }

@media (max-width: 480px) {
  .kind .kind-label { display: none; }
  .kind button { padding: 8px 11px; }
}
@media (max-width: 760px) {
  .week-layout { grid-template-columns: minmax(0, 1fr); }
  .days { grid-template-columns: minmax(0, 1fr); min-width: 0; }
  .day { min-height: 0; }
  .board { grid-template-columns: minmax(0, 1fr); }
  .tabs { margin-left: 0; }
  .brand small { display: none; }
  .sheet { top: auto; height: min(88%, 720px); width: 100%; border-radius: 16px 16px 0 0; }
  .quick { flex-wrap: wrap; }
  .quick input { flex-basis: 100%; order: 3; }
}
@media (prefers-reduced-motion: no-preference) {
  .sheet { animation: slide .18s ease-out; }
  @keyframes slide { from { transform: translateX(16px); opacity: .6; } to { transform: none; opacity: 1; } }
}
