:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --text: #1f2328;
  --muted: #656d76;
  --border: #d8dce1;
  --accent: #1f6feb;
  --accent-soft: #e7f0fe;
  --danger: #cf222e;
  --success: #1a7f37;
  --radius: 10px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1216;
    --surface: #181c22;
    --text: #e6e8eb;
    --muted: #9aa3ad;
    --border: #2e353e;
    --accent: #4c8dff;
    --accent-soft: #1b2a44;
    --danger: #ff6b6b;
    --success: #4ccf72;
    color-scheme: dark;
  }
}

* { 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.7;
}

a { color: var(--accent); }
code { background: var(--accent-soft); padding: 0 4px; border-radius: 4px; }

.container {
  max-width: 880px;
  margin: 0 auto;
  padding: 0 16px;
}

/* ---------- ヘッダー・タブ ---------- */
.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.site-header h1 {
  margin: 0;
  padding: 14px 0;
  font-size: 1.25rem;
}
.header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.header-actions { display: flex; gap: 16px; align-items: center; }

.tabs-bar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.tabs {
  display: flex;
  gap: 4px;
  overflow-x: auto;
  scrollbar-width: none;
}
.tab {
  flex: none;
  padding: 10px 14px;
  color: var(--muted);
  text-decoration: none;
  border-bottom: 3px solid transparent;
  white-space: nowrap;
}
.tab:hover { color: var(--text); }
.tab[aria-selected="true"] {
  color: var(--accent);
  border-bottom-color: var(--accent);
  font-weight: 600;
}

/* ---------- 授業カード ---------- */
.toolbar { margin: 16px 0; }
.toolbar input { width: 100%; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  margin-bottom: 16px;
}
.card h2 { margin: 0 0 8px; font-size: 1.15rem; line-height: 1.5; }
.card .date { margin: 0 0 2px; color: var(--muted); font-size: 0.875rem; }
.description { white-space: pre-wrap; overflow-wrap: anywhere; margin: 0 0 12px; }

.video {
  position: relative;
  aspect-ratio: 16 / 9;
  margin: 12px 0;
  border-radius: 8px;
  overflow: hidden;
  background: #000;
}
.video iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }

.pdf-list { list-style: none; padding: 0; margin: 12px 0; }
.pdf-list li { display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; padding: 4px 0; }
.pdf-list a { overflow-wrap: anywhere; }
.badge {
  display: inline-block;
  margin-right: 6px;
  padding: 0 6px;
  border-radius: 4px;
  background: var(--danger);
  color: #fff;
  font-size: 0.75rem;
  font-weight: 700;
}

.image-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 8px;
  margin: 12px 0;
}
.image-grid img {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid var(--border);
  display: block;
}

.empty { color: var(--muted); text-align: center; padding: 40px 0; }
.muted { color: var(--muted); font-size: 0.875rem; }
.error { color: var(--danger); margin: 8px 0; }
.error:empty, .success:empty { display: none; }
.success { color: var(--success); margin: 8px 0; }

.site-footer { padding: 24px 0 40px; text-align: center; font-size: 0.875rem; }
.site-footer a { color: var(--muted); }

/* ---------- フォーム ---------- */
input[type="text"], input[type="password"], input[type="search"], input[type="date"], select, textarea {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
}
input[type="text"], input[type="password"], input[type="search"], input[type="date"], select { height: 42px; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
input[type="file"] { display: block; margin-top: 4px; max-width: 100%; }

button {
  padding: 7px 14px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  cursor: pointer;
  white-space: nowrap;
}
button:hover:not(:disabled) { border-color: var(--accent); }
button:disabled { opacity: 0.4; cursor: default; }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
button.danger { color: var(--danger); }
.link-button { border: 0; background: none; padding: 0; color: var(--accent); text-decoration: underline; }

/* ---------- 教員用ページ ---------- */
.admin main { padding-top: 20px; padding-bottom: 40px; }
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  margin-bottom: 20px;
}
.panel.narrow { max-width: 420px; margin: 40px auto; }
.panel h2 { margin: 0 0 14px; font-size: 1.1rem; }
.panel form > label, .panel .row > label { display: block; margin-bottom: 12px; font-size: 0.9rem; font-weight: 600; }
.panel label input, .panel label select, .panel label textarea { margin-top: 4px; font-weight: 400; }
.field-label { font-size: 0.9rem; font-weight: 600; margin: 0 0 4px; }
.required { color: var(--danger); font-size: 0.75rem; font-weight: 400; }

.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; }
.row > * { flex: 1 1 200px; }
.row > button { flex: none; }
.inline-form { display: flex; gap: 8px; align-items: flex-end; margin: 12px 0; }
.inline-form .grow { flex: 1; margin: 0 !important; }
.actions { display: flex; gap: 8px; margin-top: 8px; }

.notice { background: var(--accent-soft); padding: 10px 12px; border-radius: 6px; }

.item-list { list-style: none; padding: 0; margin: 0; }
.item-list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}
.item-list li:last-child { border-bottom: 0; }
.item-list li.editing { background: var(--accent-soft); margin: 0 -8px; padding: 8px; border-radius: 6px; }
.item-title { overflow-wrap: anywhere; }
.item-actions { display: flex; gap: 4px; flex-wrap: wrap; }
.item-actions button { padding: 4px 10px; font-size: 0.875rem; }

.check-list { list-style: none; padding: 0; margin: 0 0 12px; }
.check-list label { display: flex; gap: 6px; align-items: baseline; font-weight: 400; }
.check-list a { overflow-wrap: anywhere; }
