:root {
  color-scheme: light;
  --font-ui:
    Inter,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    "PingFang SC",
    "Hiragino Sans",
    "Noto Sans SC",
    "Noto Sans JP",
    sans-serif;
  --font-ja:
    "Hiragino Sans",
    "Hiragino Kaku Gothic ProN",
    "Yu Gothic",
    "Noto Sans JP",
    -apple-system,
    BlinkMacSystemFont,
    sans-serif;
  --bg: #f3f4f2;
  --surface: #ffffff;
  --surface-soft: #eef2ee;
  --surface-quiet: #faf9f6;
  --ink: #30332f;
  --muted: #72776f;
  --line: #dedbd4;
  --primary: #6f8067;
  --primary-dark: #44523f;
  --primary-soft: #e5ebe2;
  --secondary: #667d85;
  --secondary-dark: #405a62;
  --secondary-soft: #e4ecee;
  --accent: #a77f74;
  --accent-soft: #f1e5e1;
  --warning: #b9863d;
  --warning-soft: #f4eadc;
  --shadow: 0 14px 36px rgba(67, 62, 52, 0.08);
  --shadow-soft: 0 8px 20px rgba(67, 62, 52, 0.06);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-ui);
  font-synthesis: none;
  -webkit-font-smoothing: antialiased;
}

:lang(ja) {
  font-family: var(--font-ja);
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.app {
  width: min(100%, 1060px);
  min-height: 100vh;
  margin: 0 auto;
  padding: 26px 22px 34px;
}

.topbar {
  position: relative;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
  padding-top: 4px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--primary-dark);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
}

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

h1 {
  max-width: 760px;
  margin-bottom: 8px;
  color: var(--ink);
  font-size: 34px;
  line-height: 1.14;
}

h2 {
  margin-bottom: 8px;
  font-size: 21px;
  line-height: 1.25;
}

h3 {
  margin-bottom: 8px;
  font-size: 17px;
  line-height: 1.35;
}

.subtitle {
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
}

.session-box {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
  min-width: 240px;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 10px;
  background: rgba(255, 255, 255, 0.72);
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.pill.is-paid {
  border-color: var(--primary-soft);
  background: var(--primary-soft);
  color: var(--primary-dark);
}

.primary-button,
.ghost-button,
.danger-button,
.module-button,
.chip-button {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  background: var(--surface);
  color: var(--ink);
  font-weight: 700;
  transition:
    background-color 160ms ease,
    border-color 160ms ease,
    color 160ms ease,
    transform 160ms ease,
    box-shadow 160ms ease;
}

.primary-button {
  border-color: var(--primary);
  background: var(--primary);
  color: #ffffff;
  box-shadow: var(--shadow-soft);
}

.danger-button {
  border-color: var(--accent-soft);
  background: var(--accent-soft);
  color: var(--accent);
}

.ghost-button {
  color: var(--primary-dark);
}

.primary-button:hover:not(:disabled),
.ghost-button:hover:not(:disabled),
.danger-button:hover:not(:disabled),
.module-button:hover:not(:disabled),
.chip-button:hover:not(:disabled),
.path-module:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-soft);
}

.primary-button:disabled,
.ghost-button:disabled,
.danger-button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.view-switch {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}

.home-guide {
  display: grid;
  gap: 14px;
}

.home-copy {
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.path-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.path-card {
  position: relative;
  display: grid;
  gap: 14px;
  overflow: hidden;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.path-card::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 4px;
  background: var(--secondary);
}

.path-card.is-primary::before {
  background: var(--primary);
}

.path-card:not(.is-primary) .eyebrow {
  color: var(--secondary-dark);
}

.path-card-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.path-card h3 {
  margin: 0;
  font-size: 25px;
  line-height: 1.18;
}

.path-modules {
  display: grid;
  gap: 10px;
}

.path-module {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 12px;
  align-items: center;
  width: 100%;
  min-height: 58px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  background: var(--surface-quiet);
  color: var(--ink);
  text-align: left;
}

.path-module strong {
  display: block;
  font-size: 16px;
  line-height: 1.2;
}

.path-card.is-primary .path-module:hover {
  border-color: var(--primary);
  background: var(--primary-soft);
}

.path-card:not(.is-primary) .path-module:hover {
  border-color: var(--secondary);
  background: var(--secondary-soft);
}

.module-strip {
  display: grid;
  gap: 10px;
  margin-bottom: 14px;
}

.module-toolbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.current-module-pill {
  display: inline-flex;
  align-items: center;
  min-height: 42px;
  border: 1px solid var(--primary-soft);
  border-radius: 8px;
  padding: 0 12px;
  background: var(--primary-soft);
  color: var(--primary-dark);
  font-weight: 800;
}

.module-group {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.module-group-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.module-group-title {
  margin: 0;
  font-size: 15px;
}

.module-group-note {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.module-grid {
  display: grid;
  grid-template-columns: repeat(var(--count), minmax(0, 1fr));
  gap: 8px;
}

.module-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  color: var(--muted);
  line-height: 1.25;
}

.module-button.is-active {
  border-color: var(--primary);
  background: var(--primary);
  color: #ffffff;
}

.module-order {
  display: inline-grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: 999px;
  background: #eeefed;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.path-card.is-primary .path-module:hover .module-order {
  background: var(--primary);
  color: #ffffff;
}

.path-card:not(.is-primary) .path-module:hover .module-order {
  background: var(--secondary);
  color: #ffffff;
}

.module-button.is-active .module-order {
  background: rgba(255, 255, 255, 0.18);
  color: #ffffff;
}

.intro {
  margin-bottom: 14px;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.intro-grid {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 14px;
  align-items: start;
}

.intro-copy {
  margin-bottom: 10px;
  color: #41463f;
  line-height: 1.6;
}

.hint {
  margin-bottom: 12px;
  padding: 10px 12px;
  border-left: 3px solid var(--warning);
  border-radius: 0 8px 8px 0;
  background: var(--warning-soft);
  color: #59462a;
  line-height: 1.55;
}

.tools {
  display: grid;
  gap: 10px;
  margin-bottom: 12px;
}

.tool-row {
  display: grid;
  grid-template-columns: 1fr 190px;
  gap: 10px;
}

.search-input,
.select-input,
.field input,
.field select,
.field textarea {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  padding: 10px 12px;
}

.search-input:focus,
.select-input:focus,
.field input:focus,
.field select:focus,
.field textarea:focus {
  outline: 2px solid var(--primary-soft);
  border-color: var(--primary);
}

.field textarea {
  min-height: 86px;
  resize: vertical;
}

.chip-row,
.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip-button {
  min-height: 34px;
  color: var(--muted);
}

.chip-button.is-active {
  border-color: var(--primary);
  background: var(--primary-soft);
  color: var(--primary-dark);
}

.content-area {
  display: grid;
  gap: 12px;
}

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

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

.card.is-locked {
  border-color: var(--accent-soft);
  background: #fff9f7;
}

.card-top,
.record-line {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.meta {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.lock {
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
}

.jp {
  margin: 10px 0 5px;
  font-size: 22px;
  line-height: 1.45;
  font-weight: 700;
}

.reading-stack {
  display: grid;
  gap: 5px;
  margin: 0 0 10px;
  padding: 10px 12px;
  border: 1px solid #ece8e2;
  border-radius: 8px;
  background: var(--surface-quiet);
}

.kana {
  margin: 0;
  color: var(--muted);
  font-family: var(--font-ja);
  font-size: 14px;
  line-height: 1.45;
}

.romaji {
  margin: 0;
  color: #7a716a;
  font-size: 13px;
  line-height: 1.45;
}

.kana span,
.romaji span {
  display: inline-block;
  min-width: 48px;
  margin-right: 8px;
  color: #9a9188;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.romaji span {
  font-weight: 900;
  -webkit-text-stroke: 0.12px currentColor;
}

.cn {
  margin-bottom: 10px;
  color: #3b444a;
  line-height: 1.55;
}

.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 12px;
}

.tag {
  padding: 4px 8px;
  border-radius: 8px;
  background: #eff0ed;
  color: #575b54;
  font-size: 12px;
  font-weight: 600;
}

.action-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.question-stage {
  display: grid;
  place-items: center;
  min-height: 172px;
  margin-bottom: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-quiet);
  text-align: center;
}

.question-stage strong {
  max-width: 620px;
  font-size: 24px;
  line-height: 1.45;
}

.practice-steps {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 10px;
  padding: 12px;
}

.practice-steps span {
  min-width: 86px;
  padding: 11px 14px;
  border: 1px solid #dcd7d0;
  border-radius: 8px;
  background: #ffffff;
  color: var(--primary-dark);
  font-size: 18px;
  font-weight: 900;
  box-shadow: var(--shadow-soft);
}

.practice-steps i {
  width: 22px;
  height: 2px;
  background: #c4b7a8;
  position: relative;
}

.practice-steps i::after {
  content: "";
  position: absolute;
  right: -1px;
  top: 50%;
  width: 7px;
  height: 7px;
  border-top: 2px solid #c4b7a8;
  border-right: 2px solid #c4b7a8;
  transform: translateY(-50%) rotate(45deg);
}

.answer {
  display: none;
  margin-top: 14px;
}

.answer.is-visible {
  display: block;
}

.progress-line {
  height: 9px;
  margin: 10px 0 14px;
  overflow: hidden;
  border-radius: 999px;
  background: #e6e4de;
}

.progress-line span {
  display: block;
  height: 100%;
  width: 0;
  background: var(--accent);
}

.empty {
  padding: 24px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: var(--surface-quiet);
  color: var(--muted);
  text-align: center;
}

.auth-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto auto;
  gap: 8px;
  width: min(100%, 720px);
  margin-bottom: 14px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.auth-panel.is-modal {
  grid-template-columns: 1fr;
  width: 100%;
  margin: 12px 0 0;
  padding: 0;
  border: 0;
  box-shadow: none;
}

.auth-tabs {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}

.auth-prompt {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  align-items: end;
  padding: 18px;
  background: rgba(48, 51, 47, 0.38);
}

.auth-card {
  width: min(100%, 520px);
  margin: 0 auto;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 24px 60px rgba(48, 51, 47, 0.24);
}

.admin-layout {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 14px;
  align-items: start;
}

.sidebar {
  position: sticky;
  top: 12px;
  max-height: calc(100vh - 24px);
  overflow: auto;
}

.admin-filters {
  display: grid;
  gap: 8px;
  margin-bottom: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}

.admin-filter-count {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.admin-filter-count span {
  display: inline-block;
  margin: 4px 6px 0 0;
  padding: 3px 7px;
  border-radius: 8px;
  background: #eff0ed;
  color: #575b54;
}

.admin-drag-hint {
  margin: -2px 0 0;
  color: #8f877d;
  font-size: 12px;
  line-height: 1.45;
}

.simulation-builder {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--line);
}

.simulation-row {
  margin-bottom: 8px;
}

.simulation-row.is-draggable {
  cursor: grab;
}

.simulation-row.is-dragging {
  opacity: 0.45;
}

.simulation-row.is-drop-target .item-button {
  border-color: var(--primary);
  box-shadow: inset 0 0 0 2px rgba(111, 128, 103, 0.18);
}

.simulation-row .item-button {
  margin-bottom: 6px;
}

.simulation-row-actions {
  display: flex;
  gap: 6px;
  margin-bottom: 8px;
}

.tiny-button {
  min-height: 30px;
  padding: 0 9px;
  font-size: 12px;
}

.item-button,
.user-button {
  width: 100%;
  margin-bottom: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: var(--surface);
  text-align: left;
}

.item-button.is-draggable {
  cursor: grab;
}

.item-button.is-dragging {
  opacity: 0.45;
  cursor: grabbing;
}

.item-button.is-drop-target {
  border-color: var(--primary);
  box-shadow: inset 0 0 0 2px rgba(111, 128, 103, 0.18);
}

.item-button.is-active,
.user-button.is-active {
  border-color: var(--primary);
  background: var(--primary-soft);
}

.drag-handle {
  float: right;
  margin-left: 8px;
  padding: 3px 7px;
  border-radius: 8px;
  background: #eff0ed;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.item-title {
  margin-bottom: 4px;
  font-family: var(--font-ja);
  font-size: 15px;
  font-weight: 700;
  line-height: 1.35;
}

.badge {
  display: inline-block;
  margin: 0 5px 5px 0;
  padding: 4px 7px;
  border-radius: 8px;
  background: #eff0ed;
  color: #575b54;
  font-size: 12px;
  font-weight: 800;
}

.badge.is-paid,
.badge.is-recorded {
  background: var(--primary-soft);
  color: var(--primary-dark);
}

.badge.is-live {
  background: var(--accent-soft);
  color: var(--accent);
}

.badge.is-locked {
  background: var(--accent-soft);
  color: var(--accent);
}

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

.annotation-tools {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-top: -4px;
}

.annotation-tools span {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.recorder-box {
  display: grid;
  gap: 10px;
  margin-top: 12px;
  padding: 12px;
  border: 1px solid var(--primary-soft);
  border-radius: 8px;
  background: var(--surface-soft);
}

.wave-canvas {
  width: 100%;
  height: 78px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-quiet);
}

.field {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

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

.toast {
  position: fixed;
  left: 50%;
  bottom: 22px;
  z-index: 20;
  width: min(92vw, 430px);
  transform: translateX(-50%) translateY(24px);
  opacity: 0;
  pointer-events: none;
  padding: 12px 14px;
  border-radius: 8px;
  background: #30332f;
  color: #ffffff;
  font-size: 14px;
  line-height: 1.45;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.22);
  transition:
    opacity 160ms ease,
    transform 160ms ease;
}

.toast.is-visible {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

@media (max-width: 760px) {
  .app {
    padding: 18px 14px 28px;
  }

  .topbar,
  .module-group-header,
  .admin-layout,
  .auth-panel,
  .path-grid {
    display: grid;
    grid-template-columns: 1fr;
  }

  .session-box {
    position: absolute;
    top: 0;
    right: 0;
    z-index: 2;
    flex-wrap: nowrap;
    justify-content: flex-end;
    gap: 6px;
    max-width: 100%;
    min-width: 0;
  }

  .session-box .pill {
    max-width: 148px;
    min-height: 30px;
    overflow: hidden;
    padding: 0 8px;
    font-size: 12px;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .session-box .ghost-button {
    min-height: 30px;
    padding: 0 9px;
    font-size: 12px;
  }

  h1 {
    font-size: 30px;
  }

  h2 {
    font-size: 22px;
  }

  .topbar {
    display: block;
    gap: 12px;
    margin-bottom: 16px;
    padding-top: 44px;
  }

  .home-copy,
  .path-card,
  .intro,
  .card,
  .trainer-card,
  .panel {
    padding: 16px;
  }

  .question-stage {
    min-height: 156px;
  }

  .question-stage strong {
    font-size: 22px;
  }

  .practice-steps {
    gap: 8px;
  }

  .practice-steps span {
    min-width: 74px;
    padding: 10px 11px;
    font-size: 16px;
  }

  .practice-steps i {
    width: 14px;
  }

  .module-grid,
  .content-area.is-grid,
  .intro-grid,
  .tool-row,
  .action-grid,
  .editor-grid {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    max-height: none;
  }
}
