/* translate - two themes via CSS variables, no external fonts (the server may live without internet). */
:root {
  --bg: #0b0d12; --panel: #12151c; --panel2: #1a1e28; --border: #262b38; --border2: #323a4c;
  --text: #e7eaf1; --muted: #8a93a8; --accent: #4c8dff; --accent2: #6ea1ff; --ok: #19b982; --warn: #f2b84b; --crit: #f0506e;
  --shadow: 0 20px 60px rgba(0, 0, 0, .55); --radius: 12px; --fs: 15px;
  color-scheme: dark;
}
[data-theme="light"] {
  --bg: #f3f5f9; --panel: #ffffff; --panel2: #f0f2f7; --border: #e1e5ee; --border2: #cfd5e2;
  --text: #171b26; --muted: #66708a; --accent: #2f6fe8; --accent2: #4c8dff; --shadow: 0 20px 60px rgba(20, 30, 60, .15);
  color-scheme: light;
}
[data-font="s"] { --fs: 14px; } [data-font="m"] { --fs: 15px; } [data-font="l"] { --fs: 17px; } [data-font="xl"] { --fs: 20px; }

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg); color: var(--text);
  font: 15px/1.5 Inter, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  display: flex; flex-direction: column; -webkit-font-smoothing: antialiased;
}
#app { display: flex; flex-direction: column; height: 100%; min-height: 0; }
#app[hidden] { display: none; }
.muted { color: var(--muted); } .small { font-size: 12px; } .grow { flex: 1; } .mono { font-variant-numeric: tabular-nums; }
.error { color: var(--crit); min-height: 1.2em; font-size: 13px; }
kbd { font: 11px/1 ui-monospace, Menlo, Consolas, monospace; padding: 2px 5px; border-radius: 5px; background: rgba(255, 255, 255, .18); margin-left: 4px; }
[data-theme="light"] kbd { background: rgba(255, 255, 255, .35); }

/* ------------------------------------------------------------ controls */
button, select, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 1px solid var(--border); background: var(--panel2); color: var(--text); border-radius: 9px; padding: 8px 14px; transition: background .15s, border-color .15s, transform .05s; }
button:hover { border-color: var(--border2); background: var(--panel); }
button:active { transform: translateY(1px); }
button:disabled { opacity: .5; cursor: default; transform: none; }
button.primary { background: linear-gradient(180deg, var(--accent2), var(--accent)); border-color: transparent; color: #fff; font-weight: 600; box-shadow: 0 6px 18px rgba(76, 141, 255, .28); }
button.primary:hover { filter: brightness(1.06); }
button.ghost { background: transparent; }
button.small { padding: 4px 10px; font-size: 12px; }
button.wide { width: 100%; padding: 11px; }
.icon { width: 34px; height: 34px; padding: 0; display: inline-grid; place-items: center; background: transparent; border: 1px solid transparent; border-radius: 9px; color: var(--muted); cursor: pointer; transition: background .15s, border-color .15s; }
.icon:hover { color: var(--text); background: var(--panel2); border-color: var(--border); text-decoration: none; }
.icon[hidden] { display: none; }
.icon svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
button.icon.eye { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); width: 30px; height: 30px; }
button.icon.eye::before { content: ""; width: 16px; height: 16px; border: 1.9px solid currentColor; border-radius: 75% 15%; transform: rotate(45deg); }
button.icon.eye.on::before { background: currentColor; }
select, input[type="password"], input[type="text"] { padding: 8px 12px; border-radius: 9px; border: 1px solid var(--border); background: var(--panel2); outline: none; }
select:focus, input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(76, 141, 255, .18); }
select { appearance: none; padding-right: 30px; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 15px) 50%, calc(100% - 10px) 50%; background-size: 5px 5px; background-repeat: no-repeat; cursor: pointer; }
.check { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); cursor: pointer; }
input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--accent); }

/* ------------------------------------------------------------ login gate */
.gate { flex: 1; display: grid; place-items: center; padding: 24px; background: radial-gradient(1200px 600px at 50% -10%, rgba(76, 141, 255, .18), transparent 60%), var(--bg); }
.gate[hidden] { display: none; }
.card { width: min(400px, 100%); background: var(--panel); border: 1px solid var(--border); border-radius: 18px; padding: 32px 28px 22px; box-shadow: var(--shadow); text-align: center; animation: rise .35s ease-out; }
@keyframes rise { from { opacity: 0; transform: translateY(12px); } }
.card h1 { margin: 14px 0 18px; font-size: 24px; letter-spacing: -.01em; }
.card p { margin: 0 0 22px; font-size: 14px; }
.card form { display: grid; gap: 12px; text-align: left; margin-top: 16px; }
.card form[hidden] { display: none; }
.card .hint { margin: 2px 0 0; text-align: center; line-height: 1.45; }
.field { position: relative; display: block; }
.field input { width: 100%; padding: 11px 40px 11px 12px; font-size: 15px; }
.seg.wide { display: flex; width: 100%; } .seg.wide button { flex: 1; }
.captcha { display: grid; grid-template-columns: 1fr 34px; gap: 8px 10px; align-items: center; }
.captcha img { width: 100%; height: auto; border-radius: 9px; border: 1px solid var(--border); background: #eef1f6; display: block; }
.captcha input { grid-column: 1 / -1; width: 100%; padding: 11px 12px; font-size: 15px; letter-spacing: .12em; text-transform: uppercase; }
.pending-user { margin: 6px 0 18px; font-size: 14px; }
.row-btns { display: flex; gap: 10px; justify-content: center; }
.tag.neutral { background: var(--panel2); color: var(--muted); border-color: var(--border); }
.tag.accent { background: rgba(76, 141, 255, .15); color: var(--accent2); border-color: rgba(76, 141, 255, .35); }
.tag.warn { background: rgba(242, 184, 75, .15); color: var(--warn); border-color: rgba(242, 184, 75, .35); }
.tag.crit { background: rgba(240, 80, 110, .15); color: var(--crit); border-color: rgba(240, 80, 110, .35); }
button.danger { color: var(--crit); }
button.danger:hover { border-color: var(--crit); }

/* ------------------------------------------------------------ flags + language picker */
img.fl { width: 22px; height: 16px; border-radius: 3px; object-fit: cover; box-shadow: 0 0 0 1px rgba(0, 0, 0, .18); flex: none; }
svg.fl.globe { width: 18px; height: 18px; fill: none; stroke: var(--muted); stroke-width: 1.8; flex: none; }
.lp { position: relative; min-width: 0; }
.lp-btn { display: inline-flex; align-items: center; gap: 9px; max-width: 280px; padding: 6px 30px 6px 10px; border-radius: 9px; border: 1px solid var(--border); background: var(--panel2); position: relative; text-align: left; }
.lp-btn .lp-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lp-btn .lp-caret { position: absolute; right: 11px; top: 50%; width: 6px; height: 6px; border-right: 1.6px solid var(--muted); border-bottom: 1.6px solid var(--muted); transform: translateY(-70%) rotate(45deg); }
.lp.open .lp-btn { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(76, 141, 255, .18); }
.lp-menu { position: absolute; top: calc(100% + 6px); left: 0; z-index: 25; width: min(320px, 92vw); max-height: min(420px, 70vh); background: var(--panel); border: 1px solid var(--border2); border-radius: 12px; box-shadow: var(--shadow); display: flex; flex-direction: column; overflow: hidden; animation: rise .15s ease-out; }
.lp-menu[hidden] { display: none; }
.lp-search { border: 0; border-bottom: 1px solid var(--border); border-radius: 0; padding: 11px 14px; background: transparent; outline: none; }
.lp-search:focus { box-shadow: none; }
.lp-list { overflow-y: auto; padding: 6px; }
.lp-item { display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: 8px; cursor: pointer; font-size: 14px; }
.lp-item:hover { background: var(--panel2); }
.lp-item.on { background: rgba(76, 141, 255, .15); }
.lp-item .n { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lp-item .e { color: var(--muted); font-size: 12px; white-space: nowrap; }
#settings-target .lp-btn { max-width: 100%; width: 100%; }
#settings-target .lp-menu { left: auto; right: 0; }

/* ------------------------------------------------------------ layout */
.top, .bottom { display: flex; align-items: center; gap: 12px; padding: 10px 16px; background: var(--panel); }
.top { border-bottom: 1px solid var(--border); }
.bottom { border-top: 1px solid var(--border); padding: 12px 16px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 17px; letter-spacing: -.01em; }
.pill { display: inline-flex; align-items: center; gap: 7px; font-weight: 400; font-size: 12px; color: var(--muted); padding: 3px 10px 3px 8px; border: 1px solid var(--border); border-radius: 999px; margin-left: 6px; max-width: 40vw; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); flex: none; }
.dot.on { background: var(--ok); box-shadow: 0 0 0 3px rgba(25, 185, 130, .18); } .dot.off { background: var(--crit); box-shadow: 0 0 0 3px rgba(240, 80, 110, .18); }
.actions { margin-left: auto; display: flex; gap: 4px; }

.panes { flex: 1; display: grid; grid-template-columns: 1fr 1fr; gap: 1px; background: var(--border); min-height: 0; }
.pane { display: flex; flex-direction: column; background: var(--bg); min-height: 0; }
.bar { display: flex; align-items: center; gap: 8px; padding: 8px 12px; border-bottom: 1px solid var(--border); background: var(--panel); min-height: 52px; }
.lang { display: flex; align-items: center; gap: 8px; min-width: 0; }
#count { white-space: nowrap; }

textarea, .output { flex: 1; margin: 0; padding: 18px 20px 24px; border: 0; border-radius: 0; background: transparent; resize: none; font-size: var(--fs); line-height: 1.6; overflow-y: auto; outline: none; }
.output { white-space: pre-wrap; overflow-wrap: anywhere; }
.output:empty::before { content: "Перевод появится здесь"; color: var(--muted); }
.output.error { color: var(--crit); }
.output .pending { color: var(--muted); opacity: .55; background: linear-gradient(90deg, transparent, rgba(76, 141, 255, .18), transparent); background-size: 200% 100%; animation: shimmer 1.4s linear infinite; border-radius: 4px; }
@keyframes shimmer { to { background-position: -200% 0; } }
.output .fresh { animation: fade .35s ease-out; }
@keyframes fade { from { opacity: 0; } }

/* detected language badge */
.badge { display: inline-flex; align-items: center; gap: 7px; padding: 3px 10px 3px 8px; border-radius: 999px; background: var(--panel2); border: 1px solid var(--border); font-size: 12px; white-space: nowrap; animation: fade .25s ease-out; }
.badge[hidden] { display: none; }
.badge img.fl { width: 18px; height: 13px; }
.badge .lname { color: var(--text); }
.badge .conf { width: 34px; height: 4px; border-radius: 2px; background: var(--border2); overflow: hidden; }
.badge .conf i { display: block; height: 100%; width: 0; background: var(--ok); transition: width .3s; }
.badge.low .conf i { background: var(--warn); }
.tag { font-size: 11px; padding: 2px 8px; border-radius: 999px; background: rgba(25, 185, 130, .15); color: var(--ok); border: 1px solid rgba(25, 185, 130, .35); }
.tag[hidden] { display: none; }

#status.busy::after { content: ""; display: inline-block; width: 10px; height: 10px; margin-left: 8px; border: 2px solid var(--border2); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; vertical-align: -1px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ------------------------------------------------------------ settings drawer */
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(380px, 100%); background: var(--panel); border-left: 1px solid var(--border); box-shadow: var(--shadow); z-index: 20; display: flex; flex-direction: column; animation: slide .22s ease-out; }
.drawer[hidden] { display: none; }
@keyframes slide { from { transform: translateX(30px); opacity: 0; } }
.drawer-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px; border-bottom: 1px solid var(--border); font-size: 15px; }
.drawer-body { padding: 8px 16px 16px; overflow-y: auto; display: grid; grid-template-columns: minmax(0, 1fr); gap: 6px; }
.opt { display: grid; gap: 8px; padding: 10px 0; border-bottom: 1px solid var(--border); font-size: 14px; }
.opt.row { grid-template-columns: 1fr auto; align-items: center; cursor: pointer; }
.opt > span { color: var(--text); }
.seg { display: inline-flex; background: var(--panel2); border: 1px solid var(--border); border-radius: 9px; padding: 3px; gap: 2px; }
.seg button { border: 0; background: transparent; padding: 6px 12px; border-radius: 7px; font-size: 13px; color: var(--muted); }
.seg button.on { background: var(--accent); color: #fff; }
.seg[hidden] { display: none; }
.drawer-foot { display: flex; align-items: center; justify-content: space-between; padding-top: 14px; }
.drawer.wide { width: min(560px, 100%); }
.drawer-head .muted { margin-left: auto; margin-right: 8px; }
.drawer-sub { margin: 18px 0 4px; font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.opt a { color: var(--accent2); text-decoration: none; }
.keyrow { display: flex; align-items: center; gap: 4px; }
code.key { flex: 1; min-width: 0; font: 12.5px/1.4 ui-monospace, Menlo, Consolas, monospace; padding: 7px 10px; border-radius: 8px; background: var(--panel2); border: 1px solid var(--border); overflow-wrap: anywhere; letter-spacing: .02em; }
details.opt summary { cursor: pointer; color: var(--text); list-style: none; display: flex; align-items: center; justify-content: space-between; }
details.opt summary::after { content: ""; width: 6px; height: 6px; border-right: 1.6px solid var(--muted); border-bottom: 1.6px solid var(--muted); transform: rotate(45deg); transition: transform .15s; }
details.opt[open] summary::after { transform: rotate(-135deg); }
.pw-form { display: grid; gap: 8px; margin-top: 8px; }
.pw-form input { width: 100%; }
.pw-form button { justify-self: start; }
.actions .icon { position: relative; }
.cnt { position: absolute; top: 2px; right: 2px; min-width: 16px; height: 16px; padding: 0 4px; border-radius: 8px; background: var(--warn); color: #000; font: 700 10px/16px system-ui, sans-serif; text-align: center; }
.cnt[hidden] { display: none; }
.ulist { display: grid; gap: 8px; margin: 12px 0; }
.urow { padding: 12px 14px; border: 1px solid var(--border); border-radius: 12px; background: var(--panel2); display: grid; gap: 6px; }
.uhead { display: flex; align-items: center; gap: 10px; }
.uhead b { font-size: 15px; }
.utags { display: flex; gap: 6px; margin-left: auto; }
.uacts { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
#backdrop { position: fixed; inset: 0; background: rgba(0, 0, 0, .35); z-index: 15; }
#backdrop[hidden] { display: none; }

/* toasts */
#toasts { position: fixed; left: 50%; bottom: 76px; transform: translateX(-50%); display: grid; gap: 8px; z-index: 30; pointer-events: none; }
.toast { padding: 9px 14px; border-radius: 10px; background: var(--panel2); border: 1px solid var(--border2); box-shadow: var(--shadow); font-size: 13px; animation: rise .25s ease-out; max-width: 80vw; }
.toast.crit { border-color: var(--crit); color: var(--crit); } .toast.ok { border-color: var(--ok); }

/* ------------------------------------------------------------ mode switch (text / photo) */
.mode { margin-left: 14px; }
.mode button { display: inline-flex; align-items: center; gap: 7px; padding: 6px 14px; }
.mode button svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.mode button:disabled { opacity: .45; }
.panes[hidden] { display: none; }
.nowrap { white-space: nowrap; }

/* ------------------------------------------------------------ photo translation */
.panes.photo { grid-template-columns: minmax(0, 1.55fr) minmax(280px, 1fr); }
.drop { flex: 1; min-height: 0; display: flex; padding: 16px; position: relative; }
.drop-empty { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; border: 1.5px dashed var(--border2); border-radius: 16px; padding: 24px; transition: border-color .15s, background .15s; }
.drop.over .drop-empty, .drop.over .viewer { border-color: var(--accent); background: rgba(76, 141, 255, .07); }
.drop-empty[hidden] { display: none; }
.drop-empty p { margin: 4px 0; }
.drop-title { font-size: 18px; font-weight: 600; margin-top: 18px !important; }
.drop-empty .row-btns { margin: 18px 0 14px; }
.drop-hint { max-width: 420px; line-height: 1.5; }
.drop-icon { position: relative; width: 72px; height: 72px; border-radius: 20px; background: var(--panel2); border: 1px solid var(--border); display: grid; place-items: center; color: var(--accent2); }
.drop-icon svg { width: 34px; height: 34px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.drop-badge { position: absolute; right: -8px; bottom: -8px; width: 30px; height: 30px; border-radius: 10px; background: var(--accent); color: #fff; display: grid; place-items: center; box-shadow: 0 6px 16px rgba(76, 141, 255, .35); }
.drop-badge svg { width: 15px; height: 15px; stroke-width: 2.2; }
.viewer { flex: 1; min-height: 0; display: grid; place-items: center; border-radius: 16px; border: 1.5px solid transparent; }
.viewer[hidden] { display: none; }
.stage { position: relative; max-width: 100%; max-height: 100%; line-height: 0; border-radius: 10px; overflow: hidden; box-shadow: 0 12px 40px rgba(0, 0, 0, .35); background: var(--panel2); }
.stage img { display: block; max-width: 100%; max-height: calc(100vh - 220px); object-fit: contain; }
.boxes { position: absolute; inset: 0; pointer-events: none; }
.box { position: absolute; border: 1.5px solid transparent; border-radius: 3px; transition: border-color .12s, background .12s; }
.box.on { border-color: var(--accent2); background: rgba(76, 141, 255, .18); box-shadow: 0 0 0 1px rgba(0, 0, 0, .25); }
.box.skip.on { border-color: var(--warn); background: rgba(242, 184, 75, .18); }
.scan { position: absolute; inset: 0; background: rgba(8, 10, 16, .28); overflow: hidden; }
.scan[hidden] { display: none; }
.scan i { position: absolute; left: 0; right: 0; height: 32%; background: linear-gradient(180deg, transparent, rgba(76, 141, 255, .28) 50%, transparent); border-bottom: 2px solid var(--accent2); animation: scan 1.6s ease-in-out infinite; }
@keyframes scan { 0% { top: -32%; } 100% { top: 100%; } }
.blocks { flex: 1; min-height: 0; overflow-y: auto; padding: 12px; display: grid; gap: 8px; align-content: start; }
.blocks .empty, .blocks .error { padding: 8px 4px; }
.blk { padding: 10px 12px; border: 1px solid var(--border); border-radius: 12px; background: var(--panel); display: grid; gap: 4px; cursor: default; transition: border-color .12s, background .12s; }
.blk:hover, .blk.on { border-color: var(--accent); background: rgba(76, 141, 255, .07); }
.blk .o { color: var(--muted); font-size: 13px; line-height: 1.45; overflow-wrap: anywhere; }
.blk .t { font-size: var(--fs); line-height: 1.5; overflow-wrap: anywhere; }
.blk.skip .t { color: var(--muted); font-style: italic; font-size: 13px; }
.blk .meta { display: flex; gap: 6px; align-items: center; margin-top: 2px; }
.blk .meta .tag { font-size: 10px; padding: 1px 7px; }

@media (max-width: 780px) {
  .panes { grid-template-columns: 1fr; grid-template-rows: 1fr 1fr; }
  .panes.photo { grid-template-columns: 1fr; grid-template-rows: minmax(0, 1.4fr) minmax(0, 1fr); }
  .panes.photo .bar .nowrap { display: none; }
  #photo-view button { padding: 6px 9px; font-size: 12px; }
  .mode { margin-left: 4px; }
  .mode button { padding: 6px 10px; }
  .mode button svg { display: none; }
  .drop { padding: 10px; }
  .drop-empty { padding: 16px; }
  .drop-hint { display: none; }
  .stage img { max-height: 100%; }
  .drop-title { font-size: 16px; }
  .pill { display: none; }
  #stats { display: none; }
  .lp-btn { max-width: 170px; }
  .badge .lname { display: none; }
  .bottom { padding: 10px 12px; }
}
