* { box-sizing: border-box; }

body.home-page {
  margin: 0;
  min-height: 100vh;
  color: var(--app-ink);
  background:
    radial-gradient(circle at 16% 4%, rgba(39, 105, 91, 0.11), transparent 32%),
    radial-gradient(circle at 82% 10%, rgba(163, 84, 46, 0.09), transparent 30%),
    linear-gradient(90deg, rgba(190, 204, 195, 0.22) 1px, transparent 1px),
    linear-gradient(0deg, rgba(190, 204, 195, 0.16) 1px, transparent 1px),
    linear-gradient(180deg, #fffdf8 0%, var(--app-bg) 58%, var(--app-bg-2) 100%);
  background-size: 980px 520px, 760px 460px, 56px 56px, 56px 56px, auto;
  background-repeat: no-repeat, no-repeat, repeat, repeat, no-repeat;
}

.home-header {
  min-height: 68px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 12px max(24px, calc((100% - 1180px) / 2));
  border-bottom: 1px solid var(--app-line);
  background: rgba(255, 253, 247, 0.88);
  backdrop-filter: blur(18px);
  position: sticky;
  top: 0;
  z-index: 5;
}

.home-brand {
  color: var(--app-ink);
  font-size: 20px;
  font-weight: 800;
  text-decoration: none;
}

.home-header nav { display: flex; gap: 8px; }
.home-header nav a,
.home-btn {
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 12px;
  border: 1px solid var(--app-line);
  border-radius: var(--app-radius-sm);
  background: rgba(255, 255, 255, 0.72);
  color: var(--app-muted);
  text-decoration: none;
}

.home-header nav a:hover,
.home-header nav a:focus-visible,
.home-btn:hover,
.home-btn:focus-visible {
  border-color: var(--app-accent);
  color: var(--app-accent);
  outline: none;
  box-shadow: 0 0 0 3px var(--app-focus);
}
.home-btn.primary { border-color: var(--app-line-strong); background: var(--app-accent-soft); color: var(--app-accent); font-weight: 800; }

.home-main {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 32px 0 48px;
  display: grid;
  gap: 28px;
}

.today-overview {
  min-height: 360px;
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(310px, 0.65fr);
  gap: 28px;
  align-items: center;
  padding: 34px 0;
  border-bottom: 1px solid var(--app-line);
}

.today-copy { display: grid; gap: 14px; align-content: center; }
.home-kicker,
.support-kicker,
.section-heading span { color: var(--app-accent); font-size: 12px; font-weight: 800; }
.today-copy h1 { margin: 0; font-family: var(--app-font-display); font-size: clamp(46px, 7vw, 82px); line-height: 0.95; }
.today-copy h2 { margin: 4px 0 0; font-size: 26px; line-height: 1.25; }
.today-copy p { max-width: 700px; margin: 0; color: var(--app-muted); font-size: 16px; line-height: 1.75; }
.home-actions { display: flex; flex-wrap: wrap; gap: 9px; margin-top: 8px; }

.memory-snapshot {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  border: 1px solid var(--app-line);
  border-radius: var(--app-radius);
  background: var(--app-panel);
  box-shadow: var(--app-shadow-soft);
}
.memory-snapshot div { min-height: 112px; padding: 18px; border-right: 1px solid var(--app-line); border-bottom: 1px solid var(--app-line); }
.memory-snapshot div:nth-child(2n) { border-right: 0; }
.memory-snapshot div:nth-last-child(-n+2) { border-bottom: 0; }
.memory-snapshot span,
.memory-snapshot strong { display: block; }
.memory-snapshot span { color: var(--app-muted); font-size: 12px; }
.memory-snapshot strong { margin-top: 12px; font-size: 28px; line-height: 1.1; overflow-wrap: anywhere; }

.journey-section,
.matrix-section { display: grid; gap: 18px; }
.section-heading { display: flex; justify-content: space-between; gap: 28px; align-items: end; }
.section-heading h2 { margin: 4px 0 0; font-size: 28px; }
.section-heading p { max-width: 560px; margin: 0; color: var(--app-muted); line-height: 1.65; }
.journey { margin: 0; padding: 0; display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); list-style: none; border: 1px solid var(--app-line); border-radius: var(--app-radius); overflow: hidden; background: var(--app-panel); box-shadow: var(--app-shadow-soft); }
.journey li { min-height: 178px; padding: 0; display: block; border-right: 1px solid var(--app-line); }
.journey li:last-child { border-right: 0; }
.journey li.active { background: var(--app-accent-soft); box-shadow: inset 0 3px 0 var(--app-accent); }
.journey li > a,
.journey li > div {
  min-height: 178px;
  padding: 18px;
  display: grid;
  align-content: start;
  gap: 14px;
  color: inherit;
  text-decoration: none;
}
.journey li > a:hover,
.journey li > a:focus-visible {
  background: rgba(47, 104, 93, 0.08);
  outline: none;
  box-shadow: inset 0 0 0 3px var(--app-focus);
}
.journey b { width: 30px; height: 30px; display: grid; place-items: center; border-radius: 50%; background: var(--app-accent-soft); color: var(--app-accent); }
.journey strong,
.journey span { display: block; }
.journey span { margin-top: 7px; color: var(--app-muted); font-size: 13px; line-height: 1.55; }

.matrix-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.matrix-toolbar {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--app-line);
  border-radius: var(--app-radius);
  background: rgba(255, 255, 255, 0.58);
}

.matrix-filter-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
}

.matrix-filter-group {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.matrix-chip,
.matrix-page-btn {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 10px;
  border: 1px solid var(--app-line);
  border-radius: var(--app-radius-sm);
  background: rgba(255, 255, 255, 0.74);
  color: var(--app-muted);
  cursor: pointer;
}

.matrix-chip span {
  color: var(--app-muted);
  opacity: 0.72;
  font-size: 11px;
}

.matrix-chip:hover,
.matrix-chip:focus-visible,
.matrix-page-btn:hover,
.matrix-page-btn:focus-visible {
  border-color: var(--app-accent);
  color: var(--app-accent);
  outline: none;
  box-shadow: 0 0 0 3px var(--app-focus);
}

.matrix-chip.active {
  border-color: var(--app-line-strong);
  background: var(--app-accent-soft);
  color: var(--app-accent);
  font-weight: 800;
}

.matrix-page-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  box-shadow: none;
}

.matrix-pager {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  color: var(--app-muted);
  font-size: 12px;
}

.matrix-page-info {
  min-width: 150px;
  text-align: center;
}

.legend-item {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 10px;
  border: 1px solid var(--app-line);
  border-radius: var(--app-radius-sm);
  background: rgba(255, 255, 255, 0.72);
  color: var(--app-muted);
  font-size: 12px;
}

.legend-item i {
  width: 13px;
  height: 13px;
  border: 1px solid var(--app-line);
  border-radius: 4px;
  background: var(--word-status-color);
}

.word-matrix {
  max-height: min(62vh, 720px);
  overflow: auto;
  padding: 12px;
  border: 1px solid var(--app-line);
  border-radius: var(--app-radius);
  background: var(--app-panel);
  box-shadow: var(--app-shadow-soft);
  scrollbar-width: thin;
}

.matrix-empty {
  min-height: 120px;
  display: grid;
  place-items: center;
  color: var(--app-muted);
}

.matrix-cells {
  display: grid;
  grid-template-columns: repeat(auto-fill, 9px);
  gap: 3px;
  align-items: start;
}

.word-cell {
  position: relative;
  width: 9px;
  height: 9px;
  display: block;
  border: 0;
  border-radius: 2px;
  background: var(--word-status-color);
  text-decoration: none;
  transition: transform 140ms ease, box-shadow 140ms ease, border-color 140ms ease;
}

.word-cell.unmapped {
  opacity: 0.82;
}

.word-cell span {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.word-cell:hover,
.word-cell:focus-visible {
  transform: scale(2.4);
  border-color: var(--app-ink);
  outline: none;
  box-shadow: 0 0 0 3px var(--app-focus), 0 8px 18px rgba(30, 43, 38, 0.18);
}

[data-status="new"] { --word-status-color: #e2d8c9; }
[data-status="encoded"] { --word-status-color: #9fc7d5; }
[data-status="learning"] { --word-status-color: #d8b872; }
[data-status="mastered"] { --word-status-color: #5d9d7f; }
[data-status="weak"] { --word-status-color: #d48a57; }
[data-status="due"] { --word-status-color: #c95b52; }

.home-support { display: grid; grid-template-columns: 1.35fr 0.65fr; gap: 28px; padding-top: 8px; }
.support-block { padding: 22px 0; border-top: 1px solid var(--app-line); }
.support-block h2 { margin: 7px 0; font-size: 22px; }
.support-block p { margin: 0; color: var(--app-muted); line-height: 1.65; }
.text-link { display: inline-block; margin-top: 14px; color: var(--app-accent-3); font-weight: 800; text-decoration: none; }

@media (max-width: 820px) {
  .home-header { align-items: flex-start; padding: 12px 16px; }
  .home-header nav { max-width: 68vw; overflow-x: auto; }
  .home-header nav a { flex: 0 0 auto; white-space: nowrap; }
  .home-main { width: min(100% - 20px, 680px); padding-top: 18px; }
  .today-overview,
  .home-support { grid-template-columns: 1fr; }
  .today-overview { padding-top: 12px; }
  .today-copy h1 { font-size: 52px; }
  .section-heading { display: grid; gap: 10px; }
  .matrix-filter-row { display: grid; }
  .matrix-pager { justify-content: space-between; }
  .matrix-page-info { min-width: 0; }
  .journey { grid-template-columns: 1fr; }
  .journey li { min-height: auto; border-right: 0; border-bottom: 1px solid var(--app-line); }
  .journey li > a,
  .journey li > div { min-height: auto; grid-template-columns: 30px minmax(0, 1fr); }
  .journey li:last-child { border-bottom: 0; }
  .word-matrix { max-height: 68vh; padding: 10px; }
  .matrix-cells { grid-template-columns: repeat(auto-fill, 8px); gap: 3px; }
  .word-cell { width: 8px; height: 8px; }
}
