/* Design tokens — shared vocabulary with the extension popup, inline editor and game/. */
:root {
  color-scheme: light;

  --bg: #f5f6f8;
  --bg-veil: #eef1f6;
  --surface: #ffffff;
  --surface-subtle: #f1f3f6;
  --surface-hover: #e9ecf1;
  --border: #e3e6eb;
  --border-strong: #ccd2db;

  --text: #1a1d24;
  --text-secondary: #565f6d;
  --text-muted: #8a93a1;

  --accent: #3a5bd9;
  --accent-hover: #2f4bbd;
  --accent-soft: #edf0fc;
  --on-accent: #ffffff;

  --again: #b4302c;
  --again-soft: #fbecec;
  --hard: #92600e;
  --hard-soft: #fbf2e2;
  --good: #16794f;
  --good-soft: #e7f4ee;
  --easy: #3a5bd9;
  --easy-soft: #edf0fc;

  --success: var(--good);
  --success-soft: var(--good-soft);
  --danger: var(--again);
  --danger-soft: var(--again-soft);

  --r-sm: 8px;
  --r-md: 10px;
  --r-lg: 14px;
  --r-xl: 18px;
  --r-pill: 999px;

  --shadow-xs: 0 1px 2px rgba(20, 25, 35, 0.05);
  --shadow-sm: 0 1px 3px rgba(20, 25, 35, 0.06), 0 1px 2px rgba(20, 25, 35, 0.04);
  --shadow-md: 0 6px 16px rgba(20, 25, 35, 0.07), 0 2px 6px rgba(20, 25, 35, 0.04);
  --shadow-lg: 0 16px 40px rgba(20, 25, 35, 0.09), 0 4px 12px rgba(20, 25, 35, 0.05);

  --ring: 0 0 0 3px rgba(58, 91, 217, 0.18);
  --ease: cubic-bezier(0.2, 0.7, 0.3, 1);
}

:root[data-theme="dark"] {
  color-scheme: dark;

  --bg: #0e1116;
  --bg-veil: #12161d;
  --surface: #161a21;
  --surface-subtle: #1c212a;
  --surface-hover: #232935;
  --border: #262c36;
  --border-strong: #39414f;

  --text: #e6e9ee;
  --text-secondary: #a3acba;
  --text-muted: #7c8695;

  --accent: #7d97f4;
  --accent-hover: #93a9f7;
  --accent-soft: rgba(125, 151, 244, 0.14);
  --on-accent: #0e1116;

  --again: #f08a86;
  --again-soft: rgba(240, 138, 134, 0.14);
  --hard: #e0b062;
  --hard-soft: rgba(224, 176, 98, 0.14);
  --good: #4ec294;
  --good-soft: rgba(78, 194, 148, 0.14);
  --easy: #7d97f4;
  --easy-soft: rgba(125, 151, 244, 0.14);

  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.34);
  --shadow-md: 0 8px 22px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 20px 52px rgba(0, 0, 0, 0.5);

  --ring: 0 0 0 3px rgba(125, 151, 244, 0.26);
}

* {
  box-sizing: border-box;
}

body {
  min-width: 320px;
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.55 system-ui, -apple-system, "Segoe UI", sans-serif;
}

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

button {
  border: 0;
  cursor: pointer;
  transition: background 140ms var(--ease), color 140ms var(--ease), border-color 140ms var(--ease);
}

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

:focus-visible {
  box-shadow: var(--ring);
  outline: 0;
}

.app {
  min-height: 100vh;
}

.is-hidden {
  display: none !important;
}

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

h1,
h2,
h3 {
  color: var(--text);
  letter-spacing: -0.02em;
}

.muted,
.hint {
  color: var(--text-muted);
}

/* Auth */
.auth-view {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(circle at 12% 15%, var(--accent-soft), transparent 30%),
    linear-gradient(180deg, var(--bg-veil), var(--bg));
}

.auth-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(360px, 0.9fr);
  width: min(980px, 100%);
  min-width: 0;
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 24px;
  box-shadow: var(--shadow-lg);
}

.auth-hero {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 610px;
  padding: 44px;
  color: #ffffff;
  background:
    radial-gradient(circle at 90% 10%, rgba(255, 255, 255, 0.18), transparent 28%),
    linear-gradient(145deg, #263d9d, #3a5bd9 55%, #5272e7);
  min-width: 0;
}

.hero-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  font-weight: 650;
}

.hero-mark {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  color: #304cb9;
  background: #ffffff;
  border-radius: 10px;
  font-weight: 750;
}

.hero-copy {
  max-width: 520px;
  margin: 46px 0 38px;
}

.hero-copy .eyebrow {
  color: rgba(255, 255, 255, 0.68);
}

.hero-copy h1 {
  margin-bottom: 18px;
  color: #ffffff;
  font-size: clamp(36px, 4vw, 52px);
  letter-spacing: -0.045em;
  line-height: 1.03;
}

.hero-copy > p:last-child {
  max-width: 480px;
  margin: 0;
  color: rgba(255, 255, 255, 0.76);
  font-size: 16px;
}

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

.feature-list > div {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 12px;
  align-items: center;
  padding: 12px 14px;
  background: rgba(255, 255, 255, 0.09);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: var(--r-md);
}

.feature-icon {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  background: rgba(255, 255, 255, 0.12);
  border-radius: 9px;
  font-size: 10px;
  font-weight: 750;
  letter-spacing: 0.05em;
}

.feature-list p,
.feature-list strong,
.feature-list span {
  margin: 0;
}

.feature-list strong,
.feature-list p > span {
  display: block;
}

.feature-list strong {
  color: #ffffff;
  font-size: 13.5px;
}

.feature-list p > span {
  color: rgba(255, 255, 255, 0.66);
  font-size: 12px;
}

.auth-card {
  display: flex;
  flex-direction: column;
  justify-content: center;
  width: 100%;
  min-width: 0;
  padding: 44px;
  background: var(--surface);
}

.auth-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.auth-card h2 {
  margin: 0;
  font-size: 28px;
  line-height: 1.2;
}

.auth-card .muted {
  margin-bottom: 22px;
  font-size: 14px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.auth-note {
  margin: 18px 0 0;
  color: var(--text-muted);
  font-size: 12.5px;
}

.password-field {
  position: relative;
}

.password-field input {
  padding-right: 64px;
}

.password-toggle {
  position: absolute;
  top: 50%;
  right: 7px;
  min-height: 30px;
  padding: 0 9px;
  color: var(--text-secondary);
  background: transparent;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 650;
  transform: translateY(-50%);
}

.password-toggle:hover {
  color: var(--text);
  background: var(--surface-subtle);
}

/* Forms */
.auth-form,
#cardForm {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  color: var(--text-secondary);
  font-size: 12.5px;
  font-weight: 550;
}

input,
select,
textarea {
  width: 100%;
  min-width: 0;
  padding: 10px 12px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-sm);
  outline: 0;
  transition: border-color 140ms var(--ease), box-shadow 140ms var(--ease);
}

textarea {
  resize: vertical;
}

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

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: var(--ring);
}

.field-grid,
.category-row {
  display: grid;
  gap: 10px;
}

.field-grid {
  grid-template-columns: 1fr 1fr;
}

.category-row {
  grid-template-columns: 1fr auto;
}

.checkbox-label {
  flex-direction: row;
  align-items: center;
  gap: 8px;
  color: var(--text);
}

.checkbox-label input {
  width: auto;
  accent-color: var(--accent);
}

/* Buttons */
.button-row,
.topbar-actions,
.controls-actions,
.review-actions {
  display: flex;
  gap: 10px;
}

.primary-button,
.secondary-button,
.danger-button,
.theme-toggle {
  display: inline-grid;
  min-height: 38px;
  padding: 0 15px;
  place-items: center;
  border-radius: var(--r-sm);
  font-size: 13.5px;
  font-weight: 600;
  white-space: nowrap;
}

.primary-button {
  color: var(--on-accent);
  background: var(--accent);
  box-shadow: var(--shadow-xs);
}

.primary-button:hover:not(:disabled) {
  background: var(--accent-hover);
}

.secondary-button,
.theme-toggle {
  color: var(--text);
  background: var(--surface-subtle);
  border: 1px solid var(--border);
}

.secondary-button:hover:not(:disabled),
.theme-toggle:hover:not(:disabled) {
  background: var(--surface-hover);
}

.danger-button {
  color: var(--danger);
  background: transparent;
  border: 1px solid var(--border);
}

.danger-button:hover:not(:disabled) {
  background: var(--danger-soft);
  border-color: transparent;
}

.theme-toggle {
  min-height: 34px;
  padding: 0 12px;
  color: var(--text-secondary);
  font-size: 12.5px;
}

.icon-button {
  display: grid;
  width: 38px;
  min-height: 38px;
  place-items: center;
  color: var(--text-muted);
  background: var(--surface-subtle);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
}

.icon-button:hover:not(:disabled) {
  color: var(--danger);
  background: var(--danger-soft);
  border-color: transparent;
}

.button-row .primary-button,
.button-row .secondary-button {
  flex: 1;
}

/* Tabs */
.view-tabs {
  display: inline-flex;
  gap: 2px;
  padding: 3px;
  background: var(--surface-subtle);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
}

.view-tab {
  min-height: 30px;
  padding: 0 13px;
  color: var(--text-secondary);
  background: transparent;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
}

.view-tab:hover:not(.is-active) {
  color: var(--text);
}

.view-tab.is-active {
  color: var(--text);
  background: var(--surface);
  box-shadow: var(--shadow-xs);
}

/* Status */
.status {
  display: flex;
  align-items: center;
  min-height: 20px;
  margin: 12px 0 0;
  color: var(--text-muted);
  font-size: 13.5px;
}

.status:not(:empty) {
  padding: 9px 12px;
  border-radius: var(--r-sm);
  background: var(--surface-subtle);
}

.status.is-error:not(:empty) {
  color: var(--danger);
  background: var(--danger-soft);
}

.status.is-success:not(:empty) {
  color: var(--success);
  background: var(--success-soft);
}

/* Study shell */
.study-view {
  width: min(1180px, calc(100% - 40px));
  margin: 0 auto;
  padding: 28px 0 48px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border);
}

.topbar h1 {
  margin: 0;
  font-size: 22px;
}

.topbar .eyebrow {
  margin-bottom: 2px;
}

.topbar-actions {
  align-items: center;
  flex-wrap: wrap;
}

.user-badge {
  padding: 6px 12px;
  color: var(--text-secondary);
  background: var(--surface-subtle);
  border: 1px solid var(--border);
  border-radius: var(--r-pill);
  font-size: 13px;
  font-weight: 550;
}

#studyStatus {
  margin-top: 16px;
}

.overview-strip {
  display: grid;
  grid-template-columns: 1fr 1fr 1.4fr;
  gap: 10px;
  margin: 16px 0;
}

.overview-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  min-height: 64px;
  padding: 12px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-xs);
}

.overview-item span {
  color: var(--text-muted);
  font-size: 12.5px;
  font-weight: 550;
}

.overview-item strong {
  font-size: 19px;
  font-variant-numeric: tabular-nums;
  font-weight: 680;
}

.overview-session strong {
  color: var(--accent);
  font-size: 14px;
}

/* Controls */
.controls {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
  margin: 0 0 16px;
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-xs);
}

.controls label:first-child {
  min-width: 260px;
}

.controls .checkbox-label {
  padding-bottom: 9px;
}

.controls-actions {
  align-items: center;
}

/* Workspace */
.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 348px;
  gap: 16px;
  align-items: start;
}

.review-panel,
.editor-panel,
.library-panel {
  padding: 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-xs);
}

.session-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 16px;
  align-items: center;
  margin-bottom: 16px;
}

.session-mode {
  margin-bottom: 8px;
  color: var(--text-muted);
  font-size: 12.5px;
  font-weight: 550;
}

.progress-track {
  width: 100%;
  height: 6px;
  overflow: hidden;
  background: var(--surface-hover);
  border-radius: var(--r-pill);
}

.progress-bar {
  width: 0;
  height: 100%;
  background: var(--accent);
  border-radius: inherit;
  transition: width 260ms var(--ease);
}

.progress-text {
  min-width: 64px;
  color: var(--text-secondary);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  text-align: right;
}

/* Review card */
.review-card {
  display: grid;
  min-height: 340px;
  place-items: center;
  margin-bottom: 16px;
  padding: 32px 26px;
  background: var(--surface-subtle);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  cursor: pointer;
  outline: 0;
  transition: border-color 160ms var(--ease), background 160ms var(--ease);
}

.review-card:hover {
  border-color: var(--border-strong);
}

.review-card:focus-visible {
  border-color: var(--accent);
  box-shadow: var(--ring);
}

/* Once flipped the answer is showing — the card reads as "resolved", not "act on me". */
.review-card:has(.card-meaning:not(.is-hidden)) {
  background: var(--surface);
  border-color: var(--border-strong);
}

.card-face {
  width: 100%;
  text-align: center;
}

.card-meta {
  display: inline-block;
  max-width: 100%;
  margin-bottom: 20px;
  padding: 5px 11px;
  color: var(--text-muted);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-pill);
  font-size: 12px;
  font-weight: 550;
}

.card-meta:empty {
  display: none;
}

#cardWord {
  margin-bottom: 18px;
  overflow-wrap: anywhere;
  font-size: clamp(38px, 5.5vw, 60px);
  font-weight: 650;
  letter-spacing: -0.03em;
  line-height: 1.08;
}

.card-meaning {
  width: min(620px, 100%);
  margin: 0 auto 20px;
  padding-top: 18px;
  color: var(--text-secondary);
  border-top: 1px solid var(--border);
  font-size: 19px;
  line-height: 1.5;
  animation: reveal 200ms var(--ease);
}

@keyframes reveal {
  from {
    opacity: 0;
    transform: translateY(-4px);
  }
}

.flip-hint {
  margin-bottom: 0;
  color: var(--text-muted);
  font-size: 12.5px;
}

.review-actions {
  justify-content: center;
  flex-wrap: wrap;
}

/* Grades */
.grade-actions {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-top: 12px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.grade-actions button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  border: 1px solid transparent;
  border-radius: var(--r-sm);
  font-size: 13.5px;
  font-weight: 600;
}

.grade-actions kbd {
  padding: 1px 6px;
  border: 1px solid currentColor;
  border-radius: 5px;
  font-family: inherit;
  font-size: 11px;
  opacity: 0.55;
}

.again-button {
  color: var(--again);
  background: var(--again-soft);
}

.hard-button {
  color: var(--hard);
  background: var(--hard-soft);
}

.good-button {
  color: var(--good);
  background: var(--good-soft);
}

.easy-button {
  color: var(--easy);
  background: var(--easy-soft);
}

.grade-actions button:hover {
  border-color: currentColor;
}

/* Summary */
.session-summary {
  margin-top: 18px;
  padding: 18px;
  background: var(--surface-subtle);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
}

.session-summary h2 {
  margin-bottom: 14px;
  font-size: 17px;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 10px;
  margin-bottom: 16px;
}

.summary-grid div {
  padding: 12px 10px;
  text-align: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
}

.summary-grid strong,
.summary-grid span {
  display: block;
}

.summary-grid strong {
  color: var(--text);
  font-size: 22px;
  font-variant-numeric: tabular-nums;
  font-weight: 650;
  letter-spacing: -0.02em;
}

.summary-grid span {
  margin-top: 2px;
  color: var(--text-muted);
  font-size: 11.5px;
}

/* Editor panel */
.editor-panel h2 {
  margin-bottom: 16px;
  font-size: 17px;
}

/* Library */
.library-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.library-header h2 {
  margin-bottom: 0;
  font-size: 19px;
}

.library-toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
}

#libraryCount {
  margin: 0;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 550;
}

.card-list {
  display: grid;
  gap: 10px;
  margin-top: 18px;
}

.category-group {
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
}

.category-group summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  color: var(--text);
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  list-style: none;
  transition: background 140ms var(--ease);
}

.category-group summary:hover {
  background: var(--surface-subtle);
}

.category-group summary::-webkit-details-marker {
  display: none;
}

.category-group summary::before {
  color: var(--text-muted);
  content: "▸";
  font-size: 11px;
  transition: transform 160ms var(--ease);
}

.category-group[open] summary::before {
  transform: rotate(90deg);
}

.category-group summary span {
  flex: 1;
}

.category-group summary strong {
  padding: 2px 9px;
  color: var(--text-secondary);
  background: var(--surface-subtle);
  border: 1px solid var(--border);
  border-radius: var(--r-pill);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.category-card-list {
  display: grid;
  gap: 8px;
  padding: 0 12px 12px;
}

.library-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
  padding: 12px 14px;
  background: var(--surface-subtle);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  transition: border-color 140ms var(--ease);
}

.library-card:hover {
  border-color: var(--border-strong);
}

.library-card h3 {
  margin: 0 0 4px;
  overflow-wrap: anywhere;
  font-size: 16px;
  font-weight: 650;
}

.library-card p {
  display: -webkit-box;
  margin-bottom: 8px;
  overflow: hidden;
  color: var(--text-secondary);
  font-size: 14px;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

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

.pill {
  padding: 2px 9px;
  color: var(--text-muted);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-pill);
  font-size: 11.5px;
  font-weight: 550;
}

.library-actions {
  display: flex;
  gap: 8px;
}

.library-actions button {
  min-height: 32px;
  padding: 0 12px;
  font-size: 12.5px;
}

.library-empty {
  margin: 0;
  padding: 28px 16px;
  color: var(--text-muted);
  text-align: center;
  background: var(--surface);
  border: 1px dashed var(--border-strong);
  border-radius: var(--r-md);
}

.link-button {
  padding: 0;
  color: var(--text-secondary);
  background: none;
  border: none;
  font-size: 13px;
  font-weight: 550;
  text-decoration: underline;
  text-underline-offset: 3px;
  white-space: nowrap;
}

.link-button:hover:not(:disabled) {
  color: var(--accent);
}

/* CSV import dialog */
.import-dialog {
  width: min(640px, calc(100vw - 32px));
  padding: 0;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-lg);
}

.import-dialog::backdrop {
  background: rgba(12, 16, 24, 0.5);
}

.import-dialog-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 22px;
}

.import-dialog-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.import-dialog-header h2 {
  margin: 0;
  font-size: 19px;
}

.import-dialog-header .muted {
  margin: 0;
  max-width: 240px;
  overflow-wrap: anywhere;
  text-align: right;
  font-size: 12.5px;
}

.import-summary {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.import-stat {
  display: grid;
  gap: 2px;
  padding: 12px;
  background: var(--surface-subtle);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  text-align: center;
}

.import-stat strong {
  font-size: 22px;
  line-height: 1.1;
}

.import-stat span {
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 550;
}

.import-stat.is-add strong {
  color: var(--success);
}

.import-stat.is-skip strong {
  color: var(--hard);
}

.import-stat.is-error strong {
  color: var(--danger);
}

.import-preview {
  display: grid;
  gap: 6px;
  max-height: 280px;
  padding: 4px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
}

.import-preview:focus-visible {
  outline: none;
  box-shadow: var(--ring);
}

.import-row {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--r-sm);
  font-size: 13.5px;
}

.import-row:nth-child(odd) {
  background: var(--surface-subtle);
}

.import-row-line {
  flex: none;
  min-width: 34px;
  color: var(--text-muted);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.import-row-word {
  flex: none;
  font-weight: 600;
}

.import-row-meaning {
  flex: 1;
  overflow: hidden;
  color: var(--text-secondary);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.import-row-tag {
  flex: none;
  padding: 2px 8px;
  border-radius: var(--r-pill);
  font-size: 11.5px;
  font-weight: 600;
}

.import-row.is-add .import-row-tag {
  color: var(--success);
  background: var(--success-soft);
}

.import-row.is-skip .import-row-tag {
  color: var(--hard);
  background: var(--hard-soft);
}

.import-row.is-error {
  color: var(--text-muted);
}

.import-row.is-error .import-row-tag {
  color: var(--danger);
  background: var(--danger-soft);
}

.import-preview-more {
  padding: 8px 10px;
  color: var(--text-muted);
  font-size: 12.5px;
  text-align: center;
}

.import-dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

/* Responsive */
@media (max-width: 960px) {
  .workspace {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 860px) {
  .auth-layout {
    grid-template-columns: 1fr;
    width: 100%;
    max-width: 560px;
  }

  .auth-hero {
    min-height: auto;
    padding: 28px;
  }

  .hero-copy {
    margin: 32px 0 0;
  }

  .hero-copy h1 {
    font-size: 36px;
  }

  .feature-list {
    display: none;
  }

  .topbar,
  .controls,
  .library-header {
    align-items: stretch;
    flex-direction: column;
  }

  .library-toolbar {
    flex-wrap: wrap;
  }

  .import-summary {
    grid-template-columns: 1fr;
  }

  .topbar-actions,
  .controls-actions {
    width: 100%;
    flex-wrap: wrap;
  }

  .topbar-actions button,
  .controls-actions button {
    flex: 1;
  }

  .controls label:first-child {
    min-width: 0;
  }

  .controls .checkbox-label {
    padding-bottom: 0;
  }

  .grade-actions,
  .summary-grid {
    grid-template-columns: 1fr 1fr;
  }

  .session-header {
    grid-template-columns: 1fr;
  }

  .progress-text {
    text-align: left;
  }

  .overview-strip {
    grid-template-columns: 1fr 1fr;
  }

  .overview-session {
    grid-column: 1 / -1;
  }
}

@media (max-width: 560px) {
  .auth-view {
    display: grid;
    padding: 16px;
    overflow-x: hidden;
  }

  .study-view {
    width: calc(100% - 24px);
    padding: 20px 0 32px;
  }

  .auth-card,
  .review-panel,
  .editor-panel,
  .library-panel {
    padding: 16px;
  }

  .auth-layout {
    width: min(420px, calc(100vw - 48px));
    max-width: min(420px, calc(100vw - 48px));
    border-radius: var(--r-xl);
  }

  .auth-hero {
    padding: 22px;
  }

  .hero-copy {
    margin: 26px 0 0;
  }

  .hero-copy h1 {
    font-size: 30px;
  }

  .hero-copy > p:last-child {
    font-size: 14px;
  }

  .overview-strip {
    grid-template-columns: 1fr;
  }

  .overview-session {
    grid-column: auto;
  }

  .button-row,
  .review-actions,
  .library-actions {
    flex-direction: column;
  }

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

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

  .review-card {
    min-height: 280px;
    padding: 22px 16px;
  }

  #cardWord {
    font-size: 34px;
  }

  .card-meaning {
    font-size: 17px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }
}
