:root {
    --bg: #F5F5F8; --surface: #FFFFFF; --text: #1B1B22; --muted: #5B5D6B; --line: #E6E6EC; --line-soft: #F0F0F4;
    --field-line: #D9D9E2; --field: #FAFAFC; --accent: #6D28D9; --accent-dark: #5B21B6; --accent-soft: #F1EAFD;
    --neutral: #EDEDF2; --neutral-text: #4A4C58;
    --ok-bg: #E4F4EA; --ok: #17663A; --wait-bg: #FFF1D6; --wait: #7A4A00; --bad-bg: #FDECEC; --bad: #8E1B1B; --danger: #C62828;
}

* { box-sizing: border-box; }
/* Прокручивается только .scroll: иначе на iOS жест перехватывает сама страница. */
html, body { height: 100%; margin: 0; overflow: hidden; overscroll-behavior: none; }
body { background: var(--neutral); color: var(--text); font: 15px/1.4 Inter, system-ui, sans-serif; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; opacity: .55; }
a { color: var(--accent); }
h1, h2, p { margin: 0; }
svg { flex: none; }
[hidden] { display: none !important; }

.screen { position: relative; display: flex; flex-direction: column; height: 100vh; height: 100dvh; max-width: 480px; margin: 0 auto; background: var(--bg); overflow: hidden; }
.scroll { flex: 1; min-height: 0; overflow-x: hidden; overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; touch-action: pan-y; display: flex; flex-direction: column; gap: 20px; padding: 16px 16px 24px; }
.scroll.tight { gap: 10px; padding-top: 12px; }
/* Иначе длинный список сжимается по высоте экрана, обрезается и его нельзя пролистать. */
.scroll > * { flex: none; }
.scroll > .center { flex: 0 1 auto; }
.center { margin: auto; padding: 24px; text-align: center; }
.muted { color: var(--muted); font-size: 13px; }
.grow { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.ellipsis { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stack { display: flex; flex-direction: column; gap: 10px; }

.topbar { display: flex; align-items: center; justify-content: space-between; padding: 20px 16px 12px; background: var(--surface); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 8px; font-size: 19px; font-weight: 700; letter-spacing: -.2px; }
.titlebar { display: flex; align-items: center; gap: 4px; padding: 16px 8px 8px; background: var(--surface); }
.titlebar.bordered { border-bottom: 1px solid var(--line); padding-bottom: 12px; }
.titlebar .chip { margin-right: 8px; }
.icon-button { flex: none; width: 44px; height: 44px; border: 0; border-radius: 12px; background: transparent; display: flex; align-items: center; justify-content: center; color: inherit; }
.icon-button.danger { color: var(--danger); }
.page-title { font-size: 26px; font-weight: 700; letter-spacing: -.4px; }
.section-title { font-size: 18px; font-weight: 600; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; }
.card.pad { padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.deadline { display: flex; align-items: center; gap: 6px; color: #8A3D00; font-size: 13px; font-weight: 600; }
.card-title { font-size: 17px; font-weight: 600; line-height: 1.3; }

.primary, .secondary { display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; min-height: 46px; border: 0; border-radius: 12px; font-weight: 600; text-decoration: none; }
.primary { background: var(--accent); color: #FFFFFF; }
.secondary { background: var(--accent-soft); color: var(--accent-dark); }
.footer { background: var(--surface); border-top: 1px solid var(--line); padding: 12px 16px 24px; display: flex; flex-direction: column; gap: 8px; }
.footer .primary { min-height: 50px; border-radius: 14px; font-size: 16px; }
.link-button { border: 0; background: none; padding: 8px 0; color: var(--accent); font-weight: 500; }

.actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.action { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 12px 4px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; font-size: 12px; font-weight: 500; text-align: center; }
.action-icon, .doc-icon { width: 36px; height: 36px; border-radius: 10px; background: var(--accent-soft); color: var(--accent); display: flex; align-items: center; justify-content: center; flex: none; }

.list { overflow: hidden; }
.row { display: flex; align-items: center; gap: 12px; width: 100%; padding: 12px 14px; min-height: 44px; border: 0; border-bottom: 1px solid var(--line-soft); background: transparent; color: inherit; text-align: left; text-decoration: none; }
.row:last-child { border-bottom: 0; }
.row-title { font-size: 15px; font-weight: 500; }
.row-title.bold { font-weight: 600; }

.chip { flex: none; display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--neutral); color: var(--neutral-text); }
.chip.ok { background: var(--ok-bg); color: var(--ok); }
.chip.wait { background: var(--wait-bg); color: var(--wait); }
.chip.bad { background: var(--bad-bg); color: var(--bad); }
.chip.accent { background: var(--accent-soft); color: var(--accent-dark); }

.event { display: flex; gap: 12px; align-items: center; width: 100%; padding: 12px; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; color: inherit; text-align: left; }
.date-box { width: 62px; height: 56px; flex: none; border-radius: 12px; background: var(--accent-soft); color: var(--accent-dark); display: flex; flex-direction: column; align-items: center; justify-content: center; }
.date-box b { font-size: 17px; line-height: 1; white-space: nowrap; }
.date-box span { font-size: 11px; font-weight: 600; text-transform: uppercase; margin-top: 3px; }
.date-box.wide span { margin-top: 0; white-space: nowrap; }
.date-box.wide span + span { margin-top: 3px; }

.hero { background: var(--surface); padding: 8px 16px 20px; display: flex; flex-direction: column; gap: 14px; border-bottom: 1px solid var(--line); }
.hero h1 { font-size: 24px; font-weight: 700; line-height: 1.25; letter-spacing: -.3px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.facts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.fact { display: flex; flex-direction: column; gap: 4px; }
.fact.wide { grid-column: span 2; }
.fact span { font-size: 13px; color: var(--muted); }
.fact b { font-size: 15px; font-weight: 500; }
.event-body > * { flex: none; }
.event-body { flex: 1; min-height: 0; overflow-x: hidden; overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; touch-action: pan-y; display: flex; flex-direction: column; gap: 16px; padding-bottom: 24px; }
.event-section { padding: 0 16px; display: flex; flex-direction: column; gap: 10px; }

.tabs { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 4px; padding: 4px; background: var(--neutral); border-radius: 12px; }
.tabs-wrap { background: var(--surface); padding: 0 16px 12px; border-bottom: 1px solid var(--line); }
.tab { min-height: 40px; border: 0; border-radius: 9px; background: transparent; color: var(--neutral-text); font-size: 14px; font-weight: 600; display: flex; align-items: center; justify-content: center; gap: 6px; }
.tab.on { background: var(--surface); color: var(--accent-dark); box-shadow: 0 1px 2px rgba(20, 20, 30, .12); }
.tab small { font-size: 12px; padding: 1px 7px; border-radius: 999px; background: #E0E0E8; }
.tab.on small { background: var(--accent-soft); }

.entry { padding: 12px 12px 12px 14px; display: flex; flex-direction: column; gap: 10px; }
.entry-head { display: flex; align-items: flex-start; gap: 8px; }
.entry-category { padding: 10px 12px; border: 1px solid var(--field-line); border-radius: 10px; background: var(--field); font-size: 14px; line-height: 1.35; }

.overlay { position: absolute; inset: 0; z-index: 2; background: rgba(20, 20, 30, .45); display: flex; flex-direction: column; justify-content: flex-end; }
.sheet { background: var(--surface); border-radius: 20px 20px 0 0; padding: 8px 16px 24px; display: flex; flex-direction: column; gap: 12px; max-height: 85%; }
.grabber { align-self: center; width: 40px; height: 4px; border-radius: 2px; background: var(--field-line); }
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.sheet-head b { font-size: 18px; font-weight: 600; }
.sheet-list { display: flex; flex-direction: column; overflow-y: auto; min-height: 0; }
.pick { display: flex; align-items: center; gap: 12px; min-height: 56px; padding: 6px 2px; border: 0; border-bottom: 1px solid var(--line-soft); background: transparent; text-align: left; }
.box { flex: none; width: 24px; height: 24px; border-radius: 7px; display: flex; align-items: center; justify-content: center; border: 2px solid #B9B9C6; background: var(--surface); color: #FFFFFF; }
.pick[aria-checked="true"] .box { border: 0; background: var(--accent); }
.search { display: flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 12px; border: 1px solid var(--field-line); border-radius: 12px; background: var(--field); color: var(--muted); }
.search input { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; color: var(--text); }
.alert { padding: 10px 12px; border-radius: 10px; background: var(--bad-bg); color: var(--bad); font-size: 13px; line-height: 1.4; }

.data-head { background: var(--surface); border-bottom: 1px solid var(--line); padding: 16px 0 10px; display: flex; flex-direction: column; gap: 8px; }
.data-head h1 { padding: 0 16px; }
.sections { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 4px; padding: 0 12px; }
.section-chip { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; min-width: 0; min-height: 50px; padding: 4px 0; border: 0; border-radius: 12px; background: transparent; color: var(--neutral-text); }
.section-chip small { font-size: 12px; font-weight: 600; line-height: 1; color: var(--muted); }
.section-chip.on { background: var(--accent-soft); color: var(--accent-dark); }
.section-chip.on small { color: var(--accent-dark); }
.section-name { padding: 0 16px; font-size: 15px; font-weight: 600; }
.filters { display: flex; gap: 6px; flex-wrap: wrap; }
.filter { min-height: 36px; padding: 0 14px; border: 1px solid var(--field-line); border-radius: 10px; background: var(--surface); color: #33343F; font-size: 13px; font-weight: 600; }
.filter.on { background: var(--accent-soft); color: var(--accent-dark); border-color: #C9B2F5; }
.data-tools { padding: 0 16px; display: flex; flex-direction: column; gap: 10px; }
.avatar { flex: none; width: 40px; height: 40px; border-radius: 50%; background: var(--accent-soft); color: var(--accent-dark); font-size: 14px; font-weight: 700; display: flex; align-items: center; justify-content: center; }
.fab { position: absolute; right: 16px; bottom: 96px; width: 56px; height: 56px; border: 0; border-radius: 18px; background: var(--accent); color: #FFFFFF; display: flex; align-items: center; justify-content: center; box-shadow: 0 6px 16px rgba(109, 40, 217, .35); }

.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; flex: none; }
.field-label { font-size: 14px; font-weight: 500; }
.required { color: var(--danger); }
.field > input, .date-field > input { display: block; width: 100%; min-width: 0; height: 48px; padding: 0 14px; border: 1px solid var(--field-line); border-radius: 12px; background: var(--surface); font-size: 16px; appearance: none; -webkit-appearance: none; }
.field > input:focus, .date-field > input:focus, .select.open { outline: 0; border-color: var(--accent); box-shadow: 0 0 0 2px rgba(109, 40, 217, .15); }
.field > input:disabled { background: var(--neutral); }
.field input::placeholder { color: #8A8C99; }
.select { display: flex; align-items: center; justify-content: space-between; gap: 8px; width: 100%; min-width: 0; height: 48px; padding: 0 14px; border: 1px solid var(--field-line); border-radius: 12px; background: var(--surface); text-align: left; font-size: 16px; }
.select svg { color: var(--muted); }
.select.open svg { transform: rotate(180deg); }
.select-text { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.select-text.placeholder { color: #8A8C99; }
.options { display: flex; flex-direction: column; max-height: 220px; overflow-y: auto; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); box-shadow: 0 6px 16px rgba(20, 20, 30, .08); }
.option { flex: none; min-height: 46px; padding: 10px 14px; border: 0; border-bottom: 1px solid var(--line-soft); background: transparent; text-align: left; font-size: 15px; }
.option:last-child { border-bottom: 0; }
.option.on { background: var(--accent-soft); color: var(--accent-dark); font-weight: 600; }
.panel { padding: 8px 12px; max-height: 300px; }
.choices { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.choice { height: 48px; border: 1px solid var(--field-line); border-radius: 12px; background: var(--surface); font-size: 16px; font-weight: 600; }
.choice.on { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-dark); }
.date-field { position: relative; }
.date-field > input { padding-right: 52px; }
.date-button { position: absolute; top: 0; right: 0; width: 48px; height: 48px; display: flex; align-items: center; justify-content: center; color: var(--muted); overflow: hidden; border-radius: 0 12px 12px 0; }
.date-native { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; border: 0; padding: 0; cursor: pointer; }
.outline-button { display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; height: 46px; border: 1px solid var(--field-line); border-radius: 12px; background: var(--surface); font-weight: 500; }
.music-rows { display: flex; flex-direction: column; gap: 10px; }
.music-row { display: flex; flex-direction: column; gap: 8px; padding: 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--bg); }
.music-player { width: 100%; height: 40px; }
.music-remove { align-self: flex-start; color: var(--danger); padding: 4px 0; }
.dashed-button { display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; height: 46px; border: 1px dashed var(--field-line); border-radius: 12px; background: var(--surface); font-weight: 500; }
.sheet { width: 100%; min-width: 0; overflow: hidden; }
.sheet-form { display: flex; flex-direction: column; gap: 14px; overflow-x: hidden; overflow-y: auto; min-height: 0; touch-action: pan-y; overscroll-behavior: contain; padding: 2px; }
.checklist { display: flex; flex-direction: column; gap: 8px; min-height: 0; }
.checklist .sheet-list { max-height: 240px; }
.search input { font-size: 16px; }
.picker { min-height: 0; display: flex; flex-direction: column; }
.danger-button { width: 100%; min-height: 44px; border: 0; border-radius: 12px; background: var(--bad-bg); color: var(--bad); font-weight: 600; flex: none; }
.sheet-form .primary { flex: none; }

.tabbar { display: flex; background: var(--surface); border-top: 1px solid var(--line); padding: 6px 4px 20px; }
.tabbar button { flex: 1; min-height: 48px; border: 0; background: transparent; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; color: var(--muted); font-size: 11px; font-weight: 500; }
.tabbar button[aria-current="page"] { color: var(--accent); font-weight: 600; }

.auth { flex: 1; overflow-y: auto; padding: 32px 16px; display: flex; flex-direction: column; gap: 16px; }
.auth form { display: flex; flex-direction: column; gap: 12px; padding: 16px; }
.auth label { display: flex; flex-direction: column; gap: 4px; font-size: 14px; }
.auth label input { min-height: 44px; padding: 0 12px; border: 1px solid var(--field-line); border-radius: 12px; background: var(--field); }
.consent { display: flex; align-items: flex-start; gap: 10px; font-size: 13px; line-height: 1.4; color: var(--muted); }
.consent input { flex: none; width: 22px; height: 22px; margin: 0; accent-color: var(--accent); }
.inline-link { display: inline; border: 0; padding: 0; background: none; color: var(--accent); font-size: inherit; text-decoration: underline; }
