:root {
  --bg: #0a0f1c; --panel: #121a2e; --panel2: #18223b; --line: #263353;
  --text: #e8eefc; --muted: #93a3c7; --accent: #ffc83d; --accent2: #5bd0ff;
  --ok: #3ddc84; --warn: #ffb02e; --err: #ff5a5a;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { background: var(--bg); color: var(--text); font: 14px/1.45 "Segoe UI", system-ui, sans-serif; display: flex; flex-direction: column; }

.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 16px; background: var(--panel); border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.logo { font-size: 20px; font-weight: 600; letter-spacing: .2px; }
.logo b { color: var(--accent); }
.logo .bolt { display: inline-block; filter: drop-shadow(0 0 8px var(--accent)); }
.logo em { font-style: normal; font-size: 11px; background: var(--accent2); color: #04202e; padding: 2px 7px; border-radius: 99px; margin-left: 6px; vertical-align: middle; }
.tools { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.chk { color: var(--muted); display: flex; gap: 6px; align-items: center; cursor: pointer; user-select: none; }

.btn, select { background: var(--panel2); color: var(--text); border: 1px solid var(--line); border-radius: 10px; padding: 7px 12px; font: inherit; cursor: pointer; }
.btn:hover, select:hover { border-color: var(--accent2); }
.btn:disabled { opacity: .35; cursor: default; border-color: var(--line); }
.btn.on { border-color: var(--accent); background: #2e2a12; color: var(--accent); }
.btn.ch1.on { border-color: #ffd23f; color: #ffd23f; } .btn.ch2.on { border-color: #5bd0ff; color: #5bd0ff; background: #12262e; }
.zoomctl { position: absolute; left: 12px; top: 12px; display: flex; gap: 2px; background: rgba(18, 26, 46, .9); border: 1px solid var(--line); border-radius: 10px; padding: 3px; }
.zoomctl button { background: none; border: 0; color: var(--text); font: inherit; font-weight: 700; min-width: 30px; height: 28px; border-radius: 7px; cursor: pointer; }
.zoomctl button:hover { background: var(--panel2); }
#z-val { min-width: 52px; font-size: 12px; color: var(--muted); }
.toast { position: absolute; left: 50%; bottom: 64px; transform: translate(-50%, 10px); background: #1d2a45; border: 1px solid var(--accent2); color: var(--text); padding: 8px 14px; border-radius: 10px; opacity: 0; pointer-events: none; transition: .2s; white-space: nowrap; max-width: 90%; overflow: hidden; text-overflow: ellipsis; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
body.measuring #cv { cursor: crosshair; }
.lcd { font: 700 30px Consolas, "Courier New", monospace; background: #07150e; color: #5dff93; border: 1px solid #1d3a2a; border-radius: 10px; padding: 8px 12px; text-align: right; margin: 6px 0 4px; letter-spacing: 1px; }
.seg { display: flex; gap: 6px; flex-wrap: wrap; margin: 6px 0; align-items: center; }
.seg label { margin: 0; gap: 4px; color: var(--muted); font-size: 12px; }
.seg select { padding: 4px 6px; font-size: 12px; }
#scope { width: 100%; height: 190px; display: block; border-radius: 10px; border: 1px solid var(--line); margin-top: 6px; }
#pane-tools.active { display: block; }

/* ---- bo'limlar menyusi va til tanlagich ---- */
.brand { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.sections { display: flex; gap: 4px; }
.sections a { color: var(--muted); text-decoration: none; padding: 6px 11px; border-radius: 9px; font-weight: 600; position: relative; white-space: nowrap; }
.sections a:hover { color: var(--text); background: var(--panel2); }
.sections a.active { color: #2b1d00; background: var(--accent); }
.lang-switch { padding: 5px 8px; font-size: 13px; }

/* ---- yordam chati ---- */
.sup-badge { display: inline-block; min-width: 18px; height: 18px; padding: 0 5px; margin-left: 6px; border-radius: 99px; background: var(--err); color: #fff; font-size: 11px; font-weight: 700; line-height: 18px; text-align: center; }
.sup-panel { position: fixed; right: 16px; top: 70px; bottom: 16px; width: min(380px, calc(100vw - 32px)); background: var(--panel); border: 1px solid var(--line); border-radius: 16px; box-shadow: 0 20px 60px rgba(0, 0, 0, .5); display: flex; flex-direction: column; z-index: 50; transform: translateX(120%); transition: transform .25s; }
.sup-panel.open { transform: none; }
.sup-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.sup-head b { font-size: 16px; }
.sup-x { background: none; border: 0; color: var(--muted); font-size: 18px; cursor: pointer; padding: 2px 6px; border-radius: 6px; }
.sup-x:hover { color: var(--text); background: var(--panel2); }
.sup-body { flex: 1; min-height: 0; display: flex; flex-direction: column; padding: 12px 14px; gap: 8px; }
.sup-note { color: var(--muted); }
.sup-form { display: flex; flex-direction: column; gap: 6px; }
.sup-form label { margin: 4px 0 0; color: var(--muted); font-size: 13px; }
.sup-form input, .sup-send textarea, .adm-login input, #adm-search { background: #0c1324; border: 1px solid var(--line); border-radius: 10px; color: var(--text); padding: 9px 12px; font: inherit; }
.sup-form input:focus, .sup-send textarea:focus, .adm-login input:focus, #adm-search:focus { outline: 2px solid var(--accent2); }
.sup-who { display: flex; justify-content: space-between; align-items: center; font-size: 13px; color: var(--muted); }
.link { background: none; border: 0; color: var(--accent2); cursor: pointer; font: inherit; font-size: 12px; text-decoration: underline; }
.sup-list { flex: 1; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; padding: 4px 0; }
.sup-empty { color: var(--muted); text-align: center; margin: auto 0; }
.sup-msg { display: flex; }
.sup-msg.mine { justify-content: flex-end; }
.sup-msg .b { max-width: 85%; padding: 8px 11px; border-radius: 14px; background: var(--panel2); border: 1px solid var(--line); }
.sup-msg.mine .b { background: #2e2a12; border-color: #6b5a12; }
.sup-from { font-size: 11px; font-weight: 700; color: var(--accent2); margin-bottom: 2px; }
.sup-text { white-space: pre-wrap; word-break: break-word; }
.sup-time { font-size: 10px; color: var(--muted); text-align: right; margin-top: 3px; }
.sup-err { color: #ff9b9b; font-size: 13px; min-height: 0; }
.sup-send { display: flex; gap: 8px; align-items: flex-end; }
.sup-send textarea { flex: 1; resize: none; min-width: 0; }

/* ---- admin paneli ---- */
.admin-page { height: 100%; }
.adm-login { flex: 1; display: flex; align-items: center; justify-content: center; padding: 16px; }
.adm-login form { width: min(360px, 100%); display: flex; flex-direction: column; gap: 8px; padding: 20px; }
.adm-login h3 { margin: 0 0 6px; }
.adm-main { flex: 1; min-height: 0; display: grid; grid-template-columns: 320px 1fr; }
.adm-main[hidden], .adm-login[hidden] { display: none; }
.adm-threads { border-right: 1px solid var(--line); background: var(--panel); display: flex; flex-direction: column; min-height: 0; padding: 10px; gap: 8px; }
#adm-list { overflow-y: auto; display: flex; flex-direction: column; gap: 4px; }
.adm-item { display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; background: none; border: 1px solid transparent; border-radius: 12px; padding: 8px; color: var(--text); font: inherit; cursor: pointer; }
.adm-item:hover { background: var(--panel2); }
.adm-item.active { background: var(--panel2); border-color: var(--accent2); }
.adm-item.unread .adm-prev { color: var(--text); font-weight: 600; }
.adm-av { flex: none; width: 38px; height: 38px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-weight: 800; color: #0a0f1c; }
.adm-mid { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.adm-top { display: flex; gap: 6px; align-items: baseline; }
.adm-id { color: var(--muted); font-size: 11px; font-family: Consolas, monospace; }
.adm-prev { color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.adm-right { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.adm-time { font-size: 11px; color: var(--muted); }
.adm-none { text-align: center; padding: 20px 0; }
.adm-chat { display: flex; flex-direction: column; min-height: 0; padding: 12px 16px; gap: 10px; }
.adm-user { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; }
.adm-uhead { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.adm-grid { display: grid; grid-template-columns: max-content 1fr; gap: 3px 14px; font-size: 13px; word-break: break-all; }
@media (max-width: 760px) { .adm-main { grid-template-columns: 1fr; grid-template-rows: 40% 60%; } .adm-threads { border-right: 0; border-bottom: 1px solid var(--line); } }
.btn.small { padding: 5px 10px; font-size: 13px; }
.btn.danger { color: #ff9b9b; }
.btn.primary { background: var(--accent); color: #2b1d00; border-color: var(--accent); font-weight: 700; }

.layout { flex: 1; min-height: 0; display: grid; grid-template-columns: 208px 1fr 340px; }
.side { background: var(--panel); border-right: 1px solid var(--line); padding: 10px 8px; overflow-y: auto; }
.side h2 { margin: 0 0 8px; font-size: 13px; text-transform: uppercase; letter-spacing: 1px; color: var(--muted); }
.palette details { margin-bottom: 8px; }
.palette summary { cursor: pointer; font-size: 12px; font-weight: 700; color: var(--accent2); padding: 4px 2px; user-select: none; }
.palette .grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-top: 4px; }
.part { background: var(--panel2); border: 1px solid var(--line); border-radius: 10px; padding: 2px 2px 4px; color: var(--text); cursor: pointer; display: flex; flex-direction: column; align-items: center; font: inherit; font-size: 11px; line-height: 1.2; min-width: 0; }
.part span { text-align: center; }
.part canvas { width: 100%; height: auto; }
.part:hover { border-color: var(--accent); transform: translateY(-1px); }
body.placing .part:hover { border-color: var(--accent2); }
.small { color: var(--muted); font-size: 12px; }

.stage { position: relative; min-width: 0; min-height: 0; overflow: hidden; }
#cv { position: absolute; inset: 0; display: block; touch-action: none; }
body.placing #cv { cursor: copy; }
.status { position: absolute; left: 12px; right: 12px; bottom: 12px; padding: 9px 14px; border-radius: 12px; background: rgba(18, 26, 46, .92); border: 1px solid var(--line); backdrop-filter: blur(6px); }
.status.ok { border-color: var(--ok); } .status.warn { border-color: var(--warn); } .status.err { border-color: var(--err); background: rgba(60, 16, 16, .92); }
.legend { position: absolute; right: 14px; top: 12px; display: flex; align-items: center; gap: 6px; font-size: 11px; color: var(--muted); background: rgba(18, 26, 46, .8); padding: 4px 8px; border-radius: 99px; }
.legend i { width: 90px; height: 8px; border-radius: 99px; background: linear-gradient(90deg, hsl(215,90%,55%), hsl(160,90%,57%), hsl(80,90%,58%), hsl(30,90%,60%), hsl(0,90%,60%)); }

.right { background: var(--panel); border-left: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; }
.tabs { display: flex; border-bottom: 1px solid var(--line); }
.tab { flex: 1; background: none; border: 0; border-bottom: 3px solid transparent; color: var(--muted); padding: 11px; font: inherit; font-weight: 600; cursor: pointer; }
.tab.active { color: var(--text); border-bottom-color: var(--accent); }
.tab.new::after { content: ''; display: inline-block; width: 9px; height: 9px; margin-left: 7px; border-radius: 50%; background: var(--err); animation: pulse 1s infinite; }
@keyframes pulse { 50% { transform: scale(1.5); opacity: .6; } }
.pane { display: none; flex: 1; min-height: 0; overflow-y: auto; padding: 14px; }
.pane.active { display: flex; flex-direction: column; }
#pane-info.active { display: block; }

.hint { text-align: center; color: var(--muted); padding: 20px 6px; }
.hint .big { font-size: 40px; }
.hint b { color: var(--text); font-size: 16px; }
.hint ul { text-align: left; padding-left: 18px; }
.comp-head { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.comp-head .emoji { font-size: 34px; }
.comp-head h3 { margin: 0; font-size: 20px; }
.sub { color: var(--accent); font-weight: 600; }
.live { background: #0c1324; border: 1px solid var(--line); border-radius: 12px; padding: 8px 12px; margin-bottom: 10px; }
.kv { display: flex; justify-content: space-between; padding: 3px 0; }
.kv span { color: var(--muted); } .kv.bad b { color: var(--err); }
.formula { margin-top: 6px; padding: 8px; background: #1b2540; border-radius: 8px; font-family: Consolas, monospace; color: var(--accent2); text-align: center; }
.alert { margin-top: 6px; padding: 7px 10px; border-radius: 8px; background: rgba(255, 90, 90, .15); color: #ff9b9b; font-weight: 600; }
.bar { height: 10px; background: #0a1020; border-radius: 99px; overflow: hidden; margin-top: 6px; }
.bar i { display: block; height: 100%; background: linear-gradient(90deg, #35b8e8, #7cf); }
.card { background: var(--panel2); border: 1px solid var(--line); border-radius: 12px; padding: 9px 12px; margin: 10px 0; }
.card h4 { margin: 0 0 3px; font-size: 13px; color: var(--accent2); }
.card p { margin: 0; }
label { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 6px 0; }
.row { display: flex; gap: 8px; margin-top: 8px; }
.swatches { display: flex; gap: 8px; margin: 8px 0; }
.sw { width: 30px; height: 30px; border-radius: 50%; border: 3px solid transparent; cursor: pointer; }
.sw.on { border-color: #fff; box-shadow: 0 0 10px currentColor; }
.sw.auto { background: linear-gradient(135deg, hsl(215,90%,55%), hsl(30,90%,60%), hsl(0,90%,60%)); color: #fff; font-weight: 700; font-size: 12px; }
.sl { display: flex; align-items: center; gap: 8px; }
.sl input[type=range] { width: 130px; accent-color: var(--accent); }
.sl b { min-width: 44px; text-align: right; color: var(--accent); }

.chat-log { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; padding-bottom: 8px; }
.msg .b { padding: 9px 12px; border-radius: 14px; max-width: 92%; display: inline-block; }
.msg.bot .b { background: var(--panel2); border: 1px solid var(--line); border-top-left-radius: 4px; }
.msg.me { text-align: right; } .msg.me .b { background: var(--accent); color: #2b1d00; border-top-right-radius: 4px; text-align: left; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.chip { background: transparent; color: var(--accent2); border: 1px solid var(--accent2); border-radius: 99px; padding: 4px 11px; font: inherit; font-size: 13px; cursor: pointer; }
.chip:hover { background: rgba(91, 208, 255, .15); }
.chat-form { display: flex; gap: 8px; padding-top: 8px; border-top: 1px solid var(--line); }
.chat-form input { flex: 1; background: #0c1324; border: 1px solid var(--line); border-radius: 10px; color: var(--text); padding: 9px 12px; font: inherit; min-width: 0; }
.chat-form input:focus { outline: 2px solid var(--accent2); }

@media (max-width: 980px) {
  .layout { grid-template-columns: 150px 1fr; grid-template-rows: 1fr 300px; }
  .palette .grid { grid-template-columns: 1fr; }
  .right { grid-column: 1 / -1; border-left: 0; border-top: 1px solid var(--line); }
}
