:root {
  --bg: #070a12;
  --panel: rgba(17, 24, 41, .78);
  --panel-solid: #111829;
  --line: rgba(148, 167, 205, .16);
  --line-strong: rgba(148, 167, 205, .3);
  --text: #e9eefb;
  --muted: #93a0bc;
  --mint: #7cf6c8;
  --violet: #9b8cff;
  --amber: #ffd166;
  --danger: #ff6b81;
  --r: 14px;
  --font: ui-sans-serif, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, "Noto Naskh Arabic", "Noto Sans Arabic", sans-serif;
  --serif: ui-serif, Georgia, "Times New Roman", serif;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text); font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  background-image: radial-gradient(ellipse 70% 40% at 50% -10%, rgba(124, 246, 200, .1), transparent 70%);
  background-repeat: no-repeat;
}
a { color: var(--mint); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
kbd { background: rgba(255,255,255,.07); border: 1px solid var(--line); border-bottom-color: var(--line-strong); border-radius: 5px; padding: 1px 5px; font-size: 11px; font-family: inherit; }
::selection { background: rgba(124, 246, 200, .28); }
.hidden { display: none !important; }
.spacer { flex: 1; }

.container { max-width: 1080px; margin: 0 auto; padding: 0 24px; }

.topbar {
  position: sticky; top: 0; z-index: 40; display: flex; align-items: center; gap: 14px;
  padding: 12px 24px; background: rgba(7, 10, 18, .82); backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}
.brand { display: inline-flex; align-items: baseline; gap: 6px; font-weight: 800; letter-spacing: -.02em; font-size: 19px; color: var(--text); text-decoration: none !important; }
.brand .dot { color: var(--mint); }
.brand small { font-size: 10px; font-weight: 600; color: var(--muted); letter-spacing: .12em; }
.navlink { font-size: 14px; font-weight: 600; color: var(--muted); }
.navlink:hover { color: var(--text); }
.authnav { display: flex; align-items: center; gap: 8px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 1px solid var(--line); background: rgba(255, 255, 255, .045); color: var(--text);
  border-radius: 10px; padding: 9px 16px; cursor: pointer; font-size: 14px; font-weight: 600;
  white-space: nowrap; transition: .18s ease; text-decoration: none !important;
}
.btn:hover { background: rgba(255, 255, 255, .09); border-color: var(--line-strong); }
.btn.primary { background: linear-gradient(135deg, var(--mint), #5ce0ff); color: #041018; border: 0; box-shadow: 0 8px 24px rgba(92, 224, 255, .18); }
.btn.primary:hover { filter: brightness(1.06); }
.btn.primary[disabled] { opacity: .4; filter: grayscale(.85) brightness(.7); cursor: not-allowed; box-shadow: none; background: #33415c; color: #b9c4d8; }
.btn.ghost { background: transparent; }
.btn.sm { padding: 6px 12px; font-size: 13px; border-radius: 8px; }
.btn.lg { padding: 13px 22px; font-size: 16px; border-radius: 12px; }
.btn.danger { color: var(--danger); border-color: rgba(255, 107, 129, .35); }
.icon-btn {
  width: 30px; height: 30px; border-radius: 8px; border: 1px solid var(--line);
  background: rgba(7, 10, 18, .8); color: var(--text); cursor: pointer; display: grid; place-items: center;
  font-size: 13px; transition: .15s;
}
.icon-btn:hover { background: rgba(255, 255, 255, .1); }

.hero { padding: 64px 0 34px; text-align: center; }
.eyebrow {
  display: inline-flex; align-items: center; font-size: 11px; font-weight: 700; letter-spacing: .16em;
  text-transform: uppercase; color: var(--mint); border: 1px solid rgba(124, 246, 200, .25);
  border-radius: 999px; padding: 6px 14px; background: rgba(124, 246, 200, .06);
}
.hero h1 { font-family: var(--serif); font-weight: 600; letter-spacing: -.035em; font-size: clamp(36px, 5.4vw, 60px); line-height: 1.05; margin: 20px 0 16px; }
.hero p.lead { font-size: 17px; line-height: 1.65; color: var(--muted); max-width: 720px; margin: 0 auto; }

.workspace { display: grid; grid-template-columns: 1.15fr .85fr; gap: 22px; padding-bottom: 30px; align-items: start; }

.dropzone {
  position: relative; border: 1.5px dashed var(--line-strong); border-radius: 18px;
  min-height: 340px; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(160deg, rgba(255,255,255,.035), rgba(255,255,255,.008));
  cursor: pointer; transition: .18s ease; overflow: hidden;
}
.dropzone:hover, .dropzone:focus-visible { border-color: rgba(124, 246, 200, .5); background: rgba(124, 246, 200, .04); outline: none; }
.dropzone.dragover { border-color: var(--mint); background: rgba(124, 246, 200, .09); transform: scale(1.005); }
.dropzone.busy { pointer-events: none; }
.dz-empty { text-align: center; padding: 34px; }
.dz-icon { font-size: 40px; margin-bottom: 12px; }
.dz-empty h2 { margin: 0 0 8px; font-size: 20px; }
.dz-empty p { margin: 0 0 6px; color: var(--muted); font-size: 14px; }
.dz-empty .fine { font-size: 12px; opacity: .75; margin-top: 14px; }
.dz-empty .link { color: var(--mint); text-decoration: underline; }

.dz-preview { width: 100%; height: 100%; position: absolute; inset: 0; display: flex; flex-direction: column; }
.dz-preview img { flex: 1; width: 100%; object-fit: contain; background: #050810; min-height: 0; }
.preview-meta {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 9px 12px; font-size: 12px; color: var(--muted); background: rgba(7, 10, 18, .9);
  border-top: 1px solid var(--line);
}
.preview-meta span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.controls { background: var(--panel); border: 1px solid var(--line); border-radius: 18px; padding: 20px; display: flex; flex-direction: column; gap: 16px; }
.control label { display: block; font-size: 10px; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); font-weight: 700; margin-bottom: 8px; }
.control select {
  width: 100%; background: #0a0f1c; border: 1px solid var(--line); border-radius: 9px;
  padding: 9px 10px; font-size: 13px;
}
.control select:focus { outline: none; border-color: rgba(124, 246, 200, .5); }
.control-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.lang-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.lang-chip {
  display: flex !important; flex-direction: column; align-items: flex-start; gap: 1px;
  border: 1px solid var(--line); border-radius: 10px; padding: 9px 11px; cursor: pointer;
  background: #0a0f1c; margin: 0 !important; text-transform: none !important; letter-spacing: 0 !important;
  font-size: 13px !important; color: var(--text) !important; transition: .15s;
}
.lang-chip:hover { border-color: var(--line-strong); }
.lang-chip input { display: none; }
.lang-chip small { color: var(--muted); font-size: 10px; font-weight: 600; }
.lang-chip span { font-weight: 650; }
.lang-chip .ar { font-family: "Noto Naskh Arabic", "Noto Sans Arabic", serif; font-size: 16px; line-height: 1.3; }
.lang-chip:has(input:checked) { border-color: rgba(124, 246, 200, .55); background: rgba(124, 246, 200, .08); box-shadow: inset 0 0 0 1px rgba(124, 246, 200, .15); }
.lang-chip:has(input:checked) small { color: var(--mint); }
.hint { font-size: 11px; color: var(--muted); line-height: 1.55; margin: 8px 0 0; }
.switch { display: flex !important; align-items: center; gap: 8px; font-size: 13px !important; color: var(--text) !important; text-transform: none !important; letter-spacing: 0 !important; cursor: pointer; }
.switch input { accent-color: var(--mint); width: 16px; height: 16px; }
.run { width: 100%; }
.run-note { font-size: 12px; color: var(--muted); text-align: center; margin: -4px 0 0; min-height: 16px; }
.run-note.error { color: #ffb3bd; }
.run-note.ok { color: var(--mint); }

.spinner { width: 15px; height: 15px; border-radius: 50%; border: 2px solid rgba(4, 16, 24, .25); border-top-color: #041018; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* results */
.results { padding: 18px 24px 40px; }
.result-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 14px; }
.result-head h2 { font-family: var(--serif); font-weight: 600; font-size: 28px; letter-spacing: -.02em; margin: 0 0 4px; }
.result-meta { margin: 0; font-size: 12px; color: var(--muted); }
.result-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.lang-tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.lang-tab {
  border: 1px solid var(--line); background: rgba(255,255,255,.03); border-radius: 999px;
  padding: 6px 13px; font-size: 12px; font-weight: 600; cursor: pointer; color: var(--muted);
  display: inline-flex; align-items: center; gap: 7px; transition: .15s;
}
.lang-tab:hover { border-color: var(--line-strong); color: var(--text); }
.lang-tab.active { background: rgba(124, 246, 200, .12); border-color: rgba(124, 246, 200, .5); color: var(--mint); }
.lang-tab .conf { font-size: 10px; opacity: .8; font-variant-numeric: tabular-nums; }

.text-panel { border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; background: var(--panel-solid); }
#textOut {
  width: 100%; min-height: 300px; resize: vertical; border: 0; background: transparent;
  padding: 18px; font-size: 15px; line-height: 1.7; color: var(--text); outline: none;
  font-family: "Noto Naskh Arabic", "Noto Sans Arabic", ui-sans-serif, sans-serif;
}
#textOut[dir="rtl"] { text-align: right; }
.text-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 9px 14px; border-top: 1px solid var(--line); background: rgba(7, 10, 18, .5); flex-wrap: wrap; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.save-hint { font-size: 12px; color: var(--muted); }
.save-hint a { font-weight: 600; }

.alts { margin-top: 12px; border: 1px solid var(--line); border-radius: var(--r); background: var(--panel); }
.alts summary { cursor: pointer; padding: 12px 16px; font-size: 13px; font-weight: 600; color: var(--muted); }
.alts summary:hover { color: var(--text); }
#altList { padding: 0 16px 14px; display: flex; flex-direction: column; gap: 12px; }
.alt-block { border-top: 1px solid var(--line); padding-top: 12px; }
.alt-block:first-child { border-top: 0; padding-top: 0; }
.alt-title { font-size: 11px; letter-spacing: .1em; text-transform: uppercase; color: var(--mint); font-weight: 700; margin-bottom: 6px; }
.alt-text { font-size: 13px; line-height: 1.6; color: var(--muted); white-space: pre-wrap; max-height: 180px; overflow: auto; font-family: "Noto Naskh Arabic", ui-sans-serif, sans-serif; }
.alt-block .empty-alt { color: var(--muted); font-size: 12px; font-style: italic; }

.info { padding: 20px 24px 60px; }
.info-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; border-top: 1px solid var(--line); padding-top: 30px; }
.info h3 { margin: 0 0 8px; font-size: 15px; }
.info p { margin: 0; font-size: 13px; line-height: 1.65; color: var(--muted); }

footer.site { border-top: 1px solid var(--line); padding: 24px 0 40px; color: var(--muted); font-size: 13px; }
footer.site .inner { display: flex; justify-content: space-between; gap: 20px; flex-wrap: wrap; }

/* history page */
.page-head { padding: 44px 0 22px; }
.page-head h1 { font-family: var(--serif); font-weight: 600; font-size: 38px; letter-spacing: -.03em; margin: 0 0 6px; }
.page-head p { margin: 0; color: var(--muted); }
.hist-list { display: flex; flex-direction: column; gap: 10px; padding-bottom: 60px; }
.hist-item { display: flex; align-items: center; gap: 14px; border: 1px solid var(--line); border-radius: 12px; padding: 13px 16px; background: var(--panel); cursor: pointer; transition: .15s; }
.hist-item:hover { border-color: rgba(124, 246, 200, .4); }
.hist-item .lang-badge { font-size: 10px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; color: var(--mint); border: 1px solid rgba(124, 246, 200, .3); border-radius: 6px; padding: 3px 7px; min-width: 52px; text-align: center; }
.hist-item .hist-main { flex: 1; min-width: 0; }
.hist-item .hist-title { font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hist-item .hist-preview { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px; }
.hist-item .hist-meta { font-size: 11px; color: var(--muted); text-align: right; white-space: nowrap; }
.empty-state { border: 1px dashed var(--line-strong); border-radius: var(--r); padding: 52px; text-align: center; color: var(--muted); }
.empty-state h2 { font-family: var(--serif); color: var(--text); margin: 0 0 8px; }

/* toast */
#toast {
  position: fixed; left: 50%; bottom: 28px; transform: translate(-50%, 20px);
  background: #18223c; color: var(--text); border: 1px solid var(--line-strong);
  padding: 11px 18px; border-radius: 10px; font-size: 14px; z-index: 9999;
  opacity: 0; pointer-events: none; transition: .22s ease; box-shadow: 0 18px 40px rgba(0, 0, 0, .5);
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }
#toast.error { border-color: rgba(255, 107, 129, .5); color: #ffc2cb; }
#toast.ok { border-color: rgba(124, 246, 200, .5); }

@media (max-width: 860px) {
  .workspace { grid-template-columns: 1fr; }
  .info-grid { grid-template-columns: 1fr; }
  .dropzone { min-height: 260px; }
  .hero { padding-top: 44px; }
}
