:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --panel: #ffffff;
  --ink: #1e242c;
  --muted: #66717f;
  --line: #dce2e8;
  --blue: #2d6cdf;
  --green: #267a4d;
  --amber: #9a6114;
  --red: #b33242;
  --shadow: 0 10px 30px rgba(31, 43, 57, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--ink);
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.45;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  min-height: 42px;
  border: 0;
  border-radius: 8px;
  background: var(--ink);
  color: #fff;
  padding: 0 16px;
  cursor: pointer;
}

button:hover {
  background: #354150;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 3px solid rgba(45, 108, 223, 0.24);
  outline-offset: 2px;
}

button.secondary {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
}

button.secondary:hover {
  background: #eef2f6;
}

button.danger {
  background: var(--red);
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 11px 12px;
}

textarea {
  resize: vertical;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.86rem;
}

label span {
  color: #8a95a3;
  font-weight: 400;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: center;
  padding: 28px clamp(16px, 4vw, 48px) 18px;
  border-bottom: 1px solid var(--line);
  background: #fff;
}

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

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

h1 {
  margin-bottom: 0;
  font-size: clamp(1.8rem, 3vw, 2.6rem);
  line-height: 1.05;
}

h2 {
  margin-bottom: 0;
  font-size: 1.15rem;
}

h3 {
  margin-bottom: 4px;
  font-size: 1rem;
}

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

.nav-button {
  min-height: 40px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
}

.nav-button:hover,
.nav-button.active {
  border-color: var(--ink);
  background: var(--ink);
  color: #fff;
}

.nav-button span {
  display: inline-grid;
  min-width: 22px;
  height: 22px;
  margin-left: 4px;
  place-items: center;
  border-radius: 999px;
  background: #e8f0ff;
  color: #204f9d;
  font-size: 0.78rem;
  font-weight: 800;
}

.nav-button.active span,
.nav-button:hover span {
  background: #fff;
  color: var(--ink);
}

.shell {
  max-width: 760px;
  margin: 0 auto;
  padding: 22px clamp(16px, 4vw, 48px) 42px;
}

.view {
  display: none;
}

.view.active {
  display: grid;
  gap: 14px;
}

.add-form,
.library {
  display: grid;
  gap: 14px;
}

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

.form-actions,
.library-tools,
.row-actions {
  display: flex;
  gap: 8px;
}

.library-count {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.86rem;
}

.sort-label {
  min-width: 150px;
}

.hidden {
  display: none;
}

.selection-tooltip {
  position: fixed;
  z-index: 20;
  display: none;
  max-width: min(280px, calc(100vw - 24px));
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--ink);
  box-shadow: var(--shadow);
  padding: 8px 10px;
}

.selection-tooltip.visible {
  display: block;
}

.selection-tooltip a {
  color: #fff;
  font-size: 0.88rem;
  font-weight: 700;
  text-decoration: none;
}

.selection-tooltip a:hover {
  text-decoration: underline;
}

.pill {
  max-width: 100%;
  border-radius: 999px;
  background: #e8f0ff;
  color: #204f9d;
  padding: 6px 10px;
  font-size: 0.82rem;
  font-weight: 700;
  white-space: nowrap;
}

.review-card,
.add-form,
.library {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.review-card {
  min-height: 396px;
  display: grid;
  gap: 18px;
  padding: clamp(18px, 4vw, 28px);
}

.review-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.tag {
  border-radius: 999px;
  background: #eef2f6;
  color: var(--muted);
  padding: 5px 9px;
  font-size: 0.8rem;
  font-weight: 700;
}

.review-term {
  margin: 0;
  font-size: clamp(2.25rem, 7vw, 4.8rem);
  line-height: 0.95;
  overflow-wrap: anywhere;
}

.meaning {
  min-height: 88px;
  border-left: 4px solid var(--blue);
  padding-left: 14px;
}

.meaning.hidden {
  color: var(--muted);
  border-color: var(--line);
}

.meaning p {
  margin-bottom: 8px;
}

.review-actions {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.review-actions button {
  padding: 0 10px;
}

.review-actions [data-result="forgot"] {
  background: var(--red);
}

.review-actions [data-result="hard"] {
  background: var(--amber);
}

.review-actions [data-result="good"] {
  background: var(--green);
}

.review-actions [data-result="easy"] {
  background: var(--blue);
}

.queue,
.word-list {
  display: grid;
  gap: 8px;
}

.queue-item,
.word-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 12px;
}

.queue-item p,
.word-row p {
  margin: 0;
  color: var(--muted);
  font-size: 0.88rem;
}

.word-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 10px;
  margin-top: 4px;
}

.queue-item strong,
.word-row strong {
  display: block;
  overflow-wrap: anywhere;
}

.row-actions button {
  min-height: 38px;
  padding: 0 12px;
}

.add-form,
.library {
  padding: 16px;
}

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.search {
  max-width: 180px;
}

.empty {
  display: grid;
  place-items: center;
  min-height: 220px;
  color: var(--muted);
  text-align: center;
}

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

@media (max-width: 560px) {
  .topbar,
  .shell {
    padding-left: 12px;
    padding-right: 12px;
  }

  .nav {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    justify-content: stretch;
  }

  .nav-button {
    padding: 0 8px;
  }

  .section-head {
    align-items: stretch;
    flex-direction: column;
  }

  .form-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .library-tools {
    display: grid;
    grid-template-columns: 1fr;
  }

  .sort-label {
    min-width: 0;
  }

  .field-row,
  .review-actions {
    grid-template-columns: 1fr 1fr;
  }

  .search {
    max-width: none;
  }
}
