:root {
  color-scheme: light;
  --ink: #17202a;
  --muted: #687586;
  --line: #dce3ea;
  --panel: #ffffff;
  --page: #f4f7f9;
  --blue: #1f6feb;
  --blue-dark: #174ea6;
  --green: #12805c;
  --amber: #b35c00;
  --red: #c0392b;
  --radius: 8px;
  font-family: "Yu Gothic UI", "Hiragino Kaku Gothic ProN", Meiryo, system-ui, sans-serif;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-width: 320px;
  color: var(--ink);
  background:
    linear-gradient(135deg, rgba(31, 111, 235, 0.08), transparent 34%),
    linear-gradient(315deg, rgba(18, 128, 92, 0.08), transparent 32%),
    var(--page);
}

button, input, select, textarea { font: inherit; }
.app-shell { display: grid; grid-template-columns: 264px minmax(0, 1fr); min-height: 100vh; }
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 24px 18px;
  color: #f8fbff;
  background: #14213d;
}
.brand { display: flex; gap: 12px; align-items: center; padding-bottom: 24px; border-bottom: 1px solid rgba(255,255,255,.16); }
.brand-mark { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 8px; color: #14213d; font-size: 26px; font-weight: 800; background: #f4d35e; }
.brand h1, .topbar h2, .panel h3 { margin: 0; letter-spacing: 0; }
.brand h1 { font-size: 20px; }
.eyebrow { margin: 0 0 4px; color: currentColor; opacity: .68; font-size: 12px; font-weight: 700; text-transform: uppercase; }
.nav-list { display: grid; gap: 6px; margin-top: 24px; }
.nav-list a { padding: 12px; color: #d9e7ff; text-decoration: none; border-radius: 8px; }
.nav-list a.active, .nav-list a:hover { color: #fff; background: rgba(255,255,255,.12); }
.course-chip { margin-top: 28px; padding: 14px; border: 1px solid rgba(255,255,255,.14); border-radius: 8px; background: rgba(255,255,255,.08); }
.course-chip span, .course-chip strong { display: block; }
.course-chip span { color: #c8d5e7; font-size: 12px; }
.course-chip strong { margin-top: 4px; }

.main { min-width: 0; padding: 28px; }
.topbar { display: flex; gap: 18px; align-items: center; justify-content: space-between; margin-bottom: 22px; }
.topbar h2 { font-size: clamp(22px, 3vw, 34px); }
.primary-button, .secondary-button, .icon-button, .link-button, .small-button, .danger-button {
  border: 0;
  cursor: pointer;
  border-radius: 8px;
  font-weight: 700;
  white-space: nowrap;
}
.primary-button { padding: 12px 16px; color: #fff; background: var(--blue); }
.secondary-button { padding: 10px 14px; color: var(--blue-dark); background: #e8f0fe; }
.icon-button { display: grid; place-items: center; width: 38px; height: 38px; color: #fff; font-size: 22px; background: var(--green); }
.link-button, .small-button { min-height: 32px; padding: 6px 10px; color: #394150; background: #edf1f5; }
.link-button { color: var(--blue-dark); background: #e8f0fe; }
.danger-button { min-height: 32px; padding: 6px 10px; color: #fff; background: var(--red); }

.metrics { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 18px; }
.metric, .panel { border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); box-shadow: 0 8px 22px rgba(28,43,58,.06); }
.metric { padding: 18px; }
.metric span, .metric small { display: block; color: var(--muted); }
.metric strong { display: block; margin: 8px 0 4px; font-size: 32px; }
.workspace-grid { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(320px, .75fr); gap: 18px; }
.workspace-grid.lower { align-items: start; margin-top: 18px; }
.panel { min-width: 0; padding: 18px; }
.panel-heading { display: flex; gap: 14px; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.panel h3 { font-size: 20px; }

.invite-box, .question-editor, .material-settings {
  display: grid;
  gap: 12px;
  align-items: end;
  margin-bottom: 16px;
  padding: 14px;
  border: 1px solid #e3e8ef;
  border-radius: 8px;
  background: #f8fafc;
}
.invite-box { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto auto; }
.question-editor, .material-settings { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto; }
.question-editor .wide-field { grid-column: 1 / -1; }
label { display: grid; gap: 6px; color: var(--muted); font-size: 13px; font-weight: 700; }
input, select, textarea { width: 100%; border: 1px solid #cfd8e3; border-radius: 8px; color: var(--ink); background: #fff; }
input, select { min-height: 42px; padding: 9px 10px; }
textarea { min-height: 86px; padding: 10px; resize: vertical; }
.invite-box textarea { grid-column: 1 / -1; min-height: 78px; }
.generated-alias { display: grid; align-content: center; gap: 4px; min-height: 42px; padding: 8px 10px; border: 1px solid #cfd8e3; border-radius: 8px; background: #fff; }
.generated-alias span { color: var(--muted); font-size: 12px; font-weight: 700; }
.generated-alias strong { font-size: 16px; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; min-width: 700px; }
th, td { padding: 12px 10px; text-align: left; border-bottom: 1px solid #e7edf3; }
th { color: var(--muted); font-size: 12px; }
.row-actions { display: flex; gap: 8px; align-items: center; }
.status-pill, .tag { display: inline-flex; align-items: center; min-height: 28px; padding: 4px 10px; border-radius: 999px; font-size: 12px; font-weight: 800; white-space: nowrap; }
.status-pill, .tag.active { color: var(--green); background: #e7f6f0; }
.tag.pending { color: var(--amber); background: #fff4df; }
.tag.review { color: var(--red); background: #fdecea; }
.tag.paused { color: #394150; background: #edf1f5; }

.progress-list, .question-list, .assignment-preview { display: grid; gap: 12px; }
.progress-item { display: grid; gap: 8px; }
.progress-title { display: flex; justify-content: space-between; gap: 12px; font-weight: 800; }
.bar { height: 10px; overflow: hidden; border-radius: 999px; background: #e7edf3; }
.bar span { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--green), var(--blue)); }
.question-card, .assignment-card, .learning-flow { padding: 14px; border: 1px solid #e3e8ef; border-radius: 8px; background: #fbfcfe; }
.question-card header { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 8px; }
.question-card p, .assignment-card p { margin: 0; line-height: 1.65; }
.question-meta { color: var(--muted); font-size: 12px; font-weight: 700; }
.answer { margin-top: 10px; color: var(--blue-dark); font-size: 13px; font-weight: 800; }
.question-delete { margin-top: 12px; }
.slide-link { display: block; margin-top: 8px; color: var(--blue-dark); font-weight: 800; }
.assignment-form { display: grid; grid-template-columns: minmax(0, 1fr) 120px; gap: 12px; margin-bottom: 16px; }
.learning-flow { margin-bottom: 16px; }
.compact-heading { margin-bottom: 10px; }
.flow-steps { display: grid; gap: 12px; margin: 0; padding: 0; list-style: none; }
.flow-steps li { display: grid; grid-template-columns: 32px minmax(0, 1fr); gap: 10px; align-items: start; }
.flow-steps li > span { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 999px; color: #fff; font-weight: 800; background: var(--blue); }
.flow-steps a { color: var(--blue-dark); font-weight: 800; }
.report-status { margin: 8px 0 0; color: var(--muted); font-size: 13px; font-weight: 700; }
.report-status.warning { color: var(--amber); }
.report-status.ready { color: var(--green); }

@media (max-width: 1040px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; }
  .metrics, .workspace-grid { grid-template-columns: 1fr 1fr; }
  .invite-box, .question-editor, .material-settings { grid-template-columns: 1fr; }
}

@media (max-width: 760px) {
  .main { padding: 18px; }
  .topbar, .panel-heading { align-items: stretch; flex-direction: column; }
  .metrics, .workspace-grid, .workspace-grid.lower, .assignment-form { grid-template-columns: 1fr; }
}
