:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-soft: #eef1f4;
  --text: #17202a;
  --muted: #657282;
  --line: #d8dee6;
  --primary: #2457c5;
  --primary-dark: #173f96;
  --danger: #b42318;
  --success: #0f7a4f;
  --shadow: 0 10px 30px rgba(23, 32, 42, 0.08);
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.45;
}

a { color: inherit; text-decoration: none; }
button, input, textarea, select { font: inherit; }
button { cursor: pointer; }
h1, h2, h3, p { margin-top: 0; }
h1 { font-size: clamp(28px, 4vw, 42px); line-height: 1.05; margin-bottom: 10px; }
h2 { font-size: 18px; margin-bottom: 0; }
h3 { font-size: 18px; margin-bottom: 8px; }

label { display: grid; gap: 7px; color: var(--muted); font-size: 13px; font-weight: 650; }
input, textarea, select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  padding: 10px 12px;
  min-height: 42px;
}
textarea { resize: vertical; line-height: 1.45; }
input:focus, textarea:focus, select:focus {
  outline: 2px solid rgba(36, 87, 197, 0.22);
  border-color: var(--primary);
}

.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(circle at 20% 20%, rgba(36, 87, 197, 0.08), transparent 34%),
    var(--bg);
}
.login-panel {
  width: min(440px, 100%);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 32px;
  box-shadow: var(--shadow);
}
.login-panel p { color: var(--muted); }

.ldap-lookup {
  display: grid;
  gap: 9px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
}

.lookup-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.lookup-status {
  font-size: 12px;
  font-weight: 750;
  color: var(--muted);
}

.lookup-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
  font-weight: 650;
  color: var(--text);
}

.group-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.group-chip {
  display: inline-flex;
  max-width: 100%;
  padding: 4px 9px;
  border-radius: 999px;
  color: var(--success);
  background: rgba(15, 122, 79, 0.1);
  font-size: 12px;
  font-weight: 750;
  overflow-wrap: anywhere;
}

.group-chip-muted {
  color: var(--muted);
  background: rgba(101, 114, 130, 0.12);
}

.ldap-lookup-ok {
  border-color: rgba(15, 122, 79, 0.35);
  background: rgba(15, 122, 79, 0.08);
}

.ldap-lookup-ok .lookup-status {
  color: var(--success);
}

.ldap-lookup-warn {
  border-color: rgba(180, 35, 24, 0.28);
  background: rgba(180, 35, 24, 0.08);
}

.ldap-lookup-warn .lookup-status {
  color: var(--danger);
}

.ldap-lookup-loading .lookup-status::after {
  content: "...";
}

.user-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.user-groups {
  color: var(--success);
  font-weight: 750;
}

.brand-mark {
  display: inline-grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 8px;
  background: var(--primary);
  color: white;
  font-weight: 800;
  letter-spacing: 0;
}
.brand-mark.small {
  width: 32px;
  height: 32px;
  font-size: 12px;
}

.app-shell { min-height: 100vh; }
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 64px;
  padding: 10px 24px;
  background: rgba(255, 255, 255, 0.92);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(12px);
}
.logo, .topbar-actions, .doc-main {
  display: flex;
  align-items: center;
  gap: 10px;
}
.logo { font-weight: 750; }
.topbar-actions { flex-wrap: wrap; justify-content: flex-end; }
.topbar-actions form { display: flex; }
.topbar-filter {
  width: 220px;
  min-height: 40px;
  background: var(--surface);
}
.user-pill, .status-pill {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 7px 11px;
  color: var(--muted);
  background: var(--surface);
  font-size: 13px;
}

.dashboard, .document-layout {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 48px;
}
.dashboard {
  display: grid;
  gap: 18px;
}
.doc-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 20px;
  padding: 26px 0;
}
.doc-header p, .empty-state p, .small { color: var(--muted); }
.small { font-size: 12px; }

.main-column, .context-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}
.main-column, .context-panel { padding: 18px; }
.stack { display: grid; gap: 14px; }
.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}
.section-head span { color: var(--muted); font-size: 13px; }
.section-head.compact { margin-bottom: 4px; }

.drop-zone {
  display: grid;
  place-items: stretch;
  border: 1px dashed #b7c0cc;
  background: #fbfcfd;
  transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
}
.drop-zone form {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
  min-height: 0;
}
.drop-zone input { display: none; }
.drop-zone .upload-target {
  flex: 1;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 7px;
  min-height: 0;
  padding: 20px 16px;
  cursor: pointer;
  color: var(--text);
  text-align: center;
  font-size: 15px;
}
.drop-zone .upload-hint {
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
  line-height: 1.35;
  max-width: 18ch;
}
.drop-zone.is-active,
body.is-dragging-file .drop-zone {
  border-color: var(--primary);
  background: #f8fbff;
  box-shadow: 0 0 0 4px rgba(36, 87, 197, 0.12);
}
.drop-zone.is-uploading .upload-target strong { font-size: 0; }
.drop-zone.is-uploading .upload-target strong::after {
  content: "Uploading...";
  font-size: 16px;
}
.drop-zone.is-uploading .upload-hint { display: none; }
.drop-zone.is-uploading .add-icon { display: none; }

.doc-add-tile {
  border-style: dashed;
  overflow: hidden;
}
.doc-add-tile:hover {
  border-color: var(--primary);
  background: #f8fbff;
}
.add-icon {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--surface);
  color: var(--primary);
  font-size: 30px;
  font-weight: 400;
  line-height: 1;
}

.doc-list {
  display: grid;
  gap: 18px;
}
.doc-group {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 14px;
}
.doc-group-head {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 2px 2px 0;
}
.doc-group-head h3 {
  margin: 0;
  font-size: 15px;
}
.doc-group-head span {
  color: var(--muted);
  font-size: 13px;
}
.upload-group-field {
  flex-shrink: 0;
  display: grid;
  gap: 6px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}
.upload-group-field > label {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}
.upload-group-select {
  width: 100%;
  min-height: 34px;
  padding: 6px 9px;
  font-size: 12px;
  font-weight: 700;
  text-transform: none;
  letter-spacing: normal;
  background: var(--surface);
}
.doc-group-chip {
  display: inline-flex;
  max-width: 100%;
  margin-top: 8px;
  padding: 3px 8px;
  border-radius: 999px;
  color: var(--success);
  background: rgba(15, 122, 79, 0.1);
  font-size: 11px;
  font-weight: 750;
  overflow-wrap: anywhere;
}
.doc-row {
  display: block;
  min-height: 280px;
  aspect-ratio: 1 / 1.28;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}
.doc-main {
  min-width: 0;
  height: 100%;
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  gap: 0;
}
.doc-main strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
}
.doc-main small { color: var(--muted); display: block; margin-top: 2px; }
.doc-preview {
  min-height: 0;
  padding: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
  overflow: hidden;
  background: #eef1f4;
}
.doc-preview.image-preview {
  display: block;
}
.doc-preview.missing-preview {
  display: grid;
  place-items: center;
  padding: 16px;
  text-align: center;
}
.doc-preview-fallback {
  max-width: 12em;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}
.doc-preview img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: top center;
}
.doc-meta {
  padding: 10px 12px 12px;
  border-top: 1px solid var(--line);
  min-width: 0;
  background: var(--surface);
}
.lang-progress-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 4px;
  margin-top: 8px;
}
.lang-progress-cell {
  display: grid;
  gap: 1px;
  min-width: 0;
  padding: 5px 6px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f7f8fa;
  text-align: center;
}
.lang-progress-cell .lang-code {
  color: var(--text);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.04em;
  line-height: 1.2;
}
.lang-progress-cell .lang-count {
  color: var(--muted);
  font-size: 10px;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.lang-progress-cell.is-source {
  border-color: rgba(37, 99, 235, 0.28);
  background: rgba(37, 99, 235, 0.08);
}
.lang-progress-cell.is-source .lang-count {
  color: #2563eb;
  font-weight: 800;
  font-size: 9px;
  letter-spacing: 0.02em;
}
.lang-progress-cell.is-complete {
  border-color: rgba(15, 122, 79, 0.28);
  background: rgba(15, 122, 79, 0.08);
}
.lang-progress-cell.is-complete .lang-count {
  color: var(--success);
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 9px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font-weight: 700;
  white-space: nowrap;
}
.button.primary {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}
.button.primary:hover { background: var(--primary-dark); }
.button.ghost { background: transparent; }
.button.subtle { background: var(--surface-soft); }
.button.danger {
  color: var(--danger);
  border-color: #e7bbb6;
  background: #fff8f7;
}

.empty-state {
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 24px;
  background: #fbfcfd;
  color: var(--muted);
}

.context-drawer {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}
.context-drawer summary {
  padding: 13px 16px;
  cursor: pointer;
  font-weight: 750;
}
.context-drawer .context-panel {
  border: 0;
  border-top: 1px solid var(--line);
  border-radius: 0;
}

.lang-chip-row {
  display: flex !important;
  flex-direction: row !important;
  flex-wrap: wrap !important;
  gap: 8px;
  align-items: center;
}
.lang-chip {
  display: inline-flex !important;
  flex: 0 0 auto;
  align-items: center;
  gap: 4px;
  width: max-content;
  max-width: 100%;
  margin: 0;
  padding: 6px 8px 6px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-soft);
  color: var(--text);
  font: inherit;
  line-height: 1.2;
}
.lang-chip-remove-form {
  display: inline-flex;
  margin: 0;
  padding: 0;
  border: 0;
  width: auto;
}
.lang-chip-label {
  font-weight: 600;
  font-size: 0.9rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 14rem;
}
.lang-chip-remove {
  flex-shrink: 0;
  width: 22px;
  height: 22px;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 1.05rem;
  line-height: 1;
  cursor: pointer;
}
.lang-chip-remove:hover {
  background: rgba(0, 0, 0, 0.08);
  color: var(--text);
}
.lang-chip-add {
  justify-content: center;
  width: 34px;
  height: 34px;
  padding: 0;
  font-size: 1.25rem;
  font-weight: 500;
  cursor: pointer;
  color: var(--muted);
}
.lang-chip-add:hover,
.lang-chip-add[aria-expanded="true"] {
  border-color: var(--primary);
  color: var(--primary);
  background: color-mix(in srgb, var(--primary) 10%, transparent);
}
.lang-catalog-add {
  display: grid;
  gap: 12px;
}
.lang-catalog-add[hidden] {
  display: none !important;
}
.lang-catalog-add label {
  display: grid;
  gap: 6px;
}
.lang-catalog-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}
.lang-catalog-reset-btn {
  font-size: 0.85rem;
  padding: 6px 12px;
}

.prompt-tier { display: grid; gap: 6px; }
.prompt-tier-label {
  font-weight: 650;
  font-size: 0.92rem;
}
.prompt-tier-hint {
  margin: 0;
  color: var(--muted);
  font-size: 0.85rem;
}
.context-panel textarea::placeholder {
  color: #8a96a3;
  opacity: 1;
}
.system-prompt-collapsible { display: grid; gap: 8px; }
.system-prompt-check {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
.system-prompt-readonly {
  margin: 0;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f4f6f8;
  color: var(--text);
  font-family: inherit;
  font-size: 0.9rem;
  line-height: 1.5;
  white-space: pre-wrap;
  user-select: text;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.system-prompt-collapsible:has(.system-prompt-check:checked) .system-prompt-readonly {
  display: block;
  -webkit-line-clamp: unset;
  overflow: visible;
}
.system-prompt-toggle {
  justify-self: start;
  color: var(--primary);
  font-size: 0.85rem;
  font-weight: 650;
  cursor: pointer;
}
.system-prompt-toggle .when-expanded { display: none; }
.system-prompt-collapsible:has(.system-prompt-check:checked) .system-prompt-toggle .when-collapsed { display: none; }
.system-prompt-collapsible:has(.system-prompt-check:checked) .system-prompt-toggle .when-expanded { display: inline; }
.system-prompt-collapsible.is-short .system-prompt-toggle { display: none; }

.button.save-context {
  background: #ffffff;
  color: #101418;
  border: 1px solid #d8dee6;
  font-weight: 700;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.12);
}
.button.save-context:hover { background: #f8f9fa; }

.flash-stack { display: grid; gap: 8px; margin-bottom: 16px; }
.flash {
  border-radius: 8px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  background: var(--surface);
}
.flash.error { border-color: #efb8b2; color: var(--danger); background: #fff8f7; }
.flash.warning { border-color: #e6d3a3; color: #8a6d1d; background: #fffbf0; }
.flash.success { border-color: #a9dbc4; color: var(--success); background: #f4fbf7; }

@media (max-width: 640px) {
  .topbar, .doc-header, .doc-row {
    align-items: stretch;
    flex-direction: column;
  }
  .topbar-actions { justify-content: flex-start; }
  .topbar-filter { width: 100%; }
  .dashboard, .document-layout { width: min(100% - 20px, 1180px); }
}

/* Old translation tab restored for the document workspace. */
body.md {
  margin: 0;
  min-height: 100vh;
  font-family: Roboto, -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  background: #101418;
  color: #e3e6ea;
  font-size: 14px;
}

body.md button { color: inherit; }

.material-symbols-outlined {
  font-size: 20px;
  font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 24;
  vertical-align: middle;
}

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

.app-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 20px;
  background: #181c20;
  box-shadow: 0 1px 2px rgba(0,0,0,0.3), 0 1px 3px 1px rgba(0,0,0,0.15);
  position: sticky;
  top: 0;
  z-index: 10;
}

.filename {
  flex: 1;
  font-size: 18px;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding: 0 8px;
}

.md-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  padding: 0 20px;
  border-radius: 999px;
  border: none;
  font-weight: 500;
  font-size: 14px;
  background: #262c33;
  color: #e3e6ea;
}
.md-btn.filled { background: #8ab4ff; color: #002e6b; }
.md-btn.tonal { background: #283544; color: #cfe0f5; }
.md-btn.stop-mode {
  background: color-mix(in srgb, #ffb4ab 18%, #262c33);
  color: #ffb4ab;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: none;
  background: transparent;
  color: #e3e6ea;
}
.icon-btn:hover { background: rgba(255,255,255,0.08); }

.toolbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 56px minmax(0, 1fr);
  gap: 12px;
  padding: 12px 20px;
  background: #181c20;
  border-bottom: 1px solid #2a3036;
  position: sticky;
  top: 64px;
  z-index: 9;
  box-shadow: 0 1px 2px rgba(0,0,0,0.3), 0 1px 3px 1px rgba(0,0,0,0.15);
}
.toolbar-side { display: flex; align-items: flex-end; min-width: 0; }
.toolbar-left { justify-content: flex-start; grid-column: 1; gap: 12px; }
.toolbar-right { justify-content: flex-end; grid-column: 3; gap: 12px; flex-wrap: nowrap; }
.lang-group { display: flex; flex-direction: column; gap: 6px; align-items: stretch; }
.find-replace-group {
  flex: 0 1 auto;
  min-width: 0;
  max-width: 100%;
}
.find-replace-controls {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 6px;
  min-width: 0;
}
.find-replace-input {
  box-sizing: border-box;
  width: 160px;
  max-width: 160px;
  min-width: 0;
  flex: 0 0 160px;
  padding: 8px 10px;
}
.find-replace-actions {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}
.find-replace-btn {
  min-height: 36px;
  padding: 0 12px;
  font-size: 13px;
  white-space: nowrap;
}
.card.src.find-current,
.card.tgt.find-current {
  outline: 2px solid #8ab4ff;
  outline-offset: 2px;
}
.model-group { min-width: 0; }
.src-select {
  width: 7rem;
  max-width: 7rem;
  overflow: hidden;
  text-overflow: ellipsis;
}
.md-label {
  font-size: 12px;
  color: #9aa3ad;
  letter-spacing: 0.4px;
  text-transform: uppercase;
}
.md-select,
.md-input {
  background: #1f242a;
  color: #e3e6ea;
  border: 1px solid #3a4148;
  border-radius: 8px;
  padding: 8px 14px;
  font-size: 14px;
}
.md-select { padding-right: 36px; }
.model-select {
  width: 182px;
  max-width: 18vw;
  overflow: hidden;
  text-overflow: ellipsis;
}
.md-input { min-width: 220px; }
.md-input.find-replace-input { min-width: 0; }
.md-select option { background: #1f242a; color: #e3e6ea; }

.tabs {
  display: inline-flex;
  gap: 4px;
  background: #1f242a;
  border-radius: 999px;
  padding: 4px;
  border: 1px solid #3a4148;
}
.targets-group {
  width: auto;
  max-width: 100%;
  min-width: 0;
  flex: 0 0 auto;
  align-items: stretch;
}
.tgt-select {
  width: auto;
  min-width: 7.5rem;
  max-width: 12rem;
}

.rows {
  padding: 20px 24px 32px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.row {
  display: grid;
  grid-template-columns: 1fr 56px 1fr;
  align-items: stretch;
  gap: 12px;
}
.row.hidden { display: none; }
.row.untranslated .card.src { background: #222830; border-color: #3a424c; }
.row.untranslated .card.tgt.empty-translation,
.row.untranslated .card.tgt.failed-translation {
  background: #2a2624;
  border-color: #4a433c;
  color: #c4b8a8;
}
.filter-checks {
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  align-items: center;
  justify-content: flex-start;
  gap: 14px;
  align-self: flex-end;
  padding-bottom: 2px;
  max-width: none;
}
.filter-check {
  display: inline-flex;
  flex-direction: row;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}
.filter-check .md-label {
  line-height: 1.25;
  max-width: none;
}
.filter-check input { width: 16px; height: 16px; margin: 0; accent-color: #8ab4ff; flex-shrink: 0; }
.modal-actions-stack { flex-direction: column; align-items: stretch; gap: 12px; }
.modal-actions-stack > .modal-actions { width: 100%; }
.row-actions {
  display: flex;
  align-items: center;
  justify-content: center;
}
.card {
  background: #1f242a;
  border: 1px solid #2a3036;
  border-radius: 12px;
  padding: 14px 16px;
  min-height: 72px;
  min-width: 0;
  white-space: pre-wrap;
  overflow-wrap: break-word;
  word-break: break-word;
  outline: none;
  font-size: 14px;
  line-height: 1.5;
}
.card.src { background: #181c20; }
.card.tgt:hover,
.card[contenteditable="true"]:focus { background: #262c33; }
.card[contenteditable="true"]:focus {
  border-color: #8ab4ff;
  box-shadow: 0 0 0 1px #8ab4ff;
}
.card.empty-translation { color: #9aa3ad; font-style: italic; }
.card.failed-translation { color: #c4b8a8; font-style: italic; }

.icon-btn.translate-one .material-symbols-outlined { display: none; }
.icon-btn.translate-one[data-mode="idle"] .ic-arrow { display: inline-block; }
.icon-btn.translate-one[data-mode="queued"] .ic-stop { display: inline-block; opacity: 0.6; }
.icon-btn.translate-one[data-mode="running"] .ic-spin { display: inline-block; }
.icon-btn.translate-one[data-mode="running"]:hover .ic-spin { display: none; }
.icon-btn.translate-one[data-mode="running"]:hover .ic-stop { display: inline-block; color: #ffb4ab; }
.icon-btn.translate-one .ic-spin { animation: spin 1.2s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.batch-progress {
  font-size: 13px;
  color: #9aa3ad;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
  padding: 0 4px;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
}
.modal-backdrop[hidden] { display: none; }
.modal {
  background: #1f242a;
  border: 1px solid #3a4148;
  border-radius: 16px;
  padding: 24px;
  width: 700px;
  max-width: 92vw;
  max-height: 80vh;
  box-shadow: 0 4px 8px 3px rgba(0,0,0,0.15), 0 1px 3px rgba(0,0,0,0.3);
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.modal-title { margin: 0; font-size: 18px; font-weight: 500; }
.modal-title-soft {
  font-size: 15px;
  font-weight: 400;
  color: #b0b8c0;
  letter-spacing: 0.01em;
}
.modal-hint { margin: 0; font-size: 13px; color: #9aa3ad; line-height: 1.5; }
.modal-backdrop-soft { background: rgba(0, 0, 0, 0.32); }
.modal-optional {
  gap: 12px;
  padding: 20px 22px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.12);
}
.md-textarea {
  background: #262c33;
  color: #e3e6ea;
  border: 1px solid #3a4148;
  border-radius: 8px;
  padding: 12px 14px;
  font-size: 14px;
  line-height: 1.5;
  resize: vertical;
  width: 100%;
  min-height: 200px;
  max-height: 60vh;
}
.modal-textarea {
  min-height: 96px;
  background: #23282e;
  border-color: #333a42;
}
.modal-textarea:focus {
  outline: 1px solid rgba(138, 180, 255, 0.25);
  border-color: #4a5560;
}
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; }

@media (max-width: 1100px) {
  .toolbar {
    grid-template-columns: 1fr;
    gap: 10px;
  }
  .toolbar-left,
  .toolbar-right {
    grid-column: 1;
    justify-content: flex-start;
    flex-wrap: wrap;
    align-items: flex-end;
  }
  .model-select { width: min(340px, calc(100vw - 48px)); max-width: 100%; }
  .find-replace-controls { flex-wrap: wrap; }
  .find-replace-input { width: min(160px, calc(50vw - 40px)); max-width: 160px; flex: 0 0 auto; }
}

@media (max-width: 720px) {
  .toolbar { top: 64px; }
  .targets-group { width: 100%; }
  .find-replace-group { width: 100%; }
  .row { grid-template-columns: 1fr; }
  .row-actions { justify-content: flex-start; }
}

/* Make login and dashboard match the old translation tab style. */
body:not(.md) {
  font-family: Roboto, -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  background: #101418;
  color: #e3e6ea;
  font-size: 14px;
}

body:not(.md) .topbar {
  background: #181c20;
  border-bottom: 1px solid #2a3036;
  box-shadow: 0 1px 2px rgba(0,0,0,0.3), 0 1px 3px 1px rgba(0,0,0,0.15);
  backdrop-filter: none;
}

body:not(.md) .logo {
  font-weight: 500;
}

body:not(.md) .brand-mark {
  background: #8ab4ff;
  color: #002e6b;
  border-radius: 999px;
}

body:not(.md) .login-page {
  background: #101418;
}

body:not(.md) .login-panel,
body:not(.md) .main-column,
body:not(.md) .context-panel,
body:not(.md) .context-drawer,
body:not(.md) .drop-zone {
  background: #181c20;
  border-color: #2a3036;
  box-shadow: none;
}

body:not(.md) .lang-chip {
  background: #1f242a;
  border-color: #2a3036;
  color: #e3e6ea;
}

body:not(.md) .lang-chip-remove {
  color: #9aa3ad;
}

body:not(.md) .lang-chip-remove:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #e3e6ea;
}

body:not(.md) .lang-chip-add {
  color: #9aa3ad;
}

body:not(.md) .lang-chip-add:hover,
body:not(.md) .lang-chip-add[aria-expanded="true"] {
  border-color: #8ab4ff;
  color: #8ab4ff;
  background: rgba(138, 180, 255, 0.1);
}

body:not(.md) .lang-catalog-add input.is-suggesting {
  color: #9aa3ad;
}

body:not(.md) .login-panel {
  border-radius: 16px;
}

body:not(.md) h1,
body:not(.md) h2,
body:not(.md) h3,
body:not(.md) .drop-zone .upload-target,
body:not(.md) .doc-main strong {
  color: #e3e6ea;
}

body:not(.md) label,
body:not(.md) .login-panel p,
body:not(.md) .doc-main small,
body:not(.md) .section-head span,
body:not(.md) .empty-state,
body:not(.md) .user-pill {
  color: #9aa3ad;
}

body:not(.md) .ldap-lookup {
  background: #1f242a;
  border-color: #3a4148;
}

body:not(.md) .lookup-name {
  color: #e3e6ea;
}

body:not(.md) .group-chip {
  color: #b8d0ff;
  background: #283544;
}

body:not(.md) .group-chip-muted {
  color: #9aa3ad;
  background: #252b31;
}

body:not(.md) .ldap-lookup-ok {
  border-color: rgba(138, 180, 255, 0.38);
  background: rgba(138, 180, 255, 0.08);
}

body:not(.md) .ldap-lookup-ok .lookup-status,
body:not(.md) .user-groups {
  color: #8ab4ff;
}

body:not(.md) .ldap-lookup-warn {
  border-color: rgba(255, 180, 84, 0.34);
  background: rgba(255, 180, 84, 0.08);
}

body:not(.md) .ldap-lookup-warn .lookup-status {
  color: #ffb454;
}

body:not(.md) input,
body:not(.md) textarea,
body:not(.md) select {
  background: #1f242a;
  color: #e3e6ea;
  border-color: #3a4148;
}

body:not(.md) input:focus,
body:not(.md) textarea:focus,
body:not(.md) select:focus {
  outline: 2px solid #8ab4ff;
  border-color: #8ab4ff;
}

body:not(.md) .button {
  border: 0;
  border-radius: 999px;
  background: #262c33;
  color: #e3e6ea;
  font-weight: 500;
}

body:not(.md) .button.primary {
  background: #8ab4ff;
  color: #002e6b;
}

body:not(.md) .button.subtle,
body:not(.md) .button.ghost {
  background: #283544;
  color: #cfe0f5;
}

body:not(.md) .button.save-context {
  background: #ffffff;
  color: #101418;
  border: 0;
  font-weight: 700;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
}

body:not(.md) .button.save-context:hover {
  background: #f0f2f5;
}

body:not(.md) .system-prompt-toggle {
  color: #8ab4ff;
}

body:not(.md) .context-panel textarea::placeholder {
  color: #5c6773;
}

body:not(.md) .drop-zone {
  border-color: #3a4148;
}

body:not(.md) .drop-zone .upload-hint {
  color: #9aa3ad;
}

body:not(.md) .add-icon {
  background: #283544;
  border-color: #3a4148;
  color: #8ab4ff;
}

body:not(.md) .drop-zone.is-active,
body:not(.md).is-dragging-file .drop-zone {
  border-color: #8ab4ff;
  background: #1f242a;
  box-shadow: 0 0 0 4px rgba(138, 180, 255, 0.14);
}

body:not(.md) .doc-row,
body:not(.md) .empty-state {
  background: #1f242a;
  border-color: #2a3036;
}

body:not(.md) .doc-row:hover {
  background: #262c33;
}

body:not(.md) .doc-icon {
  background: #283544;
  color: #cfe0f5;
}

body:not(.md) .doc-preview {
  color: #9aa3ad;
  background: #181c20;
}

body:not(.md) .doc-meta {
  border-top-color: #2a3036;
  background: #1f242a;
}

body:not(.md) .lang-progress-cell {
  background: #181c20;
  border-color: #2a3036;
}

body:not(.md) .lang-progress-cell .lang-code {
  color: #e3e6ea;
}

body:not(.md) .lang-progress-cell.is-source {
  background: rgba(96, 165, 250, 0.12);
  border-color: rgba(96, 165, 250, 0.28);
}

body:not(.md) .lang-progress-cell.is-source .lang-count {
  color: #93c5fd;
}

body:not(.md) .lang-progress-cell.is-complete {
  background: rgba(52, 211, 153, 0.1);
  border-color: rgba(52, 211, 153, 0.28);
}

body:not(.md) .lang-progress-cell.is-complete .lang-count {
  color: #6ee7b7;
}

body:not(.md) .upload-group-select {
  background: #1f242a;
  color: #e3e6ea;
  border-color: #3a4148;
}

body:not(.md) .upload-group-field {
  background: #181c20;
  border-bottom-color: #2a3036;
}

body:not(.md) .upload-group-field > label {
  color: #9aa3ad;
}

body:not(.md) .doc-group-chip {
  color: #9ee6c5;
  background: rgba(48, 209, 136, 0.14);
}

body:not(.md) .context-drawer summary {
  color: #e3e6ea;
}

body:not(.md) .context-drawer .context-panel {
  border-top-color: #2a3036;
}

body:not(.md) .flash {
  background: #1f242a;
  border-color: #3a4148;
  color: #e3e6ea;
}

body:not(.md) .flash.error {
  background: color-mix(in srgb, #ffb4ab 14%, #1f242a);
  border-color: #ffb4ab;
  color: #ffb4ab;
}

body:not(.md) .flash.warning {
  background: color-mix(in srgb, #e6c35c 14%, #1f242a);
  border-color: #e6c35c;
  color: #f0d78a;
}

body:not(.md) .flash.success {
  background: color-mix(in srgb, #8ab4ff 12%, #1f242a);
  border-color: #8ab4ff;
  color: #d6e3ff;
}
