:root {
  --bg: #e9f0eb;
  --header: #f4f7f4;
  --surface: #fff;
  --ink: #1c2b29;
  --muted: #5b6b68;
  --accent: #2f6b61;
  --accent-ink: #fff;
  --soft: #dfeae5;
  --line: #cfdcd6;
  --sans: Onest, system-ui, sans-serif;
  --serif: Literata, Georgia, serif;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #101c19;
  --header: #172724;
  --surface: #1d302b;
  --ink: #e8f0ed;
  --muted: #abc0b6;
  --accent: #91d0b9;
  --accent-ink: #142c23;
  --soft: #294237;
  --line: #385045;
  color-scheme: dark;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { scroll-padding-top: 120px; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 400 16px/1.65 var(--sans); }
button, a { -webkit-tap-highlight-color: transparent; }
button { font: inherit; cursor: pointer; }
a { color: var(--accent); text-underline-offset: 3px; overflow-wrap: anywhere; }
button:focus-visible, a:focus-visible { outline: 3px solid var(--accent); outline-offset: 4px; }
.header { position: sticky; top: 0; z-index: 10; background: var(--header); border-bottom: 1px solid var(--line); padding-top: max(env(safe-area-inset-top), var(--tg-inset-top, 0px)); }
.header-inner { max-width: 760px; min-height: 86px; margin: auto; padding: 14px 24px; display: flex; align-items: center; gap: 12px; }
.brand-mark { flex-shrink: 0; }
.brand { margin-right: auto; }
.brand h1 { margin: 0; font: 500 23px/1.2 var(--serif); letter-spacing: -.6px; }
.brand h1 span { font: 500 18px var(--sans); letter-spacing: .4px; }
.brand p { font-size: 11px; margin: 5px 0 0; color: var(--muted); }
.demo-label { border: 1px solid var(--line); border-radius: 6px; padding: 1px 7px; font-size: 11px; color: var(--muted); }
.contents-toggle { border: 0; border-radius: 12px; padding: 10px; color: var(--accent); background: var(--soft); display: flex; align-items: center; gap: 7px; font-size: 13px; }
.contents-toggle svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; }
.contents { max-width: 712px; margin: 0 auto; padding: 10px 24px 16px; display: flex; flex-wrap: wrap; gap: 8px; max-height: 40dvh; overflow: auto; }
.contents button { border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--ink); padding: 8px 12px; font-size: 13px; }
.course { max-width: 712px; margin: auto; padding: 24px 24px calc(100px + max(env(safe-area-inset-bottom), var(--tg-inset-bottom, 0px))); }
.course-note { display: flex; justify-content: center; align-items: center; gap: 8px; margin-bottom: 22px; color: var(--muted); font-size: 11px; text-align: center; }
.presence-dot { width: 5px; height: 5px; background: var(--accent); border-radius: 50%; flex-shrink: 0; }
.day-divider { display: flex; align-items: center; gap: 14px; margin: 28px 0 18px; scroll-margin-top: 125px; font-weight: 500; font-size: 12px; color: var(--muted); }
.day-divider::before, .day-divider::after { content: ""; height: 1px; background: var(--line); flex: 1; }
.message { background: var(--surface); border: 1px solid var(--line); border-radius: 18px 18px 18px 5px; padding: 20px 24px; margin: 0 0 12px; overflow-wrap: anywhere; }
.message-text { margin: 0; white-space: pre-wrap; }
.message-image { display: block; max-width: 100%; height: auto; border-radius: 10px; margin: 8px auto; }
.message-image[src$="author.jpg"] { max-height: 480px; width: auto; max-width: 100%; }
.message-button { display: block; width: fit-content; max-width: 100%; text-decoration: none; white-space: pre-wrap; color: var(--accent); background: var(--soft); border-radius: 9px; padding: 11px 15px; margin: 9px 0; font-size: 14px; }
.message audio { display: block; width: 100%; height: 54px; margin: 12px 0; }
.placeholder { border-left: 2px solid var(--line); padding: 12px 16px; color: var(--muted); font-size: 14px; white-space: pre-wrap; }
.video-card { margin: 14px 0; }
.video-slot { position: relative; width: 100%; aspect-ratio: 16/9; min-height: 200px; overflow: hidden; border-radius: 10px; background: #14231e; }
.video-slot > div, .video-slot iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.media-status { margin: 8px 0; font-size: 12px; color: var(--muted); }
.waiting { display: flex; align-items: center; gap: 5px; background: var(--surface); width: fit-content; border: 1px solid var(--line); border-radius: 16px 16px 16px 4px; padding: 16px 20px; }
.waiting i { width: 5px; height: 5px; border-radius: 50%; background: var(--muted); }
.loading { text-align: center; padding: 40px 16px; color: var(--muted); }
.new-messages { position: fixed; z-index: 11; bottom: calc(20px + max(env(safe-area-inset-bottom), var(--tg-inset-bottom, 0px))); left: 50%; transform: translateX(-50%); white-space: nowrap; border: 1px solid var(--line); border-radius: 24px; padding: 11px 20px; background: var(--accent); color: var(--accent-ink); font-size: 13px; box-shadow: 0 4px 18px #0002; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
body.is-expired { overflow: hidden; }
.is-expired #course-shell { filter: blur(9px); user-select: none; pointer-events: none; }
.expired { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: max(28px, var(--tg-inset-top, 0px)) 24px max(28px, var(--tg-inset-bottom, 0px)); background: #091610b8; overflow: auto; }
.expired-card { width: min(100%, 400px); padding: 32px 28px; background: var(--surface); border: 1px solid var(--line); border-radius: 24px; text-align: center; }
.lock-mark { width: 62px; height: 62px; margin: 0 auto 22px; background: var(--soft); color: var(--accent); border-radius: 50%; display: grid; place-items: center; }
.lock-mark svg { width: 32px; height: 32px; stroke: currentColor; stroke-width: 1.6; fill: none; stroke-linecap: round; }
.expired-card h2 { font: 500 28px/1.25 var(--serif); letter-spacing: -.6px; margin: 0; }
.expired-card p { margin: 18px 0 26px; font-size: 14px; color: var(--muted); }
.primary-button { display: block; border-radius: 12px; padding: 14px 20px; background: var(--accent); color: var(--accent-ink); text-decoration: none; font-weight: 500; font-size: 14px; }
@media (max-width: 480px) {
  .header-inner { min-height: 76px; padding: 12px 16px; gap: 9px; }
  .brand-mark { width: 34px; height: 34px; }
  .brand h1 { font-size: 21px; }
  .brand h1 span { font-size: 16px; }
  .contents-toggle span { display: none; }
  .contents-toggle { min-width: 40px; min-height: 40px; }
  .course { padding: 18px 12px 100px; padding-bottom: calc(100px + max(env(safe-area-inset-bottom), var(--tg-inset-bottom, 0px))); }
  .message { padding: 15px 16px; font-size: 15px; }
  .course-note { font-size: 10px; }
  .contents { padding-inline: 16px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; }
}
.header-inner, .contents {
  padding-left: max(16px, env(safe-area-inset-left), var(--tg-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right), var(--tg-inset-right, 0px));
}
.course {
  padding-left: max(12px, env(safe-area-inset-left), var(--tg-inset-left, 0px));
  padding-right: max(12px, env(safe-area-inset-right), var(--tg-inset-right, 0px));
}
