/* UI Katalog — vlastná vrstva nad Terminal.css.
   Kit nemá aplikačný shell (fixný header, tri stĺpce, náhľadová plocha),
   takže ho staviame tu. Všetky farby a rozmery berieme z premenných kitu,
   aby appka dedila jeho tému a stačilo prepísať :root.               */

/* deliace čiary appky — plná --secondary-color je na ne v tmavom režime
   priveľmi kontrastná, tak ju stlmíme; ostáva viazaná na tému kitu */
:root { --app-hair: color-mix(in srgb, var(--content-tertiary) 38%, transparent); }

html, body { height: 100%; }
body {
  margin: 0;
  overflow: hidden;
  background: var(--surface-default);
  color: var(--content-default);
  font-family: var(--font-sans);
  font-size: 13px;
}

.spacer { flex: 1; }
.count { color: var(--content-tertiary); }

/* ---------------------------------------------------------------- header */
.top {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 46px;
  padding: 0 10px;
  border-bottom: 1px solid var(--app-hair);
}
.brand { font-weight: 700; white-space: nowrap; }
.search {
  width: 300px;
  margin: 0 !important;
  padding: 4px 8px !important;
  height: 28px;
}

.seg { display: flex; }
/* segmentovaný prepínač poskladaný z Oxide tlačidiel */
.seg .ox-button { border-radius: 0; padding: 0 9px; height: 26px; }
.seg .ox-button + .ox-button { margin-left: -1px; }
.seg .ox-button:first-child { border-top-left-radius: 2px; border-bottom-left-radius: 2px; }
.seg .ox-button:last-child { border-top-right-radius: 2px; border-bottom-right-radius: 2px; }
.seg .ox-button.on {
  background: var(--surface-accent-secondary);
  color: var(--content-accent);
  box-shadow: inset 0 0 0 1px var(--stroke-accent-secondary);
  z-index: 1;
}


/* ---------------------------------------------------------------- shell */
.shell { display: flex; height: calc(100% - 46px); }
.col {
  display: flex;
  flex-direction: column;
  flex: 0 0 216px;
  min-width: 0;
  border-right: 1px solid var(--app-hair);
}
.col-head {
  padding: 10px 10px 5px;
  font-size: 10px;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--content-tertiary);
}
.col-foot { padding: 8px 10px; border-top: 1px solid var(--app-hair); }
.list { flex: 1; overflow-y: auto; padding: 0 10px 10px; }

.item {
  padding: 4px 8px;
  cursor: pointer;
  border-left: 2px solid transparent;
  font-size: 12px;
}
.item:hover { background: var(--surface-secondary); }
.item.on { border-left-color: var(--content-accent); background: var(--surface-secondary); }
.item.on .item-name { color: var(--content-accent); }
.item-name { display: flex; align-items: center; gap: 7px; font-weight: 600; }
.item-sub {
  color: var(--content-tertiary);
  font-size: 10px;
  margin-top: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.swatch { width: 9px; height: 9px; flex: 0 0 auto; }
.group {
  padding: 11px 8px 3px;
  font-size: 9.5px;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--content-tertiary);
}
.empty { padding: 20px 8px; color: var(--content-tertiary); font-size: 12.5px; line-height: 1.6; }

/* ---------------------------------------------------------------- stage */
.stage { flex: 1; display: flex; flex-direction: column; min-width: 0; }

/* druhý horný pás: názov knižnice · komponenty ako taby · akcie.
   Vľavo je len jedno menu (knižnice), komponenty patria sem hore.       */
.stage-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 40px;
  padding: 0 10px;
  border-bottom: 1px solid var(--app-hair);
}
.stage-title {
  display: flex; align-items: center;
  font-weight: 700; font-size: 13px; white-space: nowrap;
  padding-right: 10px;
  border-right: 1px solid var(--app-hair);
  flex: 0 0 auto;
}
.stage-acts {
  display: flex; align-items: center; gap: 6px; flex: 0 0 auto;
  padding-left: 10px;
  border-left: 1px solid var(--app-hair);
}

.frame-wrap {
  flex: 1;
  overflow: auto;
  display: flex;
  justify-content: center;
  background: var(--surface-secondary);
}
iframe {
  border: 0; width: 100%; height: 100%; background: #fff;
  transition: width .18s ease;
  /* bez flex:none by flexbox zmenšil iframe pod nastavenú šírku a „360"
     by v úzkom okne v skutočnosti nebolo 360 */
  flex: 0 0 auto;
}
iframe.narrow { box-shadow: 0 0 0 1px var(--content-tertiary); }

.code { height: 38%; border-top: 1px solid var(--app-hair);
  display: flex; flex-direction: column; }
.code-bar {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 10px;
  border-bottom: 1px solid var(--app-hair);
  font-size: 11px; color: var(--content-tertiary);
}
.code pre {
  margin: 0; flex: 1; overflow: auto;
  padding: 12px 10px;
  font-size: 12px; line-height: 1.6; white-space: pre;
  background: var(--surface-raise);
}

/* ---------------------------------------------------------------- modály */
.modal {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(0, 0, 0, .66);
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
}
.modal-box {
  width: min(780px, 100%); max-height: 86vh;
  display: flex; flex-direction: column;
  background: var(--surface-default);
  border: 1px solid var(--content-default);
  overflow: hidden;
}
.tk-modal-head { display: flex; align-items: center; gap: 8px; }
.modal-body { overflow: auto; display: flex; flex-direction: column; gap: 12px; }

.chips { display: flex; flex-direction: column; gap: 5px; }
.chips button {
  text-align: left;
  border: 1px solid var(--app-hair);
  background: none;
  color: var(--content-tertiary);
  padding: 7px 9px;
  font: inherit; font-size: 12.5px; line-height: 1.5;
  cursor: pointer; margin: 0;
}
.chips button:hover { color: var(--content-default); border-color: var(--content-default); }
#atlas-prompt { margin: 0 !important; }
.modal-actions { display: flex; align-items: center; gap: 10px; }

/* ---------------------------------------------------------------- feed */
.log { max-height: 280px; overflow: auto; padding: 10px;
  border: 1px solid var(--app-hair); background: var(--surface-raise); }
.ev { font-size: 11.5px; line-height: 1.6; color: var(--content-default);
  white-space: pre-wrap; overflow-wrap: anywhere; }
.ev.cmd { color: var(--content-tertiary); }
.ev.ok { color: var(--content-accent); font-weight: 700; }
.ev.err { color: var(--content-destructive); }
.ev.now::after {
  content: "_"; margin-left: 2px; font-weight: 700;
  animation: blink 1s steps(1) infinite;
}
@keyframes blink { 0%, 49% { opacity: 1 } 50%, 100% { opacity: 0 } }
#atlas-state.ok { color: var(--content-accent); }
#atlas-state.err { color: var(--content-destructive); }

/* ---------------------------------------------------------------- kandidáti */
.cands { display: flex; flex-direction: column; gap: 10px; }
.cand { border: 1px solid var(--app-hair); padding: 11px 12px; }
.cand.done { opacity: .45; }
.cand-top { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.cand-name { font-weight: 700; }
.cand-lic {
  font-size: 10px; letter-spacing: .08em; text-transform: uppercase;
  border: 1px solid var(--app-hair); padding: 2px 5px;
  color: var(--content-tertiary);
}
.cand-lic.ok { color: var(--content-accent); border-color: var(--content-accent); }
.cand-meta { font-size: 11.5px; line-height: 1.6; color: var(--content-tertiary);
  margin-top: 6px; white-space: pre-line; overflow-wrap: anywhere; }
.cand-why { font-size: 13px; line-height: 1.55; margin-top: 8px; }
.cand-caveat { font-size: 12.5px; line-height: 1.5; margin-top: 6px;
  color: var(--content-tertiary); }
.cand-caveat b { color: var(--content-destructive); }
.cand-acts { display: flex; gap: 10px; align-items: center; flex-wrap: wrap;
  margin-top: 11px; }
.cand-acts a { font-size: 12px; }

/* display:flex prebíja atribút hidden — musí zostať posledné */
[hidden] { display: none !important; }

/* ---------- výber viacerých kandidátov ---------- */
.cands-foot {
  display: flex; align-items: center; gap: 8px;
  border-top: 1px solid var(--app-hair);
  padding: 10px 10px;
  flex: 0 0 auto;
}
.cand-acts .tk-check { cursor: pointer; user-select: none; }
.cand-acts .tk-check span { font-size: 12.5px; }
.cand.picked { border-color: var(--content-accent); }
.acts-sep { width: 1px; height: 13px; background: var(--app-hair); margin: 0 2px; }
.cand-no { color: var(--content-tertiary) !important; }
.cand-no:hover { color: var(--content-destructive) !important; border-color: var(--content-destructive) !important; }
.cand-acts a.dead { color: var(--content-destructive); text-decoration: line-through;
  border-bottom-color: var(--content-destructive); }

/* ---------- rozbaľovací zoznam všetkých komponentov ----------
   Vodorovný pás je rýchly, ale pri 14 komponentoch časť ostane
   za okrajom. Tento panel ukáže všetko naraz, po kategóriách. */

/* Pri úzkom okne sa horný pás nezmestil: názov + taby + „všetky" + akcie
   dokopy pretekali a taby sa zmrštili na nulu — časť komponentov sa nedala
   nájsť inak než cez rozbaľovací zoznam. Ustupuje názov, nie navigácia. */
.stage-title { min-width: 0; overflow: hidden; text-overflow: ellipsis; }

@media (max-width: 940px) {
  .stage-title { display: none; }
}
.search { flex: 0 1 300px; min-width: 140px; height: 26px; padding: 0 8px; }
#atlas-prompt { min-height: 7rem; }
.oxx-label { margin-bottom: 0; }

@media (max-width: 940px) {
  /* prepínač šírky náhľadu je testovacia pomôcka — v úzkom okne
     ustúpi hľadaniu, ktoré je hlavná navigácia */
  #viewport { display: none; }
  .top .brand { display: none; }
}

/* upozornenie, že náhľad je pri tejto šírke orezaný */
.resp-flag {
  flex: 0 0 auto; align-self: center; white-space: nowrap; cursor: help;
  font-size: 11.5px; padding: 3px 7px;
  color: var(--content-destructive);
  border: 1px solid var(--content-destructive);
}
@media (max-width: 940px) { .resp-flag { font-size: 0; padding: 3px 6px; }
  .resp-flag::before { content: "⚠"; font-size: 12px; } }


/* ---------- výber knižnice ----------
   Natívny <select> si otvorí systémové menu, ktoré sa nedá naštýlovať —
   v mono rozhraní pôsobí ako cudzí prvok. Preto vlastný dropdown
   poskladaný z prvkov kitu: rám, mono písmo, hranaté rohy.            */
.col-top { padding: 0 10px 8px; }
.lib-picker { position: relative; }

.lib-trigger {
  width: 100%;
  display: flex; align-items: center; gap: 6px;
  height: 28px; padding: 0 26px 0 8px;
  background: var(--surface-default);
  border: 1px solid var(--stroke-default);
  color: var(--content-default);
  font: inherit; font-size: 12px;
  text-align: left; cursor: pointer;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.lib-trigger:hover { border-color: var(--content-default); }
.lib-trigger[aria-expanded="true"] { border-color: var(--content-accent); }
.lib-picker::after {
  content: "▾"; position: absolute; right: 18px; top: 5px;
  pointer-events: none; color: var(--content-tertiary); font-size: 11px;
}

.lib-menu {
  position: absolute; z-index: 40;
  top: calc(100% + 2px); left: 10px; right: 10px;
  max-height: 60vh; overflow-y: auto;
  background: var(--surface-default);
  border: 1px solid var(--content-default);
  box-shadow: 4px 4px 0 rgba(0, 0, 0, .35);
}
.lib-opt {
  width: 100%;
  display: flex; align-items: center; gap: 7px;
  padding: 5px 8px;
  background: none; border: 0; border-left: 2px solid transparent;
  color: var(--content-tertiary);
  font: inherit; font-size: 12px; text-align: left; cursor: pointer;
}
.lib-opt:hover { background: var(--surface-secondary); color: var(--content-default); }
.lib-opt.on { color: var(--content-accent); border-left-color: var(--content-accent); }
.lib-opt-name { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lib-opt-num { font-size: 10px; opacity: .6; }

/* ---------- seed farba pre Material 3 ---------- */
#pseed { align-items: stretch; }
#pseed.off { opacity: .4; }
#pseed.off * { cursor: not-allowed; }


.seed-variant {
  margin: 0 !important;
  height: auto; padding: 3px 6px !important;
  border: 1px solid var(--stroke-default);
  border-right: 0;
  background: var(--surface-default);
  color: var(--content-default);
  font: inherit; font-size: 11px;
}
#pseed .ox-button { border-radius: 0; padding: 0 9px; height: 26px; }

/* výber seed farby — štvorček bez popisu nikto nerozpozná ako ovládací
   prvok, preto chip + text a celé to je klikateľné */
.seed-pick {
  position: relative;
  display: flex; align-items: center; gap: 6px;
  padding: 0 9px;
  border: 1px solid var(--stroke-default); border-right: 0;
  color: var(--content-tertiary);
  font-size: 11px; cursor: pointer;
  white-space: nowrap;
}
.seed-pick:hover { color: var(--content-default); border-color: var(--content-default); }
.seed-pick.active { color: var(--content-default); }
.seed-chip {
  width: 11px; height: 11px; flex: 0 0 auto;
  border: 1px solid var(--stroke-default);
  background: transparent;
}
.seed-pick.active .seed-chip { border-color: var(--content-default); }
.seed-pick input[type="color"] {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  padding: 0; margin: 0; border: 0; background: none;
  opacity: 0; cursor: pointer;
}
#pseed.off .seed-pick { cursor: not-allowed; }
.seed-weak {
  display: flex; align-items: center; padding: 0 7px;
  border: 1px solid var(--stroke-default); border-right: 0;
  font-size: 10.5px; color: var(--content-tertiary);
  cursor: help;
}

/* verejná inštancia — bez zápisu */
body.readonly #cands-foot,
body.readonly #cands-clear,
body.readonly .cand-acts .oxx-check { display: none !important; }
