:root {
  color-scheme: light;
  --font-body: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-mono: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;

  --surface-canvas: #f6f7f9;
  --surface-shell: #fbfcfd;
  --surface-panel: #ffffff;
  --surface-subtle: #f1f4f7;
  --surface-selected: #eaf0ff;
  --surface-warning: #fff7e6;
  --surface-danger: #fff1f0;
  --surface-success: #ecfdf3;

  --text-primary: #17212b;
  --text-secondary: #526070;
  --text-tertiary: #728091;
  --text-inverse: #ffffff;

  --border-subtle: #dce2ea;
  --border-strong: #b8c2cf;

  --action: #2458d3;
  --action-hover: #1d46aa;
  --action-soft: #eaf0ff;
  --success: #1f7a5c;
  --warning: #ad6800;
  --danger: #b42318;
  --info: #5b4bc4;
  --focus: #5b4bc4;

  --radius-sm: 6px;
  --radius-md: 8px;
  --shadow-1: 0 1px 2px rgba(16, 24, 40, 0.06), 0 1px 3px rgba(16, 24, 40, 0.08);
  --shadow-2: 0 14px 34px rgba(16, 24, 40, 0.1);

  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-7: 32px;
  --space-8: 40px;

  --text-xs: 0.78rem;
  --text-sm: 0.9rem;
  --text-base: 1rem;
  --text-lg: 1.16rem;
  --text-xl: 1.45rem;
  --text-2xl: 2rem;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--surface-canvas);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: var(--text-base);
  line-height: 1.5;
}

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

button,
input,
select,
textarea {
  border-radius: var(--radius-sm);
}

button {
  cursor: pointer;
}

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

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

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

h1,
h2,
h3 {
  letter-spacing: 0;
}

h1 {
  font-size: var(--text-2xl);
  line-height: 1.12;
  margin-bottom: var(--space-2);
}

h2 {
  font-size: var(--text-xl);
  line-height: 1.2;
  margin-bottom: var(--space-2);
}

h3 {
  font-size: var(--text-base);
  margin-bottom: var(--space-3);
}

p {
  color: var(--text-secondary);
  margin-bottom: var(--space-4);
}

.app-shell {
  background: var(--surface-canvas);
  display: grid;
  grid-template-columns: minmax(232px, 248px) minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  background: var(--surface-shell);
  border-right: 1px solid var(--border-subtle);
  height: 100vh;
  overflow: auto;
  padding: var(--space-5);
  position: sticky;
  top: 0;
}

.brand {
  align-items: center;
  display: flex;
  gap: var(--space-3);
  margin-bottom: var(--space-7);
  min-width: 0;
}

.brand-mark {
  align-items: center;
  background: var(--text-primary);
  border-radius: var(--radius-md);
  color: var(--text-inverse);
  display: grid;
  flex: 0 0 40px;
  font-weight: 800;
  height: 40px;
  place-items: center;
  width: 40px;
}

.brand strong,
.brand span {
  display: block;
}

.brand strong {
  line-height: 1.2;
}

.brand span,
.section-label,
.eyebrow,
.panel-header span,
.muted {
  color: var(--text-secondary);
}

.brand span,
.panel-header span,
.muted {
  font-size: var(--text-sm);
}

.section-label,
.eyebrow {
  font-size: var(--text-xs);
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.primary-nav,
.list-stack,
.quick-add-form,
.settings-form,
.export-stack {
  display: grid;
  gap: var(--space-2);
}

.nav-button {
  align-items: center;
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-secondary);
  display: flex;
  justify-content: space-between;
  min-height: 40px;
  padding: 9px 10px;
  text-align: left;
  width: 100%;
}

.nav-button:hover {
  background: var(--surface-subtle);
  color: var(--text-primary);
}

.nav-button.active {
  background: var(--surface-selected);
  border-color: #c8d6ff;
  color: var(--action-hover);
  font-weight: 750;
}

.section-label {
  margin-bottom: var(--space-3);
}

.new-deck-form {
  display: grid;
  gap: var(--space-2);
  grid-template-columns: minmax(0, 1fr) 40px;
  margin-top: var(--space-4);
}

.main-panel {
  min-width: 0;
  padding: var(--space-7);
}

.content-frame {
  margin: 0 auto;
  max-width: 1180px;
}

.page-header {
  align-items: flex-start;
  display: flex;
  gap: var(--space-5);
  justify-content: space-between;
  margin-bottom: var(--space-6);
}

.page-heading {
  max-width: 720px;
  min-width: 0;
}

.page-heading p {
  margin-bottom: 0;
}

.action-row,
.page-actions,
.commit-bar,
.table-actions {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.page-actions {
  flex: 0 0 auto;
  justify-content: flex-end;
}

.topbar-auth {
  max-width: 620px;
}

.auth-form {
  display: grid;
  grid-template-columns: minmax(140px, 1fr) minmax(128px, 0.78fr) auto auto;
}

.auth-form .cloud-status {
  grid-column: 1 / -1;
  justify-self: end;
}

.topbar-auth input {
  min-height: 40px;
  min-width: 0;
}

.topbar-auth .primary-button,
.topbar-auth .secondary-button,
.topbar-auth .ghost-button {
  min-height: 40px;
  white-space: nowrap;
}

.auth-user {
  display: grid;
  gap: 2px;
  justify-items: end;
  min-width: 0;
}

.auth-email {
  font-size: var(--text-sm);
  max-width: 260px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cloud-status {
  color: var(--text-secondary);
  font-size: var(--text-xs);
  font-weight: 800;
  min-width: 0;
  overflow-wrap: anywhere;
  text-transform: uppercase;
}

.cloud-status.busy {
  color: var(--warning);
}

input,
select,
textarea {
  background: var(--surface-panel);
  border: 1px solid var(--border-strong);
  color: var(--text-primary);
  min-height: 44px;
  padding: 10px 12px;
  width: 100%;
}

input::placeholder,
textarea::placeholder {
  color: var(--text-tertiary);
}

select {
  appearance: auto;
}

textarea {
  line-height: 1.5;
  resize: vertical;
}

.rich-source {
  display: none;
}

.rich-editor {
  background: var(--surface-panel);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  line-height: 1.5;
  min-height: calc((var(--editor-rows, 3) * 1.5em) + 22px);
  overflow: auto;
  overflow-wrap: anywhere;
  padding: 10px 12px;
  white-space: pre-wrap;
  width: 100%;
}

.rich-editor:empty::before {
  color: var(--text-tertiary);
  content: attr(data-placeholder);
  pointer-events: none;
}

.rich-editor.sample-text {
  background: var(--surface-shell);
  color: #98a2ad;
}

.rich-editor.sample-text:focus {
  color: #8793a0;
}

label span {
  color: var(--text-primary);
  display: block;
  font-size: var(--text-sm);
  font-weight: 750;
  margin-bottom: var(--space-2);
}

.formatted-field {
  display: grid;
  gap: var(--space-2);
}

.formatted-field label span {
  margin-bottom: 0;
}

.primary-button,
.secondary-button,
.ghost-button,
.danger-button,
.icon-button,
.reveal-button,
.rating-button {
  border: 1px solid transparent;
  font-weight: 750;
  min-height: 44px;
  padding: 10px 14px;
  transition: background-color 140ms ease, border-color 140ms ease, box-shadow 140ms ease, transform 140ms ease;
}

.primary-button,
.reveal-button {
  background: var(--action);
  color: var(--text-inverse);
}

.primary-button:hover,
.reveal-button:hover {
  background: var(--action-hover);
}

.secondary-button,
.ghost-button,
.icon-button {
  background: var(--surface-panel);
  border-color: var(--border-strong);
  color: var(--text-primary);
}

.secondary-button:hover,
.ghost-button:hover,
.icon-button:hover {
  background: var(--surface-subtle);
  border-color: var(--border-strong);
}

.danger-button {
  background: var(--surface-danger);
  border-color: #f2b8b5;
  color: var(--danger);
}

.danger-button:hover {
  background: #ffe4e2;
}

.ghost-button {
  min-height: 36px;
  padding: 7px 10px;
}

.icon-button {
  display: grid;
  font-size: 1.2rem;
  line-height: 1;
  padding: 0;
  place-items: center;
}

.icon-button svg {
  display: block;
  fill: none;
  height: 18px;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
  width: 18px;
}

.panel,
.today-panel,
.stat-tile,
.review-card {
  background: var(--surface-panel);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
}

.panel,
.today-panel {
  box-shadow: var(--shadow-1);
  padding: var(--space-5);
}

.panel-header {
  align-items: flex-start;
  display: flex;
  gap: var(--space-3);
  justify-content: space-between;
  margin-bottom: var(--space-5);
}

.panel-header h2 {
  margin: 0;
}

.panel-header span {
  display: block;
  margin-top: 2px;
}

.dashboard-grid {
  display: grid;
  gap: var(--space-4);
  grid-template-columns: minmax(0, 1.35fr) minmax(280px, 0.9fr);
  margin-bottom: var(--space-4);
}

.today-panel {
  align-content: space-between;
  border-left: 4px solid var(--action);
  display: grid;
  gap: var(--space-6);
  min-height: 280px;
}

.today-copy h2 {
  font-size: 2.35rem;
  line-height: 1.05;
  margin-bottom: var(--space-4);
}

.today-copy p {
  max-width: 640px;
}

.today-footer {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
  justify-content: space-between;
}

.stat-grid {
  display: grid;
  gap: var(--space-3);
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.stat-tile {
  display: grid;
  gap: var(--space-2);
  min-height: 126px;
  padding: var(--space-4);
}

.stat-tile span,
.stat-tile small {
  color: var(--text-secondary);
}

.stat-tile span {
  font-size: var(--text-sm);
  font-weight: 700;
}

.stat-tile strong {
  font-size: 2rem;
  line-height: 1;
}

.stat-tile small {
  align-self: end;
  font-size: var(--text-xs);
}

.dashboard-stats-grid .stat-tile {
  min-height: 116px;
}

.deck-card-panel {
  margin-top: var(--space-4);
}

.deck-card-overview {
  display: grid;
  gap: var(--space-5);
}

.overview-metrics {
  display: grid;
  gap: var(--space-3);
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.metric-item {
  background: var(--surface-subtle);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  display: grid;
  gap: 2px;
  min-width: 0;
  padding: var(--space-3);
}

.metric-item strong {
  font-size: var(--text-xl);
  line-height: 1;
}

.metric-item span {
  color: var(--text-secondary);
  font-size: var(--text-xs);
  font-weight: 750;
}

.recent-card-stack h3 {
  color: var(--text-secondary);
  font-size: var(--text-sm);
  margin-bottom: var(--space-3);
}

.compact-row {
  padding: var(--space-3);
}

.two-column,
.import-layout {
  display: grid;
  gap: var(--space-4);
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
}

.list-row {
  align-items: center;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  display: flex;
  gap: var(--space-4);
  justify-content: space-between;
  min-width: 0;
  padding: var(--space-4);
}

.list-row-main {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.list-row-main strong,
.front-cell strong {
  overflow-wrap: anywhere;
}

.list-row-main span,
.list-row-meta span {
  color: var(--text-secondary);
  font-size: var(--text-sm);
}

.list-row-meta {
  align-items: flex-end;
  display: grid;
  gap: var(--space-2);
  justify-items: end;
  text-align: right;
}

.add-card-shell {
  display: grid;
  gap: var(--space-4);
}

.mode-tabs {
  align-items: center;
  background: var(--surface-subtle);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  display: inline-flex;
  gap: var(--space-1);
  padding: var(--space-1);
  width: fit-content;
}

.mode-tab {
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-secondary);
  font-size: var(--text-sm);
  font-weight: 750;
  min-height: 36px;
  padding: 7px 12px;
}

.mode-tab.active {
  background: var(--surface-panel);
  border-color: var(--border-subtle);
  box-shadow: var(--shadow-1);
  color: var(--text-primary);
}

.single-card-panel {
  max-width: 720px;
}

.paste-area {
  font-family: var(--font-mono);
  min-height: 460px;
  white-space: pre-wrap;
}

.paste-area.sample-text {
  background: var(--surface-shell);
  color: #98a2ad;
}

.paste-area.sample-text:focus {
  color: #8793a0;
}

.syntax-strip {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin-top: var(--space-3);
}

code {
  background: var(--surface-subtle);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 0.92em;
  padding: 2px 5px;
}

.import-layout {
  align-items: start;
  grid-template-columns: minmax(0, 1.08fr) minmax(340px, 0.92fr);
}

.preview-panel {
  align-self: start;
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 64px);
  position: sticky;
  top: var(--space-6);
}

.preview-panel .panel-header {
  flex: 0 0 auto;
}

.import-summary {
  background: var(--surface-panel);
  border-bottom: 1px solid var(--border-subtle);
  flex: 0 0 auto;
  margin: 0 calc(var(--space-5) * -1) var(--space-4);
  padding: 0 var(--space-5) var(--space-4);
  position: sticky;
  top: 0;
  z-index: 1;
}

.summary-bar {
  display: grid;
  gap: var(--space-2);
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-bottom: var(--space-3);
}

.summary-item {
  background: var(--surface-panel);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  display: grid;
  gap: 1px;
  min-width: 0;
  padding: 9px 10px;
}

.summary-item strong {
  font-size: var(--text-base);
  line-height: 1;
}

.summary-item span {
  color: var(--text-secondary);
  font-size: var(--text-xs);
  font-weight: 750;
}

.summary-item.status-valid,
.summary-item.status-warning,
.summary-item.status-error,
.summary-item.status-duplicate {
  background: var(--surface-panel);
}

.summary-item.status-valid strong {
  color: var(--success);
}

.summary-item.status-warning strong {
  color: var(--warning);
}

.summary-item.status-error strong {
  color: var(--danger);
}

.summary-item.status-duplicate strong {
  color: var(--info);
}

.commit-bar {
  justify-content: space-between;
}

.inline-check {
  align-items: center;
  color: var(--text-secondary);
  display: flex;
  font-size: var(--text-sm);
  gap: var(--space-2);
}

.inline-check input {
  min-height: auto;
  width: auto;
}

.preview-list {
  display: grid;
  gap: var(--space-2);
  min-height: 0;
  overflow: auto;
  padding-right: 2px;
}

.preview-row {
  border: 1px solid var(--border-subtle);
  border-left: 4px solid var(--success);
  border-radius: var(--radius-md);
  display: grid;
  gap: var(--space-3);
  padding: var(--space-3);
}

.preview-row.status-warning {
  border-left-color: var(--warning);
}

.preview-row.status-error {
  border-left-color: var(--danger);
}

.preview-row.status-duplicate {
  border-left-color: var(--info);
}

.preview-row-meta {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  justify-content: space-between;
}

.preview-row-body {
  display: grid;
  gap: var(--space-1);
  min-width: 0;
}

.preview-row-body span,
.line-number,
.row-messages {
  color: var(--text-secondary);
  font-size: var(--text-sm);
}

.row-messages {
  display: grid;
  gap: var(--space-1);
  margin: 0;
  padding-left: var(--space-5);
}

.preview-carousel {
  display: grid;
  gap: var(--space-4);
}

.carousel-topline {
  align-items: flex-start;
  display: flex;
  gap: var(--space-3);
  justify-content: space-between;
}

.carousel-topline > div {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.carousel-topline strong {
  overflow-wrap: anywhere;
}

.carousel-topline small,
.carousel-controls span,
.card-stepper span {
  color: var(--text-secondary);
  font-size: var(--text-sm);
}

.mock-card {
  background: linear-gradient(180deg, #ffffff 0%, #fafbfc 100%);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-1);
  display: grid;
  gap: 0;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  min-height: 310px;
  overflow: hidden;
}

.mock-card > div {
  display: grid;
  grid-template-rows: auto 1fr;
  min-width: 0;
}

.mock-card > div + div {
  border-left: 1px solid var(--border-subtle);
}

.mock-card > div > span {
  background: var(--surface-subtle);
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  font-size: var(--text-xs);
  font-weight: 800;
  padding: 8px 12px;
  text-transform: uppercase;
}

.mock-card-face {
  color: var(--text-primary);
  min-height: 240px;
  overflow-wrap: anywhere;
  padding: var(--space-5);
}

.mock-card-face p:last-child,
.mock-card-face ol:last-child,
.mock-card-face ul:last-child {
  margin-bottom: 0;
}

.empty-mock-card {
  color: var(--text-secondary);
}

.carousel-controls,
.card-stepper {
  align-items: center;
  display: flex;
  gap: var(--space-2);
  justify-content: center;
}

.preview-issues {
  border-top: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  padding-top: var(--space-3);
}

.preview-issues summary {
  cursor: pointer;
  font-size: var(--text-sm);
  font-weight: 750;
}

.preview-issues .row-messages {
  margin-top: var(--space-2);
}

.status-badge,
.type-badge {
  align-items: center;
  border: 1px solid var(--border-subtle);
  border-radius: 999px;
  display: inline-flex;
  font-size: var(--text-xs);
  font-weight: 800;
  gap: 6px;
  line-height: 1.2;
  min-height: 28px;
  padding: 5px 9px;
  white-space: nowrap;
}

.status-badge i {
  background: currentColor;
  border-radius: 999px;
  display: block;
  height: 7px;
  width: 7px;
}

.status-valid,
.status-clear,
.status-new {
  background: var(--surface-success);
  border-color: #b7e4c7;
  color: var(--success);
}

.status-warning,
.status-due,
.status-learning,
.status-relearning {
  background: var(--surface-warning);
  border-color: #f3cf8f;
  color: var(--warning);
}

.status-error,
.status-suspended {
  background: var(--surface-danger);
  border-color: #f2b8b5;
  color: var(--danger);
}

.status-duplicate,
.status-review,
.status-info {
  background: #f0efff;
  border-color: #d7d2ff;
  color: var(--info);
}

.type-badge {
  background: var(--surface-subtle);
  color: var(--text-secondary);
}

.review-start,
.review-shell,
.completion {
  margin: 0 auto;
  max-width: 860px;
}

.review-start {
  display: grid;
  gap: var(--space-3);
}

.review-scope-bar {
  align-items: end;
  display: flex;
  justify-content: flex-end;
}

.review-scope-selector {
  display: grid;
  gap: var(--space-2);
  min-width: min(320px, 100%);
  position: relative;
}

.review-scope-selector span {
  color: var(--text-secondary);
  font-size: var(--text-xs);
  font-weight: 800;
  text-transform: uppercase;
}

.add-deck-selector {
  gap: var(--space-1);
  margin-bottom: var(--space-1);
  min-width: min(270px, 100%);
  width: fit-content;
}

.add-deck-trigger {
  min-height: 36px;
  padding: 7px 10px;
}

.add-deck-menu {
  min-width: min(320px, calc(100vw - 48px));
  right: auto;
  width: max-content;
}

.review-deck-trigger {
  align-items: center;
  background: var(--surface-panel);
  border: 1px solid var(--border-strong);
  color: var(--text-primary);
  display: flex;
  gap: var(--space-3);
  justify-content: space-between;
  min-height: 44px;
  padding: 10px 12px;
  text-align: left;
  width: 100%;
}

.review-deck-trigger span:first-child {
  color: var(--text-primary);
  font-size: var(--text-base);
  font-weight: 500;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  text-transform: none;
  white-space: nowrap;
}

.review-deck-trigger span:last-child {
  color: var(--text-secondary);
  font-size: var(--text-base);
  line-height: 1;
}

.review-deck-menu {
  background: var(--surface-panel);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-2);
  left: 0;
  overflow: hidden;
  padding: var(--space-1);
  position: absolute;
  right: 0;
  top: calc(100% + var(--space-1));
  z-index: 10;
}

.review-deck-option {
  align-items: center;
  background: var(--surface-panel);
  border: 1px solid transparent;
  color: var(--text-primary);
  display: grid;
  gap: var(--space-2);
  grid-template-columns: 16px minmax(0, 1fr);
  justify-items: start;
  min-height: 34px;
  padding: 6px 8px;
  text-align: left;
  width: 100%;
}

.review-deck-option:hover,
.review-deck-option:focus-visible {
  background: var(--surface-selected);
}

.review-deck-option[aria-selected="true"] {
  background: var(--surface-panel);
  color: var(--action-hover);
  font-weight: 750;
}

.review-deck-option[aria-selected="true"]:hover,
.review-deck-option[aria-selected="true"]:focus-visible {
  background: #f3f6ff;
}

.review-deck-option[aria-selected="true"] span {
  color: var(--action-hover);
  font-weight: 800;
}

.review-deck-option span {
  color: var(--text-primary);
  font-size: var(--text-base);
  font-weight: 500;
  text-transform: none;
}

.center-panel {
  margin: 0 auto;
  max-width: 720px;
  width: 100%;
}

.review-launch-card {
  align-items: center;
  display: grid;
  gap: var(--space-4);
  grid-template-columns: minmax(0, 1fr) auto;
  min-height: 156px;
  overflow: visible;
  position: relative;
  width: 100%;
}

.review-launch-copy {
  min-width: 0;
}

.review-launch-copy h2,
.review-launch-copy p {
  margin-bottom: 0;
}

.review-launch-copy h2 {
  margin-top: var(--space-1);
}

.review-launch-actions {
  align-self: end;
}

.review-launch-actions .action-row {
  justify-content: flex-end;
}

.review-launch-actions .primary-button,
.review-launch-actions .secondary-button {
  white-space: nowrap;
}

.memoryless-review-card {
  border: 2px dashed #c4bbff;
}

.memoryless-review-card::before {
  display: none;
}

.review-option-heading {
  align-items: center;
  display: flex;
  gap: var(--space-2);
  min-width: 0;
}

.info-dot {
  align-items: center;
  background: var(--surface-subtle);
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  color: var(--text-secondary);
  display: inline-flex;
  flex: 0 0 auto;
  font-size: var(--text-xs);
  font-weight: 900;
  height: 20px;
  justify-content: center;
  line-height: 1;
  padding: 0;
  width: 20px;
}

.info-dot:hover,
.info-dot:focus-visible {
  background: #f0efff;
  border-color: #b8afff;
  color: var(--info);
}

.info-popover {
  display: inline-flex;
  position: relative;
}

.info-tooltip {
  background: var(--text-primary);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-2);
  color: var(--text-inverse);
  font-size: var(--text-sm);
  font-weight: 650;
  line-height: 1.4;
  left: calc(100% + 10px);
  max-width: min(300px, calc(100vw - 48px));
  opacity: 0;
  padding: 10px 12px;
  pointer-events: none;
  position: absolute;
  top: 50%;
  transform: translate(-4px, -50%);
  transition: opacity 120ms ease, transform 120ms ease, visibility 120ms ease;
  visibility: hidden;
  width: max-content;
  z-index: 5;
}

.info-tooltip::after {
  border: 6px solid transparent;
  border-right-color: var(--text-primary);
  content: "";
  right: 100%;
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
}

.info-popover:hover .info-tooltip,
.info-popover:focus-within .info-tooltip {
  opacity: 1;
  transform: translate(0, -50%);
  visibility: visible;
}

.review-progress {
  align-items: center;
  display: flex;
  gap: var(--space-3);
  justify-content: space-between;
  margin-bottom: var(--space-4);
}

.review-progress-actions {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  justify-content: flex-end;
}

.review-progress strong {
  display: block;
}

.review-card {
  box-shadow: var(--shadow-2);
  min-height: 380px;
  padding: var(--space-7);
}

.card-kicker {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin-bottom: var(--space-5);
}

.review-face {
  font-size: 1.75rem;
  line-height: 1.32;
}

.review-face p:last-child,
.answer-face p:last-child {
  margin-bottom: 0;
}

.answer-face {
  border-top: 1px solid var(--border-subtle);
  font-size: var(--text-lg);
  line-height: 1.55;
  margin-top: var(--space-7);
  padding-top: var(--space-6);
}

.primary-answer {
  color: var(--text-primary);
}

.supporting-notes {
  border-top: 1px solid var(--border-subtle);
  display: grid;
  gap: var(--space-3);
  margin-top: var(--space-6);
  padding-top: var(--space-5);
}

.support-note {
  color: var(--text-secondary);
  display: grid;
  gap: var(--space-1);
  font-size: var(--text-sm);
}

.support-note span {
  color: var(--text-primary);
  font-size: var(--text-xs);
  font-weight: 800;
  text-transform: uppercase;
}

.support-note p {
  margin-bottom: 0;
}

.support-tags {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.support-tags span {
  background: var(--surface-subtle);
  border: 1px solid var(--border-subtle);
  border-radius: 999px;
  color: var(--text-secondary);
  font-size: var(--text-xs);
  font-weight: 750;
  padding: 5px 8px;
}

.reveal-button {
  display: block;
  font-size: var(--text-lg);
  margin: var(--space-4) auto 0;
  min-width: 220px;
}

.rating-grid {
  display: grid;
  gap: var(--space-3);
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-top: var(--space-4);
}

.practice-next-row {
  display: flex;
  justify-content: center;
  margin-top: var(--space-4);
}

.practice-next-row .primary-button {
  min-width: 220px;
}

.rating-button {
  background: var(--surface-panel);
  border-color: var(--border-subtle);
  box-shadow: var(--shadow-1);
  display: grid;
  gap: var(--space-1);
  min-height: 82px;
  place-items: center;
  text-align: center;
}

.rating-button:hover {
  background: var(--surface-subtle);
  transform: translateY(-1px);
}

.rating-button strong,
.rating-button em {
  display: block;
}

.rating-button em {
  color: var(--text-secondary);
  font-style: normal;
}

.rating-button.again {
  border-top: 4px solid var(--danger);
}

.rating-button.hard {
  border-top: 4px solid var(--warning);
}

.rating-button.good {
  border-top: 4px solid var(--success);
}

.rating-button.easy {
  border-top: 4px solid var(--info);
}

.choice-list {
  display: grid;
  gap: var(--space-2);
  list-style: none;
  padding-left: 0;
}

.choice-list li {
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 10px 12px;
}

.choice-list.answer li.correct {
  background: var(--surface-success);
  border-color: #b7e4c7;
  font-weight: 800;
}

.table-wrap {
  overflow: auto;
}

.library-layout {
  align-items: start;
  display: grid;
  gap: var(--space-4);
  grid-template-columns: minmax(240px, 0.36fr) minmax(0, 1fr);
}

.library-main-stack {
  display: grid;
  gap: var(--space-4);
  min-width: 0;
}

.library-deck-list {
  display: grid;
  gap: var(--space-2);
}

.library-new-deck-form {
  border-top: 1px solid var(--border-subtle);
  padding-top: var(--space-4);
}

.library-deck-item {
  display: grid;
}

.library-deck-row {
  align-items: center;
  background: transparent;
  border: 1px solid var(--border-subtle);
  color: var(--text-primary);
  display: flex;
  gap: var(--space-3);
  justify-content: space-between;
  min-height: 58px;
  padding: var(--space-3);
  text-align: left;
  width: 100%;
}

.deck-trash-button {
  color: var(--danger);
  height: 36px;
  min-height: 36px;
  width: 36px;
}

.deck-trash-button:hover {
  background: var(--surface-danger);
  border-color: #f2b8b5;
}

.library-deck-row:hover {
  background: var(--surface-subtle);
}

.library-deck-row.active {
  background: var(--surface-selected);
  border-color: #c8d6ff;
}

.library-deck-row span {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.library-deck-row strong,
.library-deck-row small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.library-deck-row small {
  color: var(--text-secondary);
  font-size: var(--text-sm);
}

.library-add-cards {
  border-bottom: 1px solid var(--border-subtle);
  margin-bottom: var(--space-4);
  min-width: 0;
  padding-bottom: var(--space-4);
}

.library-add-section {
  min-width: 0;
}

.library-add-section .panel-header {
  margin-bottom: var(--space-3);
}

.library-add-section .panel-header h3 {
  font-size: var(--text-lg);
  line-height: 1.25;
  margin: 0;
}

.library-single-add {
  max-width: 720px;
}

.library-add-card-shell .paste-area {
  min-height: 360px;
}

.library-add-card-shell .preview-panel {
  max-height: none;
  position: static;
}

.library-add-card-shell .import-summary {
  margin: 0 0 var(--space-4);
  padding: 0 0 var(--space-4);
  position: static;
}

table {
  border-collapse: collapse;
  min-width: 760px;
  width: 100%;
}

th,
td {
  border-bottom: 1px solid var(--border-subtle);
  padding: 12px;
  text-align: left;
  vertical-align: top;
}

th {
  color: var(--text-secondary);
  font-size: var(--text-xs);
  font-weight: 800;
  text-transform: uppercase;
}

tbody tr:hover {
  background: var(--surface-subtle);
}

.table-actions {
  align-items: flex-start;
  gap: 6px;
}

.table-actions .ghost-button,
.table-actions .danger-button {
  align-items: center;
  display: inline-flex;
  flex: 0 0 68px;
  font-size: var(--text-sm);
  justify-content: center;
  min-height: 34px;
  padding: 6px 8px;
  text-align: center;
}

.edit-card-row:hover {
  background: transparent;
}

.edit-card-form {
  display: grid;
  gap: var(--space-4);
  padding: var(--space-2) 0;
}

.edit-choice-grid {
  grid-template-columns: minmax(120px, 180px);
}

.completion-stats {
  margin-bottom: var(--space-5);
}

.forecast-chart {
  align-items: stretch;
  display: grid;
  gap: var(--space-3);
  grid-template-columns: repeat(7, minmax(0, 1fr));
  min-height: 230px;
}

.forecast-day {
  display: grid;
  gap: var(--space-2);
  grid-template-rows: auto 1fr auto;
  min-width: 0;
  text-align: center;
}

.forecast-day span {
  color: var(--text-secondary);
  font-size: var(--text-sm);
}

.bar-track {
  align-items: end;
  background: var(--surface-subtle);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  display: flex;
  min-height: 150px;
  overflow: hidden;
}

.bar-track i {
  background: var(--action);
  display: block;
  height: var(--bar-fill);
  width: 100%;
}

.field-grid,
.timing-grid {
  display: grid;
  gap: var(--space-3);
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.advanced-settings {
  border-top: 1px solid var(--border-subtle);
  display: grid;
  gap: var(--space-3);
  margin-top: var(--space-2);
  padding-top: var(--space-5);
}

.danger-zone {
  border-top: 1px solid var(--border-subtle);
  margin-top: var(--space-2);
  padding-top: var(--space-5);
}

.danger-zone h3 {
  margin-bottom: var(--space-1);
}

.toast {
  background: var(--surface-panel);
  border: 1px solid var(--border-subtle);
  border-left: 4px solid var(--success);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-1);
  margin-bottom: var(--space-4);
  padding: 12px 14px;
}

.empty-state {
  color: var(--text-secondary);
  display: grid;
  gap: var(--space-2);
  justify-items: center;
  padding: var(--space-8);
  text-align: center;
}

.empty-state h2 {
  color: var(--text-primary);
  font-size: var(--text-lg);
  margin: 0;
}

.empty-state p {
  margin: 0;
  max-width: 440px;
}

.empty-state.small {
  padding: var(--space-4);
}

.page-empty {
  background: var(--surface-panel);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
}

hr {
  border: 0;
  border-top: 1px solid var(--border-subtle);
  margin: var(--space-5) 0;
}

@media (max-width: 980px) {
  .app-shell,
  .dashboard-grid,
  .two-column,
  .import-layout,
  .library-layout {
    grid-template-columns: 1fr;
  }

  .sidebar {
    height: auto;
    position: static;
  }

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

  .preview-panel {
    max-height: none;
    position: static;
  }

  .import-summary {
    position: static;
  }

  .overview-metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 720px) {
  .page-header {
    display: grid;
  }

  .page-actions {
    justify-content: start;
  }

  .topbar-auth {
    justify-content: stretch;
    max-width: none;
    width: 100%;
  }

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

  .auth-form .cloud-status {
    justify-self: start;
  }

  .summary-bar,
  .stat-grid,
  .field-grid,
  .timing-grid,
  .rating-grid {
    grid-template-columns: 1fr;
  }

  .forecast-chart {
    grid-template-columns: repeat(7, minmax(36px, 1fr));
    overflow-x: auto;
    padding-bottom: var(--space-1);
  }

  .mock-card {
    grid-template-columns: 1fr;
  }

  .mock-card > div + div {
    border-left: 0;
    border-top: 1px solid var(--border-subtle);
  }
}

@media (max-width: 640px) {
  :root {
    --text-2xl: 1.55rem;
    --text-xl: 1.22rem;
  }

  .main-panel,
  .sidebar {
    padding: var(--space-4);
  }

  .primary-nav {
    grid-template-columns: 1fr;
  }

  .mode-tabs {
    width: 100%;
  }

  .mode-tab {
    flex: 1 1 0;
  }

  .panel,
  .today-panel,
  .review-card {
    padding: var(--space-4);
  }

  .today-copy h2 {
    font-size: 1.75rem;
  }

  .today-footer,
  .review-scope-bar,
  .list-row {
    align-items: stretch;
    display: grid;
  }

  .list-row-meta {
    align-items: start;
    justify-items: start;
    text-align: left;
  }

  .paste-area {
    min-height: 340px;
  }

  .summary-bar {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .commit-bar {
    align-items: stretch;
    display: grid;
  }

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

  .auth-user {
    justify-items: start;
  }

  .carousel-topline,
  .carousel-controls,
  .card-stepper,
  .review-launch-card,
  .library-deck-item {
    align-items: stretch;
    display: grid;
    justify-items: stretch;
  }

  .review-launch-card {
    grid-template-columns: 1fr;
    min-height: 0;
  }

  .review-launch-actions {
    align-self: stretch;
  }

  .review-launch-actions .action-row {
    display: grid;
    justify-content: stretch;
  }

  .info-tooltip {
    left: 50%;
    right: auto;
    top: calc(100% + 8px);
    transform: translate(-50%, 4px);
  }

  .info-tooltip::after {
    border: 6px solid transparent;
    border-bottom-color: var(--text-primary);
    bottom: 100%;
    left: 50%;
    right: auto;
    top: auto;
    transform: translateX(-50%);
  }

  .info-popover:hover .info-tooltip,
  .info-popover:focus-within .info-tooltip {
    transform: translate(-50%, 0);
  }

  .carousel-controls span,
  .card-stepper span {
    text-align: center;
  }

  .review-face {
    font-size: 1.28rem;
  }

  .review-card {
    min-height: 300px;
  }

  table {
    min-width: 0;
  }

  thead {
    display: none;
  }

  table,
  tbody,
  tr,
  td {
    display: block;
    width: 100%;
  }

  tbody tr {
    border-bottom: 1px solid var(--border-subtle);
    display: grid;
    gap: var(--space-2);
    padding: var(--space-4) 0;
  }

  tbody tr:first-child {
    padding-top: 0;
  }

  tbody tr:last-child {
    border-bottom: 0;
    padding-bottom: 0;
  }

  td {
    border-bottom: 0;
    padding: 0;
  }

  td::before {
    color: var(--text-secondary);
    content: attr(data-label);
    display: block;
    font-size: var(--text-xs);
    font-weight: 800;
    margin-bottom: var(--space-1);
    text-transform: uppercase;
  }

  .table-actions {
    align-items: flex-start;
    display: flex;
  }

  .table-actions::before {
    flex: 0 0 100%;
  }
}
