:root {
  --brand: #a30a3d;
  --brand-ink: #7a0530;
  --brand-soft: #ff5d8f;
  --ink: #1c1418;
  --muted: #6b6066;
  --subtle: #8f858a;
  --line: rgba(28, 20, 24, 0.09);
  --line-strong: rgba(28, 20, 24, 0.16);
  --page: #f1eef2;
  --glass: rgba(255, 255, 255, 0.58);
  --glass-strong: rgba(255, 255, 255, 0.8);
  --glass-soft: rgba(255, 255, 255, 0.4);
  --glass-border: rgba(255, 255, 255, 0.7);
  --glass-border-soft: rgba(255, 255, 255, 0.45);
  --surface: rgba(255, 255, 255, 0.86);
  --surface-soft: rgba(255, 255, 255, 0.5);
  --today: rgba(255, 93, 143, 0.1);
  --shadow: 0 24px 60px rgba(35, 18, 26, 0.16);
  --shadow-sm: 0 10px 30px rgba(35, 18, 26, 0.10);
  --shadow-inset: inset 0 1px 0 rgba(255, 255, 255, 0.75), inset 0 -1px 0 rgba(255, 255, 255, 0.15);
  --radius-xl: 28px;
  --radius-lg: 22px;
  --radius-md: 15px;
  --blur: 26px;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", Helvetica, Arial, sans-serif;
  --font-heading: "Reddit Sans", -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", Helvetica, Arial, sans-serif;
  font-family: var(--font);
  color: var(--ink);
}

* { box-sizing: border-box; }
h1, h2, h3, .brand span, .oppekoht-button, .clock time { font-family: var(--font-heading); }
html { min-width: 320px; }
body {
  margin: 0;
  min-width: 320px;
  color: var(--ink);
  background:
    radial-gradient(760px 520px at 6% -12%, #ffd3e2 0%, rgba(255, 211, 226, 0) 60%),
    radial-gradient(680px 520px at 100% 0%, #ffe6c2 0%, rgba(255, 230, 194, 0) 55%),
    radial-gradient(820px 620px at 46% 112%, #d6e4ff 0%, rgba(214, 228, 255, 0) 62%),
    radial-gradient(600px 460px at -6% 70%, #dcf3ea 0%, rgba(220, 243, 234, 0) 55%),
    var(--page);
  background-attachment: fixed, fixed, fixed, fixed, fixed;
}
button, select { font: inherit; }
button { -webkit-tap-highlight-color: transparent; }

#app { min-height: 100vh; }
.boot,
.fatal-state {
  width: min(720px, calc(100% - 32px));
  margin: 10vh auto;
  padding: 30px;
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  background: var(--glass);
  backdrop-filter: blur(var(--blur)) saturate(160%);
  -webkit-backdrop-filter: blur(var(--blur)) saturate(160%);
  box-shadow: var(--shadow), var(--shadow-inset);
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 30;
  width: 100%;
  background: var(--glass-strong);
  backdrop-filter: blur(var(--blur)) saturate(160%);
  -webkit-backdrop-filter: blur(var(--blur)) saturate(160%);
  border-bottom: 1px solid var(--glass-border-soft);
  box-shadow: 0 1px 0 rgba(255, 255, 255, .5) inset;
}

.header-inner {
  width: min(1440px, calc(100% - 40px));
  min-height: 108px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: auto minmax(300px, 1fr) auto;
  align-items: center;
  gap: 28px;
  padding: 14px 0;
}

.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand img { width: 80px; height: 80px; flex: 0 0 auto; border-radius: 50%; box-shadow: 0 2px 8px rgba(35, 18, 26, .18); }
.brand span { font-size: 21px; font-weight: 760; letter-spacing: -0.03em; white-space: nowrap; }

.header-location { position: relative; justify-self: center; width: min(440px, 100%); }
.eyebrow {
  color: var(--brand);
  font-size: 11px;
  line-height: 1.1;
  letter-spacing: 0.16em;
  font-weight: 850;
  text-transform: uppercase;
}

.oppekoht-button {
  width: 100%;
  min-height: 46px;
  margin-top: 6px;
  padding: 0 8px 0 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border: 1px solid var(--glass-border);
  border-radius: 999px;
  background: var(--surface-soft);
  backdrop-filter: blur(14px) saturate(140%);
  -webkit-backdrop-filter: blur(14px) saturate(140%);
  color: var(--ink);
  font-size: 16px;
  font-weight: 720;
  text-align: left;
  cursor: pointer;
  box-shadow: var(--shadow-inset);
  transition: border-color .15s ease, box-shadow .15s ease, background .15s ease, transform .15s ease;
}
.oppekoht-button .chev {
  display: flex; align-items: center; justify-content: center;
  width: 30px; height: 30px; border-radius: 50%;
  background: var(--glass-strong); color: var(--brand); font-size: 13px;
  box-shadow: 0 1px 4px rgba(35, 18, 26, .12);
  transition: transform .18s ease;
}
.oppekoht-button[aria-expanded="false"] .chev { transform: rotate(180deg); }
.oppekoht-button:hover { border-color: var(--line-strong); background: var(--glass-strong); }
.oppekoht-button:active { transform: scale(.985); }
.oppekoht-button:focus-visible,
.view-tabs button:focus-visible,
.segmented button:focus-visible,
.oppekoht-option:focus-visible,
.controls select:focus-visible { outline: 3px solid rgba(163, 10, 61, .2); outline-offset: 2px; }

.clock { text-align: right; white-space: nowrap; }
.clock time { display: block; font-size: 17px; line-height: 1.2; font-weight: 760; font-variant-numeric: tabular-nums; }
.clock span { display: block; margin-top: 3px; color: var(--muted); font-size: 12px; }

.oppekoht-menu[hidden] { display: none; }
.oppekoht-menu {
  position: absolute;
  top: calc(100% + 10px);
  left: 0;
  right: 0;
  z-index: 40;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 7px;
  border: 1px solid var(--glass-border);
  border-radius: 20px;
  background: var(--glass-strong);
  backdrop-filter: blur(var(--blur)) saturate(170%);
  -webkit-backdrop-filter: blur(var(--blur)) saturate(170%);
  box-shadow: var(--shadow), var(--shadow-inset);
  animation: menu-pop .16s ease;
  transform-origin: top center;
}
@keyframes menu-pop {
  from { opacity: 0; transform: translateY(-6px) scale(.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
.oppekoht-option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 12px 14px;
  border: 0;
  border-radius: 14px;
  background: transparent;
  color: var(--ink);
  font-size: 15px;
  font-weight: 700;
  text-align: left;
  cursor: pointer;
  transition: background .12s ease;
}
.oppekoht-option:hover { background: rgba(28, 20, 24, .05); }
.oppekoht-option.selected { background: rgba(163, 10, 61, .09); color: var(--brand-ink); }
.oppekoht-option .check { color: var(--brand); font-size: 13px; font-weight: 900; }

main {
  width: min(1440px, calc(100% - 40px));
  margin: 0 auto;
  padding: 22px 0 32px;
}

.dashboard {
  display: grid;
  grid-template-columns: 330px minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.sidebar { min-width: 0; }

.identity-card,
.live-card,
.controls-card,
.timetable-section {
  position: relative;
  border: 1px solid var(--glass-border);
  background: var(--glass);
  backdrop-filter: blur(var(--blur)) saturate(170%);
  -webkit-backdrop-filter: blur(var(--blur)) saturate(170%);
  box-shadow: var(--shadow-sm), var(--shadow-inset);
}

.identity-card {
  padding: 22px;
  border-radius: var(--radius-xl);
  overflow: hidden;
}
.identity-card::before {
  content: '';
  position: absolute; inset: 0; border-radius: inherit; pointer-events: none;
  background: linear-gradient(135deg, rgba(255, 255, 255, .55) 0%, rgba(255, 255, 255, 0) 38%);
}
.identity-card h1 { margin: 7px 0 5px; font-size: 30px; line-height: 1.04; letter-spacing: -.045em; }
.identity-card p { margin: 0; color: var(--muted); font-size: 13px; }

.identity-card.merged { display: flex; flex-direction: column; }
.identity-card.merged > * { position: relative; min-width: 0; z-index: 1; }
.identity-card.merged > * + * { margin-top: 15px; padding-top: 15px; border-top: 1px solid var(--line); }
.identity-card.merged h1 { margin: 7px 0 0; }
.identity-card.merged .view-picker .controls { margin-top: 10px; }
.identity-card.merged .live-card,
.identity-card.merged .live-card.current {
  padding: 0; border: 0; border-radius: 0; background: none; backdrop-filter: none; -webkit-backdrop-filter: none; box-shadow: none; min-height: 0;
}
.identity-card.merged .live-card { padding-left: 14px; overflow: hidden; }
.identity-card.merged .live-card::before { display: none; }

.live-card {
  overflow: hidden;
  min-height: 148px;
  padding: 17px 18px 16px 20px;
  border-radius: var(--radius-lg);
}
.live-card.current { min-height: 178px; }
.live-color-bar { position: absolute; left: 0; top: 0; bottom: 0; width: 5px; border-radius: 999px; background: var(--live-accent); box-shadow: 0 0 10px 0 var(--live-accent); }
.live-card.empty { display: flex; flex-direction: column; justify-content: center; }
.live-card h2 { margin: 7px 0 5px; font-size: 23px; line-height: 1.08; letter-spacing: -.035em; }
.live-card p { margin: 3px 0; color: #51484d; font-size: 13px; }
.live-card time { display: block; margin-top: 11px; font-size: 13px; font-weight: 760; }

.tag {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  margin-top: 7px;
  padding: 4px 8px;
  border-radius: 999px;
  background: rgba(163, 10, 61, .12);
  color: var(--brand-ink);
  font-size: 10px;
  font-weight: 850;
  letter-spacing: .04em;
}

.progress-meta { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 8px; margin-top: 15px; font-size: 11px; font-weight: 780; }
.progress-meta span:nth-child(2) { font-size: 12px; color: var(--live-accent); }
.progress-meta span:last-child { text-align: right; }
.progress-track { position: relative; height: 6px; margin: 7px 0; border-radius: 999px; background: rgba(28, 20, 24, .08); }
.progress-fill { height: 100%; border-radius: inherit; background: var(--live-accent); transition: width .7s linear; }
.progress-dot { position: absolute; top: 50%; width: 14px; height: 14px; border: 2px solid #fff; border-radius: 50%; background: var(--live-accent); transform: translate(-50%, -50%); box-shadow: 0 0 0 3px rgba(255, 255, 255, .5), 0 0 10px 1px var(--live-accent); transition: left .7s linear; }
.remaining { color: var(--muted); text-align: center; font-size: 11px; font-weight: 700; }

.view-tabs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; padding: 4px; border-radius: 14px; background: rgba(28, 20, 24, .05); box-shadow: inset 0 1px 2px rgba(28, 20, 24, .05); }
.view-tabs button { border: 0; border-radius: 10px; padding: 9px 5px; background: transparent; color: var(--muted); font-size: 12px; font-weight: 780; cursor: pointer; transition: background .15s ease, color .15s ease, box-shadow .15s ease; }
.view-tabs button.active { background: var(--glass-strong); color: var(--brand); box-shadow: 0 3px 10px rgba(28, 20, 24, .12), var(--shadow-inset); }

.controls { margin-top: 10px; }
.controls label { display: flex; flex-direction: column; gap: 6px; color: var(--muted); font-size: 11px; font-weight: 780; }
.controls select {
  width: 100%; min-height: 44px; padding: 0 12px;
  border: 1px solid var(--glass-border); border-radius: 14px;
  background: var(--surface-soft);
  backdrop-filter: blur(10px);
  color: var(--ink); font-size: 14px; font-weight: 680;
  box-shadow: var(--shadow-inset);
}

.share-actions { display: flex; gap: 8px; }
.ghost-btn {
  flex: 1; min-height: 42px; padding: 0 10px;
  border: 1px solid var(--glass-border); border-radius: 13px;
  background: var(--surface-soft);
  backdrop-filter: blur(10px);
  color: var(--ink); font-size: 12.5px; font-weight: 740;
  cursor: pointer; box-shadow: var(--shadow-inset);
  transition: background .15s ease, transform .1s ease;
}
.ghost-btn:hover { background: var(--glass-strong); }
.ghost-btn:active { transform: scale(.97); }
.ghost-btn.flash { background: rgba(163, 10, 61, .12); color: var(--brand-ink); }
.color-mode { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.color-mode > span { color: var(--muted); font-size: 11px; font-weight: 780; }
.segmented { display: flex; gap: 3px; padding: 3px; border-radius: 12px; background: rgba(28, 20, 24, .05); box-shadow: inset 0 1px 2px rgba(28, 20, 24, .05); }
.segmented button { border: 0; border-radius: 9px; padding: 7px 10px; background: transparent; color: var(--muted); font-size: 10px; font-weight: 780; cursor: pointer; transition: background .15s ease, color .15s ease, box-shadow .15s ease; }
.segmented button.active { background: var(--glass-strong); color: var(--brand); box-shadow: 0 2px 8px rgba(28, 20, 24, .12), var(--shadow-inset); }

.warning { margin-bottom: 12px; padding: 12px 14px; border: 1px solid rgba(163, 10, 61, .18); border-radius: 16px; background: rgba(255, 93, 143, .1); backdrop-filter: blur(14px); color: #5e2233; font-size: 12px; }

.content { min-width: 0; }
.timetable-section { overflow: hidden; border-radius: var(--radius-xl); }
.timetable-section::before {
  content: '';
  position: absolute; inset: 0; border-radius: inherit; pointer-events: none; z-index: 0;
  background: linear-gradient(135deg, rgba(255, 255, 255, .5) 0%, rgba(255, 255, 255, 0) 32%);
}
.timetable-section > * { position: relative; z-index: 1; }
.section-heading { padding: 19px 20px 11px; }
.section-heading h2 { margin: 5px 0 3px; font-size: 22px; line-height: 1.08; letter-spacing: -.035em; }
.section-heading p { margin: 0; color: var(--muted); font-size: 12px; }
.legend { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 20px 14px; }
.legend-item { display: inline-flex; align-items: center; gap: 5px; min-height: 26px; padding: 4px 9px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface-soft); color: #4e4449; font-size: 10px; font-weight: 720; }
.legend-item i { width: 9px; height: 9px; border-radius: 3px; }

.desktop-grid {
  display: grid;
  grid-template-columns: 62px repeat(5, minmax(0, 1fr));
  gap: 1px;
  margin: 0 12px 12px;
  overflow: hidden;
  border: 1px solid var(--line-strong);
  border-radius: 16px;
  background: var(--line-strong);
}
.day-column,
.periods-column { display: grid; grid-template-rows: 42px repeat(var(--period-rows, 8), minmax(72px, 1fr)); gap: 1px; min-width: 0; background: var(--line-strong); }
.day-column h3,
.periods-column h3 { display: flex; align-items: center; justify-content: center; margin: 0; padding: 0 4px; background: rgba(255, 255, 255, .55); color: #31292d; font-size: 10px; font-weight: 860; letter-spacing: .065em; }
.day-column.active-day h3 { background: var(--brand); color: #fff; }
.grid-slot { min-height: 72px; padding: 2px; background: rgba(255, 255, 255, .72); }
.grid-slot.split { display: flex; gap: 2px; align-items: stretch; }
.grid-slot.split .lesson-card { flex: 1 1 0; min-width: 0; }
.period-cell { min-height: 72px; display: flex; align-items: center; justify-content: center; padding: 4px; background: rgba(255, 255, 255, .55); }
.period-cell b { font-size: 15px; font-weight: 880; }

.lesson-card {
  --card-accent: var(--brand);
  --card-tint: #f7edf1;
  position: relative;
  overflow: hidden;
  height: 100%;
  min-height: 68px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 10px 10px 8px 13px;
  border-radius: 10px;
  border: 1px solid color-mix(in srgb, var(--card-accent) 25%, #d8d1d4);
  background: color-mix(in srgb, var(--card-tint) 82%, transparent);
  color: #151114;
  box-shadow: none;
}
.lesson-accent { position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--card-accent); }
.lesson-card strong { font-size: 14px; line-height: 1.1; font-weight: 860; letter-spacing: -.02em; }
.lesson-card .teacher-line { margin-top: auto; color: #3f363b; font-size: 11px; line-height: 1.1; font-weight: 760; }
.lesson-card time { color: #655b60; font-size: 9px; line-height: 1; font-weight: 760; }
.lesson-card.today-card { outline: 2px solid rgba(163, 10, 61, .28); outline-offset: -2px; }
.lesson-card.cancelled { opacity: .65; }
.group-badge { display: inline-block; align-self: flex-start; margin-bottom: 1px; padding: 1px 6px; border-radius: 999px; background: color-mix(in srgb, var(--card-accent) 22%, #fff); color: #151114; font-size: 9px; font-weight: 800; letter-spacing: .02em; text-transform: uppercase; }
.lesson-card.compact { padding: 6px 7px 6px 10px; gap: 1px; }
.lesson-card.compact strong { font-size: 11px; }
.lesson-card.compact .teacher-line { font-size: 9px; }
.lesson-card.compact time { font-size: 8px; }
.lesson-card.compact .group-badge { font-size: 8px; padding: 1px 5px; }
.empty-slot { display: flex; height: 100%; align-items: center; justify-content: center; color: #b7adb1; font-size: 11px; }

.mobile-list { display: none; }

footer { padding: 4px 0 14px; color: var(--subtle); font-size: 10px; text-align: center; }

@media (max-width: 1100px) {
  .header-inner { grid-template-columns: auto minmax(240px, 1fr) auto; gap: 16px; }
  .dashboard { grid-template-columns: 290px minmax(0, 1fr); gap: 14px; }
  .desktop-grid { grid-template-columns: 56px repeat(5, minmax(120px, 1fr)); overflow-x: auto; }
  .day-column, .periods-column { grid-template-rows: 38px repeat(var(--period-rows, 8), 70px); }
  .grid-slot, .period-cell { min-height: 70px; }
  .lesson-card strong { font-size: 12px; }
}

@media (max-width: 820px) {
  .header-inner { width: min(100% - 24px, 720px); grid-template-columns: auto 1fr; gap: 10px 16px; padding: 10px 0; }
  .header-location { grid-column: 1 / -1; grid-row: 2; width: 100%; }
  .clock { justify-self: end; }
  .brand img { width: 76px; height: 76px; }
  .brand span { font-size: 19px; }
  main { width: min(100% - 24px, 720px); padding-top: 14px; }
  .dashboard { display: block; }
  .identity-card { padding: 18px; }
  .identity-card h1 { font-size: 27px; }
  .live-card { min-height: 142px; }
  .live-card.current { min-height: 164px; }
  .content { margin-top: 14px; }
  .timetable-section { border-radius: 22px; }
  .desktop-grid { display: none; }
  .mobile-list { display: block; padding: 0 16px 16px; }
  .mobile-day { padding: 12px 0 3px; }
  .mobile-day + .mobile-day { border-top: 1px solid var(--line); }
  .mobile-day h3 { margin: 0 0 8px; color: var(--brand); font-size: 11px; letter-spacing: .12em; }
  .mobile-day.active-day h3::after { content: ' · TÄNA'; }
  .mobile-lesson { display: grid; grid-template-columns: 72px minmax(0, 1fr); gap: 8px; align-items: stretch; margin-bottom: 8px; }
  .period-label { display: flex; align-items: center; justify-content: center; padding: 8px; border-radius: 12px; background: rgba(255, 255, 255, .55); color: #4d4448; font-size: 11px; font-weight: 800; text-align: center; }
  .mobile-lesson .lesson-card { min-height: 92px; border-radius: 12px; padding: 11px 11px 9px 14px; }
  .mobile-lesson .lesson-card strong { font-size: 15px; }
  .mobile-lesson .lesson-card .teacher-line { font-size: 11px; }
  .mobile-lesson .lesson-card time { font-size: 10px; }
}

@media (max-width: 560px) {
  .header-inner { width: min(100% - 16px, 720px); }
  .clock time { font-size: 15px; }
  main { width: min(100% - 16px, 720px); }
  .segmented button { padding: 7px 8px; }
  .section-heading { padding: 16px 15px 9px; }
  .section-heading h2 { font-size: 20px; }
  .legend { padding: 0 15px 11px; }
  .mobile-list { padding: 0 13px 13px; }
  .mobile-lesson { grid-template-columns: 60px minmax(0, 1fr); }
}

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

@media print {
  body { background: #fff !important; }
  .site-header, .share-actions, .view-picker, .oppekoht-menu, .warning,
  .identity-card .live-card, footer { display: none !important; }
  .identity-card.merged { border: 0; box-shadow: none; background: none; backdrop-filter: none; padding: 0 0 10px; }
  .identity-card.merged > * + * { margin-top: 0; padding-top: 0; border-top: 0; }
  main { width: 100%; padding: 0; }
  .dashboard { display: block; }
  .timetable-section, .live-card, .identity-card {
    border: 1px solid #ccc !important; box-shadow: none !important; background: #fff !important; backdrop-filter: none !important;
  }
  .timetable-section::before, .identity-card::before { display: none !important; }
  .desktop-grid { display: grid !important; }
  .mobile-list { display: none !important; }
  .lesson-card { break-inside: avoid; border: 1px solid #999 !important; background: #fff !important; }
  .day-column, .periods-column { background: #ccc; }
  .grid-slot, .period-cell { background: #fff; }
  a[href]::after { content: ""; }
}
