:root {
  color-scheme: light;
  --bg: #f7f3eb;
  --surface: #fffdf8;
  --surface-strong: #ffffff;
  --ink: #1e293b;
  --muted: #667085;
  --line: #e6dfd2;
  --line-strong: #d8ccb8;
  --teal: #0f766e;
  --teal-dark: #115e59;
  --coral: #c2410c;
  --blue: #2563eb;
  --gold: #b7791f;
  --green-soft: #d8f3ec;
  --coral-soft: #ffe5d4;
  --blue-soft: #dbeafe;
  --shadow: 0 22px 45px rgba(49, 39, 24, 0.08);
  --radius: 8px;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

* {
  box-sizing: border-box;
}

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

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.52), rgba(247, 243, 235, 0)),
    var(--bg);
}

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

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.58;
}

.sprite {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

.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;
}

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

.app-shell {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  min-height: 64px;
  padding: 10px clamp(24px, 4vw, 72px);
  background: rgba(255, 253, 248, 0.9);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(18px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 42px;
}

.brand-mark {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  color: #fff;
  background: var(--teal);
  border-radius: var(--radius);
  font-weight: 800;
  letter-spacing: 0;
  box-shadow: 0 10px 24px rgba(15, 118, 110, 0.22);
}

.brand h1,
.brand p,
.topbar h2,
.topbar p,
.section-heading h3,
.section-heading p {
  margin: 0;
}

.brand h1 {
  font-size: 1.08rem;
  line-height: 1.15;
}

.brand p {
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.8rem;
}

.nav-tabs {
  display: flex;
  align-items: center;
  gap: 8px;
}

.nav-button,
.button,
.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  color: var(--ink);
  background: transparent;
  text-decoration: none;
  transition:
    background 160ms ease,
    border-color 160ms ease,
    transform 160ms ease,
    color 160ms ease;
}

.nav-button {
  padding: 0 12px;
  color: #475467;
  font-weight: 650;
}

.nav-button:hover,
.nav-button.is-active {
  color: var(--teal-dark);
  background: var(--green-soft);
  border-color: rgba(15, 118, 110, 0.16);
}

.nav-button.is-active {
  box-shadow: inset 0 -3px 0 var(--teal);
}

.small-copy {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.45;
}

.main {
  width: 100%;
  padding: 30px clamp(24px, 4vw, 72px) 48px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 24px;
}

.eyebrow {
  color: var(--coral);
  font-size: 0.86rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: none;
}

.topbar h2 {
  margin-top: 5px;
  font-size: clamp(1.5rem, 3vw, 2.25rem);
  line-height: 1.14;
  letter-spacing: 0;
}

.topbar-actions,
.form-actions,
.capture-actions,
.entry-actions,
.review-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.sync-status {
  min-width: 86px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
}

.sync-status.is-ok {
  color: var(--teal-dark);
}

.sync-status.is-error {
  color: #b42318;
}

.cloud-sync-button {
  min-width: 126px;
}

.icon-button {
  width: 42px;
  height: 42px;
  padding: 0;
  color: var(--teal-dark);
  background: var(--surface-strong);
  border-color: var(--line);
  box-shadow: 0 7px 18px rgba(35, 28, 16, 0.06);
}

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

.icon-button.subtle {
  color: #475467;
  background: #faf7ef;
  box-shadow: none;
}

.button {
  min-width: 120px;
  padding: 0 16px;
  font-weight: 750;
  white-space: nowrap;
}

.button.primary {
  color: #fff;
  background: var(--teal);
  border-color: var(--teal);
}

.button.primary:hover {
  background: var(--teal-dark);
}

.button.secondary,
.button.compact {
  color: var(--teal-dark);
  background: #effaf6;
  border-color: rgba(15, 118, 110, 0.2);
}

.button.compact {
  min-width: auto;
  min-height: 38px;
  padding: 0 12px;
}

.button.warning {
  color: #9a3412;
  background: var(--coral-soft);
  border-color: rgba(194, 65, 12, 0.22);
}

.view {
  display: none;
}

.view.is-active {
  display: block;
}

#reviewView {
  scroll-margin-top: 12px;
}

.surface,
.review-card,
.library-tools {
  background: rgba(255, 253, 248, 0.92);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.entry-layout,
.review-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(320px, 0.65fr);
  gap: 18px;
  margin-top: 18px;
  align-items: start;
}

.surface {
  padding: 20px;
}

.section-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.section-heading h3 {
  font-size: 1.05rem;
  line-height: 1.25;
}

.section-heading p {
  margin-top: 5px;
  color: var(--muted);
  line-height: 1.5;
}

.preview-list,
.candidate-list,
.library-list {
  display: grid;
  gap: 10px;
}

.empty-state {
  padding: 24px;
  color: var(--muted);
  background: #faf7ef;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  line-height: 1.55;
}

.entry-card {
  display: grid;
  gap: 10px;
  padding: 14px;
  background: var(--surface-strong);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.term-line {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.term {
  min-width: 0;
  overflow-wrap: anywhere;
  font-weight: 800;
}

.meaning {
  margin: 3px 0 0;
  color: var(--muted);
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.pill-row {
  display: flex;
  gap: 7px;
  flex-wrap: wrap;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 8px;
  color: #475467;
  background: #f4efe6;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 700;
}

.pill.due {
  color: #9a3412;
  background: var(--coral-soft);
  border-color: rgba(194, 65, 12, 0.18);
}

.pill.mastered {
  color: var(--teal-dark);
  background: var(--green-soft);
  border-color: rgba(15, 118, 110, 0.18);
}

.field-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.field,
.search-field,
.select-field {
  display: grid;
  gap: 7px;
}

.field.span-2 {
  grid-column: 1 / -1;
}

.field span {
  color: #475467;
  font-size: 0.88rem;
  font-weight: 750;
}

.field input,
.field select,
.field textarea,
.search-field input,
.select-field select,
.transcript {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  color: var(--ink);
  background: var(--surface-strong);
  outline: none;
  transition:
    border-color 160ms ease,
    box-shadow 160ms ease;
}

.field input,
.field select,
.search-field input,
.select-field select {
  min-height: 42px;
  padding: 0 12px;
}

.field textarea,
.transcript {
  resize: vertical;
  min-height: 96px;
  padding: 12px;
  line-height: 1.55;
}

.field input:focus,
.field select:focus,
.field textarea:focus,
.search-field input:focus,
.select-field select:focus,
.transcript:focus {
  border-color: rgba(15, 118, 110, 0.65);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.12);
}

.form-actions {
  margin-top: 18px;
}

.request-layout {
  grid-template-columns: minmax(0, 1.1fr) minmax(320px, 0.9fr);
}

.request-form {
  display: grid;
  gap: 14px;
}

.request-input {
  min-height: 220px;
}

.request-list {
  display: grid;
  gap: 10px;
}

.request-item {
  display: grid;
  gap: 10px;
  padding: 12px;
  background: var(--surface-strong);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.request-item.is-done {
  opacity: 0.68;
}

.request-text {
  color: #344054;
  line-height: 1.55;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.request-actions {
  display: flex;
  justify-content: space-between;
  gap: 10px;
}

.manual-entry-surface {
  grid-column: 1 / -1;
}

.manual-entry-surface summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  cursor: pointer;
  color: var(--teal-dark);
  font-weight: 800;
}

.manual-entry-surface summary span:last-child {
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 700;
}

.manual-entry-form,
.manual-capture {
  margin-top: 18px;
}

.manual-capture {
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.favorite-active {
  color: #8a4f00;
  background: #fff5cf;
  border-color: #f1ce72;
}

.capture-surface {
  position: sticky;
  top: 24px;
}

.transcript {
  min-height: 260px;
}

.capture-actions {
  justify-content: space-between;
  margin-top: 12px;
}

.candidate {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fffaf1;
}

.candidate span {
  overflow-wrap: anywhere;
}

.review-layout {
  grid-template-columns: minmax(0, 1fr);
  max-width: 1040px;
  margin-left: auto;
  margin-right: auto;
  position: relative;
}

.review-due-counter {
  position: absolute;
  top: 14px;
  right: 14px;
  z-index: 2;
  padding: 7px 10px;
  color: var(--teal-dark);
  background: rgba(216, 243, 236, 0.94);
  border: 1px solid rgba(15, 118, 110, 0.18);
  border-radius: var(--radius);
  font-size: 0.82rem;
  font-weight: 800;
  box-shadow: 0 8px 18px rgba(35, 28, 16, 0.08);
}

.review-due-counter[hidden] {
  display: none;
}

.review-card {
  min-height: 0;
  padding: clamp(56px, 6vw, 72px) clamp(20px, 4vw, 40px) clamp(20px, 4vw, 40px);
  display: grid;
  align-content: start;
  justify-items: center;
  text-align: center;
}

.review-card-inner {
  width: min(900px, 100%);
}

.review-term-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
}

.review-term {
  margin: 0;
  font-size: clamp(1.8rem, 4.8vw, 3.5rem);
  line-height: 1.08;
  letter-spacing: 0;
  overflow-wrap: anywhere;
}

.review-context {
  max-width: 680px;
  margin: 12px auto 0;
  color: var(--muted);
  font-size: 0.98rem;
  line-height: 1.55;
}

.answer-panel {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
  text-align: left;
}

.answer-grid {
  display: grid;
  gap: 10px;
}

.answer-item span {
  display: block;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.answer-item p {
  margin: 6px 0 0;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.card-visual {
  display: grid;
  justify-items: center;
  gap: 6px;
  margin: 14px 0 0;
  padding: 12px;
  background: #f8fbfa;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.card-visual-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 10px;
  width: 100%;
}

.card-visual-item {
  display: grid;
  min-height: 142px;
  place-items: center;
  overflow: hidden;
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.card-visual img {
  width: 100%;
  max-height: 190px;
  object-fit: contain;
}

.card-visual figcaption {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 750;
}

.review-meta-editor {
  margin-top: 12px;
  padding: 12px;
  background: #faf7ef;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.review-meta-body {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.review-meta-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 12px;
}

.review-field {
  display: grid;
  gap: 6px;
}

.review-field span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.review-field textarea {
  width: 100%;
  min-height: 86px;
  padding: 10px 12px;
  color: var(--ink);
  background: var(--surface-strong);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  resize: vertical;
  outline: none;
  line-height: 1.55;
}

.review-field textarea:focus {
  border-color: rgba(15, 118, 110, 0.65);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.12);
}

.review-actions {
  justify-content: center;
  margin-top: 16px;
}

.rating-bar {
  position: sticky;
  bottom: 10px;
  z-index: 5;
  padding: 10px;
  background: rgba(255, 253, 248, 0.96);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 12px 28px rgba(35, 28, 16, 0.12);
}

.rating-button {
  min-width: 104px;
}

.previous-card-button {
  min-width: 92px;
}

.rating-button.again {
  color: #9a3412;
  background: var(--coral-soft);
  border-color: rgba(194, 65, 12, 0.28);
}

.rating-button.hard {
  color: #805300;
  background: #fff5cf;
  border-color: rgba(183, 121, 31, 0.28);
}

.rating-button.good {
  color: var(--teal-dark);
  background: var(--green-soft);
  border-color: rgba(15, 118, 110, 0.26);
}

.rating-button.easy {
  color: #1d4ed8;
  background: var(--blue-soft);
  border-color: rgba(37, 99, 235, 0.22);
}

.rating-button.delete {
  color: #9a3412;
  background: #fff7ed;
  border-color: rgba(194, 65, 12, 0.28);
  min-width: 142px;
}

.library-tools {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) repeat(3, 170px);
  gap: 12px;
  margin-bottom: 16px;
  padding: 14px;
  box-shadow: none;
}

.list-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 16px;
}

.list-header h3 {
  margin: 0;
  font-size: 1.1rem;
}

.list-header p {
  margin: 5px 0 0;
  color: var(--muted);
  line-height: 1.5;
}

.list-header .list-count {
  margin-top: 8px;
  color: var(--teal-dark);
  font-size: 0.92rem;
  font-weight: 750;
}

.list-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.search-field,
.select-field {
  position: relative;
}

.search-field .icon,
.select-field .icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
}

.search-field input,
.select-field select {
  padding-left: 40px;
}

.select-field select {
  appearance: none;
  padding-right: 30px;
}

.entry-card {
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
  cursor: pointer;
  transition:
    border-color 160ms ease,
    box-shadow 160ms ease,
    transform 160ms ease;
}

.entry-card:hover,
.entry-card:focus-visible {
  border-color: rgba(15, 118, 110, 0.34);
  box-shadow: 0 18px 34px rgba(49, 39, 24, 0.12);
  transform: translateY(-1px);
  outline: none;
}

.entry-main {
  min-width: 0;
}

.entry-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 10px;
}

.entry-note {
  margin: 10px 0 0;
  color: #344054;
  line-height: 1.55;
  overflow-wrap: anywhere;
}

.entry-visual {
  position: relative;
  margin: 10px 0 0;
  width: min(180px, 100%);
  padding: 8px;
  background: #f8fbfa;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.entry-visual img {
  display: block;
  width: 100%;
  height: auto;
  max-height: 96px;
  object-fit: contain;
}

.entry-visual-count {
  position: absolute;
  right: 6px;
  bottom: 6px;
  min-width: 28px;
  padding: 2px 6px;
  color: #fff;
  background: rgba(30, 41, 59, 0.76);
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 800;
  text-align: center;
}

.entry-examples {
  display: grid;
  gap: 4px;
  margin-top: 10px;
  color: #344054;
  line-height: 1.55;
  overflow-wrap: anywhere;
}

.entry-examples p {
  margin: 0;
}

.entry-examples strong {
  color: var(--muted);
  font-size: 0.82rem;
}

.entry-actions {
  align-content: start;
  justify-content: end;
  min-width: 190px;
}

.modal[hidden] {
  display: none;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 22px;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(30, 41, 59, 0.38);
  backdrop-filter: blur(4px);
}

.modal-panel {
  position: relative;
  z-index: 1;
  width: min(820px, 100%);
  max-height: min(86vh, 760px);
  overflow: auto;
  padding: 18px;
  background: var(--surface-strong);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 28px 64px rgba(35, 28, 16, 0.2);
}

.modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}

.modal-header h3 {
  margin: 10px 0 0;
  font-size: clamp(1.45rem, 3vw, 2.2rem);
  line-height: 1.12;
  overflow-wrap: anywhere;
}

.modal-header p {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 1.02rem;
  line-height: 1.5;
}

.modal-body {
  display: grid;
  gap: 14px;
  margin-top: 14px;
}

.detail-grid {
  display: grid;
  gap: 12px;
}

.detail-section span {
  display: block;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.detail-section p {
  margin: 6px 0 0;
  color: #344054;
  line-height: 1.55;
  overflow-wrap: anywhere;
}

.modal-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

body.modal-open {
  overflow: hidden;
}

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  max-width: min(420px, calc(100vw - 48px));
  padding: 12px 14px;
  color: #fff;
  background: #1f2937;
  border-radius: var(--radius);
  box-shadow: 0 18px 34px rgba(31, 41, 55, 0.22);
  opacity: 0;
  pointer-events: none;
  transform: translateY(10px);
  transition:
    opacity 180ms ease,
    transform 180ms ease;
}

.toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

@media (max-width: 1060px) {
  .sidebar {
    align-items: flex-start;
    flex-wrap: wrap;
  }

  .nav-tabs {
    display: grid;
    width: 100%;
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .nav-button {
    justify-content: center;
  }

  .nav-button.is-active {
    box-shadow: inset 0 -3px 0 var(--teal);
  }

  .entry-layout,
  .review-layout {
    grid-template-columns: 1fr;
  }

  .capture-surface {
    position: static;
  }
}

@media (max-width: 720px) {
  .sidebar {
    padding: 12px 14px;
  }

  .brand p {
    display: none;
  }

  .main {
    padding: 22px 14px 38px;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .topbar-actions {
    width: 100%;
  }

  .cloud-sync-button {
    flex: 1 1 180px;
  }

  .nav-tabs {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

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

  .field-grid,
  .library-tools,
  .entry-card {
    grid-template-columns: 1fr;
  }

  .surface {
    padding: 16px;
  }

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

  .list-header {
    align-items: stretch;
    flex-direction: column;
  }

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

  .button {
    width: 100%;
  }

  .icon-button {
    flex: 0 0 auto;
  }

  .review-card {
    min-height: 0;
  }

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

  .review-meta-body {
    grid-template-columns: 1fr;
  }

  .rating-bar {
    bottom: 8px;
  }

  .rating-bar .button {
    min-width: 0;
    padding: 0 8px;
  }

  .entry-actions {
    min-width: 0;
    justify-content: stretch;
  }

  .entry-actions .icon-button,
  .entry-actions .button {
    flex: 1 1 auto;
  }
}
