:root {
  --bg: #ffffff;
  --bg-secondary: #f5f5f7;
  --bg-tertiary: #e8e8ec;
  --text: #1a1a2e;
  --text-secondary: #6b7280;
  --text-strong: #1a1a2e;
  --text-muted: #6b7280;
  --text-faint: #aaa;
  --border: #e0e0e0;
  --border-light: #f0f0f0;
  --accent: #2e7d32;
  --accent-hover: #1b5e20;
  --accent-light: rgba(46, 125, 50, 0.1);
  --error: #d32f2f;
  --error-light: rgba(211, 47, 47, 0.1);
  --surface: #ffffff;
  --surface-raised: #ffffff;
  --hover-bg: #e8e8e8;
  --hover-border: #bbb;
  --placeholder: #bbb;
  --green: #2e7d32;
  --green-light: #66bb6a;
  --shadow: 0 1px 3px rgba(0,0,0,0.1);
  --shadow-md: 0 4px 6px rgba(0,0,0,0.1);
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, sans-serif;
  --font-mono: "SF Mono", Monaco, "Cascadia Code", monospace;
  --sp-xs: 4px;
  --sp-sm: 8px;
  --sp-md: 16px;
  --sp-lg: 24px;
  --sp-xl: 32px;
  --sp-2xl: 48px;
}

[data-theme="dark"] {
  --bg: #0f0f1a;
  --bg-secondary: #1a1a2e;
  --bg-tertiary: #252540;
  --text: #e8e8f0;
  --text-secondary: #9ca3af;
  --text-strong: #ffffff;
  --text-muted: #888;
  --text-faint: #555;
  --border: #2d2d44;
  --border-light: #1e1e35;
  --accent: #4caf50;
  --accent-hover: #66bb6a;
  --accent-light: rgba(76, 175, 80, 0.15);
  --error: #ef5350;
  --error-light: rgba(239, 83, 80, 0.15);
  --surface: #1a1a2e;
  --surface-raised: #252540;
  --hover-bg: #333;
  --hover-border: #555;
  --placeholder: #444;
  --green: #4caf50;
  --green-light: #81c784;
  --shadow: 0 1px 3px rgba(0,0,0,0.3);
  --shadow-md: 0 4px 6px rgba(0,0,0,0.4);
  --sp-xs: 4px;
  --sp-sm: 8px;
  --sp-md: 16px;
  --sp-lg: 24px;
  --sp-xl: 32px;
  --sp-2xl: 48px;
}

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
  transition: background 0.2s, color 0.2s;
}

.navbar {
  position: sticky;
  top: 0;
  z-index: 100;
  background: color-mix(in srgb, var(--surface) 75%, transparent);
  border-bottom: 1px solid transparent;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  transition: border-color 0.3s, box-shadow 0.3s;
}

.navbar.scrolled {
  border-bottom-color: var(--border);
  box-shadow: 0 1px 8px rgba(0, 0, 0, 0.06);
}

[data-theme="dark"] .navbar.scrolled {
  box-shadow: 0 1px 8px rgba(0, 0, 0, 0.15);
}

.navbar-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 24px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

/* ---- Brand ---- */
.navbar-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  flex-shrink: 0;
}

.brand-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  background: var(--accent);
}

.brand-text {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-strong);
  letter-spacing: -0.4px;
}

/* ---- Desktop nav links ---- */
.nav-links {
  display: none;
  align-items: center;
  justify-content: center;
  gap: 4px;
  flex: 1;
}

@media (min-width: 769px) {
  .nav-links {
    display: flex;
  }
}

.nav-link {
  position: relative;
  padding: 6px 14px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-muted);
  text-decoration: none;
  border-radius: 6px;
  transition: color 0.15s, background 0.15s;
}

.nav-link:hover {
  color: var(--text);
  background: var(--hover-bg);
}

.nav-link.active {
  color: var(--text-strong);
}

.nav-link.active::after {
  content: "";
  position: absolute;
  bottom: 0;
  left: 14px;
  right: 14px;
  height: 2px;
  background: var(--green);
  border-radius: 1px;
}

/* ---- Right actions ---- */
.nav-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.theme-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: color-mix(in srgb, var(--surface) 40%, transparent);
  cursor: pointer;
  transition: all 0.2s;
}
.theme-btn.svg-btn svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}
.theme-btn:hover {
  background: var(--hover-bg);
  border-color: var(--border-light);
}
.theme-btn:active {
  transform: scale(0.92);
}
.theme-btn.toggling svg {
  transform: rotate(360deg);
}
.theme-btn.svg-btn svg {
  color: #e67e22;
}
[data-theme="dark"] .theme-btn.svg-btn svg {
  color: #a0aec0;
}

/* ---- User avatar + dropdown ---- */
.user-area {
  display: none;
}

@media (min-width: 769px) {
  .user-area {
    display: block;
  }
}

.user-wrapper {
  position: relative;
}

.user-avatar {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  border: none;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
}

.user-avatar:hover {
  transform: scale(1.08);
  box-shadow: 0 0 0 3px var(--accent-light);
}

.user-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 200;
  min-width: 200px;
  background: color-mix(in srgb, var(--surface) 95%, transparent);
  backdrop-filter: blur(20px);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 6px;
  opacity: 0;
  transform: translateY(-4px) scale(0.96);
  pointer-events: none;
  transition: all 0.15s ease;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
}

[data-theme="dark"] .user-dropdown {
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
}

.user-wrapper.open .user-dropdown {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

.dropdown-header {
  padding: 8px 10px 6px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.dropdown-email {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-strong);
}

.dropdown-role {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: capitalize;
}

.dropdown-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 8px 10px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.1s;
  text-align: left;
  text-decoration: none;
}

.dropdown-item:hover {
  background: var(--hover-bg);
}

.dropdown-logout {
  color: var(--error);
}
.dropdown-logout:hover {
  background: color-mix(in srgb, var(--error) 12%, transparent);
}

/* ---- Hamburger ---- */
.hamburger {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 4px;
  width: 32px;
  height: 32px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
  padding: 6px;
  transition: border-color 0.15s;
}

@media (min-width: 769px) {
  .hamburger {
    display: none;
  }
}

.hamburger span {
  display: block;
  width: 16px;
  height: 2px;
  background: var(--text-muted);
  border-radius: 1px;
  transition: all 0.25s ease;
  transform-origin: center;
}

.hamburger.open span:nth-child(1) {
  transform: translateY(6px) rotate(45deg);
}

.hamburger.open span:nth-child(2) {
  opacity: 0;
  transform: scaleX(0);
}

.hamburger.open span:nth-child(3) {
  transform: translateY(-6px) rotate(-45deg);
}

/* ---- Drawer ---- */
.drawer-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(0, 0, 0, 0.15);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s;
}

.drawer-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

[data-theme="dark"] .drawer-overlay {
  background: rgba(0, 0, 0, 0.5);
}

.mobile-drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: 101;
  width: min(320px, 80vw);
  background: var(--surface);
  box-shadow: -4px 0 20px rgba(0,0,0,0.25);
  border-left: 1px solid var(--border);
  padding: 72px 16px 24px;
  transform: translateX(105%);
  transition: transform 0.3s cubic-bezier(0.22, 1, 0.36, 1);
  overflow-y: auto;
}

.mobile-drawer.open {
  transform: translateX(0);
}

.mobile-links, .mobile-links * {
  pointer-events: auto;
}

.mobile-links {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.mobile-link {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 14px;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 500;
  color: var(--text-muted);
  text-decoration: none;
  transition: all 0.12s;
}

.mobile-link:hover {
  background: var(--hover-bg);
  color: var(--text);
}

.mobile-link.active {
  color: var(--text-strong);
  background: color-mix(in srgb, var(--green) 10%, transparent);
}

.mobile-logout {
  margin-top: 8px;
  color: var(--error);
  border-top: 1px solid var(--border);
  padding-top: 16px;
  border-radius: 0;
}

.mobile-logout:hover {
  color: var(--error);
  background: color-mix(in srgb, var(--error) 10%, transparent);
}

body.drawer-open {
  overflow: hidden;
}

.app {
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px;
}

header {
  text-align: center;
  padding-bottom: 32px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

/* ── Hero header (F3) ──────────────────── */
.hero-header {
  text-align: center;
  padding: 10px 0 20px;
}
.hero-title {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.5px;
  margin: 0 0 4px;
  color: var(--text);
}
.hero-desc {
  font-size: 14px;
  color: var(--text-muted);
  margin: 0;
}

/* ── Layout: two column ────────────────── */
.layout-single {
  max-width: 560px;
  margin: 0 auto;
  width: 100%;
}

/* ── Generator section (left column) ──── */
.generator-section {
  display: flex;
  flex-direction: column;
}
.generator-bar {
  display: flex;
  gap: 8px;
  align-items: stretch;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 4px;
  background: var(--surface);
  box-shadow: 0 2px 12px rgba(0,0,0,0.15);
}
.generator-input {
  flex: 1;
  border: none;
  outline: none;
  background: transparent;
  color: var(--text);
  font-size: 14px;
  padding: 10px 12px;
  resize: none;
  font-family: inherit;
  line-height: 1.5;
  min-height: 20px;
  max-height: 200px;
}
.generator-input::placeholder {
  color: var(--placeholder);
}
#generate-btn {
  background: var(--accent);
  color: #fff;
  border: none;
  font-weight: 700;
  padding: 10px 24px;
  letter-spacing: 0.3px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  white-space: nowrap;
  transition: opacity 0.15s;
}
#generate-btn:hover:not(:disabled) {
  opacity: 0.85;
  filter: brightness(1.1);
}
#generate-btn.loading {
  opacity: 0.6;
  pointer-events: none;
}

/* Generator toolbar */
.generator-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 6px 0;
}
.char-count {
  font-size: 12px;
  color: var(--text-muted);
}
.toolbar-actions {
  display: flex;
  gap: 6px;
}
.toolbar-actions button {
  padding: 4px 12px;
  font-size: 12px;
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border-light);
  border-radius: 6px;
  cursor: pointer;
  transition: color 0.1s, border-color 0.1s;
}
.toolbar-actions button:hover {
  color: var(--text);
  border-color: var(--hover-border);
}
#regenerate-btn {
  font-size: 14px;
  line-height: 1;
  display: none;
}
#regenerate-btn.visible {
  display: inline-block;
}
#regenerate-btn[disabled] {
  opacity: 0.4;
  cursor: not-allowed;
}

/* Feature strip */
.feature-strip {
  display: flex;
  gap: 12px;
  justify-content: center;
  padding: 10px 0 4px;
  flex-wrap: wrap;
}
.feature-tag {
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
}

/* ── Flashcard Box ── */
/* ── Card Footer: Action Icons ── */
.card-icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  border-radius: 4px;
  padding: 4px 6px;
  cursor: pointer;
  color: var(--text-faint);
  transition: all 0.15s;
  line-height: 1;
}
.card-icon-btn svg {
  width: 14px;
  height: 14px;
  display: block;
}
.card-icon-btn:hover {
  background: var(--hover-bg);
  color: var(--text);
}
.card-icon-btn.edit-btn:hover {
  color: var(--green);
  background: color-mix(in srgb, var(--green) 10%, transparent);
}
.card-icon-btn.delete-btn:hover {
  color: var(--error);
  background: color-mix(in srgb, var(--error) 10%, transparent);
}
/* ── Edit Mode ── */
.card-edit-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.card-edit-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-faint);
}

.card-edit-textarea {
  background: var(--bg);
  border: 1px solid var(--border-light);
  border-radius: 6px;
  color: var(--text);
  font-size: 13px;
  padding: 8px 10px;
  font-family: inherit;
  width: 100%;
  resize: vertical;
  min-height: 32px;
  line-height: 1.45;
  transition: border-color 0.15s;
}
.card-edit-textarea:focus {
  outline: none;
  border-color: var(--green);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--green) 20%, transparent);
}

.card-edit-actions {
  display: flex;
  gap: 6px;
  justify-content: flex-end;
  margin-top: 6px;
}

.card-btn-save {
  padding: 5px 14px;
  font-size: 12px;
  font-weight: 600;
  border: none;
  border-radius: 5px;
  background: var(--green);
  color: #fff;
  cursor: pointer;
  transition: all 0.15s;
}
.card-btn-save:hover {
  background: var(--green-light);
  box-shadow: 0 1px 4px color-mix(in srgb, var(--green) 30%, transparent);
}

.card-btn-cancel {
  padding: 5px 12px;
  font-size: 12px;
  border: 1px solid var(--border-light);
  border-radius: 5px;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s;
}
.card-btn-cancel:hover {
  background: var(--hover-bg);
  color: var(--text);
}

/* ── History ── */

.history-item {
  background:var(--surface); border:1px solid var(--border); border-radius:6px;
  padding:8px 12px; display:flex; align-items:center; justify-content:space-between;
  font-size:13px;
}
.history-item:hover { border-color:var(--border-light) }
.history-item {
  background:var(--surface); border:1px solid var(--border); border-radius:6px;
  padding:8px 12px; display:flex; align-items:center; justify-content:space-between;
  font-size:13px;
}
.history-item:hover { border-color:var(--border-light) }

/* Toast notifications */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  padding: 10px 20px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  z-index: 9999;
  display: none;
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
  max-width: 90vw;
  text-align: center;
}

.toast.error {
  background: #ffebeb;
  color: #c62828;
  border: 1px solid #e57373;
}

.toast.success {
  background: #e8f5e9;
  color: #2e7d32;
  border: 1px solid #81c784;
}

[data-theme="dark"] .toast.error {
  background: #5a1a1a;
  color: #ff8a80;
  border: 1px solid #8a2a2a;
}

[data-theme="dark"] .toast.success {
  background: #1a3a1a;
  color: #69f0ae;
  border: 1px solid #2a5a2a;
}

/* ---- Generate page ---- */
.gen-layout {
  max-width: 1100px;
  margin: 0 auto;
  width: 100%;
  display: grid;
  grid-template-columns: 1fr;
  transition: grid-template-columns 0.25s;
}

.gen-layout.split {
  grid-template-columns: 1fr 1fr 1fr;
  gap: 16px;
}

/* Left panel — input */
.gen-left {
  display: flex;
  flex-direction: column;
}

.gen-left-header {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 600;
  color: var(--accent);
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border-light);
  margin-bottom: 14px;
}

.gen-left .generator-section {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.gen-left .generator-bar {
  flex-direction: column;
  gap: 10px;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  background: var(--surface);
}

.gen-left .generator-input {
  min-height: 200px;
  max-height: none;
  resize: vertical;
  border: none;
  outline: none;
  background: transparent;
  color: var(--text);
  font-size: 14px;
  padding: 0;
  font-family: inherit;
  line-height: 1.6;
}

.gen-left #generate-btn {
  width: 100%;
  background: #2e7d32;
  color: #fff;
  border: none;
  font-weight: 700;
  padding: 10px 0;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  transition: opacity 0.15s;
}
.gen-left #generate-btn:hover:not(:disabled) { opacity: 0.85; }
.gen-left #generate-btn:disabled { opacity: 0.5; cursor: default; }
body.light .gen-left #generate-btn { background: #2e7d32; }

/* ── Progress bar ───────────────── */
.gen-progress {
  display: none;
  margin-top: 12px;
  padding: 0 2px;
}
.gen-progress.visible { display: block; }

.gen-progress-track {
  width: 100%;
  height: 3px;
  background: var(--border-light);
  border-radius: 2px;
  overflow: hidden;
}

.gen-progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #2e7d32, #66bb6a);
  border-radius: 2px;
  transition: width 0.3s ease;
}
.gen-progress-fill.error {
  background: linear-gradient(90deg, #e53935, #ff6b6b);
}

.gen-progress-label {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 6px;
  display: flex;
  justify-content: space-between;
}

.gen-left .generator-toolbar {
  padding: 8px 2px 0;
}

/* ── Right panel — output ────────── */
.gen-right {
  display: none;
  flex-direction: column;
  min-height: 0;
}

.gen-layout.split .gen-right {
  display: flex;
}

.gen-layout.split .gen-right {
  display: flex;
}

/* Shared column headers */
.gen-col-header {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  padding-bottom: 10px;
  border-bottom: 2px solid var(--border-light);
  margin-bottom: 14px;
  flex-shrink: 0;
}
.gen-col-header svg { width: 14px; height: 14px; flex-shrink: 0; }
.gen-col-header .gen-col-badge {
  margin-left: auto;
  font-size: 10px;
  font-weight: 500;
  color: var(--text-muted);
  background: var(--bg);
  padding: 2px 8px;
  border-radius: 8px;
}
.gen-col-header .gen-cards-header-actions {
  margin-left: auto;
}

/* Middle column — copy output */
.gen-mid-col {
  display: none;
  flex-direction: column;
  min-width: 0;
}
.gen-layout.split .gen-mid-col {
  display: flex;
}
.gen-mid-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.gen-copy-textarea {
  width: 100%;
  flex: 1;
  min-height: 200px;
  font-family: var(--font-mono, monospace);
  font-size: 12px;
  line-height: 1.65;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
  color: var(--text);
  resize: none;
}
.gen-mid-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}
.gen-mid-actions .btn-sm {
  flex: 1;
  justify-content: center;
  padding: 6px 12px;
}

.gen-right-scroll {
  flex: 1;
  overflow-y: auto;
  max-height: calc(100vh - 220px);
  padding-right: 4px;
}

.gen-right-scroll::-webkit-scrollbar { width: 4px; }
.gen-right-scroll::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

/* Source panel */
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 600;
}

  display: flex;
  align-items: center;
  gap: 8px;
}

  font-size: 10px;
  color: var(--text-muted);
  background: var(--bg);
  padding: 2px 8px;
  border-radius: 4px;
}

  color: var(--text-muted);
  transition: transform 0.15s;
}

  padding: 0 14px 12px;
}

  margin: 0;
  font-size: 12px;
  line-height: 1.7;
  color: var(--text);
}

/* Cards section in output */
.gen-cards-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border-light);
  margin-bottom: 0;
}

.gen-cards-header-left {
  display: flex;
  align-items: center;
  gap: 10px;
}
.gen-cards-header-actions {
  display: flex;
  gap: 8px;
}
.gen-cards-header-actions .btn-sm {
  padding: 6px 12px;
}

.gen-cards-header-left h2 {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
}

.gen-cards-grid {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 16px;
}

@media (max-width: 900px) {
  .gen-layout.split {
    grid-template-columns: 1fr;
    gap: 16px;
  }
  .gen-layout.split .gen-left .generator-input { min-height: 120px; }
  .gen-right-scroll { max-height: none; }
}

.history-preview { color:var(--text-muted); font-size:12px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; flex:1; margin-right:12px }

/* Signup banner when anonymous generation limit reached */
.signup-banner {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 24px;
  background: linear-gradient(135deg, #fff, #e8f5e9);
  border: 1px solid #c8e6c9;
  border-radius: 8px;
  margin: 16px 0;
}
.signup-icon { font-size: 36px; flex-shrink: 0 }
.signup-text { flex: 1 }
.signup-text strong { font-size: 15px; color: var(--text-strong); display: block; margin-bottom: 6px }
.signup-text p { font-size: 13px; color: var(--text-muted); margin: 0 0 12px; line-height: 1.4 }
.signup-text .btn-primary {
  display: inline-block;
  background: var(--accent);
  color: #fff;
  padding: 8px 20px;
  border-radius: 6px;
  text-decoration: none;
  font-size: 13px;
  font-weight: 600;
  transition: background .15s;
}
.signup-text .btn-primary:hover { background: var(--accent-hover) }
[data-theme="dark"] .signup-banner {
  background: linear-gradient(135deg, var(--surface), #1a2a1a);
  border-color: #3a5a3a;
}
.kbd-hints {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
  margin: 12px 0;
  font-size: 12px;
  color: var(--text-muted);
}
.kbd-hints kbd {
  background: var(--surface);
  border: 1px solid var(--border-light);
  border-radius: 4px;
  padding: 2px 6px;
  font-size: 11px;
  font-family: inherit;
}
.history-meta { color:var(--text-faint); font-size:11px; white-space:nowrap; margin-right:12px }
.history-actions { display:flex; gap:4px; flex-shrink:0 }

/* ── General button base ─────────────── */
.btn {
  background: var(--btn-bg);
  color: var(--btn-text);
  border: 1px solid var(--border-light);
  border-radius: 6px;
  padding: 6px 12px;
  font-size: 12px;
  cursor: pointer;
  transition: all .1s;
  font-family: inherit;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.btn:hover { background: var(--hover-bg); border-color: var(--hover-border); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-sm { padding: 4px 10px; font-size: 11px; }
.btn svg { flex-shrink: 0; }

@media (max-width: 768px) {
  .app {
    padding: 16px;
  }
}

/* ── Landing sections ───────────────────── */
.landing-section {
  max-width: 800px;
  margin: 0 auto;
  padding: 48px 16px;
}
#example {
  padding-top: 16px;
}
.hero-title {
  font-size: 32px;
  font-weight: 700;
  color: var(--text);
  text-align: center;
  margin-bottom: 12px;
}
.hero-subtitle {
  font-size: 16px;
  color: var(--text-muted);
  text-align: center;
  max-width: 500px;
  margin: 0 auto;
}
.section-title {
  font-size: 24px;
  font-weight: 600;
  color: var(--text);
  text-align: center;
  margin-bottom: 8px;
}
.section-subtitle {
  font-size: 14px;
  color: var(--text-muted);
  text-align: center;
  margin-bottom: 24px;
}
.features-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
}
.feature-card {
  background: var(--surface);
  border: 1px solid var(--border-light);
  border-radius: 12px;
  padding: 24px;
  text-align: center;
}
.example-grid {
  display: flex;
  gap: 16px;
  align-items: center;
  margin-top: 24px;
}
.example-card {
  flex: 1;
  background: var(--surface);
  border: 1px solid var(--border-light);
  border-radius: 12px;
  padding: 20px;
  min-width: 0;
}
.example-output { flex: 1.5; }
.example-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
  margin-bottom: 12px;
}
.example-text {
  font-size: 13px;
  color: var(--text);
  line-height: 1.6;
  word-break: break-word;
}
.example-arrow {
  flex-shrink: 0;
  display: flex;
  align-items: center;
}
.example-flashcards {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.example-card-item {
  background: var(--bg);
  border: 1px solid var(--border-light);
  border-radius: 8px;
  padding: 10px 12px;
}
.example-q {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 4px;
}
.example-a {
  font-size: 12px;
  color: var(--green);
}

/* Staggered card reveal */
.example-card-item {
  animation: exampleFadeIn 0.4s ease both;
}
.example-card-item:nth-child(1) { animation-delay: 0.1s; }
.example-card-item:nth-child(2) { animation-delay: 0.6s; }
.example-card-item:nth-child(3) { animation-delay: 1.1s; }
.example-card-item:nth-child(4) { animation-delay: 1.6s; }

@keyframes exampleFadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

@media (max-width: 640px) {
  .example-grid { flex-direction: column; }
  .example-arrow { transform: rotate(90deg); }
}


.feature-icon { display: flex; justify-content: center; align-items: center; height: 36px; margin-bottom: 12px; color: var(--accent); }
.feature-card h3 {
  font-size: 16px; font-weight: 600; margin-bottom: 8px; color: var(--text);
}
.feature-card p {
  font-size: 13px; color: var(--text-muted); line-height: 1.5;
}
.pricing-toggle {
  display: flex; align-items: center; justify-content: center; gap: 12px;
  margin-bottom: 24px;
}
.toggle-label { font-size: 14px; color: var(--text-muted); cursor: pointer; }
.toggle-label.active { color: var(--text); font-weight: 600; }
.toggle-switch {
  position: relative; display: inline-block; width: 40px; height: 22px;
}
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
  position: absolute; cursor: pointer; inset: 0;
  background: var(--border-light); border-radius: 22px; transition: 0.3s;
}
.toggle-slider::before {
  content: ""; position: absolute; height: 16px; width: 16px;
  left: 3px; bottom: 3px; background: var(--text);
  border-radius: 50%; transition: 0.3s;
}
.toggle-switch input:checked + .toggle-slider { background: var(--accent); }
.toggle-switch input:checked + .toggle-slider::before { transform: translateX(18px); }
.savings-badge {
  background: var(--accent-light); color: var(--accent);
  font-size: 11px; padding: 2px 6px; border-radius: 4px; font-weight: 600;
}
.pricing-grid {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 20px;
  max-width: 600px; margin: 0 auto;
}
.pricing-card {
  background: var(--surface); border: 1px solid var(--border-light);
  border-radius: 12px; padding: 28px 24px; position: relative;
}
.pricing-card.popular {
  border-color: var(--accent); box-shadow: 0 0 20px var(--accent-light);
}
.popular-badge {
  position: absolute; top: -10px; left: 50%; transform: translateX(-50%);
  background: var(--accent); color: #fff; font-size: 11px; font-weight: 700;
  padding: 3px 12px; border-radius: 12px; text-transform: uppercase;
  letter-spacing: 0.5px;
}
.plan-name { font-size: 18px; font-weight: 700; margin-bottom: 12px; color: var(--text); }
.plan-price { font-size: 28px; font-weight: 700; color: var(--text); margin-bottom: 16px; }
.price-period { font-size: 14px; font-weight: 400; color: var(--text-muted); }
.plan-features { list-style: none; padding: 0; margin: 0 0 20px; }
.plan-features li { padding: 6px 0; font-size: 13px; color: var(--text-muted); }
.plan-features li::before {
  content: "\2713"; color: var(--accent); font-weight: 700; margin-right: 8px;
}
.pricing-btn { width: 100%; text-align: center; }
.popular .pricing-btn { background:var(--accent); color:#fff; border-color:var(--accent); font-weight:600 }
.popular .pricing-btn:hover { background:var(--accent-hover); border-color:var(--accent-hover) }
.popular .pricing-btn:disabled { opacity:0.5; cursor:not-allowed }
#footer { border-top: 1px solid var(--border-light); padding: 24px 16px; }
.footer-content {
  max-width: 800px; margin: 0 auto;
  display: flex; justify-content: space-between; align-items: center;
  font-size: 13px; color: var(--text-muted);
}
.footer-links { display: flex; gap: 16px; }
.footer-links a { color: var(--text-muted); text-decoration: none; }
.footer-links a:hover { color: var(--text); }
@media (max-width: 640px) {
  /* Navbar */
  .navbar-inner {
    padding: 0 16px;
    height: 60px;
  }
  
  .brand-text {
    font-size: 16px;
  }
  
  .hamburger {
    min-height: 44px;
    min-width: 44px;
    padding: 12px;
  }
  
  .theme-btn {
    min-height: 44px;
    min-width: 44px;
    width: 44px;
    height: 44px;
  }
  
  /* Layout */
  .features-grid { grid-template-columns: 1fr; }
  .pricing-grid { grid-template-columns: 1fr; }
  .footer-content { flex-direction: column; gap: 8px; text-align: center; }

  /* Hero */
  .hero-header { padding: 40px 16px 24px; }
  .hero-title { font-size: 22px; }
  .hero-desc { font-size: 13px; }

  /* Generator */
  .layout-single { max-width: 100%; padding: 0 12px; }
  .generator-bar { flex-direction: column; border-radius: 8px; padding: 8px; }
  .generator-input { max-height: 120px; min-height: 40px; padding: 8px; font-size: 15px; }
  #generate-btn { width: 100%; border-radius: 8px; padding: 10px; }
  .generator-toolbar { flex-direction: row; padding: 6px 0; font-size: 12px; }
  .toolbar-actions { gap: 6px; }

  /* Feature strip */
  .feature-strip { gap: 4px; flex-wrap: wrap; justify-content: center; padding: 8px 0; }
  .feature-tag { font-size: 11px; padding: 3px 8px; }

  /* Landing sections */
  .landing-section { padding: 32px 16px; }
  .section-title { font-size: 20px; }
  .section-subtitle { font-size: 13px; }
  .feature-card { padding: 20px 16px; }
  .pricing-card { padding: 24px 16px; }
  .plan-name { font-size: 16px; }
  .plan-price { font-size: 24px; }

  /* Footer */
  .footer-links { justify-content: center; }
  
  /* Touch targets & mobile UX */
  button, .btn, .nav-link, .mobile-link {
    min-height: 44px;
    min-width: 44px;
  }
  
  /* Button improvements */
  .btn-primary, #generate-btn {
    padding: 12px 16px;
    font-size: 16px;
  }
  
  /* Input improvements */
  input[type="text"], input[type="email"], input[type="password"], textarea {
    font-size: 16px; /* Prevent zoom on iOS */
    min-height: 44px;
  }
  
  /* Form spacing */
  .form-group {
    margin-bottom: 16px;
  }
}

/* ── Settings page ──────────────────────── */

#settings-layout {
  display: flex;
  gap: 0;
  min-height: calc(100vh - 60px);
  max-width: 1000px;
  margin: 0 auto;
  padding-top: 80px;
}

/* ── Sidebar (Minimal Lines) ──────────── */
#settings-sidebar {
  width: 180px;
  flex-shrink: 0;
  padding: var(--sp-xl) 0;
}
.sidebar-section-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--text-muted);
  padding: 0 var(--sp-lg) var(--sp-md);
}
.sidebar-item {
  display: block;
  padding: 8px var(--sp-lg);
  color: var(--text-muted);
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  border-left: 2px solid transparent;
  transition: color 100ms, border-color 100ms;
}
.sidebar-item:hover { color: var(--text); }
.sidebar-item.active {
  color: var(--text);
  font-weight: 600;
  border-left-color: var(--accent);
}

/* ── Content panel ────────────────────── */
#settings-content { flex: 1; padding: var(--sp-xl) var(--sp-xl) var(--sp-xl) 0; }
.settings-panel { display: none; }
.settings-panel.active { display: block; }

.settings-card {
  background: var(--surface);
  border: 1px solid var(--border-light);
  border-radius: 12px;
  padding: var(--sp-xl);
}
.panel-title {
  font-size: 18px;
  font-weight: 700;
  margin: 0 0 var(--sp-lg);
  color: var(--text);
  letter-spacing: -0.01em;
}
.panel-subtitle {
  font-size: 14px;
  font-weight: 600;
  margin: 0 0 var(--sp-md);
  color: var(--text);
}
.settings-rule {
  border: none;
  border-top: 1px solid var(--border-light);
  margin: var(--sp-lg) 0;
}

/* ── Account / row fields ─────────────── */
.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--sp-sm) 0;
}
.row-label { font-size: 13px; color: var(--text-muted); font-weight: 500; }
.row-value { font-size: 14px; color: var(--text); font-weight: 500; }

.field { margin-bottom: var(--sp-md); }
.field-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: var(--sp-xs);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Input refinements */
.input {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border-light);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
  outline: none;
  box-sizing: border-box;
  transition: border-color 100ms, box-shadow 100ms;
}
.input:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-light);
}

/* ── Stats grid ────────────────────────── */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-bottom: var(--sp-sm);
}
.stat-card {
  border: 1px solid var(--border-light);
  border-radius: 10px;
  padding: var(--sp-lg) var(--sp-md);
  text-align: center;
  aspect-ratio: 2 / 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
.stat-figure {
  display: block;
  font-size: 28px;
  font-weight: 700;
  color: var(--accent);
  line-height: 1;
  margin-bottom: var(--sp-xs);
}
.stat-label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* ── Progress bar ──────────────────────── */
.progress-group { margin-top: var(--sp-sm); }
.progress-bar {
  height: 6px;
  background: var(--border-light);
  border-radius: 3px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 3px;
  transition: width 100ms;
}
.progress-legend {
  font-size: 12px;
  color: var(--text-muted);
  margin: var(--sp-sm) 0 0;
}

/* ── Plan display ──────────────────────── */
.plan-label {
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
  margin: 0 0 var(--sp-sm);
}
.feature-checklist { list-style: none; padding: 0; margin: 0; }
.feature-checklist li {
  padding: 4px 0;
  font-size: 13px;
  color: var(--text-muted);
}
.feature-checklist li::before {
  content: "\2713";
  color: var(--accent);
  font-weight: 700;
  margin-right: var(--sp-sm);
}
.text-caption { color: var(--text-muted); font-size: 13px; margin: 0 0 var(--sp-md); }

/* ── Plan compact cards ────────────────── */
.plan-compact {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}
.plan-compact .pricing-card {
  padding: var(--sp-md);
}
.plan-compact .plan-name { font-size: 15px; }
.plan-compact .plan-price { font-size: 22px; }
.plan-compact .plan-features li { font-size: 12px; padding: 3px 0; }
.plan-compact .pricing-btn { font-size: 12px; padding: 6px 12px; }

/* ── Stats grid ──────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: var(--sp-sm);
}
.stats-card {
  border: 1px solid var(--border-light);
  border-radius: 10px;
  padding: var(--sp-lg) var(--sp-md);
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
.stats-card .stat-figure {
  display: block;
  font-size: 28px;
  font-weight: 700;
  color: var(--accent);
  line-height: 1;
  margin-bottom: var(--sp-xs);
}
.stats-card .stat-label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.stats-chart-wrap {
  max-width: 100%;
  margin: 0 auto;
}
.stats-chart-wrap canvas {
  width: 100% !important;
  max-height: 240px;
}
.stats-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.stats-table th {
  text-align: left;
  padding: 8px 12px;
  font-weight: 600;
  color: var(--text-muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 1px solid var(--border-light);
}
.stats-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border-light);
  color: var(--text);
}
.stats-table tr:last-child td {
  border-bottom: none;
}
.stats-table th:last-child,
.stats-table td:last-child {
  text-align: right;
}

@media (max-width: 640px) {
  .stats-grid {
    grid-template-columns: 1fr;
  }
}

/* ── Buttons ────────────────────────────── */
.btn-outline {
  background: transparent;
  border: 1px solid var(--border-light);
  color: var(--text-muted);
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 13px;
  cursor: pointer;
  transition: color 100ms, border-color 100ms;
}
.btn-outline:hover {
  color: var(--text);
  border-color: var(--text-muted);
}

/* ── Mobile ─────────────────────────────── */
@media (max-width: 640px) {
  #settings-layout { flex-direction: column; padding-top: 70px; }
  #settings-sidebar {
    width: 100%; display: flex; border-right: none;
    border-bottom: 1px solid var(--border-light);
    padding: var(--sp-sm) 0; overflow-x: auto;
  }
  .sidebar-section-label { display: none; }
  .sidebar-item {
    flex: 1; text-align: center; border-left: none;
    border-bottom: 2px solid transparent; padding: var(--sp-sm);
    white-space: nowrap; font-size: 12px;
  }
  .sidebar-item.active { border-left-color: transparent; border-bottom-color: var(--accent); }
  #settings-content { padding: var(--sp-md); }
  .settings-card { padding: var(--sp-md); }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .stat-card { aspect-ratio: auto; padding: var(--sp-md); }
  .plan-compact { grid-template-columns: 1fr; }
}

/* ── Results page ───────────────────────── */
.results-page {
  max-width: 1200px;
  margin: 0 auto;
  padding: 80px 20px 40px;
}
.results-container {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* Top bar */
.results-topbar {
  display: flex;
  align-items: center;
  gap: 12px;
}
.results-back {
  display: flex;
  align-items: center;
  gap: 4px;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 13px;
  padding: 4px 8px;
  border-radius: 6px;
}
.results-back:hover { color: var(--text); background: var(--surface); }
.results-date { font-size: 12px; color: var(--text-muted); flex: 1; }
.results-actions { display: flex; gap: 6px; }

.btn-action {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 12px;
  font-size: 11px;
  border: 1px solid var(--border-light);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text-muted);
  cursor: pointer;
  transition: color 0.1s, border-color 0.1s;
}
.btn-action:hover { color: var(--text); border-color: var(--border); }
.btn-action:disabled { opacity: 0.4; cursor: not-allowed; }

.btn-del { background: var(--error); color: #fff; border-color: var(--error); }
.btn-del:hover { background: var(--error); opacity: 0.85; border-color: var(--error); }

.card-count-badge {
  font-size: 11px;
  color: var(--text-muted);
  background: var(--surface);
  padding: 2px 10px;
  border-radius: 10px;
  border: 1px solid var(--border-light);
}

/* 3-column layout */
.results-three-col {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 16px;
  align-items: start;
}

.res-col {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 300px;
}

.res-col-header {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 600;
  padding-bottom: 8px;
  border-bottom: 2px solid var(--border-light);
  color: var(--text);
  flex-shrink: 0;
}
.res-col-header svg { width: 14px; height: 14px; flex-shrink: 0; }

.res-col-input .res-col-header { color: var(--accent); border-color: var(--accent-light); }
.res-col-output .res-col-header { color: var(--green, #4caf50); border-color: var(--green, #4caf50); }

.res-col-badge {
  margin-left: auto;
  font-size: 10px;
  font-weight: 500;
  color: var(--text-muted);
  background: var(--bg);
  padding: 2px 8px;
  border-radius: 8px;
}

.res-col-body {
  flex: 1;
  overflow-y: auto;
  max-height: 600px;
}

/* Input column */
.res-input-body {
  font-size: 13px;
  line-height: 1.7;
  color: var(--text);
  background: color-mix(in srgb, var(--accent) 3%, transparent);
  border: 1px solid var(--accent-light);
  border-radius: 10px;
  padding: 14px;
  white-space: pre-wrap;
  word-break: break-word;
}

/* Output column */
.res-output-body {
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
}
.res-output-textarea {
  width: 100%;
  flex: 1;
  min-height: 200px;
  font-family: var(--font-mono, monospace);
  font-size: 12px;
  line-height: 1.65;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
  color: var(--text);
  resize: none;
}
.res-output-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

/* Cards column */
.res-cards-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* Card box — more spacious */
.card-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
}
.card-box:hover {
  border-color: var(--border-light);
  box-shadow: 0 2px 8px rgba(0,0,0,0.06), 0 0 0 1px var(--border-light);
}
[data-theme="dark"] .card-box:hover {
  box-shadow: 0 2px 8px rgba(0,0,0,0.15), 0 0 0 1px var(--border-light);
}

.card-box-header {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.card-box .card-pos-label {
  font-size: 10px;
  font-weight: 600;
  color: var(--text-faint);
  flex-shrink: 0;
  padding: 2px 6px;
  background: var(--bg);
  border-radius: 4px;
  min-width: 22px;
  text-align: center;
  font-family: var(--font-mono);
}

.card-box-content {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.card-box .card-question {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-strong);
  word-break: break-word;
  line-height: 1.45;
}

.card-answer-wrap {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  border-top: 1px solid var(--border);
  padding-top: 8px;
}

.card-box .card-answer {
  font-size: 13px;
  color: var(--green);
  word-break: break-word;
  line-height: 1.45;
}

.card-box-footer {
  display: flex;
  justify-content: flex-end;
  gap: 2px;
}

.card-icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  border-radius: 4px;
  padding: 4px 6px;
  cursor: pointer;
  color: var(--text-faint);
  transition: all 0.15s;
  line-height: 1;
}

@media (max-width: 860px) {
  .results-three-col {
    grid-template-columns: 1fr;
  }
  .res-col {
    min-height: 0;
  }
  .res-col-body {
    max-height: none;
  }
  .results-page { padding: 70px 12px 24px; }
  .res-output-textarea {
    min-height: 150px;
  }
}
@media (max-width: 480px) {
  .results-topbar { flex-wrap: wrap; }
  .results-actions { flex: 1; justify-content: flex-end; }
}

/* ── Consent banner ── */
#consent-banner {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 20px;
  padding-bottom: max(12px, env(safe-area-inset-bottom, 12px));
  background: var(--bg);
  border-top: 1px solid var(--border);
  box-shadow: 0 -2px 12px rgba(0,0,0,0.1);
  font-size: 13px;
  color: var(--text);
  flex-wrap: wrap;
}
.consent-text {
  flex: 1;
  min-width: 200px;
  line-height: 1.4;
}
.consent-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}
.consent-btn {
  padding: 6px 16px;
  border-radius: 6px;
  border: 1px solid var(--border);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  background: var(--bg);
  color: var(--text);
  transition: all .12s;
}
.consent-btn:hover {
  border-color: var(--accent);
}
.consent-accept {
  background: #2e7d32;
  color: #fff;
  border-color: #2e7d32;
}
.consent-accept:hover {
  background: #256d27;
  border-color: #256d27;
}
.consent-decline {
  background: transparent;
  color: var(--text-muted);
}
.consent-decline:hover {
  color: var(--text);
  border-color: var(--text-muted);
}

/* ---- Review page ---- */
.study-reveal-hint {
  margin-top: 16px;
  font-size: 11px;
  color: var(--text-muted);
  opacity: 0.6;
}
.study-reveal-hint kbd {
  background: var(--surface);
  border: 1px solid var(--border-light);
  border-radius: 3px;
  padding: 1px 6px;
  font-size: 10px;
  font-family: inherit;
}
.study-edit-label {
  display: block;
  font-size: 10px;
  color: var(--text-muted);
  margin-bottom: 4px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.study-edit-label + .study-edit-label {
  margin-top: 10px;
}
.study-edit-actions {
  display: flex;
  gap: 8px;
  margin-top: 10px;
  justify-content: center;
}
.study-edit-save {
  padding: 6px 16px;
  background: #2e7d32;
  color: #fff;
  border: none;
  border-radius: 6px;
  font-weight: 600;
  cursor: pointer;
  font-size: 12px;
}
.review-error { padding: 40px 0; color: var(--text-muted); text-align: center; }
.study-edit-cancel {
  padding: 6px 16px;
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
  font-size: 12px;
}

/* ── Review page layout ──────────────────── */
.review-page { max-width: 800px; margin: 24px auto; padding: 0 16px; }
.review-tabs { display: flex; gap: 8px; margin-bottom: 20px; }
.review-tab {
  padding: 8px 20px; border: 1px solid var(--border-light); border-radius: 6px;
  cursor: pointer; font-size: 13px; font-weight: 500;
  background: var(--surface); color: var(--text);
  transition: all .15s;
}
.review-tab:hover { border-color: var(--hover-border); }
.review-tab.active { background: #2e7d32; color: #fff; border-color: #2e7d32; }
.review-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; flex-wrap: wrap; gap: 8px; }
.review-header h1 { font-size: 20px; font-weight: 600; color: var(--text); margin: 0; }
.review-count { font-size: 13px; color: var(--text-muted); }
.flip-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; margin-bottom: 12px; cursor: pointer;
  transition: border-color .15s; overflow: hidden;
}
.flip-card:hover { border-color: var(--hover-border); }
.flip-card-inner { padding: 16px 20px; min-height: 60px; }
.flip-card-side { display: none; line-height: 1.6; font-size: 14px; color: var(--text); white-space: pre-wrap; word-break: break-word; }
.flip-card-side.active { display: block; }
.flip-card-side.answer { color: var(--text-muted); }
.flip-card-meta {
  display: flex; gap: 12px; padding: 8px 20px; border-top: 1px solid var(--border);
  font-size: 11px; color: var(--text-faint); align-items: center; flex-wrap: wrap;
}
.flip-card-pos { font-weight: 600; color: var(--text-muted); }
.flip-card-due { color: var(--error); font-weight: 600; }
.flip-card-ret { color: #4caf50; }
.study-session { display: none; }
.study-session.active { display: block; }
.study-progress { margin-bottom: 16px; font-size: 13px; color: var(--text-muted); text-align: center; }
.study-card {
  position: relative;
  background: var(--surface); border: 1px solid var(--border-light);
  border-radius: 12px; padding: 32px 28px; margin-bottom: 20px;
  min-height: 180px; cursor: pointer;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  text-align: center; font-size: 16px; line-height: 1.7;
  transition: border-color .15s;
  white-space: pre-wrap; word-break: break-word;
}
.study-card:hover { border-color: var(--hover-border); }
.study-ratings { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.study-rating-btn {
  padding: 12px 20px; border: 1px solid var(--border-light); border-radius: 8px;
  cursor: pointer; font-size: 13px; font-weight: 500; min-width: 100px;
  background: var(--surface); color: var(--text);
  transition: all .12s; text-align: center;
}
.study-rating-btn .btn-label-row {
  display: inline-flex; align-items: center; gap: 4px;
}
.study-rating-btn .btn-interval { display: block; font-size: 11px; color: var(--text-faint); margin-top: 2px; font-weight: 400; }
.study-rating-btn kbd {
  font: inherit; font-size: 10px; color: var(--text-faint);
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 3px; padding: 0 5px;
  line-height: 18px; display: inline-block;
}
.study-rating-btn.again kbd { color: #ff6b6b; }
.study-rating-btn.hard kbd { color: #ffa726; }
.study-rating-btn.good kbd { color: #4caf50; }
.study-rating-btn.easy kbd { color: #42a5f5; }
.study-rating-btn.again:hover { border-color: #ff6b6b; background: rgba(255,107,107,0.08); }
.study-rating-btn.hard:hover { border-color: #ffa726; background: rgba(255,167,38,0.08); }
.study-rating-btn.good:hover { border-color: #4caf50; background: rgba(76,175,80,0.08); }
.study-rating-btn.easy:hover { border-color: #42a5f5; background: rgba(66,165,245,0.08); }
.study-rating-btn.skip kbd { color: var(--text-muted); }
.study-rating-btn.skip:hover { border-color: var(--text-muted); background: rgba(128,128,128,0.08); }
.study-empty { text-align: center; padding: 60px 20px; color: var(--text-muted); font-size: 15px; }
.study-empty h2 { font-size: 22px; margin-bottom: 8px; color: var(--text); }
.study-edit-input {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-size: 13px;
  line-height: 1.5;
  padding: 8px 10px;
  font-family: inherit;
  resize: vertical;
  box-sizing: border-box;
}
.study-edit-input:focus {
  outline: none;
  border-color: #2e7d32;
  box-shadow: 0 0 0 2px rgba(46,125,50,0.15);
}
.study-card-edit {
  position: absolute;
  top: 10px;
  right: 10px;
  transition: opacity .15s;
  padding: 4px 8px;
  background: var(--surface);
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
  font-size: 11px;
  display: flex;
  align-items: center;
  gap: 4px;
  z-index: 1;
}
.study-card-edit:hover { border-color: var(--text-muted); color: var(--text); }
.study-card-edit:active { opacity: 0.7; }

@media (max-width: 640px) {
  .study-session { padding-bottom: 110px; }
  .study-ratings {
    position: fixed !important;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 100;
    background: var(--bg);
    padding: 10px 12px;
    padding-bottom: max(10px, env(safe-area-inset-bottom, 10px));
    border-top: 1px solid var(--border);
    box-shadow: 0 -2px 8px rgba(0,0,0,0.08);
    gap: 6px;
  }
  .study-rating-btn {
    flex: 1;
    min-width: 70px;
    padding: 10px 8px;
    font-size: 12px;
  }
  .study-rating-btn .btn-interval { font-size: 10px; }
}

/* ── Login page ──────────────────────────── */
.forgot-row { text-align: right; margin-top: -10px; margin-bottom: 14px; }
.forgot-link { font-size: 12px; color: var(--btn-p-c); text-decoration: none; }
.back-to-login { display: block; text-align: center; margin-top: 16px; color: var(--btn-p-c); text-decoration: none; }

/* ── Utility classes ─────────────────────── */
.hidden { display: none !important; }
