:root {
  --bg: #0f1115; --panel: #171a21; --panel-2: #1e222b; --line: #2a2f3a;
  --text: #e8eaf0; --muted: #9aa3b2; --accent: #7c5cff; --accent-2: #a48bff;
  --ok: #33c48d; --warn: #f2b84b; --err: #ff6b6b; --radius: 14px;
  color-scheme: dark;
}
@media (prefers-color-scheme: light) {
  :root { --bg: #f5f6fa; --panel: #ffffff; --panel-2: #f0f2f7; --line: #e1e4ec;
          --text: #161a22; --muted: #5d6677; color-scheme: light; }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, sans-serif; }
a { color: var(--accent-2); }
button, input, select, textarea { font: inherit; color: inherit; }
.boot { padding: 40px; text-align: center; color: var(--muted); }

/* ---------- верх ---------- */
.top { position: sticky; top: 0; z-index: 10; background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.top-in { max-width: 1100px; margin: 0 auto; padding: 10px 16px; display: flex; align-items: center; gap: 12px; }
.brand { font-weight: 700; font-size: 17px; letter-spacing: .2px; white-space: nowrap; }
.brand span { color: var(--accent-2); }
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin-left: auto; }
.chip { font-size: 12px; padding: 3px 9px; border-radius: 99px; background: var(--panel-2);
  border: 1px solid var(--line); color: var(--muted); white-space: nowrap; }
.chip.as { cursor: pointer; color: var(--ok); border-color: color-mix(in srgb, var(--ok) 40%, var(--line)); }
.chip.as.warn { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 50%, var(--line)); }
.tabs { max-width: 1100px; margin: 0 auto; padding: 0 12px 8px; display: flex; gap: 4px; overflow-x: auto; }
.tab { border: 0; background: transparent; padding: 7px 13px; border-radius: 10px; cursor: pointer;
  color: var(--muted); white-space: nowrap; }
.tab.on { background: var(--panel-2); color: var(--text); }
.tab .dot { display: inline-block; min-width: 18px; padding: 0 5px; margin-left: 4px; border-radius: 99px;
  background: var(--accent); color: #fff; font-size: 11px; line-height: 18px; text-align: center; }

main { max-width: 1100px; margin: 0 auto; padding: 16px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 14px; }
.card h2 { margin: 0 0 12px; font-size: 17px; }
.card h3 { margin: 16px 0 8px; font-size: 14px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .4px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.grow { flex: 1 1 auto; }

/* ---------- формалар ---------- */
label.field { display: block; margin: 10px 0; }
label.field > span { display: block; font-size: 13px; color: var(--muted); margin-bottom: 4px; }
input[type=text], input[type=password], input[type=number], select, textarea {
  width: 100%; background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; outline: none; }
textarea { min-height: 130px; resize: vertical; }

/* промпттар: сол жакта номерлер */
/* Туруктуу бийиктик: промпт көп болсо талаа чоңойбой, ичинде жылдырылат (бурчунан тартып чоңойтсо болот) */
.pwrap { position: relative; display: flex; background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px;
  overflow: hidden; height: 300px; min-height: 140px; max-height: 80vh; resize: vertical; }
.pwrap:focus-within { border-color: var(--accent); }
.pwrap textarea { border: 0; border-radius: 0; background: transparent; height: 100%; min-height: 0; resize: none;
  overflow-y: auto; line-height: 1.5; padding: 10px 12px 10px 8px; white-space: pre-wrap; overflow-wrap: break-word; }
.pwrap.plain textarea { padding-left: 12px; }
.gutter { flex: none; width: 40px; height: 100%; padding: 10px 6px 10px 0; text-align: right; color: var(--muted);
  font-size: 12px; line-height: 1.5; overflow: hidden; user-select: none; border-right: 1px solid var(--line);
  background: color-mix(in srgb, var(--panel) 60%, var(--panel-2)); font-variant-numeric: tabular-nums; }
.gutter > div { line-height: 22.5px; }
.measure { position: absolute; left: -9999px; top: 0; visibility: hidden; padding: 0 12px 0 8px;
  font: inherit; line-height: 1.5; white-space: pre-wrap; overflow-wrap: break-word; box-sizing: border-box; }
.measure > div { line-height: 1.5; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); }
.seg { display: flex; flex-wrap: wrap; gap: 6px; }
.seg button { border: 1px solid var(--line); background: var(--panel-2); padding: 8px 12px; border-radius: 10px; cursor: pointer; }
.seg button.on { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 22%, var(--panel-2)); }
.btn { border: 0; background: var(--accent); color: #fff; padding: 11px 18px; border-radius: 11px; cursor: pointer; font-weight: 600; }
.btn:hover { background: var(--accent-2); }
.btn:disabled { opacity: .55; cursor: default; }
.btn.ghost { background: var(--panel-2); color: var(--text); border: 1px solid var(--line); font-weight: 500; }
.btn.small { padding: 6px 11px; font-size: 13px; border-radius: 9px; }
.btn.danger { background: transparent; color: var(--err); border: 1px solid var(--line); }
.drop { border: 1.5px dashed var(--line); border-radius: 12px; padding: 14px; text-align: center; color: var(--muted); cursor: pointer; }
.drop.over { border-color: var(--accent); }
.thumbs { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 8px; margin-top: 10px; }
.thumb { position: relative; background: var(--panel-2); border-radius: 10px; overflow: hidden; border: 1px solid var(--line); }
.thumb img { width: 100%; height: 92px; object-fit: cover; display: block; }
.thumb .n { position: absolute; top: 4px; left: 4px; background: rgba(0,0,0,.6); color: #fff; font-size: 11px; padding: 1px 6px; border-radius: 6px; }
.thumb .x { position: absolute; top: 3px; right: 3px; border: 0; background: rgba(0,0,0,.6); color: #fff; border-radius: 6px; cursor: pointer; }
.thumb input { border: 0; border-top: 1px solid var(--line); border-radius: 0; padding: 5px 6px; font-size: 12px; }
.hint { font-size: 13px; color: var(--muted); margin-top: 6px; }
.msg { margin-top: 12px; padding: 10px 12px; border-radius: 10px; background: var(--panel-2); border: 1px solid var(--line); font-size: 14px; }
.msg.err { border-color: color-mix(in srgb, var(--err) 50%, var(--line)); }
.msg.ok { border-color: color-mix(in srgb, var(--ok) 50%, var(--line)); }
code { background: var(--panel-2); padding: 1px 5px; border-radius: 5px; font-size: 13px; }

/* ---------- тапшырмалар жана галерея ---------- */
/* Кезек: туруктуу бийиктик, ичинде жылдырылат */
.jobs-scroll { max-height: 65vh; overflow-y: auto; padding-right: 4px; }
.job { border: 1px solid var(--line); border-radius: 12px; padding: 12px; margin-bottom: 10px; background: var(--panel); }
.job-h { display: flex; gap: 8px; align-items: center; }
.job-t { font-weight: 600; }
.badge { font-size: 12px; padding: 2px 8px; border-radius: 99px; background: var(--panel-2); color: var(--muted); }
.badge.done { color: var(--ok); } .badge.failed { color: var(--err); } .badge.active, .badge.waiting { color: var(--warn); }
.prompt { color: var(--muted); font-size: 13px; margin: 6px 0; white-space: pre-wrap; word-break: break-word; max-height: 4.5em; overflow: hidden; }
.bar { height: 6px; background: var(--panel-2); border-radius: 99px; overflow: hidden; margin: 8px 0 2px; }
.bar > i { display: block; height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent-2)); transition: width .4s; }
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; }
.media { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; display: flex; flex-direction: column; }
.media img, .media video { width: 100%; display: block; background: #000; max-height: 360px; object-fit: contain; }
.media audio { width: 100%; margin: 10px 0 0; }
.media .b { padding: 10px; display: flex; flex-direction: column; gap: 8px; }
.media .nm { font-size: 12px; color: var(--muted); word-break: break-all; }
.media.saved { border-style: dashed; background: transparent; color: var(--ok); }
.job .gallery { margin-top: 10px; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); }

/* ---------- админ ---------- */
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 600; }
.tbl { overflow-x: auto; }
.auth { max-width: 380px; margin: 8vh auto; }
.auth .brand { font-size: 24px; text-align: center; margin-bottom: 18px; }
.toast { position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%); background: var(--panel-2);
  border: 1px solid var(--line); padding: 10px 16px; border-radius: 12px; z-index: 50; max-width: 92vw; box-shadow: 0 8px 30px rgba(0,0,0,.35); }
.voice-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 8px; max-height: 340px; overflow: auto; padding: 2px; }
.voice { border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; background: var(--panel-2); cursor: pointer; display: flex; gap: 8px; align-items: center; }
.voice.on { border-color: var(--accent); }
.voice .play { border: 0; background: var(--panel); border-radius: 8px; width: 30px; height: 30px; cursor: pointer; flex: none; }
.voice .vn { font-weight: 600; font-size: 14px; } .voice .vt { font-size: 12px; color: var(--muted); }
@media (max-width: 600px) {
  main { padding: 12px; } .card { padding: 14px; }
  .chips { display: none; }
  .gallery { grid-template-columns: 1fr 1fr; }
}
