:root {
  color-scheme: light;
  --background: #f7f5f1;
  --surface: #ffffff;
  --surface-soft: #fbfaf7;
  --text: #252321;
  --muted: #716c66;
  --border: #e4ded5;
  --accent: #9f4139;
  --accent-strong: #81332d;
  --accent-soft: #f3e6e3;
  --focus: rgba(159, 65, 57, 0.32);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

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

a {
  color: var(--accent);
}

button,
select {
  font: inherit;
}

button,
a,
select,
summary {
  outline-offset: 3px;
}

button:focus-visible,
a:focus-visible,
select:focus-visible,
summary:focus-visible {
  outline: 3px solid var(--focus);
}

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

.skip-link {
  position: fixed;
  top: 10px;
  left: 10px;
  z-index: 30;
  transform: translateY(-180%);
  border-radius: 8px;
  background: var(--accent);
  color: #ffffff;
  padding: 10px 12px;
  font-weight: 700;
  text-decoration: none;
}

.skip-link:focus {
  transform: translateY(0);
}

.progress-bar {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 20;
  width: 100%;
  height: 3px;
  background: var(--accent);
  transform: scaleX(0);
  transform-origin: left;
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 22px;
  padding: 14px clamp(18px, 4vw, 56px);
  border-bottom: 1px solid var(--border);
  background:
    radial-gradient(circle at 68px 18px, rgba(159, 65, 57, 0.08), transparent 70px),
    rgba(247, 245, 241, 0.95);
  backdrop-filter: blur(14px);
}

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

.brand-icon {
  position: relative;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 40px;
  height: 40px;
  border: 1px solid rgba(159, 65, 57, 0.22);
  border-radius: 10px;
  background: var(--accent-soft);
  color: var(--accent);
}

.brand-icon::before {
  content: "";
  position: absolute;
  inset: -5px;
  z-index: -1;
  border-radius: 14px;
  background: rgba(159, 65, 57, 0.06);
}

.brand-icon svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.site-title {
  margin: 0;
  color: var(--text);
  font-size: 1rem;
  font-weight: 700;
}

.site-subtitle {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 0.86rem;
}

.site-nav {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 16px;
}

.site-nav a {
  color: var(--muted);
  font-size: 0.93rem;
  font-weight: 650;
  text-decoration: none;
}

.site-nav a:hover {
  color: var(--accent);
}

.language-selector {
  display: inline-flex;
  gap: 4px;
  padding: 3px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
}

.language-selector button {
  min-height: 30px;
  padding: 0 10px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 750;
}

.language-selector button.active {
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.content-toolbar {
  padding: 14px clamp(18px, 4vw, 56px) 0;
}

.header-controls {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  max-width: 1260px;
  margin: 0 auto;
}

.header-controls button {
  min-height: 38px;
  border-color: rgba(159, 65, 57, 0.24);
  color: var(--accent-strong);
  font-size: 0.9rem;
  font-weight: 750;
}

.header-controls button[aria-pressed="true"] {
  background: var(--accent-soft);
}

.word-legend {
  margin: 0;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 650;
}

label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
}

select,
button {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
}

select {
  min-height: 42px;
  min-width: 170px;
  padding: 9px 36px 9px 12px;
}

button {
  min-height: 40px;
  padding: 0 13px;
  cursor: pointer;
}

.layout {
  display: grid;
  grid-template-columns: minmax(250px, 320px) minmax(0, 1fr);
  grid-template-areas: "list reader";
  gap: 32px;
  max-width: 1320px;
  margin: 0 auto;
  padding: 22px clamp(18px, 4vw, 56px) 52px;
}

.article-list {
  grid-area: list;
  align-self: start;
  position: sticky;
  top: 96px;
}

.list-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 0 2px 9px;
  border-bottom: 1px solid var(--border);
}

.list-header span:first-child {
  color: var(--text);
  font-weight: 750;
}

#article-count {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 650;
}

.article-button {
  display: grid;
  gap: 7px;
  width: 100%;
  padding: 15px 4px;
  border: 0;
  border-bottom: 1px solid var(--border);
  border-radius: 0;
  background: transparent;
  text-align: left;
}

.article-button:hover {
  color: var(--accent);
}

.article-button.active {
  margin-top: 8px;
  margin-bottom: 8px;
  padding: 14px;
  border: 1px solid rgba(159, 65, 57, 0.22);
  border-radius: 8px;
  background: var(--accent-soft);
  color: var(--text);
}

.article-preview-title {
  color: inherit;
  font-weight: 750;
  line-height: 1.35;
}

.article-preview-summary {
  display: -webkit-box;
  overflow: hidden;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.45;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.meta {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 650;
}

.meta span + span::before {
  content: "·";
  margin-right: 7px;
  color: var(--border);
}

.reader {
  grid-area: reader;
  min-width: 0;
}

.article-shell {
  max-width: 900px;
  margin: 0 auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
}

.article-hero {
  display: grid;
  gap: 17px;
  padding: clamp(24px, 4vw, 44px);
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

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

.pill {
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 5px 9px;
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
}

.topic-row .pill:first-child {
  border-color: rgba(159, 65, 57, 0.22);
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.article-title {
  max-width: 760px;
  margin: 0;
  color: var(--text);
  font-size: clamp(2rem, 3.2vw, 3.1rem);
  font-weight: 780;
  line-height: 1.12;
  letter-spacing: 0;
}

.article-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 11px;
  margin: -2px 0 0;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 650;
}

.article-meta span {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.level-badge {
  border: 1px solid rgba(159, 65, 57, 0.2);
  border-radius: 999px;
  padding: 4px 8px;
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.icon {
  width: 1.05em;
  height: 1.05em;
  flex: 0 0 auto;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.section-kicker,
.vocab-list h2,
.grammar-list h2,
.expression-list h2,
.questions-list h2,
.source-box h2 {
  display: flex;
  align-items: center;
  gap: 7px;
}

.section-kicker {
  margin-bottom: 7px;
  color: var(--accent-strong);
  font-size: 0.78rem;
  font-weight: 750;
  letter-spacing: 0;
}

.quick-summary {
  max-width: 740px;
  padding: 16px 17px;
  border-left: 4px solid var(--accent);
  border-radius: 8px;
  background: var(--accent-soft);
}

.quick-summary p:last-child {
  margin-bottom: 0;
  line-height: 1.65;
}

.article-visual {
  max-width: 740px;
  margin: 3px 0 0;
}

.article-visual img {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  border: 1px solid var(--border);
  border-radius: 10px;
}

.visual-scene {
  position: relative;
  aspect-ratio: 16 / 6.5;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 10px;
  background:
    linear-gradient(180deg, rgba(159, 65, 57, 0.08), transparent 60%),
    linear-gradient(180deg, #fbfaf7 0%, #f1eee8 100%);
}

.visual-sun {
  position: absolute;
  top: 18%;
  right: 12%;
  width: 54px;
  height: 54px;
  border-radius: 50%;
  background: rgba(159, 65, 57, 0.13);
}

.visual-track {
  position: absolute;
  right: 0;
  bottom: 25%;
  left: 0;
  height: 10px;
  background: rgba(37, 35, 33, 0.14);
}

.visual-train {
  position: absolute;
  bottom: 31%;
  left: 13%;
  width: 58%;
  height: 26%;
  border-radius: 18px 18px 8px 8px;
  background: var(--accent);
  box-shadow: inset 0 -10px 0 rgba(0, 0, 0, 0.09);
}

.visual-train::before {
  content: "";
  position: absolute;
  top: 23%;
  left: 8%;
  width: 72%;
  height: 28%;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.78);
}

.visual-people {
  position: absolute;
  right: 16%;
  bottom: 30%;
  width: 48px;
  height: 48px;
  border-radius: 8px;
  border-bottom: 11px solid var(--accent-strong);
  border-left: 10px solid transparent;
  border-right: 10px solid transparent;
  opacity: 0.82;
}

.article-visual figcaption {
  margin-top: 7px;
  color: var(--muted);
  font-size: 0.84rem;
}

.story-body,
.vocab-list,
.grammar-list,
.expression-list,
.questions-list,
.takeaway-box,
.source-box {
  max-width: 760px;
  margin: 0 auto;
  padding: clamp(24px, 4vw, 42px);
}

.story-body {
  display: grid;
  gap: 22px;
}

.paragraph {
  border-bottom: 1px solid var(--border);
  padding-bottom: 19px;
}

.paragraph:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.vi {
  margin-bottom: 10px;
  font-size: 1.16rem;
  line-height: 1.78;
}

.translation {
  margin: 0;
  padding-left: 14px;
  border-left: 3px solid var(--accent-soft);
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.65;
}

.vocab {
  border: 0;
  border-radius: 4px;
  padding: 0 2px;
  background: transparent;
  color: var(--accent-strong);
  font-weight: 700;
  cursor: pointer;
  text-decoration: underline dotted var(--accent);
  text-underline-offset: 4px;
}

.vocab::after {
  content: attr(data-level);
  margin-left: 2px;
  color: var(--muted);
  font-size: 0.58em;
  font-weight: 750;
  vertical-align: super;
}

.vocab:hover,
.vocab:focus-visible {
  background: var(--accent-soft);
}

.vocab-level-A2 {
  color: #7a4f19;
}

.vocab-level-B1 {
  color: var(--accent-strong);
}

.vocab-level-B2plus {
  color: #5d4a8f;
}

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

.vocab-card,
.grammar-card,
.question-card {
  padding: 14px 0;
  border-top: 1px solid var(--border);
}

.vocab-card h3,
.grammar-card h3,
.question-card h3 {
  margin-bottom: 5px;
  font-size: 1rem;
  font-weight: 750;
  line-height: 1.4;
}

.vocab-card p,
.grammar-card p,
.question-card p {
  margin-bottom: 0;
  color: var(--muted);
  line-height: 1.58;
}

.vocab-meta {
  margin-bottom: 6px;
  color: var(--accent-strong);
  font-size: 0.82rem;
  font-weight: 750;
}

.vocab-card .example,
.grammar-card .example {
  margin-top: 8px;
}

.translated-example {
  margin-top: 5px;
  color: var(--muted);
  font-size: 0.92rem;
}

.grammar-list {
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  background: var(--surface-soft);
}

.expression-list {
  border-bottom: 1px solid var(--border);
}

.expression-card {
  padding: 14px 0;
  border-top: 1px solid var(--border);
}

.expression-card h3 {
  margin-bottom: 6px;
  font-size: 1rem;
  font-weight: 750;
}

.expression-card p,
.expression-card li,
.expression-card span {
  color: var(--muted);
  line-height: 1.58;
}

.expression-card ul {
  margin: 10px 0 0;
  padding-left: 20px;
}

.grammar-pattern {
  margin-bottom: 8px;
  color: var(--accent-strong);
  font-size: 0.8rem;
  font-weight: 750;
}

.answer-toggle {
  min-height: 34px;
  margin-top: 4px;
  padding: 0 11px;
  border-color: rgba(159, 65, 57, 0.28);
  color: var(--accent-strong);
  font-size: 0.86rem;
  font-weight: 700;
}

.answer {
  margin-top: 10px;
  padding-left: 14px;
  border-left: 3px solid var(--accent-soft);
}

.source-box {
  border-top: 1px solid var(--border);
}

.takeaway-box {
  border-top: 1px solid var(--border);
  background: var(--accent-soft);
}

.takeaway-box p:last-child {
  margin-bottom: 0;
  line-height: 1.6;
}

.source-box p {
  color: var(--muted);
  line-height: 1.6;
}

.full-story-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  width: fit-content;
  min-height: 42px;
  padding: 0 14px;
  border: 1px solid var(--accent);
  border-radius: 8px;
  background: var(--accent);
  color: #ffffff;
  font-weight: 750;
  text-decoration: none;
}

.full-story-link:hover {
  background: var(--accent-strong);
}

dialog {
  width: min(410px, calc(100vw - 32px));
  padding: 18px;
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 18px 44px rgba(37, 35, 33, 0.14);
  color: var(--text);
}

dialog::backdrop {
  background: rgba(37, 35, 33, 0.28);
}

.icon-button {
  float: right;
  display: grid;
  place-items: center;
  width: 34px;
  min-height: 34px;
  padding: 0;
  border-radius: 999px;
  color: var(--muted);
  font-size: 1.3rem;
  line-height: 1;
}

.eyebrow {
  margin: 2px 0 5px;
  color: var(--accent-strong);
  font-size: 0.78rem;
  font-weight: 750;
}

#vocab-term {
  margin-bottom: 8px;
  font-size: 1.5rem;
}

#vocab-meaning {
  line-height: 1.6;
}

#vocab-example span {
  color: var(--muted);
  font-size: 0.94rem;
}

.example {
  margin-top: 8px;
  margin-bottom: 0;
  color: var(--muted);
  font-style: italic;
  line-height: 1.55;
}

.site-footer {
  padding: 26px clamp(18px, 4vw, 56px);
  border-top: 1px solid var(--border);
  color: var(--muted);
}

.site-footer p {
  max-width: 760px;
  margin: 0 auto;
  line-height: 1.6;
}

@media (max-width: 1040px) {
  .layout {
    grid-template-columns: minmax(220px, 280px) minmax(0, 1fr);
    gap: 24px;
  }
}

@media (max-width: 860px) {
  .layout {
    grid-template-columns: 1fr;
    grid-template-areas:
      "reader"
      "list";
  }

  .article-list {
    position: static;
  }
}

@media (max-width: 640px) {
  .app-header {
    align-items: flex-start;
    flex-direction: column;
    gap: 12px;
  }

  .site-nav {
    justify-content: flex-start;
  }

  .language-selector {
    align-self: stretch;
    justify-content: space-between;
  }

  .header-controls {
    display: grid;
    grid-template-columns: 1fr;
  }

  .header-controls button,
  .word-legend {
    width: 100%;
  }

  select {
    width: 100%;
  }

  .layout {
    padding: 18px 16px 42px;
  }

  .article-shell {
    border-radius: 8px;
  }

  .article-title {
    font-size: 2rem;
  }

  .article-meta {
    font-size: 0.86rem;
  }

  .vi {
    font-size: 1.06rem;
    line-height: 1.76;
  }

  .vocab-grid,
  .grammar-grid,
  .question-grid {
    grid-template-columns: 1fr;
  }

  .story-body,
  .vocab-list,
  .grammar-list,
  .expression-list,
  .questions-list,
  .takeaway-box,
  .source-box {
    padding: 22px;
  }
}
