:root {
  color-scheme: light;
  --bg: #eef6fb;
  --surface: #ffffff;
  --surface-2: #f7fbfe;
  --ink: #142533;
  --muted: #60717d;
  --line: #cbdce8;
  --brand-blue: #0779c1;
  --brand-blue-dark: #063a77;
  --brand-blue-soft: #e6f3fb;
  --green: var(--brand-blue);
  --green-dark: var(--brand-blue-dark);
  --green-soft: var(--brand-blue-soft);
  --steel: #315f9b;
  --steel-soft: #e9f3fa;
  --yellow: #b8872c;
  --yellow-soft: #fff1d5;
  --red: #b84a3c;
  --red-soft: #fce8e4;
  --blue: #1b558f;
  --shadow: 0 14px 34px rgba(6, 58, 119, 0.1);
  font-family: "Yu Gothic UI", "Meiryo", system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
}

body:not(.is-admin) .admin-only {
  display: none;
}

button {
  font: inherit;
  cursor: pointer;
}

input {
  font: inherit;
}

img {
  display: block;
  max-width: 100%;
}

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

.site-header {
  min-height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 24px;
  background: rgba(255, 255, 255, 0.96);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 20;
  backdrop-filter: blur(10px);
  transition: transform 180ms ease, box-shadow 180ms ease;
  will-change: transform;
}

.site-header.is-hidden {
  transform: translateY(calc(-100% - 2px));
}

body.is-header-hidden .phrase-chapter-nav {
  top: 8px;
  max-height: calc(100dvh - 16px);
}

@media (prefers-reduced-motion: reduce) {
  .site-header {
    transition: none;
  }
}

.login-view {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    linear-gradient(rgba(238, 246, 251, 0.78), rgba(238, 246, 251, 0.94)),
    url("assets/rebar-site.svg") center / cover no-repeat;
}

.login-view[hidden] {
  display: none;
}

.login-panel {
  width: min(440px, 100%);
  display: grid;
  gap: 18px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 24px;
  box-shadow: var(--shadow);
}

.login-logo {
  width: min(320px, 100%);
  height: auto;
  justify-self: start;
}

.login-panel h1 {
  margin-top: 4px;
  font-size: 28px;
  line-height: 1.3;
}

.login-panel p {
  margin-top: 6px;
  color: var(--muted);
  line-height: 1.6;
}

.login-form {
  display: grid;
  gap: 12px;
}

.login-form label,
.filter-row,
.admin-tools {
  display: grid;
  gap: 6px;
}

.login-form label span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 900;
}

.login-form input,
.filter-row input,
.admin-tools input {
  min-height: 42px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: white;
  color: var(--ink);
  padding: 0 12px;
}

.form-error {
  margin: 0;
  color: var(--red);
  font-weight: 800;
}

.demo-accounts {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.demo-accounts button {
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface-2);
  color: var(--ink);
  padding: 0 10px;
  font-weight: 800;
}

.brand {
  min-width: 0;
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: var(--ink);
  text-decoration: none;
}

.brand > span {
  display: none;
}

.brand-logo {
  width: 210px;
  height: 42px;
  border-radius: 8px;
  object-fit: contain;
  background: white;
}

.brand-mark {
  width: 42px;
  height: 42px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: var(--green);
  color: white;
  font-size: 22px;
  font-weight: 900;
}

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

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

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

.help-button {
  width: fit-content;
  min-height: 34px;
  padding: 0 14px;
}

.top-nav {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
  overflow-x: auto;
}

.nav-button {
  min-height: 38px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  padding: 0 14px;
  font-weight: 800;
  white-space: nowrap;
}

.nav-button.is-active {
  background: var(--surface);
  color: var(--green-dark);
  box-shadow: 0 1px 5px rgba(6, 58, 119, 0.1);
}

.progress-pill {
  min-width: 104px;
  min-height: 42px;
  border-radius: 8px;
  display: grid;
  justify-content: center;
  place-items: center;
  grid-template-columns: auto auto auto;
  gap: 2px;
  background: var(--green-soft);
  color: var(--green-dark);
  font-weight: 900;
}

.progress-pill small {
  grid-column: 1 / -1;
  color: var(--muted);
  font-size: 11px;
  line-height: 1;
}

.header-logout {
  min-height: 42px;
}

main {
  padding: 24px;
}

.view {
  display: none;
}

.view.is-active {
  display: block;
}

.learn-home {
  display: grid;
  gap: 12px;
  margin-bottom: 18px;
  scroll-margin-top: 88px;
}

.learn-home-copy,
.learn-home-chapters {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
}

.learn-home-copy {
  display: grid;
  gap: 10px;
}

.learn-home-copy h1,
.learn-home-chapters h2 {
  margin-top: 4px;
  font-size: 26px;
  line-height: 1.25;
}

.learn-home-copy h1 .home-id,
.learn-home-chapters h2 .home-id {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.78em;
  font-weight: 800;
}

body.lang-id .learn-home-copy h1 .home-id,
body.lang-id .learn-home-chapters h2 .home-id {
  margin-top: 0;
  color: inherit;
  font-size: 1em;
  font-weight: 900;
}

.learn-home-copy p,
.learn-home-chapters p {
  color: var(--muted);
  line-height: 1.65;
}

.learn-home-copy .help-button {
  justify-self: start;
  margin-top: 2px;
}

.learn-home-language {
  width: min(420px, 100%);
  margin-top: 2px;
}

body.lang-ja .learn-home .home-id,
body.lang-ja .learn-home .home-sep,
body.lang-id .learn-home .home-ja,
body.lang-id .learn-home .home-sep {
  display: none;
}

body.lang-id .learn-home-steps .home-id {
  color: var(--ink);
  font-size: 1em;
  font-weight: 900;
}

.learn-home-steps {
  margin: 2px 0 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  list-style: none;
}

.learn-home-steps li,
.learn-home-note {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
  padding: 10px 12px;
}

.learn-home-steps strong,
.learn-home-steps span,
.learn-home-note strong {
  display: block;
}

.learn-home-steps span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}

.learn-home-note {
  border-color: #dfc07f;
  background: var(--yellow-soft);
}

.learn-home-note p {
  margin-top: 6px;
}

.learn-chapter-links {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 8px;
  margin-top: 12px;
}

.learn-chapter-link {
  min-width: 0;
  min-height: 72px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--green);
  border-radius: 8px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 3px 8px;
  align-items: center;
  padding: 10px 12px;
  background: var(--surface);
  color: var(--ink);
  text-align: left;
}

.learn-chapter-link:hover,
.learn-chapter-link:focus-visible,
.learn-chapter-link.is-active {
  border-color: var(--green);
  border-left-color: var(--green);
  background: var(--green-soft);
  outline: none;
}

.learn-chapter-link.part-2 {
  border-left-color: var(--steel);
}

.learn-chapter-link.part-3 {
  border-left-color: var(--yellow);
}

.learn-chapter-link.part-4 {
  border-left-color: var(--blue);
}

.learn-chapter-order,
.learn-chapter-status {
  color: var(--steel);
  font-size: 12px;
  font-weight: 900;
}

.learn-chapter-link strong {
  grid-column: 1 / -1;
  min-width: 0;
  font-size: 15px;
  line-height: 1.35;
}

.learn-chapter-link small {
  min-width: 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.learn-chapter-status {
  justify-self: end;
  border-radius: 999px;
  background: var(--steel-soft);
  padding: 3px 8px;
}

.learn-chapter-link.is-done .learn-chapter-status {
  background: var(--green);
  color: white;
}

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

.chapter-rail,
.lesson-panel,
.section-head,
.test-board,
.result-box {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.chapter-rail {
  position: sticky;
  top: 96px;
  height: calc(100dvh - 120px);
  max-height: calc(100dvh - 120px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.rail-head {
  padding: 18px;
  border-bottom: 1px solid var(--line);
}

.rail-head h1 {
  font-size: 22px;
  line-height: 1.35;
}

.rail-head p,
.section-head p,
.lesson-lead,
.text-card p,
.tool-card p,
.result-box p {
  color: var(--muted);
  line-height: 1.75;
}

.rail-head p {
  margin-top: 6px;
  font-size: 13px;
}

.language-toggle {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 4px;
  margin-top: 12px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
}

.language-toggle button {
  min-height: 32px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.language-toggle button.is-active {
  background: var(--surface);
  color: var(--green-dark);
  box-shadow: 0 1px 5px rgba(6, 58, 119, 0.1);
}

.mobile-lesson-nav {
  display: none;
}

.mobile-chapter-controls {
  display: grid;
  grid-template-columns: 80px minmax(0, 1fr) 80px;
  gap: 8px;
}

.mobile-chapter-picker {
  position: relative;
}

.mobile-chapter-picker summary {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 7px;
  display: grid;
  place-items: center;
  background: var(--surface);
  color: var(--ink);
  font-weight: 900;
  cursor: pointer;
  list-style: none;
}

.mobile-chapter-picker summary::-webkit-details-marker {
  display: none;
}

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

.chapter-list {
  flex: 1;
  min-height: 0;
  max-height: none;
  overflow: auto;
  padding: 10px 10px 18px;
  scroll-padding-bottom: 18px;
  display: grid;
  gap: 8px;
}

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

.chapter-button:hover,
.chapter-button:focus-visible,
.chapter-button.is-active {
  border-color: var(--green);
  background: var(--green-soft);
  outline: none;
}

.chapter-button.part-1 {
  border-left: 4px solid var(--green);
}

.chapter-button.part-2 {
  border-left: 4px solid var(--steel);
}

.chapter-button.part-3 {
  border-left: 4px solid var(--yellow);
}

.chapter-button.part-4 {
  border-left: 4px solid var(--blue);
}

.chapter-num {
  width: 42px;
  height: 42px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: var(--steel-soft);
  color: var(--steel);
  font-weight: 900;
}

.chapter-button.is-done .chapter-num {
  background: var(--green);
  color: white;
}

.chapter-button strong,
.chapter-button small {
  display: block;
}

.chapter-button strong {
  font-size: 14px;
  line-height: 1.35;
}

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

.done-mark {
  color: var(--green);
  font-weight: 900;
}

.lesson-panel {
  min-height: calc(100vh - 120px);
  overflow: hidden;
  scroll-margin-top: 88px;
}

.lesson-visual {
  min-height: 280px;
  background: #dceefa;
  border-bottom: 1px solid var(--line);
}

.lesson-visual img {
  width: 100%;
  height: min(42vh, 360px);
  object-fit: cover;
}

.lesson-body {
  padding: 24px;
}

.lesson-kicker {
  color: var(--green-dark);
  font-size: 13px;
  font-weight: 900;
}

.lesson-body h2,
.section-head h2 {
  margin-top: 6px;
  font-size: 28px;
  line-height: 1.3;
}

.lesson-lead {
  margin-top: 10px;
  font-size: 15px;
}

.lesson-blocks {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 14px;
}

.lesson-block {
  min-width: 0;
  min-height: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px 14px;
  background: var(--surface-2);
}

.lesson-block.block-wide,
.phrase-panel {
  grid-column: 1 / -1;
}

.lesson-block h3 {
  font-size: 15px;
  line-height: 1.45;
}

.lesson-block p,
.lesson-block ul {
  margin: 8px 0 0;
  color: var(--muted);
  line-height: 1.65;
}

.lesson-block p:first-child,
.lesson-block ul:first-child {
  margin-top: 0;
}

.lesson-block ul {
  padding-left: 18px;
  font-size: 14px;
}

.lesson-heading {
  min-height: auto;
  background: var(--steel-soft);
}

.lesson-heading h3,
.lesson-heading h4 {
  margin: 0;
  color: var(--steel);
}

.callout-block {
  border-color: #dfc07f;
  background: var(--yellow-soft);
}

.callout-block h3 {
  color: #755314;
}

.bilingual-text,
.title-text,
.lead-text,
.bilingual-list li {
  display: grid;
  gap: 5px;
}

.ja-text {
  color: var(--ink);
}

.id-text {
  color: var(--muted);
  font-size: 0.94em;
}

rt {
  font-size: 0.58em;
  color: var(--muted);
}

.phrase-panel {
  margin-top: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
  padding: 14px;
}

.phrase-panel h3,
.admin-panel h3 {
  margin: 0 0 12px;
  font-size: 16px;
}

.table-scroll {
  min-width: 0;
  width: 100%;
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 620px;
  background: white;
}

th,
td {
  border: 1px solid var(--line);
  padding: 10px;
  text-align: left;
  vertical-align: top;
  line-height: 1.7;
}

th {
  background: var(--steel-soft);
  color: var(--steel);
  font-size: 13px;
}

.image-block {
  margin: 0;
}

.image-block img {
  width: min(100%, 680px);
  max-height: 360px;
  object-fit: contain;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
}

.image-block figcaption {
  margin-top: 8px;
  color: var(--muted);
  font-size: 13px;
}

.tool-photo-section {
  min-width: 0;
  display: grid;
  gap: 12px;
  margin-bottom: 16px;
}

.tool-photo-section h3 {
  min-width: 0;
  margin: 0;
  font-size: 18px;
}

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

.tool-photo-card {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: white;
}

.tool-photo-card img {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: contain;
  background: #ffffff;
  border-bottom: 1px solid var(--line);
}

.tool-photo-card div {
  display: grid;
  gap: 4px;
  padding: 10px;
}

.tool-photo-card strong,
.tool-photo-card span {
  line-height: 1.35;
}

.tool-photo-card span {
  color: var(--steel);
  font-size: 13px;
  font-weight: 800;
}

.tool-photo-card p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}

.lesson-actions,
.test-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 22px;
}

.primary-button,
.secondary-button,
.icon-button {
  border-radius: 7px;
  border: 1px solid var(--line);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-weight: 900;
}

.primary-button,
.secondary-button {
  min-height: 42px;
  padding: 0 16px;
}

.primary-button {
  background: var(--green);
  border-color: var(--green);
  color: white;
}

.primary-button:hover {
  background: var(--green-dark);
}

.secondary-button {
  background: var(--surface);
  color: var(--ink);
}

.secondary-button:hover,
.icon-button:hover {
  background: var(--surface-2);
}

.primary-button:disabled,
.secondary-button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.icon-button {
  width: 40px;
  height: 40px;
  background: white;
  color: var(--ink);
  font-size: 20px;
}

.section-head {
  min-height: 190px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(220px, 360px);
  align-items: center;
  gap: 18px;
  padding: 24px;
  overflow: hidden;
}

.section-head img {
  width: 100%;
  max-height: 170px;
  object-fit: contain;
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(190px, 1fr));
  gap: 10px;
  margin-top: 12px;
}

.filter-row {
  grid-template-columns: minmax(220px, 420px);
  margin-top: 12px;
}

.phrase-layout {
  display: grid;
  grid-template-columns: minmax(132px, 176px) minmax(0, 1fr);
  gap: 10px;
  align-items: start;
  margin-top: 12px;
}

.phrase-layout.has-no-nav {
  grid-template-columns: 1fr;
}

.phrase-chapter-nav {
  position: sticky;
  top: 92px;
  max-height: calc(100dvh - 112px);
  display: grid;
  gap: 6px;
  overflow: auto;
  padding-right: 2px;
}

.phrase-chapter-nav[hidden] {
  display: none;
}

.phrase-chapter-nav button {
  min-width: 0;
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  align-items: center;
  gap: 6px;
  padding: 5px 7px;
  background: var(--surface);
  color: var(--ink);
  text-align: left;
}

.phrase-chapter-nav button:hover,
.phrase-chapter-nav button:focus-visible,
.phrase-chapter-nav button[aria-current="true"] {
  border-color: var(--green);
  background: var(--green-soft);
  outline: none;
}

.phrase-chapter-num {
  min-width: 42px;
  min-height: 24px;
  border-radius: 7px;
  display: grid;
  place-items: center;
  background: var(--steel-soft);
  color: var(--steel);
  font-size: 10px;
  font-weight: 900;
}

.phrase-chapter-title {
  min-width: 0;
  overflow: hidden;
  font-size: 12px;
  font-weight: 900;
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.phrase-layout .card-grid {
  margin-top: 0;
}

.text-card,
.tool-card {
  min-height: 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  display: grid;
  align-content: start;
  gap: 6px;
}

.text-card .tag,
.tool-card .tag {
  width: fit-content;
  min-height: 22px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  padding: 1px 8px;
  background: var(--steel-soft);
  color: var(--steel);
  font-size: 11px;
  font-weight: 900;
}

.text-card strong,
.tool-card strong {
  font-size: 16px;
  line-height: 1.35;
}

.phrase-card {
  min-height: 0;
  scroll-margin-top: 110px;
}

.phrase-card p {
  line-height: 1.45;
}

.tool-thumb {
  width: 100%;
  aspect-ratio: 16 / 9;
  border: 1px solid var(--line);
  border-radius: 7px;
  display: grid;
  place-items: center;
  background: var(--surface-2);
  color: var(--steel);
  font-size: 42px;
}

.test-board {
  display: grid;
  grid-template-columns: minmax(260px, 360px) 1fr;
  gap: 18px;
  align-items: center;
  margin-top: 16px;
  padding: 20px;
}

.score-panel {
  display: grid;
  gap: 9px;
}

.score-panel span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 900;
}

.score-panel strong {
  font-size: 30px;
}

.meter {
  height: 12px;
  border-radius: 999px;
  background: var(--steel-soft);
  overflow: hidden;
}

.meter span {
  display: block;
  width: 0;
  height: 100%;
  background: var(--green);
}

.result-box {
  margin-top: 14px;
  padding: 18px;
}

.result-box strong {
  display: block;
  font-size: 20px;
  margin-bottom: 6px;
}

.final-exam-info {
  margin-top: 12px;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.final-exam-info div {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 10px;
}

.final-exam-info span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
}

.final-exam-info strong {
  display: block;
  margin-top: 3px;
  font-size: 16px;
  line-height: 1.3;
}

.final-exam-info .is-locked strong {
  color: var(--yellow);
}

.final-exam-info .is-pass strong {
  color: var(--green-dark);
}

.final-exam-info .is-fail strong {
  color: var(--red);
}

.quiz-dialog {
  width: min(760px, calc(100vw - 28px));
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0;
  box-shadow: var(--shadow);
}

.quiz-dialog::backdrop {
  background: rgba(23, 32, 37, 0.44);
}

.quiz-dialog header,
.quiz-dialog footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 16px;
}

.quiz-dialog header {
  border-bottom: 1px solid var(--line);
}

.quiz-dialog footer {
  border-top: 1px solid var(--line);
  justify-content: flex-end;
}

.quiz-content {
  padding: 16px;
  display: grid;
  gap: 14px;
}

.quiz-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: var(--surface-2);
}

.quiz-item .tag {
  width: fit-content;
  min-height: 24px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  padding: 2px 9px;
  margin-bottom: 10px;
  background: var(--steel-soft);
  color: var(--steel);
  font-size: 12px;
  font-weight: 900;
}

.quiz-item strong {
  display: block;
  margin-bottom: 10px;
}

.quiz-options {
  display: grid;
  gap: 8px;
}

.quiz-options label {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 7px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  background: white;
}

.quiz-options label.is-correct {
  border-color: var(--green);
  background: var(--green-soft);
}

.quiz-options label.is-wrong {
  border-color: var(--red);
  background: var(--red-soft);
}

.quiz-feedback,
.quiz-summary {
  margin-top: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: white;
}

.quiz-summary {
  background: var(--green-soft);
  border-color: var(--green);
}

.quiz-summary.is-fail {
  border-color: var(--red);
  background: var(--red-soft);
}

.onboarding-dialog {
  width: min(720px, calc(100vw - 28px));
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0;
  box-shadow: var(--shadow);
}

.onboarding-dialog::backdrop {
  background: rgba(23, 32, 37, 0.48);
}

.onboarding-dialog header,
.onboarding-dialog footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 16px;
}

.onboarding-dialog header {
  border-bottom: 1px solid var(--line);
}

.onboarding-dialog footer {
  border-top: 1px solid var(--line);
  justify-content: flex-end;
}

.onboarding-dialog h2 {
  margin-top: 4px;
  font-size: 24px;
  line-height: 1.25;
}

.onboarding-content {
  padding: 16px;
  display: grid;
  gap: 14px;
}

.onboarding-content section,
.onboarding-steps {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
  padding: 14px;
}

.onboarding-content h3 {
  font-size: 18px;
  line-height: 1.35;
}

.onboarding-content p {
  margin-top: 8px;
  line-height: 1.65;
}

.onboarding-content .id-text {
  color: var(--muted);
}

.onboarding-steps {
  margin: 0;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  list-style: none;
  counter-reset: none;
}

.onboarding-steps li {
  min-width: 0;
  border-radius: 7px;
  background: white;
  padding: 12px;
}

.onboarding-steps strong,
.onboarding-steps span {
  display: block;
}

.onboarding-steps span {
  margin-top: 5px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}

.onboarding-note {
  border-color: #dfc07f;
  background: var(--yellow-soft);
}

.progress-detail,
.admin-grid {
  display: grid;
  gap: 16px;
  margin-top: 16px;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(150px, 1fr));
  gap: 10px;
}

.summary-grid div {
  min-height: 86px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 12px;
  display: grid;
  align-content: center;
  gap: 6px;
}

.summary-grid span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.summary-grid strong {
  font-size: 20px;
  line-height: 1.3;
}

.progress-card-list,
.progress-log-list {
  display: grid;
  gap: 8px;
}

.progress-card,
.progress-log-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.progress-card {
  padding: 10px;
}

.progress-card.is-complete {
  border-color: var(--green);
  background: var(--green-soft);
}

.progress-card-head {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: start;
  gap: 8px;
}

.progress-card-num {
  min-height: 24px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 2px 8px;
  background: var(--steel-soft);
  color: var(--steel);
  font-size: 12px;
  font-weight: 900;
  white-space: nowrap;
}

.progress-card-head strong {
  min-width: 0;
  font-size: 15px;
  line-height: 1.35;
}

.progress-card-meta {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
  margin: 8px 0 0;
}

.progress-card-meta div {
  min-width: 0;
  border-radius: 7px;
  background: var(--surface-2);
  padding: 6px 8px;
}

.progress-card-meta dt {
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
}

.progress-card-meta dd {
  margin: 2px 0 0;
  font-size: 13px;
  line-height: 1.35;
}

.progress-log-card {
  display: grid;
  gap: 3px;
  padding: 8px 10px;
}

.progress-log-card span,
.progress-log-card small {
  color: var(--muted);
  font-size: 12px;
}

.progress-log-card strong {
  font-size: 14px;
}

.final-admin-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  padding: 10px;
  background: var(--surface);
}

.final-admin-card.is-pass {
  border-color: var(--green);
  background: var(--green-soft);
}

.final-admin-card.is-fail {
  border-color: var(--red);
  background: var(--red-soft);
}

.final-admin-card span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
}

.final-admin-card strong {
  display: block;
  margin-top: 3px;
  font-size: 14px;
  line-height: 1.35;
}

.admin-tools {
  grid-template-columns: minmax(220px, 1fr) auto auto;
  align-items: center;
  margin-top: 16px;
}

.admin-settings {
  margin-top: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 10px;
}

.admin-settings label {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.admin-settings span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.admin-settings input {
  width: 72px;
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 0 8px;
}

.admin-settings small {
  color: var(--muted);
  font-weight: 900;
}

.admin-settings p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.admin-grid {
  grid-template-columns: minmax(280px, 360px) minmax(0, 1fr);
}

.admin-grid > *,
.admin-panel,
.admin-user,
.summary-grid,
.final-admin-card,
.table-scroll {
  min-width: 0;
}

.admin-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
}

.admin-user {
  width: 100%;
  min-height: 64px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 10px;
  text-align: left;
}

.admin-user + .admin-user {
  margin-top: 8px;
}

.admin-user.is-active,
.admin-user:hover {
  border-color: var(--green);
  background: var(--green-soft);
}

.admin-user strong,
.admin-user small {
  display: block;
}

.admin-user small {
  margin-top: 3px;
  color: var(--muted);
}

.status-badge {
  min-height: 28px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  background: var(--steel-soft);
  color: var(--steel);
  padding: 2px 10px;
  font-size: 12px;
  font-weight: 900;
  white-space: nowrap;
}

.log-panel {
  margin-top: 16px;
}

.log-table {
  min-width: 760px;
}

.empty-text {
  color: var(--muted);
  line-height: 1.7;
}

@media (max-width: 1120px) {
  .lesson-blocks,
  .card-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

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

@media (max-width: 860px) {
  .site-header {
    align-items: stretch;
    flex-direction: column;
    padding: 12px;
  }

  .brand,
  .progress-pill {
    min-width: 0;
  }

  .header-logout {
    width: 100%;
  }

  .top-nav {
    width: 100%;
  }

  .nav-button {
    flex: 1;
  }

  main {
    padding: 12px;
  }

  .learn-layout,
  .section-head,
  .test-board,
  .admin-grid,
  .admin-tools {
    grid-template-columns: 1fr;
  }

  .final-exam-info,
  .final-admin-card,
  .learn-home-steps,
  .onboarding-steps {
    grid-template-columns: 1fr;
  }

  .learn-home {
    gap: 10px;
    margin-bottom: 12px;
    scroll-margin-top: 122px;
  }

  .learn-home-copy,
  .learn-home-chapters {
    padding: 14px;
  }

  .learn-chapter-links {
    grid-template-columns: 1fr;
  }

  .chapter-rail {
    display: none;
  }

  .mobile-lesson-nav {
    display: grid;
    gap: 8px;
    margin-bottom: 16px;
  }

  .mobile-chapter-picker[open] .mobile-chapter-list {
    position: absolute;
    left: 50%;
    right: auto;
    transform: translateX(-50%);
    top: calc(100% + 6px);
    z-index: 15;
    width: min(calc(100vw - 24px), 420px);
    max-height: 34vh;
    overflow: auto;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
    padding: 8px;
    box-shadow: var(--shadow);
  }

  .mobile-chapter-list .chapter-button {
    min-height: 44px;
    grid-template-columns: 30px minmax(0, 1fr);
    gap: 7px;
    padding: 6px 8px;
  }

  .mobile-chapter-list .chapter-num {
    width: 30px;
    height: 30px;
    align-self: start;
    border-radius: 7px;
    font-size: 12px;
  }

  .mobile-chapter-list .chapter-button strong {
    display: -webkit-box;
    overflow: hidden;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 1;
    font-size: 12px;
    line-height: 1.3;
  }

  .mobile-chapter-list .chapter-button small {
    display: block;
    margin-top: 2px;
    overflow: hidden;
    color: var(--muted);
    font-size: 9px;
    line-height: 1.25;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .mobile-chapter-list .done-mark {
    display: none;
  }

  .mobile-language-toggle {
    margin-top: 0;
  }

  .lesson-visual {
    min-height: 0;
  }

  .lesson-visual img {
    height: 120px;
  }

  .lesson-panel {
    min-height: 0;
  }

  .lesson-body,
  .section-head,
  .test-board,
  .learn-home-copy,
  .learn-home-chapters,
  .admin-panel {
    padding: 16px;
  }
}

@media (max-width: 620px) {
  .site-header {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 6px;
    padding: 8px 10px;
  }

  .brand {
    grid-column: 1;
  }

  .brand-logo {
    width: 150px;
    height: 34px;
  }

  .brand-mark {
    width: 34px;
    height: 34px;
    font-size: 18px;
  }

  .brand strong {
    font-size: 14px;
  }

  .brand small {
    font-size: 10px;
  }

  .header-logout {
    grid-column: 2;
    grid-row: 1;
    justify-self: end;
    width: auto;
    min-height: 34px;
    padding: 0 10px;
  }

  .top-nav,
  .progress-pill {
    grid-column: 1 / -1;
  }

  .progress-pill {
    min-height: 32px;
  }

  .nav-button {
    min-height: 32px;
    padding: 0 8px;
    font-size: 12px;
  }

  .final-exam-info {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px;
  }

  .final-admin-card {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px;
    padding: 8px;
  }

  .final-exam-info div {
    padding: 8px;
  }

  .final-exam-info strong {
    font-size: 14px;
  }

  .onboarding-dialog header,
  .onboarding-dialog footer,
  .quiz-dialog header,
  .quiz-dialog footer {
    padding: 12px;
  }

  .onboarding-dialog h2 {
    font-size: 20px;
  }

  .onboarding-content {
    padding: 12px;
    gap: 10px;
  }

  .onboarding-content section,
  .onboarding-steps {
    padding: 10px;
  }

  .onboarding-content h3 {
    font-size: 16px;
  }

  .lesson-visual img {
    height: 72px;
  }

  main {
    padding: 4px;
  }

  .lesson-body,
  .section-head,
  .test-board,
  .learn-home-copy,
  .learn-home-chapters,
  .admin-panel {
    padding: 10px;
  }

  .learn-home {
    gap: 8px;
    margin-bottom: 8px;
    scroll-margin-top: 120px;
  }

  .learn-home-copy {
    gap: 8px;
  }

  .learn-home-copy h1,
  .learn-home-chapters h2 {
    font-size: 22px;
  }

  .learn-home-copy p,
  .learn-home-chapters p,
  .learn-home-note p {
    font-size: 13px;
    line-height: 1.5;
  }

  .learn-home-steps {
    gap: 6px;
  }

  .learn-home-steps li,
  .learn-home-note {
    padding: 8px 10px;
  }

  .learn-chapter-links {
    gap: 6px;
    margin-top: 8px;
  }

  .learn-chapter-link {
    min-height: 58px;
    padding: 8px 10px;
  }

  .learn-chapter-link strong {
    font-size: 14px;
    line-height: 1.25;
  }

  .mobile-lesson-nav {
    gap: 6px;
    margin-bottom: 10px;
  }

  .mobile-chapter-controls {
    gap: 6px;
    grid-template-columns: 64px minmax(0, 1fr) 64px;
  }

  .mobile-chapter-controls .secondary-button,
  .mobile-chapter-picker summary,
  .mobile-language-toggle button {
    min-height: 36px;
  }

  .mobile-language-toggle {
    gap: 3px;
    padding: 3px;
  }

  .lesson-kicker {
    font-size: 12px;
  }

  .lesson-body h2,
  .section-head h2 {
    margin-top: 3px;
    font-size: 22px;
    line-height: 1.24;
  }

  .lesson-lead {
    margin-top: 6px;
    font-size: 13px;
    line-height: 1.55;
  }

  .lesson-blocks {
    gap: 8px;
    margin-top: 12px;
  }

  .lesson-block {
    min-height: 0;
    padding: 10px;
  }

  .lesson-block h3 {
    font-size: 14px;
    line-height: 1.35;
  }

  .lesson-block p,
  .lesson-block ul {
    margin-top: 6px;
    line-height: 1.62;
  }

  .lesson-block ul {
    padding-left: 16px;
    font-size: 13px;
  }

  .bilingual-text,
  .title-text,
  .lead-text,
  .bilingual-list li {
    gap: 3px;
  }

  .phrase-panel {
    margin-top: 12px;
    padding: 8px;
  }

  .phrase-panel h3,
  .admin-panel h3 {
    margin-bottom: 6px;
    font-size: 14px;
  }

  .lesson-body .table-scroll {
    overflow: visible;
  }

  .lesson-body .table-scroll table {
    min-width: 0;
    border-collapse: separate;
    border-spacing: 0;
    background: transparent;
  }

  .lesson-body .table-scroll thead {
    display: none;
  }

  .lesson-body .table-scroll tbody {
    display: grid;
    gap: 8px;
  }

  .lesson-body .table-scroll tr {
    display: grid;
    border: 1px solid var(--line);
    border-radius: 8px;
    overflow: hidden;
    background: white;
  }

  .lesson-body .table-scroll td {
    border: 0;
    border-bottom: 1px solid var(--line);
    display: grid;
    grid-template-columns: 1fr;
    gap: 3px;
    padding: 8px;
    line-height: 1.48;
    overflow-wrap: break-word;
    word-break: normal;
  }

  .lesson-body .table-scroll td:last-child {
    border-bottom: 0;
  }

  .lesson-body .table-scroll td::before {
    content: attr(data-label);
    color: var(--steel);
    font-size: 11px;
    font-weight: 900;
    line-height: 1.35;
  }

  .phrase-panel .table-scroll tbody {
    gap: 6px;
  }

  .phrase-panel .table-scroll tr {
    border-radius: 7px;
  }

  .phrase-panel .table-scroll td {
    gap: 3px;
    padding: 5px 8px;
    line-height: 1.35;
  }

  .phrase-panel .table-scroll td::before {
    font-size: 10px;
    line-height: 1.25;
  }

  #progressView .progress-detail {
    gap: 8px;
    margin-top: 8px;
  }

  #progressView .summary-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px;
  }

  #progressView .summary-grid div {
    min-height: 0;
    padding: 8px;
    gap: 2px;
  }

  #progressView .summary-grid strong {
    font-size: 16px;
  }

  #progressView .table-scroll {
    overflow: visible;
  }

  #progressView table {
    min-width: 0;
    border-collapse: separate;
    border-spacing: 0;
    background: transparent;
  }

  #progressView thead {
    display: none;
  }

  #progressView tbody {
    display: grid;
    gap: 6px;
  }

  #progressView tr {
    display: grid;
    border: 1px solid var(--line);
    border-radius: 7px;
    overflow: hidden;
    background: white;
  }

  #progressView td {
    border: 0;
    border-bottom: 1px solid var(--line);
    display: grid;
    grid-template-columns: 68px minmax(0, 1fr);
    gap: 6px;
    padding: 6px 8px;
    line-height: 1.35;
    overflow-wrap: anywhere;
  }

  #progressView td:last-child {
    border-bottom: 0;
  }

  #progressView td::before {
    content: attr(data-label);
    color: var(--steel);
    font-size: 10px;
    font-weight: 900;
    line-height: 1.35;
  }

  #progressView .admin-panel {
    padding: 8px;
  }

  #progressView .progress-card-list,
  #progressView .progress-log-list {
    gap: 6px;
  }

  #progressView .progress-card {
    padding: 8px;
  }

  #progressView .progress-card-head {
    grid-template-columns: auto minmax(0, 1fr);
    gap: 6px;
  }

  #progressView .progress-card-head .status-badge {
    grid-column: 1 / -1;
    justify-self: start;
  }

  #progressView .progress-card-head strong {
    font-size: 14px;
    line-height: 1.3;
  }

  #progressView .progress-card-num {
    min-height: 20px;
    padding: 1px 7px;
    font-size: 10px;
  }

  #progressView .progress-card-meta {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 4px;
    margin-top: 6px;
  }

  #progressView .progress-card-meta div {
    padding: 5px 6px;
  }

  #progressView .progress-card-meta dt {
    font-size: 10px;
  }

  #progressView .progress-card-meta dd {
    font-size: 12px;
  }

  .lesson-blocks,
  .card-grid,
  .tool-photo-grid {
    grid-template-columns: 1fr;
  }

  #phrasesView .section-head {
    min-height: 0;
    gap: 4px;
    padding: 8px;
  }

  #phrasesView .section-head img {
    display: none;
  }

  #phrasesView .section-head p {
    font-size: 12px;
    line-height: 1.35;
  }

  #phrasesView .filter-row {
    grid-template-columns: 1fr;
    margin-top: 6px;
  }

  #phrasesView .filter-row input {
    min-height: 34px;
    padding: 0 10px;
  }

  #phrasesView .phrase-layout {
    grid-template-columns: 52px minmax(0, 1fr);
    gap: 5px;
    margin-top: 6px;
  }

  #phrasesView .phrase-layout.has-no-nav {
    grid-template-columns: 1fr;
  }

  #phrasesView .phrase-chapter-nav {
    top: 126px;
    max-height: calc(100dvh - 132px);
    gap: 4px;
    padding-right: 0;
  }

  body.is-header-hidden #phrasesView .phrase-chapter-nav {
    top: 6px;
    max-height: calc(100dvh - 12px);
  }

  #phrasesView .phrase-chapter-nav button {
    min-height: 32px;
    grid-template-columns: 1fr;
    gap: 0;
    padding: 2px;
    place-items: center;
  }

  #phrasesView .phrase-chapter-num {
    width: 46px;
    min-height: 25px;
    font-size: 10px;
    line-height: 1;
  }

  #phrasesView .phrase-chapter-title {
    display: none;
  }

  #phrasesView .card-grid {
    gap: 6px;
    margin-top: 0;
  }

  #phrasesView .phrase-card {
    gap: 3px;
    padding: 8px 10px;
    border-radius: 7px;
    scroll-margin-top: 132px;
  }

  #phrasesView .phrase-card .tag {
    min-height: 18px;
    padding: 0 6px;
    font-size: 10px;
  }

  #phrasesView .phrase-card strong {
    font-size: 14px;
    line-height: 1.25;
  }

  #phrasesView .phrase-card p {
    font-size: 12px;
    line-height: 1.3;
  }

  .tool-photo-card div {
    gap: 3px;
    padding: 7px;
  }

  .tool-photo-card p {
    font-size: 12px;
    line-height: 1.45;
  }

  .summary-grid {
    grid-template-columns: 1fr;
  }

  .lesson-actions,
  .test-actions {
    gap: 8px;
    margin-top: 14px;
  }

  .primary-button,
  .secondary-button {
    width: 100%;
    min-height: 38px;
  }
}

@media (max-width: 360px) {
  .tool-photo-grid {
    grid-template-columns: 1fr;
  }
}
