:root {
  --background: #f6f7f8;
  --foreground: #172026;
  --muted: #5d6872;
  --line: #d9dee3;
  --paper: #ffffff;
  --paper-soft: #eef3f2;
  --ink: #172026;
  --red: #b63f32;
  --red-dark: #8f2f26;
  --teal: #0e6f6a;
  --green: #306b4f;
  --gold: #b3831e;
  --blue: #315f8c;
  --shadow: 0 18px 45px rgb(23 32 38 / 0.08);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  min-width: 320px;
  margin: 0;
  background:
    linear-gradient(90deg, rgb(23 32 38 / 0.035) 1px, transparent 1px),
    linear-gradient(180deg, rgb(23 32 38 / 0.035) 1px, transparent 1px),
    var(--background);
  background-size: 28px 28px;
  color: var(--foreground);
  font-family:
    Inter,
    ui-sans-serif,
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
}

button,
a {
  font: inherit;
}

button {
  cursor: pointer;
}

.n3-app {
  min-height: 100dvh;
  color: var(--ink);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  min-height: 72px;
  padding: 12px clamp(16px, 4vw, 52px);
  border-bottom: 1px solid var(--line);
  background: rgb(246 247 248 / 0.92);
  backdrop-filter: blur(16px);
}

.brand {
  display: inline-flex;
  align-items: center;
  min-width: max-content;
  gap: 12px;
  color: inherit;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border: 2px solid var(--ink);
  border-radius: 8px;
  background: var(--red);
  color: white;
  font-size: 16px;
  font-weight: 850;
  box-shadow: 4px 4px 0 var(--ink);
}

.brand strong,
.brand small {
  display: block;
}

.brand strong {
  font-size: 17px;
  line-height: 1.1;
}

.brand small {
  color: var(--muted);
  font-size: 12px;
  margin-top: 3px;
}

.tabs {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
}

.tab {
  min-height: 34px;
  padding: 0 12px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  white-space: nowrap;
}

.tab.active {
  background: var(--ink);
  color: white;
}

.study-shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 48px;
}

.today-band {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(310px, 0.65fr);
  gap: 24px;
  align-items: stretch;
  margin-bottom: 24px;
}

.today-copy {
  min-width: 0;
  padding: clamp(24px, 4vw, 40px);
  border: 2px solid var(--ink);
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgb(182 63 50 / 0.11), transparent 38%),
    linear-gradient(315deg, rgb(14 111 106 / 0.12), transparent 42%),
    white;
  box-shadow: var(--shadow);
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--red-dark);
  font-size: 12px;
  font-weight: 850;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  overflow-wrap: anywhere;
}

h1 {
  max-width: 760px;
  margin: 0;
  font-size: clamp(34px, 6vw, 72px);
  font-weight: 900;
  letter-spacing: 0;
  line-height: 0.98;
}

.today-copy p:last-child {
  max-width: 660px;
  margin: 18px 0 0;
  color: var(--muted);
  font-size: 17px;
  line-height: 1.7;
}

.scoreboard {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  padding: 14px;
  border: 2px solid var(--ink);
  border-radius: 8px;
  background: var(--ink);
  color: white;
  box-shadow: var(--shadow);
}

.scoreboard div {
  display: flex;
  min-height: 116px;
  flex-direction: column;
  justify-content: space-between;
  padding: 14px;
  border: 1px solid rgb(255 255 255 / 0.2);
  border-radius: 6px;
}

.metric {
  font-size: clamp(25px, 4vw, 38px);
  font-weight: 900;
  line-height: 1;
}

.scoreboard span:last-child {
  color: rgb(255 255 255 / 0.72);
  font-size: 13px;
}

.workspace {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  gap: 24px;
  align-items: start;
}

.daily-panel,
.main-panel,
.focus-card,
.image-card,
.mini-drill,
.reading-card,
.quiz-card,
.plan-day {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
  box-shadow: 0 12px 32px rgb(23 32 38 / 0.06);
}

.daily-panel {
  position: sticky;
  top: 92px;
  padding: 20px;
}

.panel-heading h2,
.section-head h2,
.focus-card h2,
.image-card h2,
.mini-drill h2 {
  margin: 0;
  font-size: clamp(22px, 3vw, 32px);
  font-weight: 850;
  letter-spacing: 0;
  line-height: 1.08;
}

.progress-track {
  height: 10px;
  margin: 18px 0;
  overflow: hidden;
  border-radius: 999px;
  background: #e5e9ed;
}

.progress-track span {
  display: block;
  height: 100%;
  width: 0%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--red), var(--teal));
  transition: width 180ms ease;
}

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

.task {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr);
  gap: 12px;
  align-items: start;
  width: 100%;
  min-height: 72px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfc;
  color: var(--ink);
  text-align: left;
}

.task.done {
  border-color: rgb(48 107 79 / 0.45);
  background: #eef7f1;
}

.task.active {
  border-color: rgb(49 95 140 / 0.55);
  background: #eef4fb;
}

.check {
  display: grid;
  width: 28px;
  height: 28px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: white;
  color: var(--green);
  font-weight: 900;
}

.task.done .check::before {
  content: "✓";
}

.task-text strong,
.task-text small {
  display: block;
}

.task-text strong {
  font-size: 14px;
  line-height: 1.45;
}

.task-text small {
  margin-top: 5px;
  color: var(--muted);
  font-size: 12px;
}

.main-panel {
  min-height: 610px;
  padding: clamp(18px, 3vw, 28px);
}

.task-workbench {
  display: grid;
  gap: 18px;
  margin-bottom: 16px;
  padding: clamp(18px, 3vw, 24px);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
  box-shadow: 0 12px 32px rgb(23 32 38 / 0.06);
}

.task-detail-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 14px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line);
}

.task-detail-head h2 {
  margin: 0;
  font-size: clamp(24px, 4vw, 42px);
  font-weight: 900;
  letter-spacing: 0;
  line-height: 1.08;
}

.complete-task,
.primary-action,
.ghost-action,
.icon-action {
  min-height: 40px;
  border: 1px solid var(--ink);
  border-radius: 8px;
  font-weight: 820;
  white-space: nowrap;
}

.complete-task,
.primary-action {
  padding: 0 14px;
  background: var(--ink);
  color: white;
}

.complete-task.done {
  border-color: var(--green);
  background: var(--green);
}

.ghost-action {
  padding: 0 14px;
  background: white;
  color: var(--ink);
}

.icon-action {
  display: grid;
  width: 42px;
  padding: 0;
  place-items: center;
  background: white;
  color: var(--ink);
  font-size: 20px;
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

.today-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(250px, 0.78fr);
  gap: 16px;
}

.support-grid {
  margin-top: 16px;
}

.focus-card,
.mini-drill,
.image-card {
  padding: 22px;
}

.focus-card ol {
  display: grid;
  gap: 14px;
  margin: 20px 0 0;
  padding-left: 22px;
  color: var(--muted);
  line-height: 1.7;
}

.image-card {
  display: grid;
  gap: 18px;
  grid-row: span 2;
  align-content: start;
  background: #101820;
  color: white;
}

.image-card img {
  display: block;
  width: 100%;
  aspect-ratio: 1.62;
  object-fit: cover;
  border: 1px solid rgb(255 255 255 / 0.22);
  border-radius: 8px;
  background: linear-gradient(135deg, #24313a, #65312b);
}

.image-card .eyebrow {
  color: #f3c15f;
}

.image-card p:last-child,
.mini-drill p:last-child {
  color: rgb(255 255 255 / 0.74);
  line-height: 1.7;
}

.mini-drill {
  background: var(--teal);
  color: white;
}

.mini-drill .eyebrow {
  color: #cceae6;
}

.jp {
  font-family:
    "Hiragino Sans",
    "Yu Gothic",
    "Noto Sans JP",
    ui-sans-serif,
    system-ui,
    sans-serif;
}

.mini-drill .jp {
  margin: 22px 0 12px;
  padding: 14px;
  border-radius: 8px;
  background: rgb(255 255 255 / 0.12);
  font-size: clamp(18px, 3vw, 26px);
  font-weight: 800;
  line-height: 1.55;
}

.study-section {
  display: grid;
  gap: 20px;
}

.section-head {
  display: grid;
  gap: 6px;
  max-width: 760px;
}

.section-head p:last-child {
  margin: 6px 0 0;
  color: var(--muted);
  line-height: 1.7;
}

.section-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.vocab-tools {
  display: grid;
  grid-template-columns: minmax(230px, 0.72fr) minmax(0, 1fr);
  gap: 12px;
  align-items: start;
}

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

.search-field input {
  width: 100%;
  min-height: 42px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  color: var(--ink);
  font: inherit;
}

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

.chip,
.pill {
  display: inline-flex;
  width: fit-content;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: white;
  color: var(--muted);
  font-size: 12px;
  font-weight: 760;
  line-height: 1;
}

.chip {
  min-height: 32px;
  padding: 0 11px;
}

.chip.active {
  border-color: var(--teal);
  background: #edf8f7;
  color: var(--teal);
}

.pill {
  min-height: 24px;
  padding: 0 9px;
}

.result-line {
  margin: -4px 0 0;
  color: var(--muted);
  font-size: 14px;
}

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

.flash-card {
  display: flex;
  min-height: 178px;
  flex-direction: column;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfc;
  color: var(--ink);
  text-align: left;
}

.flash-card.reveal {
  border-color: rgb(182 63 50 / 0.55);
  background: #fff6f4;
}

.vocab-table-wrap {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  box-shadow: 0 12px 32px rgb(23 32 38 / 0.06);
}

.table-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
  padding: 16px;
  border-bottom: 1px solid var(--line);
}

.table-head h3 {
  margin: 0;
  font-size: 22px;
}

.table-head span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 760;
}

.table-scroll {
  max-height: 520px;
  overflow: auto;
}

.vocab-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

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

.vocab-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #f6f7f8;
  color: var(--muted);
  font-size: 12px;
}

.word-row {
  cursor: pointer;
}

.word-row:hover {
  background: #fbfcfc;
}

.word-extra td {
  background: #fff8ef;
  color: var(--muted);
  line-height: 1.6;
}

.word-extra span,
.word-extra small {
  display: block;
}

.word,
.pattern {
  font-size: clamp(24px, 3vw, 34px);
  font-weight: 900;
  line-height: 1.1;
}

.kana {
  color: var(--muted);
  font-weight: 750;
}

.flash-detail,
.grammar-detail {
  display: none;
  gap: 6px;
  width: 100%;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.55;
}

.flash-card.reveal .flash-detail,
.grammar-card.active .grammar-detail {
  display: grid;
}

.flash-detail strong {
  color: var(--red-dark);
}

.flash-detail small,
.grammar-detail small {
  color: var(--muted);
}

.grammar-list {
  display: grid;
  gap: 12px;
}

.grammar-card {
  display: grid;
  gap: 8px;
  width: 100%;
  min-height: 92px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfc;
  color: var(--ink);
  text-align: left;
}

.grammar-card.active {
  border-color: rgb(14 111 106 / 0.55);
  background: #edf8f7;
}

.grammar-detail {
  padding-top: 8px;
  border-top: 1px solid rgb(14 111 106 / 0.2);
}

.grammar-detail strong {
  color: var(--teal);
  font-size: 16px;
}

.grammar-detail em {
  color: var(--red-dark);
  font-style: normal;
}

.reading-card {
  padding: clamp(20px, 3vw, 30px);
  border-left: 8px solid var(--blue);
}

.reading-card p {
  margin: 0;
  font-size: clamp(18px, 3vw, 28px);
  font-weight: 760;
  line-height: 1.8;
}

.reading-card p + p {
  margin-top: 12px;
}

.reading-notes {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.reading-notes span {
  min-height: 58px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper-soft);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.5;
}

.audio-panel {
  display: grid;
  gap: 14px;
}

.audio-controls,
.timer-panel {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.audio-status {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}

.subtitle-list {
  display: grid;
  gap: 8px;
}

.subtitle {
  display: grid;
  gap: 5px;
  width: 100%;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfc;
  color: var(--ink);
  text-align: left;
}

.subtitle.active {
  border-color: rgb(182 63 50 / 0.55);
  background: #fff6f4;
}

.subtitle span {
  font-size: clamp(17px, 2vw, 22px);
  font-weight: 820;
  line-height: 1.55;
}

.subtitle ruby {
  ruby-align: center;
}

.subtitle rt {
  color: var(--red-dark);
  font-size: 10px;
  font-weight: 760;
  line-height: 1;
}

.subtitle small {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.task-notes {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.task-notes span {
  min-height: 48px;
  padding: 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper-soft);
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.task-vocab-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.mini-word {
  display: grid;
  gap: 6px;
  min-height: 132px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfc;
}

.mini-word span {
  color: var(--red-dark);
  font-size: 12px;
  font-weight: 850;
}

.mini-word strong {
  font-size: 22px;
  line-height: 1.1;
}

.mini-word small,
.mini-word p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.grammar-drill-list {
  display: grid;
  gap: 12px;
}

.grammar-drill {
  display: grid;
  gap: 8px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfc;
}

.grammar-drill p,
.grammar-drill small {
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
}

.grammar-drill textarea {
  min-height: 84px;
  resize: vertical;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  color: var(--ink);
  font: inherit;
  line-height: 1.5;
}

.timer-panel {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfc;
}

.timer-panel strong {
  min-width: 90px;
  color: var(--blue);
  font-size: 30px;
  line-height: 1;
}

.compact-reading h3 {
  margin: 0 0 12px;
  font-size: 19px;
}

.compact-reading p {
  font-size: clamp(16px, 2vw, 22px);
}

.reading-questions {
  display: grid;
  gap: 8px;
}

.reading-questions details {
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfc;
}

.reading-questions summary {
  cursor: pointer;
  font-weight: 820;
  line-height: 1.45;
}

.reading-questions p {
  margin: 10px 0 0;
  color: var(--muted);
  line-height: 1.6;
}

.quiz-list {
  display: grid;
  gap: 14px;
}

.quiz-card {
  padding: 18px;
}

.quiz-card h3 {
  margin: 0 0 14px;
  font-size: 19px;
  line-height: 1.4;
}

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

.option {
  min-height: 46px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfc;
  color: var(--ink);
  text-align: left;
}

.option.correct {
  border-color: rgb(48 107 79 / 0.55);
  background: #edf7f0;
  color: var(--green);
  font-weight: 800;
}

.option.wrong {
  border-color: rgb(182 63 50 / 0.55);
  background: #fff2f0;
  color: var(--red-dark);
  font-weight: 800;
}

.hint {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.plan-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 10px;
}

.plan-day {
  display: grid;
  gap: 9px;
  min-height: 176px;
  padding: 14px;
}

.plan-day span {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border-radius: 8px;
  background: var(--ink);
  color: white;
  font-weight: 900;
}

.plan-day strong {
  color: var(--red-dark);
  font-size: 15px;
  line-height: 1.35;
}

.plan-day p,
.plan-day small {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

.plan-day small {
  color: var(--teal);
  font-weight: 760;
}

@media (max-width: 980px) {
  .topbar,
  .today-band,
  .workspace,
  .today-grid {
    grid-template-columns: 1fr;
  }

  .topbar {
    display: grid;
    align-items: stretch;
  }

  .tabs {
    width: 100%;
  }

  .daily-panel {
    position: static;
  }

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

  .vocab-tools,
  .task-vocab-grid,
  .task-notes {
    grid-template-columns: 1fr;
  }

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

@media (max-width: 640px) {
  .study-shell {
    width: min(100% - 20px, 1180px);
    padding-top: 16px;
  }

  .today-copy {
    padding: 22px;
  }

  .scoreboard,
  .reading-notes,
  .card-grid,
  .option-grid,
  .plan-grid {
    grid-template-columns: 1fr;
  }

  .scoreboard div {
    min-height: 82px;
  }

  .main-panel,
  .daily-panel {
    padding: 14px;
  }

  .task-detail-head {
    display: grid;
  }

  .complete-task,
  .primary-action,
  .ghost-action {
    width: 100%;
  }

  .icon-action {
    width: calc(50% - 5px);
  }

  .vocab-table {
    min-width: 620px;
  }
}
