:root {
  color-scheme: light;
  --paper: #f5f4ee;
  --card: #fffefa;
  --ink: #202a21;
  --muted: #59645a;
  --border: #e3e5da;
  --green: #214e3b;
  --green-dark: #193e2f;
  --mint: #e5eee3;
  --mint-card: #ecf1e7;
  font-family: "Segoe UI", -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  background: var(--paper);
  color: var(--ink);
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-height: 100dvh; }
button, input { font: inherit; }
button { cursor: pointer; -webkit-tap-highlight-color: transparent; }
button:focus-visible, a:focus-visible, input:focus-visible, summary:focus-visible {
  outline: 2px solid #347054;
  outline-offset: 3px;
}
h1, h2, h3, p { margin: 0; }
.page-width { width: min(1120px, calc(100% - 64px)); margin-inline: auto; }

.site-header { border-bottom: 1px solid var(--border); background: var(--card); }
.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 72px;
  padding-top: env(safe-area-inset-top);
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  font-weight: 720;
  text-decoration: none;
}
.brand-icon { display: block; border-radius: 25%; }
.quiet-button {
  min-height: 44px;
  padding: 8px 13px;
  color: var(--green);
  border: 0;
  border-radius: 10px;
  background: transparent;
  font-size: .86rem;
  font-weight: 650;
}
.quiet-button:hover { background: var(--mint); }
.today-button { border: 1px solid #cbd9c9; background: var(--card); padding-inline: 16px; }

.agenda-main { padding-top: 56px; padding-bottom: max(42px, env(safe-area-inset-bottom)); }
.title-row {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 28px;
}
.today-label { margin-bottom: 6px; color: var(--green); font-size: .93rem; font-weight: 630; }
.today-label::first-letter, .day-header h2::first-letter, .next-time::first-letter { text-transform: uppercase; }
h1 {
  font-size: clamp(2.15rem, 5vw, 3.65rem);
  font-weight: 735;
  line-height: 1.07;
  letter-spacing: -.06em;
}

.agenda-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(220px, 285px); gap: 22px; }
.week-panel, .next-panel { border: 1px solid var(--border); border-radius: 22px; background: var(--card); }
.week-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 21px 24px 12px;
}
.week-header h2 { font-size: clamp(1.05rem, 2.4vw, 1.34rem); font-weight: 720; letter-spacing: -.025em; }
.week-navigation { display: flex; gap: 5px; flex-shrink: 0; }
.arrow-button {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0 0 3px;
  color: var(--green);
  border: 1px solid var(--border);
  border-radius: 11px;
  background: var(--card);
  font-size: 1.65rem;
  line-height: 1;
}
.arrow-button:hover { background: var(--mint); }
.week-days {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 7px;
  margin-inline: 24px;
  padding: 5px 0 22px;
}
.day-button {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  min-width: 0;
  min-height: 75px;
  padding: 9px 1px 5px;
  color: var(--ink);
  border: 1px solid transparent;
  border-radius: 12px;
  background: #f7f7f0;
}
.day-button:hover, .day-button[aria-current="date"] { border-color: #9cbeaa; }
.day-button[aria-pressed="true"] { border-color: var(--green); background: var(--green); color: white; }
.day-name { font-size: .75rem; }
.day-number { font-size: 1.15rem; line-height: 1.1; font-variant-numeric: tabular-nums; }
.day-button::after { content: ""; width: 5px; height: 5px; border-radius: 50%; }
.day-button.has-lessons::after { background: #508663; }
.day-button.has-lessons[aria-pressed="true"]::after { background: #c3e3b3; }

.day-content { padding: 22px 24px 26px; border-top: 1px solid var(--border); }
.day-header { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin-bottom: 17px; }
.day-header h2 { font-size: 1.1rem; letter-spacing: -.025em; }
.day-header span { font-size: .80rem; color: var(--muted); white-space: nowrap; }
.lesson-list { display: grid; gap: 9px; margin: 0; padding: 0; list-style: none; }
.lesson {
  display: grid;
  grid-template-columns: 63px minmax(0, 1fr);
  padding: 15px 14px;
  background: #f1f4ec;
  border: 1px solid #e8ede1;
  border-radius: 12px;
}
.lesson-clock {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding-top: 1px;
  color: var(--green);
  font-size: .88rem;
  font-weight: 720;
  line-height: 1.25;
  font-variant-numeric: tabular-nums;
}
.lesson-end { color: var(--muted); font-size: .75rem; font-weight: 500; }
.lesson-body { padding-left: 13px; border-left: 2px solid #87af93; overflow-wrap: anywhere; }
.lesson-body h3 { font-size: 1rem; font-weight: 715; line-height: 1.25; }
.lesson-body p { margin-top: 5px; font-size: .84rem; line-height: 1.4; }
.lesson-location { color: var(--green-dark); font-weight: 580; }
.lesson-meta, .lesson-details { color: var(--muted); }
.lesson-details { margin-top: 7px; font-size: .83rem; }
.lesson-details summary { width: fit-content; cursor: pointer; }
.lesson-details p { white-space: pre-wrap; }
.empty-state {
  padding: 28px 14px;
  color: var(--muted);
  background: #f7f7f0;
  border-radius: 12px;
  text-align: center;
  font-size: .92rem;
}

.sidebar { display: grid; align-content: start; gap: 10px; }
.next-panel { padding: 21px; background: var(--mint-card); border-color: #dce5d8; }
.next-panel h2 { margin-bottom: 14px; color: var(--green); font-size: .92rem; }
.next-panel h3 { margin-top: 6px; font-size: 1.13rem; line-height: 1.24; overflow-wrap: anywhere; }
.next-time, .next-empty { color: var(--muted); font-size: .83rem; line-height: 1.5; }
.next-link {
  min-height: 44px;
  margin-top: 8px;
  padding: 0;
  color: var(--green);
  background: transparent;
  border: 0;
  font-size: .85rem;
  font-weight: 700;
  text-align: left;
}
.next-link::after { content: " →"; }
.next-link:hover { text-decoration: underline; }
.sync-status { padding: 3px 4px; color: var(--muted); font-size: .77rem; line-height: 1.55; }
.status-warning { color: #854524; }

.login-layout { display: grid; place-items: center; min-height: 100dvh; padding: 20px; }
.login-panel {
  width: min(100%, 410px);
  padding: clamp(24px, 7vw, 36px);
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 22px;
}
.login-panel h1 { margin-top: 18px; font-size: 2.35rem; }
.login-panel > p { margin-top: 10px; color: var(--muted); font-size: .94rem; line-height: 1.5; }
.login-panel form { display: grid; gap: 9px; margin-top: 25px; }
.login-panel label { font-size: .9rem; font-weight: 650; }
.login-panel input {
  min-width: 0;
  min-height: 47px;
  padding: 8px 11px;
  color: var(--ink);
  border: 1px solid #aeb9ac;
  border-radius: 9px;
  background: white;
  font-size: 1rem;
}
.primary-button {
  display: flex;
  justify-content: space-between;
  align-items: center;
  min-height: 47px;
  margin-top: 5px;
  padding: 10px 13px;
  color: white;
  border: 0;
  border-radius: 9px;
  background: var(--green);
  font-weight: 650;
}
.primary-button:hover { background: var(--green-dark); }
.form-error { color: #964427; font-size: .87rem; }

@media (max-width: 760px) {
  .page-width { width: calc(100% - 36px); }
  .header-inner { min-height: 61px; }
  .agenda-main { padding-top: 34px; }
  .agenda-grid { grid-template-columns: minmax(0, 1fr); gap: 13px; }
}

@media (max-width: 480px) {
  .page-width { width: calc(100% - 28px); }
  .title-row { gap: 8px; margin-bottom: 18px; }
  .today-button { padding-inline: 10px; font-size: .77rem; }
  .week-panel, .next-panel { border-radius: 17px; }
  .week-header { padding: 12px 12px 9px; }
  .week-days { gap: 4px; margin-inline: 12px; padding-bottom: 13px; }
  .day-button { min-height: 67px; gap: 4px; border-radius: 8px; }
  .day-name { font-size: .68rem; }
  .day-content { padding: 16px 12px 17px; }
  .day-header { margin-bottom: 13px; }
  .lesson { grid-template-columns: 53px minmax(0, 1fr); padding: 12px 9px; }
  .lesson-body { padding-left: 9px; }
  .next-panel { padding: 15px; }
}

@media (max-width: 350px) {
  .title-row h1 { font-size: 1.9rem; }
}
