:root {
  color-scheme: light;
  --bg: #F5F7FA;
  --surface: #FFFFFF;
  --surface-soft: #EDF2F5;
  --primary: #526D82;
  --primary-dark: #40596C;
  --text: #25313C;
  --muted: #6B7785;
  --line: #DDE4E9;
  --success: #6F9183;
  --warning: #C38B5F;
  --danger: #B86B6B;
  --shadow: 0 10px 28px rgba(37, 49, 60, .08);
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--bg); color: var(--text); }
body {
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
  padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom);
}
button, input { font: inherit; }
button { color: inherit; }
.hidden { display: none !important; }
.shell { width: min(100%, 720px); min-height: 100vh; margin: 0 auto; padding: 22px 16px 40px; }
.topbar { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.eyebrow { margin: 0 0 3px; color: var(--primary); font-size: 11px; font-weight: 800; letter-spacing: .14em; }
h1 { margin: 0; font-size: 29px; line-height: 1.1; letter-spacing: -.03em; }
.sync { display: flex; align-items: center; gap: 7px; margin-top: 6px; color: var(--muted); font-size: 12px; white-space: nowrap; }
.sync span { width: 8px; height: 8px; border-radius: 50%; background: var(--warning); }
.sync.ok span { background: var(--success); }
.default-mode-card { display: grid; gap: 14px; margin-top: 24px; padding: 16px; border: 1px solid var(--line); border-radius: 18px; background: var(--surface); box-shadow: 0 4px 18px rgba(37,49,60,.045); }
.default-mode-copy h2 { margin: 2px 0 4px; font-size: 16px; }
.default-mode-copy p:last-child { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.4; }
.card-eyebrow { margin: 0; color: var(--primary); font-size: 10px; font-weight: 800; letter-spacing: .11em; }
.default-mode-switch { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; padding: 4px; border-radius: 14px; background: var(--surface-soft); }
.default-mode-switch button { min-height: 42px; padding: 0 10px; border: 0; border-radius: 11px; background: transparent; color: var(--muted); cursor: pointer; font-size: 13px; font-weight: 750; }
.default-mode-switch button.active { background: var(--surface); color: var(--primary-dark); box-shadow: 0 3px 10px rgba(37,49,60,.09); }
.week-nav { display: grid; grid-template-columns: 44px 1fr 44px; gap: 8px; align-items: center; margin: 22px 0 16px; }
.icon-button, .week-title { border: 0; background: transparent; cursor: pointer; }
.icon-button { width: 44px; height: 44px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); font-size: 30px; line-height: 1; }
.week-title { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.week-title strong { font-size: 15px; }
.week-title span { color: var(--muted); font-size: 11px; }
.days { display: grid; grid-template-columns: repeat(7, 1fr); gap: 5px; padding-bottom: 18px; overflow: hidden; }
.day { min-width: 0; padding: 9px 2px 8px; border: 1px solid transparent; border-radius: 14px; background: transparent; cursor: pointer; text-align: center; }
.day span { display: block; color: var(--muted); font-size: 10px; text-transform: uppercase; }
.day strong { display: block; margin-top: 5px; font-size: 16px; }
.day.has-lessons::after { content: ""; display: block; width: 4px; height: 4px; margin: 5px auto 0; border-radius: 50%; background: var(--primary); }
.day.active { border-color: var(--primary); background: var(--primary); color: white; box-shadow: 0 6px 16px rgba(82,109,130,.22); }
.day.active span { color: rgba(255,255,255,.78); }
.day.active::after { background: white; }
.add-lesson-button { display: flex; width: 100%; min-height: 58px; margin: 0 0 14px; padding: 10px 13px; border: 1px dashed var(--primary); border-radius: 16px; align-items: center; gap: 11px; background: rgba(82,109,130,.055); color: var(--primary-dark); cursor: pointer; text-align: left; }
.add-lesson-button .add-icon { display: grid; width: 34px; height: 34px; border-radius: 11px; place-items: center; background: var(--primary); color: white; font-size: 22px; line-height: 1; }
.add-lesson-button strong, .add-lesson-button small { display: block; }
.add-lesson-button strong { font-size: 14px; }
.add-lesson-button small { margin-top: 2px; color: var(--muted); font-size: 11px; font-weight: 500; }
.add-lesson-button.past-date { border-color: var(--line); background: var(--surface-soft); color: var(--muted); }
.content { min-height: 300px; }
.lesson-list { display: grid; gap: 12px; }
.lesson-card-wrap { position: relative; }
.lesson-card { position: relative; width: 100%; padding: 17px; border: 1px solid var(--line); border-radius: 18px; background: var(--surface); box-shadow: 0 4px 18px rgba(37,49,60,.045); cursor: pointer; text-align: left; }
.lesson-card-wrap.deletable .lesson-card { padding-right: 55px; }
.trash-button { position: absolute; z-index: 2; right: 11px; top: 11px; display: grid; width: 36px; height: 36px; border: 0; border-radius: 11px; place-items: center; background: #F7ECEC; color: var(--danger); cursor: pointer; font-size: 18px; }
.lesson-card:active { transform: scale(.992); }
.card-top { display: flex; justify-content: space-between; gap: 12px; }
.lesson-time { flex: 0 0 66px; color: var(--primary); font-size: 16px; font-weight: 800; }
.lesson-main { flex: 1; min-width: 0; }
.lesson-title { margin: 0 0 4px; font-size: 16px; line-height: 1.25; }
.lesson-kind { margin: 0; color: var(--muted); font-size: 12px; }
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 6px 9px; border-radius: 999px; background: var(--surface-soft); color: var(--primary-dark); font-size: 11px; font-weight: 700; }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--primary); }
.badge.recording::before, .badge.ready::before { background: var(--success); }
.badge.processing::before { background: var(--primary); }
.badge.warning::before { background: var(--warning); }
.badge.error::before { background: var(--danger); }
.badge.muted::before { background: var(--muted); }
.card-footer { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 13px; flex-wrap: wrap; }
.card-meta { display: flex; align-items: center; justify-content: flex-end; gap: 5px 9px; min-width: 0; margin-left: auto; flex-wrap: wrap; text-align: right; }
.mode-label, .pdf-label { color: var(--muted); font-size: 11px; line-height: 1.25; }
.pdf-label { color: var(--success); font-weight: 700; }
.state-card { display: flex; min-height: 280px; padding: 30px 22px; border: 1px dashed var(--line); border-radius: 20px; align-items: center; justify-content: center; flex-direction: column; text-align: center; color: var(--muted); }
.state-card h2 { margin: 8px 0 5px; color: var(--text); font-size: 18px; }
.state-card p { max-width: 310px; margin: 0 0 18px; font-size: 13px; line-height: 1.5; }
.state-icon { display: grid; place-items: center; width: 42px; height: 42px; border-radius: 50%; background: #F4E7E7; color: var(--danger); font-weight: 800; }
.state-icon.calm { background: #E8F0EC; color: var(--success); }
.spinner { width: 28px; height: 28px; margin-bottom: 10px; border: 3px solid var(--line); border-top-color: var(--primary); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.primary-button, .secondary-button, .mode-button { min-height: 46px; border: 0; border-radius: 14px; cursor: pointer; font-weight: 700; }
.primary-button:disabled, .secondary-button:disabled, .icon-button:disabled { opacity: .45; cursor: default; }
.primary-button { padding: 0 19px; background: var(--primary); color: white; }
.secondary-button { padding: 0 16px; background: var(--surface-soft); color: var(--primary-dark); }
.backdrop { position: fixed; inset: 0; z-index: 10; background: rgba(25,35,43,.42); backdrop-filter: blur(2px); }
.sheet { position: fixed; z-index: 11; left: 50%; bottom: 0; width: min(100%, 720px); max-height: 86vh; padding: 13px 18px calc(25px + env(safe-area-inset-bottom)); border-radius: 24px 24px 0 0; background: var(--surface); box-shadow: 0 -14px 36px rgba(37,49,60,.16); transform: translateX(-50%); overflow-y: auto; }
.grabber { width: 38px; height: 4px; margin: 0 auto 14px; border-radius: 5px; background: var(--line); }
.close-button { position: absolute; right: 16px; top: 18px; width: 35px; height: 35px; border: 0; border-radius: 50%; background: var(--surface-soft); color: var(--muted); font-size: 23px; cursor: pointer; }
.sheet h2 { max-width: calc(100% - 48px); margin: 7px 0 4px; font-size: 21px; }
.sheet-meta { margin: 0 0 20px; color: var(--muted); font-size: 13px; }
.section-label { margin: 22px 0 9px; color: var(--muted); font-size: 11px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.mode-grid { display: grid; gap: 8px; }
.mode-button { display: flex; align-items: center; justify-content: space-between; padding: 0 14px; background: var(--surface-soft); text-align: left; }
.mode-button.active { outline: 2px solid var(--primary); background: #E9F0F4; color: var(--primary-dark); }
.mode-button small { color: var(--muted); font-weight: 500; }
.mode-source-note { margin: 9px 0 0; color: var(--muted); font-size: 11px; }
.reset-mode { width: 100%; margin-top: 9px; }
.link-box { padding: 13px; border-radius: 14px; background: var(--surface-soft); }
.link-box p { margin: 0 0 10px; color: var(--muted); font-size: 12px; overflow-wrap: anywhere; }
.link-form { display: grid; gap: 9px; }
.link-form input, .form-grid input, .form-grid select { width: 100%; height: 46px; padding: 0 12px; border: 1px solid var(--line); border-radius: 13px; background: var(--surface); color: var(--text); outline: 0; }
.link-form input:focus, .form-grid input:focus, .form-grid select:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(82,109,130,.12); }
.button-row { display: flex; flex-wrap: wrap; gap: 8px; }
.note { margin: 10px 0 0; color: var(--muted); font-size: 11px; line-height: 1.45; }
.form-grid { display: grid; gap: 12px; }
.form-grid label { display: grid; gap: 6px; color: var(--muted); font-size: 11px; font-weight: 700; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
.now-button { min-height: 42px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-soft); color: var(--primary-dark); cursor: pointer; font-weight: 700; }
.now-button.active { border-color: var(--primary); background: #E9F0F4; }
.delete-actions { display: grid; gap: 9px; margin-top: 20px; }
.danger-button { min-height: 46px; padding: 0 16px; border: 0; border-radius: 14px; background: var(--danger); color: white; cursor: pointer; font-weight: 750; }
.wide { width: 100%; }
.toast { position: fixed; z-index: 20; left: 50%; bottom: calc(22px + env(safe-area-inset-bottom)); width: max-content; max-width: calc(100% - 32px); padding: 11px 15px; border-radius: 12px; background: #202A33; color: #FFFFFF; box-shadow: 0 10px 28px rgba(0,0,0,.24); transform: translateX(-50%); font-size: 13px; font-weight: 650; text-align: center; }

@media (prefers-color-scheme: dark) {
  :root { color-scheme: dark; --bg: #182027; --surface: #222D35; --surface-soft: #2B3740; --text: #EEF3F5; --muted: #A7B2BA; --line: #394751; --primary: #8EA9BB; --primary-dark: #C6D7E1; --shadow: 0 12px 30px rgba(0,0,0,.22); }
  .mode-button.active { background: #30434F; }
  .state-icon { background: #493437; }
  .state-icon.calm { background: #30453D; }
}

@media (max-width: 360px) {
  .shell { padding-inline: 12px; }
  .days { gap: 2px; }
  .day strong { font-size: 14px; }
  .card-footer { align-items: flex-start; }
  .card-meta { max-width: 100%; }
  .form-row { grid-template-columns: 1fr; }
}
