/* SEBERD Lab — общая тёмная тема виджета (.lab)
 * Собрано из 1GENETATOR_TOOLS/tpl_tool.css с фиксированным акцентом #ff6600 (Seberd).
 * Подключать первым, затем локальный style.css инструмента.
 */
:root {
  /* backgrounds */
  --ink:   #06080f;
  --ink1:  #090d18;
  --ink2:  #0d1220;
  --ink3:  #111826;
  --ink4:  #16202e;
  /* borders */
  --b0: #1a2740;
  --b1: #243856;
  --b2: #304a6e;
  /* text levels */
  --t0: #2e4464;
  --t1: #4e6888;
  --t2: #7a9ab8;
  --t3: #a8c4dc;
  --t4: #cde0f2;
  --t5: #e4f0fc;
  /* accent — unique per tool */
  --ac:   #ff6600;
  --ac2:  #e65c00;
  --acg:  color-mix(in oklch, #ff6600 12%, transparent);
  --acg2: color-mix(in oklch, #ff6600 6%, transparent);
  --acb:  color-mix(in oklch, #ff6600 22%, transparent);
  /* second accent for gradients */
  --vc:  #8b5cf6;
  /* semantic */
  --green:  #10b981;
  --greeng: color-mix(in oklch, #10b981 14%, transparent);
  --red:    #f43f5e;
  --redg:   color-mix(in oklch, #f43f5e 14%, transparent);
  --orange: #f59e0b;

  /* fonts */
  --ff:  'Manrope', system-ui, sans-serif;
  --ffm: 'JetBrains Mono', ui-monospace, monospace;
  --ffd: 'Syne', var(--ff);

  /* fluid type scale — works 360px → 8K */
  --fxs: clamp(9px,  .8vw, 14px);
  --fsm: clamp(10px, .9vw, 15px);
  --fb:  clamp(11px, 1vw,  16px);
  --flg: clamp(14px, 1.4vw,22px);
  --fxl: clamp(18px, 2vw,  32px);

  /* fluid spacing */
  --sp1: clamp(3px,  .3vw,  5px);
  --sp2: clamp(5px,  .5vw,  8px);
  --sp3: clamp(8px,  .8vw, 13px);
  --sp4: clamp(11px, 1.1vw,18px);

  --rad:  clamp(5px, .5vw,  8px);
  --rad2: clamp(3px, .3vw,  5px);
}

/* ── reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* КРИТИЧНО: color-scheme:dark сбрасывает белый фон браузера у всех input */
* { color-scheme: dark; }

body {
  font-family: var(--ff);
  font-size: var(--fb);
  color: var(--t2);
  background: transparent;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* Глобальный сброс нативных стилей браузера для всех форм-элементов */
input, textarea, select, button {
  -webkit-appearance: none;
  appearance: none;
  font: inherit;
  color: inherit;
  color-scheme: dark;
  background: transparent;
  border: none;
}

/* ═══════════════════════════════════
   .lab — WIDGET CONTAINER (v4: полная ширина, высота от контента / vh)
═══════════════════════════════════ */
.lab {
  width: 100%;
  max-width: none;
  min-height: min(72vh, 900px);
  height: auto;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--ink);
  border: 1px solid var(--b0);
  border-radius: clamp(8px, .8vw, 14px);
  background-image:
    radial-gradient(ellipse 60% 40% at 15% -10%, rgba(255, 102, 0,.05) 0%, transparent 55%),
    radial-gradient(ellipse 50% 40% at 85% 110%, rgba(139,92,246,.04) 0%, transparent 55%),
    radial-gradient(rgba(255, 102, 0,.02) 1px, transparent 1px);
  background-size: 100% 100%, 100% 100%, 26px 26px;
}

/* ═══ TOPBAR ═══ */
.lab-top {
  flex-shrink: 0;
  height: clamp(42px, 6%, 54px);
  display: flex;
  align-items: center;
  gap: var(--sp3);
  padding: 0 var(--sp4);
  background: var(--ink1);
  border-bottom: 1px solid var(--b0);
}

.lab-brand { display: flex; align-items: center; gap: var(--sp2); flex-shrink: 0; }

.brand-dot {
  width: clamp(6px, .55vw, 9px);
  height: clamp(6px, .55vw, 9px);
  border-radius: 50%;
  background: var(--ac);
  box-shadow: 0 0 clamp(6px, .7vw, 12px) var(--ac);
  animation: dot-pulse 2.5s ease-in-out infinite;
}

@keyframes dot-pulse {
  0%, 100% { opacity: 1; box-shadow: 0 0 10px var(--ac); }
  50%      { opacity: .4; box-shadow: 0 0 3px var(--ac); }
}

.brand-name {
  font-family: var(--ffd);
  font-size: var(--flg);
  font-weight: 800;
  color: var(--t5);
  letter-spacing: -.03em;
  line-height: 1;
  white-space: nowrap;
}

.brand-name em { font-style: normal; color: var(--ac); }

/* nav pills */
.lab-nav {
  display: flex; gap: 2px; margin: 0 auto;
  background: var(--ink2); border: 1px solid var(--b0);
  border-radius: calc(var(--rad) + 2px); padding: 3px;
}

.nav-btn {
  background: transparent; border: none; border-radius: var(--rad);
  color: var(--t1); font-family: var(--ff); font-size: var(--fsm);
  font-weight: 500; padding: var(--sp1) var(--sp3);
  cursor: pointer; transition: all .14s; white-space: nowrap; user-select: none;
}

.nav-btn:hover { color: var(--t4); }

.nav-btn.active {
  background: var(--ac); color: #050b14; font-weight: 700;
  box-shadow: 0 2px 12px rgba(255, 102, 0, .28);
}

.lab-badge {
  font-size: var(--fxs); font-family: var(--ffm); color: var(--t0);
  border: 1px solid var(--b0); padding: 2px 8px; border-radius: 20px;
  background: var(--ink2); flex-shrink: 0; white-space: nowrap;
}

/* ═══ STAGE — flex:1, panels absolute ═══ */
.lab-stage {
  flex: 1;
  min-height: 0;         /* CRITICAL: prevents overflow */
  position: relative;
  overflow: hidden;
}

/* ═══ PANELS — all absolute, swap via GSAP ═══ */
.lab-panel {
  position: absolute;
  inset: 0;              /* top:0; right:0; bottom:0; left:0 */
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* ─── Panel layouts ─── */
.panel-layout {
  flex: 1;
  min-height: 0;
  padding: var(--sp3) var(--sp4);
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--sp3);
  overflow: hidden;
}

/* TODO placeholder (shows until panel is implemented) */
.todo-placeholder {
  grid-column: 1 / -1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--sp2);
  color: var(--t0);
  text-align: center;
  border: 2px dashed var(--b0);
  border-radius: var(--rad);
  height: 100%;
}

.todo-ico  { font-size: var(--fxl); line-height: 1; }
.todo-ttl  { font-family: var(--ffd); font-size: var(--flg); color: var(--t1); }
.todo-hint { font-size: var(--fsm); color: var(--t0); font-family: var(--ffm); }

/* ═══ SHARED COMPONENTS ═══ */

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: var(--sp1); border: 1px solid var(--b1); background: var(--ink3);
  color: var(--t3); font-family: var(--ff); font-size: var(--fsm);
  font-weight: 600; padding: clamp(4px,.4vw,7px) clamp(10px,1vw,16px);
  border-radius: var(--rad2); cursor: pointer; transition: all .12s;
  white-space: nowrap; user-select: none; line-height: 1;
}

.btn:hover:not(:disabled) {
  border-color: var(--b2); color: var(--t5);
  transform: translateY(-1px); box-shadow: 0 3px 12px rgba(0,0,0,.3);
}

.btn:active:not(:disabled) { transform: translateY(0); box-shadow: none; }
.btn:disabled { opacity: .22; cursor: not-allowed; }

.btn-p {
  background: var(--ac); border-color: var(--ac2); color: #050b14; font-weight: 700;
  box-shadow: 0 2px 10px rgba(255, 102, 0, .2);
}

.btn-p:hover:not(:disabled) {
  filter: brightness(1.12);
  box-shadow: 0 3px 18px rgba(255, 102, 0, .4);
  color: #050b14;
}

.btn-o { background: var(--acg2); border-color: var(--ac2); color: var(--ac); }
.btn-o:hover:not(:disabled) { background: var(--acg); }

.btn-g { background: transparent; border-color: transparent; color: var(--t1); }
.btn-g:hover:not(:disabled) { background: var(--ink3); border-color: var(--b0); color: var(--t3); transform: none; box-shadow: none; }

.btn-sm   { font-size: var(--fxs); padding: 2px 8px; }
.btn-full { width: 100%; }

.row-g  { display: flex; align-items: center; gap: var(--sp1); }

/* Input */
.field-lbl {
  font-family: var(--ffm); font-size: var(--fxs);
  text-transform: uppercase; letter-spacing: .1em; color: var(--t1);
  margin-bottom: var(--sp1); display: block;
}

/* ── ГЛАВНЫЙ ИНПУТ ─────────────────────────────────────────
   Полная декларация: ни один браузер не перекроет стили
   color-scheme: dark — убирает белый автофилл
───────────────────────────────────────────────────────── */
.main-input {
  width: 100%;
  /* Явные цвета — не надеяться на наследование */
  background-color: var(--ink1);
  color: var(--t5);
  caret-color: var(--ac);

  border: 1px solid var(--b0);
  border-radius: var(--rad);
  outline: none;

  font-family: var(--ffm);
  font-size: var(--fb);
  line-height: 1.5;
  padding: var(--sp2) var(--sp3);

  /* Убиваем нативный вид браузера */
  -webkit-appearance: none;
  appearance: none;
  color-scheme: dark;

  transition: border-color 150ms ease, box-shadow 150ms ease, background 150ms ease;
}

.main-input:hover:not(:focus) {
  border-color: var(--b1);
  background-color: color-mix(in oklch, var(--ink1) 90%, var(--ac));
}

.main-input:focus {
  border-color: var(--ac2);
  box-shadow: 0 0 0 3px var(--acg), inset 0 1px 3px rgba(0,0,0,.3);
  background-color: var(--ink2);
}

.main-input::placeholder { color: var(--t0); font-style: italic; }

/* Фикс белого фона автозаполнения в Chrome */
.main-input:-webkit-autofill,
.main-input:-webkit-autofill:hover,
.main-input:-webkit-autofill:focus {
  -webkit-text-fill-color: var(--t5);
  -webkit-box-shadow: 0 0 0 1000px var(--ink1) inset;
  caret-color: var(--ac);
}

/* Textarea */
.ta {
  flex: 1; width: 100%;
  background: var(--ink1); border: 1px solid var(--b0);
  border-radius: var(--rad); color: var(--t5);
  font-family: var(--ffm); font-size: var(--fsm); line-height: 1.65;
  padding: var(--sp2) var(--sp3);
  resize: none; outline: none;          /* resize:none — NEVER allow user to resize */
  transition: border-color .14s, box-shadow .14s;
}
.ta:focus { border-color: var(--ac2); box-shadow: 0 0 0 3px var(--acg); }
.ta::placeholder { color: var(--t0); }
.ta[readonly] { color: var(--t4); cursor: default; }

/* Error line */
.err-line {
  font-size: var(--fsm); font-family: var(--ffm);
  color: var(--red); min-height: 1em;
}
.err-line:not(:empty)::before { content: '⚠ '; }

/* Example chips */
.chip {
  border: 1px solid var(--b0); background: transparent;
  color: var(--t0); font-family: var(--ffm); font-size: var(--fxs);
  padding: clamp(2px,.2vw,3px) clamp(6px,.6vw,10px);
  border-radius: 3px; cursor: pointer; transition: all .12s; white-space: nowrap;
}
.chip:hover { border-color: var(--ac2); color: var(--ac); background: var(--acg2); }

/* Result placeholder */
.result-placeholder {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: var(--sp2); text-align: center; color: var(--t0);
}
.ph-ico   { font-size: var(--fxl); }
.ph-title { font-family: var(--ffd); font-size: var(--flg); color: var(--t1); font-weight: 700; }
.ph-sub   { font-size: var(--fsm); }
.ph-sub code { font-family: var(--ffm); color: var(--ac); }

/* Toast — position:absolute inside .lab, NOT fixed */
.toast {
  position: absolute;
  bottom: 16px; left: 50%; transform: translateX(-50%);
  background: var(--ac); color: #050b14;
  font-size: var(--fsm); font-weight: 700; font-family: var(--ffm);
  padding: 5px 16px; border-radius: var(--rad2);
  z-index: 999; pointer-events: none; opacity: 0; white-space: nowrap;
  box-shadow: 0 4px 16px rgba(255, 102, 0, .3);
}
.toast.on { pointer-events: auto; }

/* Footer */
.lab-foot {
  flex-shrink: 0;
  height: clamp(28px, 3.5vh, 40px);
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--sp3); padding: 0 var(--sp4);
  background: var(--ink1); border-top: 1px solid var(--b0);
  font-size: var(--fxs); color: var(--t0); flex-wrap: wrap;
}

.foot-r { display: flex; gap: var(--sp1); }

.foot-r code {
  font-family: var(--ffm); font-size: var(--fxs);
  background: var(--ink2); border: 1px solid var(--b0);
  padding: 1px 5px; border-radius: 3px;
}

/* Scrollbars */
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--b1); border-radius: 2px; }
::selection { background: var(--ac); color: #050b14; }

/* Responsive */
@media (max-width: 600px) {
  .panel-layout { grid-template-columns: 1fr; }
  .nav-btn span { display: none; }
}
/* Premium-панель «Практика» — типовой layout (дублирует паттерн из локальных style.css) */
.p-main {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: var(--sp3) var(--sp4);
  gap: var(--sp3);
  overflow: auto;
}

/* Карточки шагов/теории (__TOPIC_STEPS_HTML) */
.sbl-card {
  border: 1px solid var(--b0);
  border-radius: var(--rad);
  padding: var(--sp3);
  background: var(--ink2);
  margin-bottom: var(--sp2);
}
.sbl-card h4 {
  margin: 0 0 var(--sp2);
  color: var(--t4);
  font-size: var(--fb);
  font-weight: 700;
}
.sbl-card .muted {
  color: var(--t2);
  font-size: var(--fsm);
  line-height: 1.55;
}
.sbl-card code {
  font-family: var(--ffm);
  font-size: 0.95em;
  color: var(--ac);
}

/* Подсказки: см. _shared/tool-hints.js + [data-sbl-hint] */
.sbl-hint-wrap {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
button.sbl-hint-trigger {
  flex-shrink: 0;
  width: 1.25rem;
  height: 1.25rem;
  padding: 0;
  border-radius: 50%;
  border: 1px solid var(--b1);
  background: var(--ink3);
  color: var(--t3);
  font-size: var(--fxs);
  font-weight: 700;
  line-height: 1;
  cursor: help;
}
button.sbl-hint-trigger:hover,
button.sbl-hint-trigger:focus-visible {
  border-color: var(--ac2);
  color: var(--ac);
  outline: none;
}
.sbl-hint-popover {
  display: none;
  margin-top: var(--sp2);
  padding: var(--sp2) var(--sp3);
  border-radius: var(--rad);
  border: 1px solid var(--b0);
  background: var(--ink1);
  color: var(--t3);
  font-size: var(--fsm);
  line-height: 1.5;
  max-width: 42rem;
}
.sbl-hint-popover.is-open {
  display: block;
}
