@font-face {
  font-family: "Amarante";
  src: url("./Amarante-Regular.ttf") format("truetype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

:root {
  color-scheme: light;
  --bg: #f3f7f1;
  --surface: rgba(255, 255, 255, 0.92);
  --surface-strong: #fffefa;
  --surface-soft: #eaf3f6;
  --ink: #183247;
  --ink-soft: #53646f;
  --muted: #7e8d93;
  --line: rgba(24, 50, 71, 0.14);
  --blue: #1f6ea5;
  --blue-soft: #dcedf7;
  --pink: #c54175;
  --pink-soft: #fde4ee;
  --green: #3d9a64;
  --green-soft: #e2f3e9;
  --amber: #e8a400;
  --amber-soft: #fff0b8;
  --shadow: 0 16px 34px rgba(30, 48, 58, 0.12);
  --shadow-soft: 0 8px 18px rgba(30, 48, 58, 0.08);
  --r-card: 8px;
  --r-control: 8px;
  --rail-width: 356px;
  --panel-width: 292px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", sans-serif;
  font-size: 16px;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  min-height: 100%;
  background: var(--bg);
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(180deg, rgba(255, 254, 250, 0.96), rgba(239, 247, 242, 0.92)),
    var(--bg);
  overflow-x: hidden;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(31, 110, 165, 0.06) 1px, transparent 1px),
    linear-gradient(90deg, rgba(61, 154, 100, 0.045) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: linear-gradient(to bottom, rgba(0, 0, 0, 0.48), transparent 64%);
}

button,
input {
  font: inherit;
}

button {
  color: inherit;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.app-shell {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: var(--rail-width) minmax(0, 1fr) var(--panel-width);
  gap: 16px;
  width: min(1720px, 100%);
  min-height: 100vh;
  margin: 0 auto;
  padding: 18px;
}

.dictionary-rail,
.insight-panel {
  position: sticky;
  top: 18px;
  align-self: start;
  height: calc(100vh - 36px);
  overflow: auto;
  scrollbar-width: thin;
}

.dictionary-rail {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 18px;
  border: 2px solid rgba(24, 50, 71, 0.09);
  border-radius: 10px;
  background: var(--surface);
  box-shadow: var(--shadow-soft);
  backdrop-filter: blur(14px) saturate(1.18);
}

.brand-lockup,
.mobile-brand {
  display: flex;
  align-items: center;
  min-width: 0;
}

.brand-lockup {
  gap: 12px;
}

.brand-mark {
  width: 56px;
  height: 56px;
  object-fit: cover;
  border-radius: 8px;
  box-shadow: 0 6px 0 var(--amber-soft), 0 10px 18px rgba(24, 50, 71, 0.12);
}

.wordmark {
  margin: 0;
  font-family: "Amarante", Georgia, serif;
  font-size: 1.64rem;
  line-height: 1;
  letter-spacing: 0;
}

.wordmark span {
  color: var(--pink);
}

.wordmark strong {
  color: var(--blue);
  font-weight: 400;
}

.brand-subtitle {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 760;
}

.search-form {
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr) 28px;
  gap: 8px;
  align-items: center;
  min-height: 58px;
  padding: 0 12px 0 15px;
  border: 2px solid color-mix(in srgb, var(--blue), transparent 58%);
  border-radius: var(--r-control);
  background: var(--surface-strong);
  box-shadow: 0 4px 0 color-mix(in srgb, var(--blue-soft), white 28%);
}

.search-form:focus-within {
  border-color: var(--blue);
  box-shadow: 0 4px 0 var(--amber), 0 12px 24px rgba(31, 110, 165, 0.13);
}

.field-icon,
.icon-button svg,
.text-button svg {
  display: block;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.field-icon {
  width: 20px;
  height: 20px;
  color: var(--green);
}

#word-search {
  width: 100%;
  min-width: 0;
  border: 0;
  outline: 0;
  color: var(--ink);
  background: transparent;
  font-size: 1.12rem;
  font-weight: 820;
}

#word-search::placeholder {
  color: color-mix(in srgb, var(--muted), transparent 16%);
  font-weight: 560;
}

input[type="search"]::-webkit-search-cancel-button {
  display: none;
}

.icon-button {
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: color-mix(in srgb, var(--surface-strong), transparent 6%);
  cursor: pointer;
}

.icon-button svg {
  width: 17px;
  height: 17px;
}

.icon-button:hover,
.result-row:hover,
.text-button:hover {
  transform: translateY(-1px);
}

.clear-button {
  width: 28px;
  height: 28px;
  color: var(--muted);
  border: 0;
  background: var(--blue-soft);
}

.mode-strip {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #f1f6ed;
}

.mode-pill {
  min-height: 34px;
  border: 0;
  border-radius: 7px;
  color: var(--ink-soft);
  background: transparent;
  font-size: 0.78rem;
  font-weight: 760;
  cursor: pointer;
}

.mode-pill.is-active {
  color: var(--ink);
  background: var(--amber-soft);
  box-shadow: inset 0 -2px 0 color-mix(in srgb, var(--amber), transparent 20%);
}

.rail-section {
  min-height: 0;
}

.rail-section:first-of-type {
  flex: 1;
  overflow: auto;
  padding-bottom: 8px;
}

.section-kicker {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 820;
  text-transform: uppercase;
}

.section-kicker output {
  color: var(--blue);
  font-variant-numeric: tabular-nums;
}

.results-list,
.review-list {
  display: grid;
  gap: 8px;
}

.results-list {
  padding-bottom: 4px;
}

.result-row,
.review-chip {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--r-card);
  background: var(--surface-strong);
  text-align: left;
}

.result-row {
  display: grid;
  gap: 5px;
  padding: 12px 12px 11px;
  cursor: pointer;
  box-shadow: 0 2px 0 rgba(24, 50, 71, 0.05);
  transition: transform 0.18s ease, border-color 0.18s ease, background 0.18s ease, box-shadow 0.18s ease;
}

.result-row.is-selected {
  border-color: color-mix(in srgb, var(--green), transparent 22%);
  background: color-mix(in srgb, var(--green-soft), white 42%);
  box-shadow: inset 4px 0 0 var(--green), 0 3px 0 rgba(61, 154, 100, 0.14);
}

.result-word {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  min-width: 0;
}

.result-word strong,
.review-chip strong {
  min-width: 0;
  overflow: hidden;
  color: var(--ink);
  font-size: 1.02rem;
  font-weight: 860;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.result-word span {
  flex: 0 0 auto;
  color: var(--green);
  font-size: 0.68rem;
  font-weight: 860;
  text-transform: uppercase;
}

.result-row p {
  display: -webkit-box;
  margin: 0;
  overflow: hidden;
  color: var(--ink-soft);
  font-size: 0.83rem;
  line-height: 1.35;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.empty-note {
  margin: 0;
  padding: 14px;
  border: 1px dashed var(--line);
  border-radius: var(--r-card);
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.4;
}

.review-chip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 10px 9px 12px;
}

.review-chip button {
  flex: 0 0 auto;
  width: 25px;
  height: 25px;
  border: 0;
  border-radius: 50%;
  color: var(--muted);
  background: var(--surface-soft);
  cursor: pointer;
}

.article-shell {
  min-width: 0;
  padding: 14px 0;
}

.mobile-topbar {
  display: none;
}

.article-stage {
  min-height: calc(100vh - 64px);
  padding: clamp(16px, 3vw, 44px);
  border: 2px solid rgba(24, 50, 71, 0.09);
  border-radius: 10px;
  background: var(--surface-strong);
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px) saturate(1.08);
}

.loading-state {
  display: grid;
  place-items: center;
  align-content: center;
  min-height: 62vh;
  gap: 14px;
  color: var(--muted);
  font-weight: 700;
}

.loading-state img {
  width: 76px;
  height: 76px;
  object-fit: contain;
  border-radius: 16px;
}

.word-article {
  display: grid;
  gap: clamp(18px, 3vw, 32px);
  max-width: 980px;
  margin: 0 auto;
  transition: opacity 0.12s ease;
}

.word-article.is-previewing {
  opacity: 0.72;
}

.article-hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 22px;
  align-items: start;
  padding-bottom: 22px;
  border-bottom: 3px solid var(--amber-soft);
}

.word-title {
  margin: 0;
  color: var(--blue);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", sans-serif;
  font-size: clamp(3.1rem, 5.8vw, 6rem);
  font-weight: 900;
  letter-spacing: 0;
  line-height: 0.94;
  overflow-wrap: anywhere;
}

.hero-summary {
  max-width: 720px;
  margin: 14px 0 0;
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", sans-serif;
  font-size: clamp(1.2rem, 1.85vw, 1.55rem);
  font-weight: 760;
  line-height: 1.36;
}

.pron-row,
.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 16px;
}

.pron-chip,
.part-chip,
.pos-token {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 760;
}

.pron-chip {
  gap: 6px;
  padding: 4px 9px;
  color: var(--ink-soft);
  background: color-mix(in srgb, var(--blue-soft), white 28%);
}

.pron-chip b {
  color: var(--green);
  font-size: 0.68rem;
  text-transform: uppercase;
}

.hero-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 144px;
}

.text-button,
.save-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  border-radius: 8px;
  border: 1px solid color-mix(in srgb, var(--blue), transparent 70%);
  background: var(--surface-strong);
  color: var(--blue);
  font-weight: 800;
  cursor: pointer;
  text-decoration: none;
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.text-button svg,
.save-button svg {
  width: 17px;
  height: 17px;
}

.save-button {
  padding: 0 16px;
  color: #163049;
  border-color: color-mix(in srgb, var(--amber), transparent 18%);
  background: var(--amber);
  box-shadow: 0 4px 0 color-mix(in srgb, var(--amber), black 13%);
}

.save-button.is-saved {
  border-color: color-mix(in srgb, var(--green), transparent 52%);
  background: var(--green);
  color: white;
  box-shadow: 0 4px 0 color-mix(in srgb, var(--green), black 16%);
}

.copy-button {
  padding: 0 13px;
}

.content-section {
  display: grid;
  gap: 14px;
}

.content-section header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.content-section h2 {
  margin: 0;
  color: var(--blue);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", sans-serif;
  font-size: 1.06rem;
  font-weight: 900;
}

.definition-list,
.parts-grid,
.example-list {
  display: grid;
  gap: 10px;
}

.definition-row,
.part-card,
.etymology-card,
.example-card {
  border: 1px solid var(--line);
  border-radius: var(--r-card);
  background: white;
}

.definition-row {
  display: grid;
  grid-template-columns: 60px minmax(0, 1fr);
  gap: 16px;
  padding: 16px;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.5);
}

.pos-token {
  align-self: start;
  padding: 4px 8px;
  color: var(--ink);
  background: var(--amber-soft);
  font-size: 0.7rem;
  text-transform: uppercase;
  justify-content: center;
}

.definition-row p,
.part-card p,
.etymology-card p,
.example-card p {
  margin: 0;
  color: var(--ink);
  line-height: 1.58;
}

.definition-row p {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", sans-serif;
  font-size: 1.06rem;
  font-weight: 650;
}

.parts-grid {
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
}

.part-card {
  padding: 14px;
}

.part-card strong {
  display: block;
  margin-bottom: 6px;
  color: var(--blue);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", sans-serif;
  font-size: 1.18rem;
  font-weight: 900;
}

.part-card p {
  color: var(--ink-soft);
  font-size: 0.93rem;
}

.structure-line {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 9px;
}

.part-chip {
  padding: 5px 10px;
  color: var(--ink);
  background: var(--amber-soft);
}

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

.etymology-card {
  display: grid;
  gap: 10px;
  padding: 17px;
  border-left: 5px solid var(--green);
}

.etymology-card p {
  color: var(--ink-soft);
}

.example-card {
  padding: 15px;
}

.example-card blockquote {
  margin: 0;
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", sans-serif;
  font-size: 1.06rem;
  line-height: 1.52;
  font-weight: 650;
}

.example-card p {
  margin-top: 9px;
  color: var(--green);
  font-size: 0.93rem;
  font-weight: 650;
}

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

.focus-panel,
.metric-tile,
.pack-panel {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  box-shadow: var(--shadow-soft);
  backdrop-filter: blur(12px) saturate(1.1);
}

.focus-panel {
  position: relative;
  overflow: hidden;
  padding: 18px;
}

.panel-art {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 74px;
  height: 74px;
  opacity: 0.16;
}

.panel-art img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.panel-eyebrow {
  margin: 0 0 26px;
  color: var(--green);
  font-size: 0.72rem;
  font-weight: 860;
  text-transform: uppercase;
}

.focus-panel h2 {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", sans-serif;
  font-size: 2.1rem;
  line-height: 0.98;
  color: var(--blue);
  font-weight: 900;
  overflow-wrap: anywhere;
}

.focus-panel > p:not(.panel-eyebrow) {
  margin: 13px 0 18px;
  color: var(--ink-soft);
  line-height: 1.45;
}

.focus-panel .text-button {
  width: 100%;
}

.metric-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.metric-tile {
  padding: 14px;
  border-radius: var(--r-card);
  box-shadow: inset 0 -3px 0 var(--amber-soft);
}

.metric-tile span {
  display: block;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 830;
  text-transform: uppercase;
}

.metric-tile strong {
  display: block;
  margin-top: 6px;
  color: var(--ink);
  font-size: 1.55rem;
  font-variant-numeric: tabular-nums;
}

.pack-panel {
  padding: 16px;
}

.pack-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.pack-list span {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--ink-soft);
  background: var(--surface-strong);
  font-size: 0.76rem;
  font-weight: 800;
}

@media (max-width: 1180px) {
  .app-shell {
    grid-template-columns: 320px minmax(0, 1fr);
  }

  .insight-panel {
    display: none;
  }
}

@media (max-width: 1380px) {
  .article-hero {
    grid-template-columns: 1fr;
  }

  .hero-actions {
    flex-flow: row wrap;
    min-width: 0;
  }

  .save-button,
  .copy-button {
    flex: 1 1 150px;
  }
}

@media (max-width: 860px) {
  body {
    background: var(--bg);
  }

  body::before {
    opacity: 0.55;
  }

  .app-shell {
    display: block;
    min-height: 100vh;
    padding: 0;
  }

  .dictionary-rail {
    position: sticky;
    top: 0;
    z-index: 8;
    height: auto;
    max-height: 62vh;
    padding: calc(12px + var(--safe-top)) 12px 12px;
    border-width: 0 0 1px;
    border-radius: 0 0 22px 22px;
    box-shadow: 0 12px 32px rgba(23, 32, 47, 0.12);
  }

  .brand-lockup,
  .mode-strip,
  .rail-review {
    display: none;
  }

  .search-form {
    min-height: 52px;
  }

  .results-list {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 2px;
    scroll-snap-type: x proximity;
  }

  .result-row {
    flex: 0 0 min(78vw, 310px);
    scroll-snap-align: start;
  }

  .article-shell {
    padding: 0;
  }

  .mobile-topbar {
    display: flex;
    position: sticky;
    top: 0;
    z-index: 6;
    align-items: center;
    justify-content: space-between;
    height: calc(52px + var(--safe-top));
    padding: var(--safe-top) 14px 0;
    border-bottom: 1px solid var(--line);
    background: rgba(250, 252, 255, 0.72);
    backdrop-filter: blur(22px) saturate(1.35);
  }

  .mobile-brand {
    gap: 8px;
    font-family: "Amarante", Georgia, serif;
    color: var(--blue);
    font-size: 1.05rem;
  }

  .mobile-brand-mark {
    width: 28px;
    height: 28px;
    border-radius: 7px;
    object-fit: cover;
  }

  .article-stage {
    min-height: auto;
    padding: 22px 16px calc(34px + var(--safe-bottom));
    border: 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
    backdrop-filter: none;
  }

  .article-hero {
    grid-template-columns: 1fr;
  }

  .hero-actions {
    flex-flow: row wrap;
    min-width: 0;
  }

  .save-button,
  .copy-button {
    flex: 1 1 140px;
  }

  .word-title {
    font-size: clamp(2.7rem, 16vw, 4.9rem);
  }

  .definition-row {
    grid-template-columns: 1fr;
    gap: 8px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.001ms !important;
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
  }
}
