:root {
  color-scheme: light;
  --ink: #202124;
  --muted: #667085;
  --line: #d7dde5;
  --paper: #fbfcfd;
  --panel: #ffffff;
  --brand: #0f766e;
  --brand-2: #2563eb;
  --accent: #f59e0b;
  --good: #15803d;
  --bad: #b42318;
  --shadow: 0 14px 35px rgba(16, 24, 40, 0.08);
  font-family: "Yu Gothic", "Hiragino Kaku Gothic ProN", Meiryo, system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(90deg, rgba(15, 118, 110, 0.08), transparent 42%),
    linear-gradient(180deg, #f7fafc 0%, #edf2f7 100%);
  color: var(--ink);
}

button,
input,
textarea {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.58;
}

.shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
}

.sidebar {
  background: #102a43;
  color: #eff6ff;
  padding: 24px 18px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 48px;
}

.brand-mark {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: #f59e0b;
  color: #111827;
  font-weight: 800;
}

.brand-mark.small {
  width: 36px;
  height: 36px;
  font-size: 15px;
}

.brand-title {
  font-size: 18px;
  font-weight: 800;
}

.brand-sub {
  font-size: 12px;
  color: #b8c7d9;
}

.nav-list,
.app-list {
  display: grid;
  gap: 8px;
}

.nav-button {
  width: 100%;
  min-height: 44px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 8px;
  background: transparent;
  color: #dbeafe;
  text-align: left;
}

.nav-button.active,
.nav-button:hover {
  background: rgba(255, 255, 255, 0.12);
}

.nav-icon {
  width: 24px;
  text-align: center;
}

.user-box {
  margin-top: auto;
  padding: 14px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 8px;
  color: #dbeafe;
}

.user-box strong {
  display: block;
  color: #ffffff;
}

.logout {
  margin-top: 10px;
  min-height: 36px;
  width: 100%;
  border-radius: 8px;
  background: #e2e8f0;
  color: #102a43;
}

.main {
  min-width: 0;
  padding: 28px clamp(16px, 3vw, 36px);
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: center;
  margin-bottom: 22px;
}

.eyebrow {
  color: var(--brand);
  font-size: 13px;
  font-weight: 800;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 6px;
  font-size: clamp(25px, 3vw, 38px);
  letter-spacing: 0;
}

h2 {
  font-size: 24px;
  margin-bottom: 12px;
}

h3 {
  font-size: 18px;
  margin-bottom: 8px;
}

.muted {
  color: var(--muted);
  line-height: 1.8;
}

.auth-wrap {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(320px, 0.9fr);
}

.auth-visual {
  position: relative;
  overflow: hidden;
  padding: clamp(28px, 6vw, 72px);
  background: #102a43;
  color: #ffffff;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 520px;
}

.wire-board {
  display: grid;
  gap: 18px;
  max-width: 640px;
}

.wire-row {
  display: grid;
  grid-template-columns: 100px minmax(120px, 1fr) 74px;
  align-items: center;
  gap: 14px;
}

.wire-label {
  color: #dbeafe;
  font-weight: 700;
}

.wire-line {
  height: 16px;
  border-radius: 999px;
  background: linear-gradient(90deg, #d97706, #fbbf24, #b45309);
  box-shadow: inset 0 2px 2px rgba(255, 255, 255, 0.4), 0 10px 20px rgba(0, 0, 0, 0.18);
}

.wire-line.thin {
  height: 9px;
}

.wire-line.thick {
  height: 26px;
}

.wire-note {
  color: #fef3c7;
  font-weight: 800;
}

.auth-panel {
  padding: clamp(22px, 4vw, 48px);
  display: flex;
  align-items: center;
  background: #ffffff;
}

.auth-card {
  width: 100%;
  max-width: 470px;
}

.tabs {
  display: inline-grid;
  grid-template-columns: 1fr 1fr;
  padding: 4px;
  background: #eef2f7;
  border-radius: 8px;
  margin-bottom: 18px;
}

.tab {
  min-height: 38px;
  padding: 0 14px;
  border-radius: 6px;
  background: transparent;
  color: #475467;
}

.tab.active {
  background: #ffffff;
  color: var(--ink);
  box-shadow: 0 1px 5px rgba(16, 24, 40, 0.12);
}

.form {
  display: grid;
  gap: 14px;
}

.field {
  display: grid;
  gap: 6px;
}

.field span {
  font-weight: 700;
  color: #344054;
}

.field input {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  background: #ffffff;
}

.field textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  background: #ffffff;
  line-height: 1.7;
  resize: vertical;
}

.field input[readonly],
.field textarea[readonly] {
  background: #f8fafc;
}

.primary,
.secondary {
  min-height: 44px;
  border-radius: 8px;
  padding: 0 16px;
  font-weight: 800;
}

.primary {
  background: var(--brand);
  color: #ffffff;
}

.secondary {
  background: #e2e8f0;
  color: #1f2937;
}

.notice {
  border-left: 4px solid var(--brand-2);
  padding: 12px 14px;
  background: #eff6ff;
  color: #1e3a8a;
  border-radius: 8px;
  line-height: 1.7;
}

.error {
  border-left-color: var(--bad);
  background: #fff1f0;
  color: var(--bad);
}

.grid {
  display: grid;
  gap: 16px;
}

.grid.two {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.grid.three {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 18px;
}

.module-card {
  min-height: 190px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.app-tree {
  display: grid;
  gap: 16px;
}

.tree-group {
  padding: 0;
  overflow: hidden;
}

.tree-heading {
  min-height: 74px;
  display: grid;
  grid-template-columns: 34px 1fr;
  gap: 12px;
  align-items: center;
  padding: 18px;
  border-bottom: 1px solid var(--line);
  background: #f8fafc;
}

.tree-heading h2,
.tree-heading p,
.tree-item h3,
.tree-item p {
  margin-bottom: 0;
}

.tree-toggle {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: #e2e8f0;
  color: #334155;
  font-weight: 800;
}

.tree-children {
  display: grid;
  padding: 6px 0 8px;
}

.tree-item {
  position: relative;
  display: grid;
  grid-template-columns: 28px 36px minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  min-height: 104px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
}

.tree-item:last-child {
  border-bottom: 0;
}

.tree-item.active {
  background: #eff6ff;
}

.tree-branch {
  width: 18px;
  height: 52px;
  border-left: 2px solid #cbd5e1;
  border-bottom: 2px solid #cbd5e1;
  border-bottom-left-radius: 8px;
  justify-self: center;
}

.tree-item-main {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.tree-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.status-pill {
  width: fit-content;
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 800;
  background: #ecfdf3;
  color: #027a48;
}

.lesson-layout {
  display: grid;
  grid-template-columns: minmax(280px, 380px) minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.problem-box {
  border: 2px solid #1f2937;
  background: #ffffff;
  display: grid;
  grid-template-columns: 56px 1fr;
  min-height: 200px;
}

.problem-number {
  display: grid;
  place-items: start center;
  padding-top: 28px;
  border-right: 1px solid #1f2937;
  font-size: 24px;
  font-weight: 800;
}

.problem-text {
  padding: 24px;
  font-size: 20px;
  line-height: 1.8;
}

.choice-list {
  display: grid;
  gap: 10px;
}

.choice {
  width: 100%;
  min-height: 56px;
  padding: 12px 14px;
  display: grid;
  grid-template-columns: 42px 1fr auto;
  gap: 10px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  text-align: left;
}

.choice.selected {
  border-color: var(--brand-2);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.choice.correct {
  border-color: var(--good);
  background: #f0fdf4;
}

.choice.wrong {
  border-color: var(--bad);
  background: #fff1f0;
}

.kana {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: #eef2f7;
  font-weight: 800;
}

.score {
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}

.steps {
  display: grid;
  gap: 12px;
}

.step {
  display: grid;
  grid-template-columns: 34px 1fr;
  gap: 10px;
  align-items: start;
}

.step-num {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: #fef3c7;
  color: #92400e;
  display: grid;
  place-items: center;
  font-weight: 800;
}

.formula {
  padding: 12px 14px;
  border-radius: 8px;
  background: #111827;
  color: #ffffff;
  font-size: 18px;
  font-weight: 800;
  overflow-wrap: anywhere;
}

.frac {
  display: inline-grid;
  grid-template-rows: auto auto;
  align-items: center;
  justify-items: center;
  min-width: 2.2em;
  margin: 0 0.12em;
  vertical-align: middle;
  line-height: 1.05;
}

.frac span:first-child {
  width: 100%;
  padding: 0 0.18em 0.12em;
  border-bottom: 2px solid currentColor;
}

.frac span:last-child {
  padding-top: 0.12em;
}

.frac.inline {
  font-size: 0.92em;
  transform: translateY(-0.04em);
}

.formula.soft {
  background: #ecfdf3;
  color: #065f46;
}

.formula-stack {
  display: grid;
  gap: 12px;
}

.simulator {
  display: grid;
  gap: 12px;
}

.range-row {
  display: grid;
  grid-template-columns: 92px 1fr 70px;
  gap: 12px;
  align-items: center;
}

input[type="range"] {
  width: 100%;
  accent-color: var(--brand);
}

.meter {
  height: 18px;
  border-radius: 999px;
  background: #e5e7eb;
  overflow: hidden;
}

.meter-fill {
  height: 100%;
  width: 40%;
  background: linear-gradient(90deg, var(--brand), var(--accent));
}

.compare-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 15px;
}

.compare-table th,
.compare-table td {
  border-bottom: 1px solid var(--line);
  padding: 10px 8px;
  text-align: left;
  vertical-align: top;
}

.compare-table th {
  color: #475467;
  background: #f8fafc;
}

.admin-tools {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}

.code-chip {
  padding: 9px 12px;
  border-radius: 8px;
  background: #111827;
  color: #ffffff;
  font-weight: 800;
}

.formula-hero {
  font-size: clamp(38px, 7vw, 78px);
  font-weight: 900;
  line-height: 1;
  color: #fef3c7;
  margin-bottom: 28px;
}

.path-list {
  display: grid;
  gap: 12px;
  margin-top: 18px;
}

.path-list.compact {
  margin-top: 0;
}

.path-item {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 14px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  box-shadow: var(--shadow);
}

.path-list.compact .path-item {
  grid-template-columns: minmax(0, 1fr) auto;
  box-shadow: none;
}

.path-item.active {
  border-color: var(--brand-2);
  background: #eff6ff;
}

.path-item.locked {
  background: #f8fafc;
  color: #667085;
}

.locked-tab {
  opacity: 0.55;
}

.gate-note {
  margin-bottom: 16px;
}

.stat {
  min-height: 110px;
  display: grid;
  align-content: center;
  gap: 4px;
}

.stat strong,
.big-score {
  font-size: clamp(34px, 5vw, 54px);
  line-height: 1;
}

.stat span {
  color: var(--muted);
  font-weight: 800;
}

.lesson-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.concept-list {
  display: grid;
  gap: 12px;
  margin-bottom: 18px;
}

.concept-list div {
  display: grid;
  gap: 4px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}

.concept-list strong {
  font-size: 20px;
}

.concept-list span {
  color: var(--muted);
  line-height: 1.7;
}

.formula-card {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.formula-tile {
  min-height: 88px;
  border-radius: 8px;
  background: #111827;
  color: #ffffff;
  font-size: 20px;
  font-weight: 900;
}

.segmented {
  display: grid;
  gap: 8px;
  margin-bottom: 18px;
}

.segmented button {
  min-height: 48px;
  border-radius: 8px;
  background: #eef2f7;
  color: #334155;
  font-weight: 800;
}

.segmented button.active {
  background: var(--brand);
  color: #ffffff;
}

.formula-board {
  display: grid;
  gap: 12px;
  margin-bottom: 18px;
}

.arrow {
  text-align: center;
  font-size: 28px;
  font-weight: 900;
  color: var(--muted);
}

.active-step {
  padding: 8px;
  border-radius: 8px;
  background: #f8fafc;
}

.step-controls {
  display: flex;
  gap: 10px;
  margin-top: 16px;
}

.full {
  grid-column: 1 / -1;
}

.problem-text.compact {
  min-height: auto;
  padding: 0;
  font-size: 18px;
  border: 0;
}

.wide {
  width: 100%;
}

.invite-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.template-box {
  display: grid;
  gap: 12px;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

@media (max-width: 900px) {
  .shell,
  .auth-wrap,
  .lesson-layout,
  .grid.two,
  .grid.three {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }
}

@media (max-width: 560px) {
  .main {
    padding: 18px 12px;
  }

  .tree-heading {
    grid-template-columns: 30px 1fr;
    padding: 14px;
  }

  .tree-item {
    grid-template-columns: 24px 34px minmax(0, 1fr);
    padding: 14px;
  }

  .tree-item button {
    grid-column: 2 / 4;
    width: 100%;
  }

  .path-item,
  .formula-card {
    grid-template-columns: 1fr;
  }

  .problem-box {
    grid-template-columns: 42px 1fr;
  }

  .problem-text {
    padding: 16px;
    font-size: 17px;
  }

  .choice {
    grid-template-columns: 34px 1fr;
  }

  .score {
    grid-column: 2;
  }
}
