:root {
  --paper: #f3efe4;
  --paper-deep: #e7e0d1;
  --card: #fbf8f2;
  --ink: #1b2421;
  --muted: #5c675f;
  --line: #d8d0bf;
  --header: #14241e;
  --gold: #b5833f;
  --green: #1e6b45;
  --green-deep: #144c31;
  --shadow: 0 10px 30px rgba(28, 36, 30, 0.06);
  --serif: "Iowan Old Style", Palatino, "Palatino Linotype", Georgia, serif;
  --sans: "Segoe UI", system-ui, sans-serif;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background:
    radial-gradient(circle at top left, rgba(181, 131, 63, 0.08), transparent 32rem),
    var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.5;
}

a { color: inherit; }

button, input { font: inherit; color: inherit; }

.skip {
  position: absolute;
  left: 12px;
  top: -40px;
  background: white;
  padding: 8px 12px;
  z-index: 20;
}

.skip:focus { top: 12px; }

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

.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 14px 28px;
  background: var(--header);
  color: #f6f1e7;
  border-bottom: 3px solid var(--gold);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  min-width: 190px;
}

.mark {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  background: var(--gold);
  color: var(--header);
  font-family: var(--serif);
  font-weight: 700;
  font-size: 1.25rem;
}

.brand strong {
  display: block;
  font-family: var(--serif);
  font-size: 1.15rem;
  letter-spacing: 0.01em;
  line-height: 1.1;
}

.brand small {
  display: block;
  color: #d9c7a4;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-size: 0.68rem;
}

.search {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(246, 241, 231, 0.18);
  border-radius: 999px;
  padding: 8px 14px;
}

.search input {
  width: 100%;
  background: transparent;
  border: 0;
  outline: none;
  color: #f6f1e7;
}

.search input::placeholder { color: #c9bfae; }

.lang {
  display: flex;
  border: 1px solid rgba(246, 241, 231, 0.3);
  border-radius: 999px;
  overflow: hidden;
}

.lang button {
  background: transparent;
  border: 0;
  color: #f6f1e7;
  padding: 7px 12px;
  cursor: pointer;
}

.lang button[aria-pressed="true"] {
  background: #f6f1e7;
  color: var(--header);
}

.wrap {
  width: min(1180px, calc(100% - 40px));
  margin: 0 auto;
}

.hero {
  padding: 42px 0 10px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--gold);
  letter-spacing: 0.16em;
  text-transform: uppercase;
  font-size: 0.75rem;
  font-weight: 700;
}

h1 {
  margin: 0;
  font-family: var(--serif);
  font-size: clamp(2.15rem, 4.2vw, 3.5rem);
  font-weight: 600;
  letter-spacing: -0.03em;
  line-height: 1.05;
  max-width: 16ch;
}

.deck {
  max-width: 40rem;
  margin: 16px 0 0;
  color: var(--ink);
  font-size: 1.2rem;
}

.ai-note {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 0.95rem;
}

.stats {
  display: flex;
  gap: 28px;
  margin: 26px 0 0;
}

.stats div { min-width: 90px; }

.stats dt {
  margin: 0;
  color: var(--muted);
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.stats dd {
  margin: 2px 0 0;
  font-family: var(--serif);
  font-size: 1.8rem;
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-top: 22px;
}

.seg {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.seg button {
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 7px 12px;
  cursor: pointer;
}

.seg button[aria-pressed="true"] {
  background: var(--ink);
  color: var(--paper);
  border-color: var(--ink);
}

#showing { margin: 0; color: var(--muted); font-size: 0.92rem; }

.layout {
  display: grid;
  grid-template-columns: 230px 1fr;
  gap: 36px;
  align-items: start;
  padding: 28px 0 20px;
}

.subjects {
  position: sticky;
  top: 86px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding-top: 8px;
}

.subjects a {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  text-decoration: none;
  padding: 8px 10px;
  border-left: 2px solid transparent;
  color: var(--muted);
}

.subjects a.active,
.subjects a:hover {
  color: var(--ink);
  border-left-color: var(--gold);
  background: rgba(255, 255, 255, 0.45);
}

.subjects .n {
  font-variant-numeric: tabular-nums;
  color: var(--muted);
}

.subject {
  scroll-margin-top: 92px;
  margin: 0 0 42px;
}

.subject-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  margin: 0;
  padding-bottom: 8px;
  border-bottom: 2px solid var(--ink);
  font-family: var(--serif);
  font-size: 2rem;
  font-weight: 600;
}

.subject-title span {
  font-family: var(--sans);
  font-size: 0.95rem;
  color: var(--muted);
  font-weight: 500;
}

.class-head {
  display: flex;
  align-items: baseline;
  gap: 12px;
  margin: 26px 0 12px;
}

.class-head h3 {
  margin: 0;
  font-family: var(--serif);
  font-size: 1.35rem;
  font-weight: 600;
}

.class-head .gloss { color: var(--muted); font-size: 0.88rem; }

.class-head .count {
  margin-left: auto;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 12px;
}

.card {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 164px;
  padding: 16px 16px 14px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
}

.card h3 {
  margin: 0;
  font-family: var(--serif);
  font-size: 1.12rem;
  font-weight: 600;
  line-height: 1.28;
  letter-spacing: -0.01em;
}

.pill {
  display: inline-block;
  margin: 0;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--paper-deep);
  color: var(--muted);
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.actions {
  display: flex;
  gap: 8px;
  margin-top: auto;
}

.actions a {
  text-decoration: none;
  border-radius: 999px;
  padding: 7px 12px;
  font-size: 0.86rem;
  font-weight: 600;
}

.open {
  background: var(--green);
  color: white;
}

.open:hover { background: var(--green-deep); }

.save {
  border: 1px solid var(--line);
  color: var(--ink);
}

.save:hover { border-color: var(--ink); }

.empty {
  padding: 28px 0 10px;
  color: var(--muted);
}

.apps {
  margin: 10px auto 0;
  padding: 28px 0 64px;
  border-top: 1px solid var(--line);
}

.apps h2 {
  margin: 0 0 6px;
  font-family: var(--serif);
  font-size: 1.8rem;
  font-weight: 600;
}

.apps > p { margin: 0 0 16px; color: var(--muted); max-width: 40rem; }

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

.app {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 16px;
  text-decoration: none;
  background: var(--header);
  color: #f6f1e7;
  border-radius: 16px;
}

.app strong { font-family: var(--serif); font-size: 1.15rem; }

.app span { color: #d9c7a4; font-size: 0.88rem; }

.site-footer {
  padding: 18px 28px 28px;
  color: var(--muted);
  font-size: 0.85rem;
}

@media (max-width: 860px) {
  .site-header { flex-wrap: wrap; padding: 12px 16px; }
  .search { order: 3; flex-basis: 100%; }
  .toolbar { flex-direction: column; align-items: flex-start; }
  .layout { grid-template-columns: 1fr; gap: 12px; }
  .subjects {
    position: sticky;
    top: 132px;
    flex-direction: row;
    overflow-x: auto;
    background: rgba(243, 239, 228, 0.94);
    padding: 8px 0;
    z-index: 5;
  }
  .subjects a { white-space: nowrap; border-left: 0; border-bottom: 2px solid transparent; }
  .subjects a.active, .subjects a:hover { border-bottom-color: var(--gold); }
  .app-grid { grid-template-columns: 1fr; }
  .wrap { width: min(1180px, calc(100% - 28px)); }
  .stats { gap: 18px; }
}
