:root {
  --bg: #0b0d12;
  --surface: #151924;
  --surface-2: #1d2230;
  --line: #2a3142;
  --text: #eef1f7;
  --muted: #a3acc0;
  --accent: #7c8cff;
  --accent-ink: #0b0d12;
  --live: #3ddc97;
  --radius: 18px;
  color-scheme: dark;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #f4f6fb;
    --surface: #ffffff;
    --surface-2: #eef1f8;
    --line: #dde2ee;
    --text: #12151d;
    --muted: #535c70;
    --accent: #3f4fe0;
    --accent-ink: #ffffff;
    --live: #0b7a4b;
    color-scheme: light;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Hiragino Sans", "Noto Sans JP", "Yu Gothic UI", sans-serif;
  line-height: 1.6;
  -webkit-text-size-adjust: 100%;
}

.wrap {
  width: 100%;
  max-width: 720px;
  margin: 0 auto;
  padding: 0 16px;
}

.skip {
  position: absolute;
  left: -9999px;
}
.skip:focus {
  left: 16px;
  top: 16px;
  z-index: 10;
  background: var(--surface);
  color: var(--text);
  padding: 8px 12px;
  border-radius: 8px;
}

:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

/* ---- ヘッダー ---- */
.top { padding: 32px 0 16px; }
.eyebrow {
  margin: 0;
  font-size: 0.75rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--accent);
  font-weight: 700;
}
h1 {
  margin: 4px 0 0;
  font-size: clamp(1.75rem, 6vw, 2.5rem);
  letter-spacing: -0.02em;
  line-height: 1.2;
}
.clock {
  margin: 6px 0 0;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

/* ---- 今の授業 ---- */
.now {
  margin: 8px 0 32px;
  padding: 20px;
  border-radius: var(--radius);
  background:
    radial-gradient(120% 140% at 100% 0%, color-mix(in srgb, var(--accent) 22%, transparent), transparent 60%),
    var(--surface);
  border: 1px solid var(--line);
}
.now-label {
  margin: 0;
  font-size: 0.85rem;
  color: var(--muted);
  font-weight: 600;
}
.now-meta {
  margin: 6px 0 12px;
  font-size: 1.05rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.now-empty {
  margin: 8px 0 4px;
  font-size: 1.25rem;
  font-weight: 700;
}
.now-sub {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 0.8rem;
  background: var(--surface-2);
  color: var(--muted);
  border: 1px solid var(--line);
  vertical-align: 2px;
}
.badge.live {
  color: var(--live);
  border-color: color-mix(in srgb, var(--live) 50%, transparent);
}

/* ---- 曜日タブ ---- */
.section-title {
  margin: 0 0 12px;
  font-size: 1.1rem;
}
.tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  padding: 4px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  margin-bottom: 16px;
}
[role="tab"] {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-weight: 700;
  font-size: 1.05rem;
  padding: 10px 0;
  min-height: 44px;
  border-radius: 10px;
  cursor: pointer;
}
[role="tab"][aria-selected="true"] {
  background: var(--accent);
  color: var(--accent-ink);
}

#panel {
  display: grid;
  gap: 12px;
}

.slot {
  padding: 14px 16px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--line);
}
.slot.is-current { border-color: var(--accent); }
.slot-head {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin: 0 0 8px;
  font-size: 0.95rem;
}
.slot-period { font-weight: 800; }
.slot-time {
  color: var(--muted);
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}

/* ---- 授業の行 ---- */
.opts {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 8px;
}
.opt {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 48px;
}
.opt-name {
  flex: 1;
  min-width: 0;
  font-weight: 600;
  overflow-wrap: anywhere;
}
.opts.big .opt-name { font-size: 1.2rem; }
.opt.is-starred .opt-name { color: var(--text); }

.star {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 1.3rem;
  width: 44px;
  height: 44px;
  margin-left: -10px;
  border-radius: 10px;
  cursor: pointer;
}
.star[aria-pressed="true"] { color: #f5c542; }

.btn {
  appearance: none;
  border: 1px solid transparent;
  font: inherit;
  font-weight: 700;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 12px;
  cursor: pointer;
  white-space: nowrap;
}
.btn.primary {
  background: var(--accent);
  color: var(--accent-ink);
  padding: 10px 18px;
  min-height: 44px;
}
.opts.big .btn.primary {
  padding: 12px 22px;
  min-height: 52px;
  font-size: 1.05rem;
}
.btn.ghost {
  background: transparent;
  color: var(--text);
  border-color: var(--line);
}
.btn.small {
  padding: 6px 12px;
  min-height: 40px;
  font-size: 0.85rem;
}
.btn.icon {
  background: var(--surface-2);
  color: var(--text);
  width: 40px;
  height: 40px;
  font-size: 1rem;
}

.hint {
  margin: 16px 0 48px;
  color: var(--muted);
  font-size: 0.85rem;
}

/* ---- 埋め込み表示 ---- */
dialog {
  width: min(760px, 100vw);
  height: min(92dvh, 960px);
  max-width: 100vw;
  max-height: 100dvh;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  display: none;
  flex-direction: column;
  overflow: hidden;
}
dialog[open] { display: flex; }
dialog::backdrop {
  background: rgb(0 0 0 / 0.6);
  backdrop-filter: blur(4px);
}
.sheet-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px 10px 16px;
  border-bottom: 1px solid var(--line);
}
.sheet-head h2 {
  flex: 1;
  min-width: 0;
  margin: 0;
  font-size: 1rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.sheet-body {
  position: relative;
  flex: 1;
  background: #fff;
}
.sheet-loading {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  margin: 0;
  color: #535c70;
}
.sheet-loading[hidden] { display: none; }
#sheet-frame {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
}
.sheet-note {
  margin: 0;
  padding: 8px 16px;
  font-size: 0.8rem;
  color: var(--muted);
  border-top: 1px solid var(--line);
}

@media (max-width: 600px) {
  dialog {
    width: 100vw;
    height: 100dvh;
    border-radius: 0;
    border: 0;
  }
}

@media (prefers-reduced-motion: no-preference) {
  .btn, [role="tab"], .star { transition: filter 0.15s, background-color 0.15s; }
  .btn:hover, [role="tab"]:hover { filter: brightness(1.1); }
}
