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

:root {
  --bg:        #0a0a0a;
  --surface:   #111111;
  --surface2:  #181818;
  --border:    rgba(255,255,255,0.08);
  --accent:    #66FCF1;
  --accent-dim:#45a29e;
  --text:      #ffffff;
  --muted:     #888888;
  --success:   #1db954;
  --warning:   #f0a500;
  --error:     #e53e3e;
  --edited:    rgba(240,165,0,0.12);
  --edited-border: #f0a500;
  --radius:    8px;
}

html, body {
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: 'Poppins', -apple-system, sans-serif;
  font-size: 14px;
  line-height: 1.6;
}

/* ── Top Bar ──────────────────────────────────────────────────────────────── */
.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}

.topbar-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 28px;
  height: 64px;
  display: flex;
  align-items: center;
  gap: 24px;
}

.logo {
  font-size: 22px;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: -0.5px;
  white-space: nowrap;
}

.user-info {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-left: auto;
}

.user-email {
  font-size: 12px;
  color: var(--muted);
}

.api-row {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.api-row label {
  font-size: 13px;
  color: var(--muted);
  white-space: nowrap;
}

.key-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.key-wrap input {
  width: 260px;
  padding: 7px 34px 7px 12px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: inherit;
  font-size: 13px;
  outline: none;
  transition: border-color .2s;
}

.key-wrap input:focus { border-color: var(--accent-dim); }

.icon-btn {
  position: absolute;
  right: 8px;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--muted);
  display: flex;
  align-items: center;
  padding: 0;
}
.icon-btn:hover { color: var(--text); }
.modal-header .icon-btn {
  position: static;
  font-size: 18px;
  padding: 4px 8px;
  margin-left: auto;
}

.btn-outline-sm {
  padding: 6px 14px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: border-color .15s, color .15s;
  white-space: nowrap;
}
.btn-outline-sm:hover { border-color: var(--accent-dim); color: var(--accent); }

/* API key Save button states */
.save-key-empty  { opacity: 0.45; cursor: default; }
.save-key-saved  { border-color: rgba(29,185,84,0.4) !important; color: var(--success) !important; }
.save-key-new    { border-color: var(--accent) !important; color: var(--accent) !important; font-weight: 700; }

.saved-label {
  font-size: 12px;
  color: var(--success);
  font-weight: 600;
}

/* ── Main ─────────────────────────────────────────────────────────────────── */
.main {
  max-width: 1200px;
  margin: 0 auto;
  padding: 40px 28px 60px;
}

/* ── Setup Grid ───────────────────────────────────────────────────────────── */
.setup-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
}

@media (max-width: 768px) {
  .setup-grid { grid-template-columns: 1fr; }
  .key-wrap input { width: 200px; }
}

/* ── Card ─────────────────────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 28px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.step-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: var(--accent);
}

/* ── Upload Tabs ──────────────────────────────────────────────────────────── */
.upload-tabs {
  display: flex;
  border-bottom: 1px solid rgba(102,252,241,0.15);
  margin-bottom: 16px;
}

.upload-tab {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--muted);
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  padding: 8px 16px;
  margin-bottom: -1px;
  cursor: pointer;
  transition: color .15s, border-color .15s;
}

.upload-tab:hover { color: var(--text); }

.upload-tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

/* ── Paste Area ───────────────────────────────────────────────────────────── */
.paste-area {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.paste-textarea {
  width: 100%;
  height: 160px;
  background: rgba(255,255,255,0.04);
  border: 2px dashed rgba(102,252,241,0.25);
  border-radius: 10px;
  padding: 14px;
  color: var(--text);
  font-family: monospace;
  font-size: 12px;
  resize: vertical;
  outline: none;
  box-sizing: border-box;
  transition: border-color .2s;
}

.paste-textarea:focus { border-color: var(--accent); }
.paste-textarea::placeholder { color: var(--muted); }

/* ── Drop Zone ────────────────────────────────────────────────────────────── */
.drop-zone {
  border: 2px dashed rgba(102,252,241,0.25);
  border-radius: 10px;
  padding: 40px 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  text-align: center;
  cursor: pointer;
  transition: border-color .2s, background .2s;
}

.drop-zone:hover,
.drop-zone.drag-over {
  border-color: var(--accent);
  background: rgba(102,252,241,0.04);
}

.drop-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  margin-top: 4px;
}

.drop-sub {
  font-size: 13px;
  color: var(--muted);
}

.btn-browse {
  margin-top: 4px;
  padding: 9px 24px;
  background: transparent;
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  color: var(--accent);
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s, color .15s;
}
.btn-browse:hover {
  background: rgba(102,252,241,0.1);
}

/* ── File Ready ───────────────────────────────────────────────────────────── */
.file-ready {
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(102,252,241,0.06);
  border: 1px solid rgba(102,252,241,0.2);
  border-radius: var(--radius);
  padding: 10px 14px;
}

.file-name-text {
  font-weight: 600;
  font-size: 13px;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.seg-count {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
}

.clear-btn {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 14px;
  padding: 0 4px;
  line-height: 1;
  transition: color .15s;
}
.clear-btn:hover { color: var(--error); }

/* ── Language Chips ───────────────────────────────────────────────────────── */
.chips-wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.chip {
  padding: 8px 16px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--muted);
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all .15s;
  user-select: none;
}

.chip:hover {
  border-color: var(--accent-dim);
  color: var(--text);
}

.chip.active {
  border-color: var(--accent);
  background: rgba(102,252,241,0.1);
  color: var(--accent);
}

.selection-note {
  font-size: 12px;
  color: var(--muted);
  margin-top: -8px;
}

/* ── Translate Button ─────────────────────────────────────────────────────── */
.btn-translate {
  margin-top: auto;
  padding: 13px 28px;
  background: var(--accent);
  color: #0a0a0a;
  border: none;
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: opacity .15s, transform .1s;
  letter-spacing: .02em;
}

.btn-translate:hover:not(:disabled) { opacity: .88; }
.btn-translate:active { transform: scale(.98); }
.btn-translate:disabled { opacity: .3; cursor: not-allowed; }

/* ── Progress ─────────────────────────────────────────────────────────────── */
.progress-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
  min-height: 340px;
  text-align: center;
}

.spinner-lg {
  width: 48px;
  height: 48px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.progress-msg {
  font-size: 18px;
  font-weight: 600;
  color: var(--text);
}

.progress-sub {
  font-size: 13px;
  color: var(--muted);
  min-height: 20px;
}

.progress-track {
  width: 320px;
  max-width: 100%;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 2px;
  transition: width .4s ease;
}

/* ── Review Bar ───────────────────────────────────────────────────────────── */
.review-bar {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 20px;
}

.review-tabs {
  display: grid;
  grid-template-columns: repeat(2, 210px);
  gap: 6px;
}

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

.rtab {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all .15s;
  white-space: nowrap;
}

.rtab:hover { border-color: var(--accent-dim); color: var(--text); }

.rtab.active {
  border-color: var(--accent);
  background: rgba(102,252,241,0.08);
  color: var(--accent);
}

.rtab.loading { border-color: var(--warning); color: var(--warning); }
.rtab.error   { border-color: var(--error);   color: var(--error); }

.edit-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  background: var(--warning);
  color: #0a0a0a;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 700;
  display: none;
}

.rtab-spinner {
  width: 12px;
  height: 12px;
  border: 2px solid rgba(240,165,0,0.3);
  border-top-color: var(--warning);
  border-radius: 50%;
  animation: spin .6s linear infinite;
}

.btn-accent {
  padding: 9px 20px;
  background: var(--accent);
  color: #0a0a0a;
  border: none;
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: opacity .15s;
  white-space: nowrap;
}
.btn-accent:hover { opacity: .85; }

.btn-stay {
  width: 100%;
  padding: 12px 24px;
  font-size: 14px;
  border-radius: 10px;
  letter-spacing: 0.02em;
  box-shadow: 0 4px 14px rgba(102, 252, 241, 0.35);
  transition: opacity .15s, box-shadow .15s, transform .1s;
}
.btn-stay:hover {
  opacity: 1;
  box-shadow: 0 6px 20px rgba(102, 252, 241, 0.5);
  transform: translateY(-1px);
}

/* ── HTML Preview Panel ───────────────────────────────────────────────────── */
.preview-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  margin-bottom: 20px;
}

.preview-panel-label {
  padding: 10px 20px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--muted);
  background: var(--surface2);
  border-bottom: 1px solid var(--border);
}

.original-frame {
  width: 100%;
  height: 520px;
  border: none;
  background: #fff;
  display: block;
}

/* ── Review Table ─────────────────────────────────────────────────────────── */
.review-table-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
}

.review-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

.review-table.auto-layout { table-layout: auto; }

.review-table thead {
  background: var(--surface2);
  border-bottom: 1px solid var(--border);
}

.review-table th {
  padding: 14px 20px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--muted);
  text-align: left;
}

.col-original    { width: 50%; }
.col-translation { width: 50%; }

.review-table tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background .1s;
}

.review-table tbody tr:last-child { border-bottom: none; }
.review-table tbody tr:hover { background: rgba(255,255,255,0.02); }

.review-table td {
  padding: 12px 20px;
  vertical-align: top;
  font-size: 13px;
}

.td-original {
  color: var(--muted);
  line-height: 1.5;
  word-break: break-word;
}

.seg-label {
  display: inline-block;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--accent-dim);
  background: rgba(102,252,241,0.08);
  border: 1px solid rgba(102,252,241,0.2);
  border-radius: 4px;
  padding: 1px 6px;
  margin-bottom: 4px;
}

.memory-badge {
  color: #a78bfa;
  background: rgba(167,139,250,0.08);
  border-color: rgba(167,139,250,0.25);
}

.td-translation {
  padding: 8px 12px;
}

.trans-textarea {
  width: 100%;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 6px;
  color: var(--text);
  font-family: inherit;
  font-size: 13px;
  line-height: 1.5;
  padding: 6px 8px;
  resize: none;
  overflow: hidden;
  min-height: 36px;
  transition: border-color .15s, background .15s;
  outline: none;
}

.trans-textarea:hover {
  border-color: var(--border);
  background: var(--surface2);
}

.trans-textarea:focus {
  border-color: var(--accent-dim);
  background: var(--surface2);
}

.trans-textarea.edited {
  background: var(--edited);
  border-color: var(--edited-border);
}

/* ── Review Error ─────────────────────────────────────────────────────────── */
.review-error {
  background: rgba(229,62,62,0.08);
  border: 1px solid rgba(229,62,62,0.3);
  border-radius: 10px;
  padding: 20px 24px;
  color: var(--error);
  font-size: 14px;
}

/* ── Toast ────────────────────────────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%);
  background: #1e1e1e;
  border: 1px solid var(--border);
  color: var(--text);
  padding: 12px 24px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 500;
  box-shadow: 0 8px 32px rgba(0,0,0,.5);
  z-index: 999;
  white-space: nowrap;
  transition: opacity .3s;
}
.toast.error   { border-color: var(--error);   color: var(--error); }
.toast.success { border-color: var(--success);  color: var(--success); }

/* ── Dashboard ────────────────────────────────────────────────────────────── */
.dash-header { margin: 36px 0 14px; }
.dash-list   { display: flex; flex-direction: column; gap: 12px; }

.dash-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px 22px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  transition: border-color .15s;
}
.dash-card:hover { border-color: rgba(255,255,255,0.15); }

.dash-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.dash-card-name {
  font-weight: 600; font-size: 15px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.dash-card-badges { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.dash-all-done {
  font-size: 11px; font-weight: 700; white-space: nowrap;
  padding: 3px 10px; border-radius: 999px;
  background: rgba(29,185,84,0.12); color: var(--success);
  border: 1px solid rgba(29,185,84,0.3);
}
.dash-not-shared {
  font-size: 11px; font-weight: 600; white-space: nowrap;
  padding: 3px 10px; border-radius: 999px;
  background: rgba(255,200,80,0.1); color: #f0b429;
  border: 1px solid rgba(255,200,80,0.3);
}
.dash-done-badge {
  font-size: 11px; font-weight: 700; white-space: nowrap;
  padding: 3px 10px; border-radius: 999px;
  background: rgba(102,252,241,0.1); color: var(--cyan);
  border: 1px solid rgba(102,252,241,0.3);
}
.dash-card-done { opacity: 0.6; }
.btn-done-sm {
  padding: 6px 14px; background: transparent;
  border: 1px solid rgba(102,252,241,0.35); border-radius: var(--radius);
  color: var(--cyan); font-size: 12px;
  font-weight: 600; cursor: pointer; transition: background .15s, border-color .15s;
}
.btn-done-sm:hover { background: rgba(102,252,241,0.08); border-color: var(--cyan); }

.dash-lang-rows { display: flex; flex-direction: column; gap: 6px; }
.dash-lang-row  { display: flex; align-items: center; gap: 10px; font-size: 13px; }
.dash-lang-name { min-width: 100px; color: var(--text); }
.dash-lang-ts   { font-size: 11px; color: var(--muted); margin-left: 4px; }

.dash-lang-tag {
  font-size: 11px; font-weight: 600;
  padding: 2px 9px; border-radius: 999px; white-space: nowrap;
}
.dash-lang-tag.reviewed  { background: rgba(29,185,84,0.1);  color: var(--success); border: 1px solid rgba(29,185,84,0.3); }
.dash-lang-tag.in-review { background: rgba(102,252,241,0.08); color: var(--accent);  border: 1px solid rgba(102,252,241,0.2); }
.dash-lang-tag.pending   { background: var(--surface2); color: var(--muted); border: 1px solid var(--border); }

.dash-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
}
.dash-shared-ts  { font-size: 11px; color: var(--muted); }
.dash-card-actions { display: flex; gap: 8px; }

.btn-danger-sm {
  padding: 6px 14px; background: transparent;
  border: 1px solid rgba(229,62,62,0.35); border-radius: var(--radius);
  color: var(--error); font-family: inherit; font-size: 12px;
  font-weight: 600; cursor: pointer; transition: background .15s, border-color .15s;
}
.btn-danger-sm:hover { background: rgba(229,62,62,0.08); border-color: var(--error); }

/* ── Reviewer badge (on language tab) ────────────────────────────────────── */
.reviewer-badge {
  font-size: 10px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 999px;
  background: rgba(29,185,84,0.12);
  color: var(--success);
  border: 1px solid rgba(29,185,84,0.3);
  margin-left: 6px;
}

/* ── Review status bar (below review-bar, above table) ───────────────────── */
.review-status-bar {
  font-size: 12px;
  color: var(--success);
  background: rgba(29,185,84,0.06);
  border: 1px solid rgba(29,185,84,0.18);
  border-radius: 8px;
  padding: 8px 16px;
  margin-bottom: 12px;
}

/* ── Resume Banner ────────────────────────────────────────────────────────── */
.resume-banner {
  background: rgba(102,252,241,0.04);
  border: 1px solid rgba(102,252,241,0.2);
  border-radius: 12px;
  padding: 16px 20px;
  margin-bottom: 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.resume-title { font-weight: 600; font-size: 14px; color: var(--accent); }
.resume-file  { font-size: 12px; color: var(--muted); margin-top: 2px; }
.resume-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }

/* ── Share Modal ──────────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  width: 100%;
  max-width: 520px;
  overflow: hidden;
}

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

.modal-title {
  font-size: 15px;
  font-weight: 700;
}

.modal-body {
  padding: 20px 24px 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  max-height: calc(80vh - 60px);
  overflow-y: auto;
}

.modal-footer {
  padding: 14px 24px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
}

/* ── Glossary modal ───────────────────────────────────────────────────────── */
.glossary-lang-section {
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
}

.glossary-lang-header {
  background: var(--surface2);
  padding: 9px 14px;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--muted);
}

.glossary-entries {
  padding: 10px 14px;
  display: flex;
  flex-direction: column;
  gap: 7px;
  max-height: 180px;
  overflow-y: auto;
}

.glossary-entry-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-size: 13px;
  cursor: pointer;
}

.glossary-entry-row input[type="checkbox"] { margin-top: 2px; flex-shrink: 0; accent-color: var(--accent); }
.glossary-entry-text { color: var(--muted); line-height: 1.4; }
.glossary-entry-text .orig { color: var(--text); }

.glossary-selector {
  padding: 10px 14px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

.glossary-selector-label {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
}

.glossary-select,
.glossary-name-input {
  flex: 1;
  min-width: 140px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: inherit;
  font-size: 13px;
  padding: 7px 10px;
  outline: none;
  transition: border-color .15s;
}
.glossary-select:focus,
.glossary-name-input:focus { border-color: var(--accent-dim); }

.modal-desc {
  font-size: 13px;
  color: var(--muted);
}

.modal-link-row {
  display: flex;
  gap: 8px;
  align-items: center;
}

.modal-link-input {
  flex: 1;
  padding: 8px 12px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: inherit;
  font-size: 12px;
  outline: none;
  transition: border-color .2s;
}
.modal-link-input:focus { border-color: var(--accent-dim); }

.modal-setting {
  border-top: 1px solid var(--border);
  padding-top: 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.modal-setting-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
}

.modal-setting-hint {
  font-size: 11px;
  color: var(--muted);
}

/* ── Mobile (≤ 640px) ─────────────────────────────────────────────────────── */
@media (max-width: 640px) {
  /* Topbar: stack API key row below logo */
  .topbar-inner {
    height: auto;
    min-height: 56px;
    padding: 10px 16px;
    flex-wrap: wrap;
    gap: 8px;
  }
  .logo { font-size: 18px; }
  .api-row { width: 100%; margin-left: 0; justify-content: flex-start; }
  .key-wrap { flex: 1; min-width: 0; }
  .key-wrap input { width: 100%; }

  /* Layout */
  .main { padding: 20px 16px 40px; }
  .card { padding: 20px; }

  /* Review bar: stack tabs + actions */
  .review-tabs { grid-template-columns: repeat(2, 1fr); width: 100%; }
  .review-actions { width: 100%; }
  .btn-outline-sm { font-size: 12px; padding: 6px 10px; }
  .btn-accent { font-size: 12px; padding: 7px 14px; }

  /* Review table: stack original above translation */
  .review-table thead { display: none; }
  .review-table,
  .review-table tbody,
  .review-table tr,
  .review-table td { display: block; width: 100%; }
  .review-table tr { border-bottom: 1px solid var(--border); }
  .review-table tr:last-child { border-bottom: none; }
  .td-original { padding: 12px 16px 4px; }
  .td-translation { padding: 4px 12px 12px; }

  /* Toast: allow wrapping */
  .toast {
    white-space: normal;
    max-width: calc(100vw - 32px);
    text-align: center;
    bottom: 16px;
  }

  /* Dashboard */
  .dash-card { padding: 14px 16px; }
  .dash-card-footer { flex-direction: column; align-items: flex-start; gap: 8px; }
  .dash-lang-ts { display: block; margin-left: 0; margin-top: 2px; }
  .dash-card-actions { width: 100%; }
  .btn-danger-sm, .btn-done-sm, .dash-card-actions .btn-outline-sm { flex: 1; text-align: center; }

  /* Resume banner */
  .resume-banner { flex-direction: column; align-items: flex-start; gap: 10px; }
  .resume-actions { width: 100%; }

  /* Modal: bottom sheet on mobile */
  .modal-overlay { align-items: flex-end; padding: 0; }
  .modal { border-radius: 14px 14px 0 0; max-width: 100%; }
}

/* ── Source language selector ─────────────────────────────────────────────── */
.source-lang-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}
.source-lang-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  white-space: nowrap;
}
.source-lang-select {
  padding: 6px 10px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: inherit;
  font-size: 13px;
  outline: none;
  cursor: pointer;
}
.source-lang-select:focus { border-color: var(--accent-dim); }

/* ── Links section ────────────────────────────────────────────────────────── */
.links-section {
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}
.links-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 20px;
  cursor: pointer;
  user-select: none;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}
.links-header:hover { background: var(--surface2); }
.links-chevron {
  font-size: 11px;
  color: var(--muted);
  transition: transform 0.2s;
}
.links-body {
  border-top: 1px solid var(--border);
  overflow-x: auto;
}
.links-body.collapsed { display: none; }
.links-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.links-table th {
  padding: 8px 12px;
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
  background: var(--surface2);
  white-space: nowrap;
}
.links-table td { padding: 6px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.links-table tr:last-child td { border-bottom: none; }
.link-col-original { width: 30%; }
.link-col-lang { min-width: 180px; }
.link-original-cell { color: var(--text); }
.link-href-small {
  color: var(--muted);
  font-size: 11px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 280px;
  display: block;
}
.link-override-cell { min-width: 180px; }
.link-input {
  width: 100%;
  padding: 6px 10px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-family: inherit;
  font-size: 12px;
  outline: none;
  transition: border-color 0.2s;
}
.link-input:focus { border-color: var(--accent-dim); }
.link-input::placeholder { color: var(--muted); font-size: 11px; }

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