/* =========================================================================
   HappyTrad – design system
   ========================================================================= */

:root {
  --font: "Inter", "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  --mono: "JetBrains Mono", "Cascadia Code", "Consolas", ui-monospace, monospace;

  --bg: #f5f6fa;
  --bg-grad: radial-gradient(1200px 600px at 100% -10%, rgba(99, 102, 241, .08), transparent 60%),
             radial-gradient(900px 500px at -10% 110%, rgba(139, 92, 246, .06), transparent 60%);
  --surface: #ffffff;
  --surface-2: #f1f3f8;
  --surface-3: #e9ecf4;
  --border: #e3e6ee;
  --border-strong: #cfd4e0;
  --text: #0f172a;
  --text-2: #334155;
  --muted: #64748b;
  --accent: #6366f1;
  --accent-2: #8b5cf6;
  --accent-soft: rgba(99, 102, 241, .1);
  --accent-text: #4f46e5;
  --on-accent: #fff;
  --ring: 0 0 0 3px rgba(99, 102, 241, .25);

  --st-untranslated: #ef4444;
  --st-translated: #3b82f6;
  --st-review: #f59e0b;
  --st-validated: #10b981;
  --danger: #ef4444;
  --warning: #f59e0b;
  --success: #10b981;
  --info: #0ea5e9;

  --shadow-sm: 0 1px 2px rgba(15, 23, 42, .05);
  --shadow: 0 1px 3px rgba(15, 23, 42, .06), 0 6px 24px -8px rgba(15, 23, 42, .1);
  --shadow-lg: 0 24px 60px -12px rgba(15, 23, 42, .25);
  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 18px;
  --sidebar-w: 256px;
  --topbar-h: 64px;
  color-scheme: light;
}

:root[data-theme="dark"] {
  --bg: #0a0c13;
  --bg-grad: radial-gradient(1200px 600px at 100% -10%, rgba(99, 102, 241, .14), transparent 60%),
             radial-gradient(900px 500px at -10% 110%, rgba(139, 92, 246, .1), transparent 60%);
  --surface: #11141f;
  --surface-2: #171b29;
  --surface-3: #1f2435;
  --border: #232a3c;
  --border-strong: #323a50;
  --text: #e7eaf3;
  --text-2: #c3c9d8;
  --muted: #8a93aa;
  --accent: #818cf8;
  --accent-2: #a78bfa;
  --accent-soft: rgba(129, 140, 248, .14);
  --accent-text: #a5b4fc;
  --ring: 0 0 0 3px rgba(129, 140, 248, .35);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
  --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 30px -10px rgba(0, 0, 0, .6);
  --shadow-lg: 0 30px 70px -10px rgba(0, 0, 0, .7);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg-grad), var(--bg);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  font-feature-settings: "cv11", "ss01";
}
a { color: var(--accent-text); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0; line-height: 1.25; letter-spacing: -.01em; }
h1 { font-size: 24px; font-weight: 700; }
h2 { font-size: 18px; font-weight: 650; }
h3 { font-size: 15px; font-weight: 600; }
p { margin: 0 0 .75em; }
code, .mono { font-family: var(--mono); font-size: .92em; }
::selection { background: rgba(99, 102, 241, .25); }
.icon { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.icon-sm { width: 15px; height: 15px; }
.icon-lg { width: 22px; height: 22px; }

/* Scrollbars */
* { scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 10px; border: 3px solid transparent; background-clip: content-box; }

/* ------------------------------------------------------------------ Shell */
.shell { display: grid; grid-template-columns: var(--sidebar-w) 1fr; min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column;
  background: color-mix(in srgb, var(--surface) 85%, transparent);
  backdrop-filter: blur(16px);
  border-right: 1px solid var(--border);
  padding: 18px 14px;
  z-index: 40;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 18px; font-weight: 750; font-size: 17px; letter-spacing: -.02em; color: var(--text); }
.brand:hover { text-decoration: none; }
.brand-logo {
  width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 6px 18px -6px rgba(99, 102, 241, .7);
}
.brand small { display: block; font-size: 11px; font-weight: 500; color: var(--muted); letter-spacing: 0; }
.nav { display: flex; flex-direction: column; gap: 2px; overflow-y: auto; flex: 1; margin: 0 -6px; padding: 0 6px; }
.nav-label { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); padding: 16px 10px 6px; }
.nav a {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 9px;
  color: var(--text-2); font-weight: 500; transition: background .15s, color .15s;
}
.nav a:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.nav a.active { background: var(--accent-soft); color: var(--accent-text); }
.nav a .dot { width: 9px; height: 9px; border-radius: 3px; flex: none; margin: 0 4px; }
.nav a .nav-meta { margin-left: auto; font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }
.sidebar-foot { border-top: 1px solid var(--border); padding-top: 12px; margin-top: 8px; display: flex; flex-direction: column; gap: 8px; }
.user-chip { display: flex; align-items: center; gap: 10px; padding: 6px 8px; border-radius: 10px; color: var(--text); }
.user-chip:hover { background: var(--surface-2); text-decoration: none; }
.avatar {
  width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; flex: none;
  font-size: 12px; font-weight: 700; color: #fff; background: linear-gradient(135deg, #f472b6, #8b5cf6);
}
.user-chip .who { min-width: 0; line-height: 1.2; }
.user-chip .who b { display: block; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-chip .who span { font-size: 11px; color: var(--muted); }
.foot-actions { display: flex; gap: 6px; }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 30; height: var(--topbar-h);
  display: flex; align-items: center; gap: 14px; padding: 0 28px;
  background: color-mix(in srgb, var(--bg) 75%, transparent);
  backdrop-filter: blur(14px) saturate(1.4);
  border-bottom: 1px solid color-mix(in srgb, var(--border) 60%, transparent);
}
.topbar .title { display: flex; flex-direction: column; min-width: 0; }
.topbar .title h1 { font-size: 18px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.crumbs { font-size: 12px; color: var(--muted); display: flex; gap: 6px; align-items: center; }
.crumbs a { color: var(--muted); }
.topbar .actions { margin-left: auto; display: flex; gap: 8px; align-items: center; }
.menu-btn { display: none; }
.content { padding: 28px; max-width: 1400px; width: 100%; margin: 0 auto; }
.backdrop { display: none; }

/* ------------------------------------------------------------------ Controls */
.btn {
  --b-bg: var(--surface); --b-fg: var(--text); --b-bd: var(--border);
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 36px; padding: 0 14px; border-radius: 10px; border: 1px solid var(--b-bd);
  background: var(--b-bg); color: var(--b-fg); font: inherit; font-weight: 550; font-size: 13.5px;
  cursor: pointer; white-space: nowrap; user-select: none;
  transition: transform .06s, background .15s, border-color .15s, box-shadow .15s, opacity .15s;
  box-shadow: var(--shadow-sm);
}
.btn:hover { background: var(--surface-2); text-decoration: none; border-color: var(--border-strong); }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: none; box-shadow: var(--ring); }
.btn:disabled, .btn.disabled { opacity: .5; pointer-events: none; }
.btn-primary {
  --b-bg: linear-gradient(135deg, var(--accent), var(--accent-2)); --b-fg: var(--on-accent); --b-bd: transparent;
  background: var(--b-bg); box-shadow: 0 6px 18px -8px rgba(99, 102, 241, .8);
}
.btn-primary:hover { background: var(--b-bg); filter: brightness(1.07); border-color: transparent; }
.btn-success { --b-bg: var(--success); --b-fg: #fff; --b-bd: transparent; }
.btn-success:hover { background: var(--success); filter: brightness(1.07); }
.btn-danger { --b-fg: var(--danger); }
.btn-danger:hover { background: rgba(239, 68, 68, .08); border-color: rgba(239, 68, 68, .4); }
.btn-ghost { --b-bg: transparent; --b-bd: transparent; box-shadow: none; color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-2); border-color: transparent; }
.btn-sm { height: 30px; padding: 0 10px; font-size: 12.5px; border-radius: 8px; gap: 6px; }
.btn-icon { width: 36px; padding: 0; }
.btn-sm.btn-icon { width: 30px; }
.btn .kbd { margin-left: 2px; }

.input, .select, .textarea {
  width: 100%; height: 38px; padding: 0 12px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); font: inherit; transition: border-color .15s, box-shadow .15s;
}
.textarea { height: auto; min-height: 90px; padding: 10px 12px; resize: vertical; line-height: 1.5; }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--accent); box-shadow: var(--ring); }
.select { appearance: none; padding-right: 32px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center; }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.field label, .label { font-size: 13px; font-weight: 600; color: var(--text-2); }
.field .hint { font-size: 12px; color: var(--muted); }
.field-error, .validation-summary-errors { color: var(--danger); font-size: 12.5px; }
.validation-summary-errors ul { margin: 0; padding-left: 18px; }
.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-weight: 500; }
.check input { width: 16px; height: 16px; accent-color: var(--accent); }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 18px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0 18px; }
.input-icon { position: relative; }
.input-icon .icon { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.input-icon .input { padding-left: 36px; }

.kbd {
  display: inline-flex; align-items: center; height: 20px; padding: 0 6px; border-radius: 5px; font: 600 11px var(--mono);
  color: var(--muted); background: var(--surface-2); border: 1px solid var(--border); border-bottom-width: 2px;
}
.btn-primary .kbd { background: rgba(255, 255, 255, .18); border-color: rgba(255, 255, 255, .25); color: #fff; }

/* ------------------------------------------------------------------ Cards */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow); }
.card-pad { padding: 22px; }
.card-head { display: flex; align-items: center; gap: 12px; padding: 18px 22px; border-bottom: 1px solid var(--border); }
.card-head .sub { color: var(--muted); font-size: 12.5px; }
.card-head .right { margin-left: auto; display: flex; gap: 8px; }
.card-body { padding: 22px; }
.stack { display: flex; flex-direction: column; gap: 22px; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.tnum { font-variant-numeric: tabular-nums; }
.page-head { display: flex; align-items: flex-end; gap: 16px; margin-bottom: 24px; flex-wrap: wrap; }
.page-head p { color: var(--muted); margin: 6px 0 0; }
.page-head .actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }

/* Stat tiles */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 24px; }
.stat { padding: 18px 20px; position: relative; overflow: hidden; }
.stat .label { font-size: 12.5px; font-weight: 550; color: var(--muted); display: flex; align-items: center; gap: 8px; }
.stat .value { font-size: 28px; font-weight: 750; letter-spacing: -.03em; margin-top: 6px; font-variant-numeric: tabular-nums; }
.stat .trend { font-size: 12px; color: var(--muted); }
.stat .ico { position: absolute; right: 16px; top: 16px; width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center; }

/* Project cards */
.projects { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 18px; }
.project-card {
  display: flex; flex-direction: column; gap: 16px; padding: 20px; color: var(--text);
  transition: transform .18s, box-shadow .18s, border-color .18s; position: relative; overflow: hidden;
}
.project-card::before { content: ""; position: absolute; inset: 0 0 auto 0; height: 3px; background: var(--pc, var(--accent)); }
.project-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); text-decoration: none; border-color: var(--border-strong); }
.project-card .top { display: flex; align-items: center; gap: 12px; }
.project-card .mark {
  width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center; font-weight: 800; font-size: 16px; color: #fff;
  background: var(--pc, var(--accent)); box-shadow: 0 8px 20px -10px var(--pc, var(--accent));
}
.project-card .meta { font-size: 12px; color: var(--muted); display: flex; gap: 12px; flex-wrap: wrap; }
.project-card .meta span { display: inline-flex; gap: 5px; align-items: center; }
.ring { --p: 0; --c: var(--accent); width: 56px; height: 56px; border-radius: 50%; margin-left: auto; flex: none;
  background: conic-gradient(var(--c) calc(var(--p) * 1%), var(--surface-3) 0); display: grid; place-items: center; }
.ring::after { content: attr(data-label); width: 44px; height: 44px; border-radius: 50%; background: var(--surface); display: grid; place-items: center; font-size: 12px; font-weight: 700; }

/* Progress */
.progress { display: flex; height: 8px; border-radius: 99px; overflow: hidden; background: var(--surface-3); }
.progress > span { display: block; height: 100%; transition: width .4s; }
.progress.thin { height: 5px; }
.legend { display: flex; flex-wrap: wrap; gap: 14px; font-size: 12px; color: var(--muted); }
.legend i { display: inline-block; width: 8px; height: 8px; border-radius: 3px; margin-right: 6px; vertical-align: 0; }
.bg-untranslated { background: var(--st-untranslated); }
.bg-translated { background: var(--st-translated); }
.bg-review { background: var(--st-review); }
.bg-validated { background: var(--st-validated); }

/* Badges / chips */
.badge {
  display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 8px; border-radius: 99px;
  font-size: 11.5px; font-weight: 600; background: var(--surface-2); color: var(--text-2); border: 1px solid var(--border); white-space: nowrap;
}
.badge.accent { background: var(--accent-soft); color: var(--accent-text); border-color: transparent; }
.badge.success { background: rgba(16, 185, 129, .12); color: #059669; border-color: transparent; }
.badge.warning { background: rgba(245, 158, 11, .14); color: #b45309; border-color: transparent; }
.badge.danger { background: rgba(239, 68, 68, .12); color: #dc2626; border-color: transparent; }
.badge.info { background: rgba(14, 165, 233, .12); color: #0284c7; border-color: transparent; }
:root[data-theme="dark"] .badge.success { color: #34d399; }
:root[data-theme="dark"] .badge.warning { color: #fbbf24; }
:root[data-theme="dark"] .badge.danger { color: #f87171; }
:root[data-theme="dark"] .badge.info { color: #38bdf8; }

/* Tables */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: separate; border-spacing: 0; }
.table th { text-align: left; font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; padding: 10px 16px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.table td { padding: 12px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tr:last-child td { border-bottom: none; }
.table tbody tr { transition: background .12s; }
.table tbody tr:hover { background: var(--surface-2); }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }

/* Alerts */
.alert { display: flex; gap: 12px; align-items: flex-start; padding: 12px 16px; border-radius: 12px; border: 1px solid var(--border); background: var(--surface-2); margin-bottom: 18px; }
.alert.success { background: rgba(16, 185, 129, .08); border-color: rgba(16, 185, 129, .3); }
.alert.danger { background: rgba(239, 68, 68, .08); border-color: rgba(239, 68, 68, .3); }
.alert.warning { background: rgba(245, 158, 11, .08); border-color: rgba(245, 158, 11, .3); }

.empty { text-align: center; padding: 56px 20px; color: var(--muted); }
.empty > .icon { width: 44px; height: 44px; stroke-width: 1.5; color: var(--border-strong); margin-bottom: 12px; }
.empty h3 { color: var(--text); margin-bottom: 6px; }

/* Activity */
.feed { list-style: none; margin: 0; padding: 0; }
.feed li { display: flex; gap: 12px; padding: 12px 0; border-bottom: 1px dashed var(--border); }
.feed li:last-child { border-bottom: none; }
.feed .avatar { width: 28px; height: 28px; font-size: 11px; }
.feed .txt { min-width: 0; flex: 1; font-size: 13px; }
.feed .txt .snip { color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block; }
.feed time { font-size: 11.5px; color: var(--muted); white-space: nowrap; }

/* Toasts */
.toasts { position: fixed; right: 20px; bottom: 20px; display: flex; flex-direction: column; gap: 10px; z-index: 1000; pointer-events: none; }
.toast {
  pointer-events: auto; min-width: 260px; max-width: 420px; display: flex; gap: 10px; align-items: flex-start;
  padding: 12px 14px; border-radius: 12px; background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-lg);
  animation: toast-in .25s cubic-bezier(.2, .9, .3, 1.2);
}
.toast.success .icon { color: var(--success); }
.toast.error .icon { color: var(--danger); }
.toast.info .icon { color: var(--accent); }
.toast.out { animation: toast-out .2s forwards; }
@keyframes toast-in { from { opacity: 0; transform: translateY(10px) scale(.97); } }
@keyframes toast-out { to { opacity: 0; transform: translateX(20px); } }

/* Modals */
.modal { position: fixed; inset: 0; z-index: 900; display: none; align-items: center; justify-content: center; padding: 20px; }
.modal.open { display: flex; }
.modal::before { content: ""; position: absolute; inset: 0; background: rgba(10, 12, 20, .45); backdrop-filter: blur(4px); animation: fade .2s; }
.modal-box { position: relative; width: 100%; max-width: 520px; max-height: calc(100vh - 40px); overflow: auto; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); animation: pop .22s cubic-bezier(.2, .9, .3, 1.15); }
.modal-box.wide { max-width: 720px; }
.modal-head { display: flex; align-items: center; gap: 10px; padding: 18px 22px; border-bottom: 1px solid var(--border); }
.modal-head .btn { margin-left: auto; }
.modal-body { padding: 22px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 22px; border-top: 1px solid var(--border); background: var(--surface-2); border-radius: 0 0 var(--radius-lg) var(--radius-lg); }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(.98); } }

.spinner { width: 16px; height: 16px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; animation: spin .7s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }
.skeleton { background: linear-gradient(90deg, var(--surface-2), var(--surface-3), var(--surface-2)); background-size: 200% 100%; animation: shimmer 1.2s infinite; border-radius: 6px; }
@keyframes shimmer { to { background-position: -200% 0; } }

/* ------------------------------------------------------------------ Login */
.auth { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; }
.auth-hero {
  position: relative; overflow: hidden; padding: 56px; color: #fff; display: flex; flex-direction: column; justify-content: space-between;
  background: radial-gradient(800px 500px at 20% 10%, rgba(255, 255, 255, .18), transparent 60%),
              linear-gradient(140deg, #4338ca 0%, #6d28d9 55%, #a21caf 100%);
}
.auth-hero::after {
  content: ""; position: absolute; inset: 0; opacity: .25;
  background-image: linear-gradient(rgba(255,255,255,.12) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.12) 1px, transparent 1px);
  background-size: 44px 44px; mask-image: radial-gradient(circle at 70% 60%, #000, transparent 70%);
}
.auth-hero > * { position: relative; z-index: 1; }
.auth-hero h2 { font-size: 40px; font-weight: 800; letter-spacing: -.03em; line-height: 1.1; max-width: 520px; }
.auth-hero p { opacity: .85; font-size: 16px; max-width: 460px; margin-top: 16px; }
.auth-demo { margin-top: 36px; display: flex; flex-direction: column; gap: 10px; max-width: 460px; }
.auth-demo .pair { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.auth-demo .pair div { background: rgba(255, 255, 255, .12); border: 1px solid rgba(255, 255, 255, .2); border-radius: 12px; padding: 10px 14px; backdrop-filter: blur(8px); font-size: 13.5px; }
.auth-demo .pair small { display: block; font-size: 10.5px; opacity: .7; font-weight: 700; letter-spacing: .08em; }
.auth-form { display: grid; place-items: center; padding: 40px 24px; }
.auth-form .box { width: 100%; max-width: 380px; }
.auth-form h1 { font-size: 28px; margin: 28px 0 6px; }

/* ------------------------------------------------------------------ Editor */
body.editor-mode .content { max-width: none; padding: 0; flex: 1; min-height: 0; }
body.editor-mode .main { height: 100vh; }
.editor { display: grid; grid-template-columns: 280px minmax(0, 1fr) 380px; height: calc(100vh - var(--topbar-h)); min-height: 0; }
.ed-files { border-right: 1px solid var(--border); display: flex; flex-direction: column; min-height: 0; background: color-mix(in srgb, var(--surface) 60%, transparent); }
.ed-files .head { padding: 14px 14px 10px; display: flex; flex-direction: column; gap: 10px; }
.ed-files .list { overflow-y: auto; padding: 0 8px 12px; flex: 1; }
.file-item { display: block; width: 100%; text-align: left; border: 0; background: none; font: inherit; color: var(--text-2); padding: 9px 10px; border-radius: 10px; cursor: pointer; }
.file-item:hover { background: var(--surface-2); }
.file-item.active { background: var(--accent-soft); color: var(--accent-text); }
.file-item .n { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 13px; }
.file-item .n span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-item .n em { margin-left: auto; font-style: normal; font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }
.file-item .d { font-size: 11px; color: var(--muted); margin: 2px 0 6px 26px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-item .progress { margin-left: 26px; }

.ed-main { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.ed-toolbar { display: flex; flex-direction: column; gap: 10px; padding: 12px 18px; border-bottom: 1px solid var(--border); background: color-mix(in srgb, var(--surface) 70%, transparent); }
.ed-toolbar .row1 { display: flex; gap: 10px; align-items: center; }
.ed-toolbar .search { flex: 1; min-width: 160px; }
.chips { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  display: inline-flex; align-items: center; gap: 7px; height: 30px; padding: 0 11px; border-radius: 99px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text-2); font: inherit; font-size: 12.5px; font-weight: 550; cursor: pointer; white-space: nowrap; transition: all .15s;
}
.chip:hover { border-color: var(--border-strong); }
.chip.active { background: var(--accent); color: #fff; border-color: var(--accent); box-shadow: 0 4px 14px -6px var(--accent); }
.chip.active b { opacity: .85; }
.chip i { width: 8px; height: 8px; border-radius: 3px; }
.chip b { font-weight: 650; font-variant-numeric: tabular-nums; opacity: .7; }

.ed-list { flex: 1; overflow-y: auto; padding: 10px 18px 80px; min-height: 0; }
.seg {
  display: grid; grid-template-columns: 4px minmax(0, 1fr) minmax(0, 1fr); gap: 0; margin-bottom: 6px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px; cursor: pointer; overflow: hidden;
  transition: border-color .12s, box-shadow .12s;
}
.seg:hover { border-color: var(--border-strong); }
.seg.active { border-color: var(--accent); box-shadow: var(--ring); cursor: default; }
.seg .bar { background: var(--st-untranslated); }
.seg[data-status="Translated"] .bar { background: var(--st-translated); }
.seg[data-status="NeedsReview"] .bar { background: var(--st-review); }
.seg[data-status="Validated"] .bar { background: var(--st-validated); }
.seg .src, .seg .tgt { padding: 10px 14px; min-width: 0; }
.seg .tgt { border-left: 1px solid var(--border); background: color-mix(in srgb, var(--surface-2) 45%, transparent); position: relative; }
.seg .key { display: flex; align-items: center; gap: 6px; font: 500 11px var(--mono); color: var(--muted); margin-bottom: 4px; min-width: 0; }
.seg .key span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.seg .txt { white-space: pre-wrap; word-break: break-word; font-size: 14px; line-height: 1.55; }
.seg .txt.placeholder-empty { color: var(--muted); font-style: italic; }
.seg .meta { display: flex; gap: 6px; align-items: center; margin-bottom: 4px; min-height: 18px; }
.seg .meta .state { font-size: 11px; font-weight: 600; color: var(--muted); }
.seg .flags { margin-left: auto; display: flex; gap: 4px; }
.flag { width: 18px; height: 18px; display: grid; place-items: center; border-radius: 5px; }
.flag .icon { width: 12px; height: 12px; }
.flag.dirty { background: var(--accent-soft); color: var(--accent-text); }
.flag.qa { background: rgba(239, 68, 68, .12); color: var(--danger); }
.flag.changed { background: rgba(245, 158, 11, .14); color: var(--warning); }
.ph { background: rgba(14, 165, 233, .14); color: #0369a1; border-radius: 4px; padding: 0 3px; font-family: var(--mono); font-size: .9em; }
:root[data-theme="dark"] .ph { color: #7dd3fc; }
.ws { color: var(--accent); opacity: .6; }
.gl { border-bottom: 2px dotted var(--accent-2); }
mark { background: rgba(250, 204, 21, .4); color: inherit; border-radius: 3px; padding: 0 1px; }

.seg-editor textarea {
  width: 100%; min-height: 64px; border: 0; outline: none; resize: none; background: transparent; color: var(--text);
  font: inherit; font-size: 14px; line-height: 1.55; padding: 0; overflow: hidden;
}
.seg-actions { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; margin-top: 8px; padding-top: 8px; border-top: 1px dashed var(--border); }
.seg-actions .qa-inline { font-size: 12px; display: flex; gap: 6px; flex-wrap: wrap; margin-right: auto; }
.list-foot { text-align: center; padding: 16px; color: var(--muted); font-size: 12.5px; }

.ed-side { border-left: 1px solid var(--border); overflow-y: auto; min-height: 0; background: color-mix(in srgb, var(--surface) 60%, transparent); }
.ed-side .close-side { display: none; }
.panel { padding: 16px 18px; border-bottom: 1px solid var(--border); }
.panel h4 { font-size: 11.5px; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); font-weight: 650; margin-bottom: 10px; display: flex; align-items: center; gap: 8px; }
.panel h4 .badge { margin-left: auto; text-transform: none; letter-spacing: 0; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 12px; font-size: 12.5px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; word-break: break-all; }
.comment-box { font-size: 12.5px; background: var(--surface-2); border-radius: 10px; padding: 8px 10px; color: var(--text-2); white-space: pre-wrap; word-break: break-word; }
.tm-item { display: block; width: 100%; text-align: left; font: inherit; color: inherit; border: 1px solid var(--border); background: var(--surface); border-radius: 12px; padding: 10px 12px; margin-bottom: 8px; cursor: pointer; transition: border-color .12s, transform .1s; }
.tm-item:hover { border-color: var(--accent); }
.tm-item .top { display: flex; gap: 8px; align-items: center; margin-bottom: 6px; }
.tm-item .score { font-weight: 750; font-size: 12px; padding: 1px 7px; border-radius: 6px; color: #fff; background: var(--st-validated); }
.tm-item .score.fuzzy { background: var(--st-review); }
.tm-item .score.mt { background: var(--accent); }
.tm-item .from { font-size: 11px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }
.tm-item .s { font-size: 12.5px; color: var(--muted); margin-bottom: 4px; }
.tm-item .t { font-size: 13.5px; }
.diff del { background: rgba(239, 68, 68, .16); color: #b91c1c; text-decoration: line-through; border-radius: 3px; }
.diff ins { background: rgba(16, 185, 129, .18); color: #047857; text-decoration: none; border-radius: 3px; }
:root[data-theme="dark"] .diff del { color: #fca5a5; }
:root[data-theme="dark"] .diff ins { color: #6ee7b7; }
.qa-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.qa-list li { display: flex; gap: 8px; font-size: 12.5px; align-items: flex-start; }
.qa-list .icon { width: 15px; height: 15px; margin-top: 2px; }
.qa-list .error .icon { color: var(--danger); }
.qa-list .warning .icon { color: var(--warning); }
.qa-list .info .icon { color: var(--info); }
.hist { list-style: none; margin: 0; padding: 0; }
.hist li { position: relative; padding: 0 0 12px 18px; font-size: 12.5px; }
.hist li::before { content: ""; position: absolute; left: 4px; top: 6px; width: 7px; height: 7px; border-radius: 50%; background: var(--accent); }
.hist li::after { content: ""; position: absolute; left: 7px; top: 16px; bottom: 0; width: 1px; background: var(--border); }
.hist li:last-child::after { display: none; }
.hist .t { color: var(--text-2); white-space: pre-wrap; word-break: break-word; }

.ed-status { display: flex; gap: 16px; align-items: center; padding: 8px 18px; border-top: 1px solid var(--border); font-size: 12px; color: var(--muted); background: color-mix(in srgb, var(--surface) 70%, transparent); }
.ed-status .progress { flex: 1; max-width: 280px; }
.shortcuts { display: grid; grid-template-columns: 1fr auto; gap: 10px 20px; font-size: 13.5px; align-items: center; }
.shortcuts > span:nth-child(even) { display: flex; gap: 4px; justify-content: flex-end; }

/* ------------------------------------------------------------------ Responsive */
@media (max-width: 1280px) {
  .editor { grid-template-columns: 250px minmax(0, 1fr) 330px; }
}
@media (max-width: 1100px) {
  .stats { grid-template-columns: repeat(2, 1fr); }
  .editor { grid-template-columns: 240px minmax(0, 1fr); }
  .ed-side {
    position: fixed; right: 0; top: 0; bottom: 0; width: min(400px, 92vw); z-index: 60; background: var(--surface);
    transform: translateX(100%); transition: transform .25s cubic-bezier(.2, .8, .2, 1); box-shadow: var(--shadow-lg);
  }
  .ed-side.open { transform: none; }
  .ed-side .close-side { display: inline-flex; }
  .side-toggle { display: inline-flex !important; }
}
@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; width: 280px; transform: translateX(-100%); transition: transform .25s cubic-bezier(.2, .8, .2, 1); background: var(--surface); box-shadow: var(--shadow-lg); }
  body.nav-open .sidebar { transform: none; }
  body.nav-open .backdrop, body.side-open .backdrop { display: block; position: fixed; inset: 0; background: rgba(10, 12, 20, .4); z-index: 35; backdrop-filter: blur(2px); }
  body.side-open .backdrop { z-index: 55; }
  .menu-btn { display: inline-flex; }
  .topbar { padding: 0 16px; }
  .content { padding: 18px 16px; }
  .auth { grid-template-columns: 1fr; }
  .auth-hero { display: none; }
  .editor { grid-template-columns: 1fr; }
  .ed-files { display: none; }
  .file-select { display: block !important; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .stats { grid-template-columns: 1fr 1fr; gap: 10px; }
  .stat .value { font-size: 22px; }
  .stat .ico { display: none; }
  .projects { grid-template-columns: 1fr; }
  .seg { grid-template-columns: 4px minmax(0, 1fr); }
  .seg .tgt { grid-column: 2; border-left: 0; border-top: 1px solid var(--border); }
  .ed-list { padding: 8px 10px 80px; }
  .ed-toolbar { padding: 10px; }
  .topbar .actions .btn .lbl { display: none; }
  .hide-sm { display: none !important; }
  .crumbs { display: none; }
  .page-head .actions { margin-left: 0; }
}
.file-select { display: none; }
.side-toggle { display: none !important; }
