/* Aïoli Studio — the shell: top bar, rail, pane, main area, phone tab bar, account menu, bell, page header, tabs.
   Layout ported from the reference admin (frame = top bar + rail of icons with labels, then the list pane, then the page),
   in the design of 2026-12-01 (the kiosk's white header with a hairline — navy in the dark theme —, blue links, the active item
   marked by a short yellow bar). Tokens: base.css. */

/* DENSITY: « Compact » = the page at 90 % (--zf), « Sparse » = 100 %. Heights in vh are divided by --zf so they still fill the
   screen; JS that places pop-ups or follows drags converts screen coordinates with zRect / zW / zH (dom.js). */
html { --zf: 1; --topbar: 56px; --railw: 72px; --panew: 264px; }
html.compact { --zf: .9; }
body.shell { zoom: var(--zf); }

#topbar { position: fixed; top: 0; left: 0; right: 0; z-index: 50; height: var(--topbar); display: flex; align-items: center; gap: 6px;
  padding: 0 12px 0 0; background: var(--frame); color: var(--frame-t); border-bottom: 1px solid var(--frame-line); }
#topbar .icon-btn { color: var(--frame-m); }
#topbar .icon-btn:hover { background: var(--frame-2); }
.tb-pane { width: var(--railw); display: flex; justify-content: center; flex: none; }
.tb-brand { display: flex; align-items: center; gap: 10px; color: var(--frame-t); text-decoration: none; min-width: 0; }
.tb-brand:hover { text-decoration: none; }
.tb-brand img { height: 34px; width: auto; } /* shown / hidden by theme: base.css .on-light / .on-dark */
.tb-brand .tb-prod { font: 500 12px var(--mono); letter-spacing: .14em; text-transform: uppercase; color: var(--frame-m); }
.tb-ws { margin-left: 14px; padding: 5px 14px; border: 0; border-radius: var(--pill); background: var(--frame-2); color: var(--frame-m); font: 600 13px var(--display);
  max-width: 240px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* signed in with the emergency access (src/emergency.js): visible for the whole session */
.tb-emergency { margin-left: 12px; padding: 4px 14px; border: 0; border-radius: var(--pill); background: var(--danger-solid); color: var(--on-danger); box-shadow: inset 4px 0 0 var(--yellow); font-size: 13px; font-weight: 700;
  min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tb-sp { flex: 1; }
.tb-icon .pill { position: absolute; top: 2px; right: 0; border: 2px solid var(--frame); }

/* pop-ups of the top bar (account menu, bell): placed under their button by ui.js placePop (zoom-aware) */
.pop { position: fixed; z-index: 60; width: 280px; background: var(--surface); color: var(--ink); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow-pop); padding: 8px; }
.pop-head { display: grid; gap: 2px; padding: 10px 12px 12px; border-bottom: 1px solid var(--line-2); margin-bottom: 6px; }
.pop-head b { font-size: 14px; overflow: hidden; text-overflow: ellipsis; }
.pop-head span { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; }
.pop-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 12px; font-size: 13px; }
.pop-row > span { color: var(--ink-2); }
.pop a, .pop .pop-item { display: flex; align-items: center; gap: 10px; width: 100%; padding: 9px 12px; border: 0; border-radius: var(--radius-xs); background: none;
  color: var(--ink); font: 600 13.5px var(--sans); text-align: left; text-decoration: none; cursor: pointer; }
.pop a:hover, .pop .pop-item:hover { background: var(--hover); text-decoration: none; }
.pop .pop-item.out { color: var(--danger); font-weight: 700; }
.pop .ic svg { width: 16px; height: 16px; color: var(--muted); }
.pop-sep { height: 1px; margin: 6px 0; background: var(--line-2); }
.pop-empty { padding: 16px 12px; color: var(--muted); font-size: 13px; }
/* the bell (runs of the agents + the Studio's background jobs, public/app/bell.js) */
[data-act="bell"] { position: relative; }
[data-act="bell"].bell-run::after { content: ''; position: absolute; top: 6px; right: 6px; width: 7px; height: 7px; border-radius: 50%; background: var(--yellow); box-shadow: 0 0 0 2px var(--frame); animation: bellp 1.2s infinite; }
@keyframes bellp { 50% { opacity: .3; } }
.bell-n { position: absolute; top: 2px; right: 0; min-width: 16px; height: 16px; border-radius: 8px; background: var(--yellow); color: var(--navy); font: 800 10px/16px var(--display); text-align: center; padding: 0 4px; }
.pop-bell { width: 320px; }
.bk-list { max-height: 45vh; overflow-y: auto; }
.pop a.bk, .pop div.bk { display: flex; flex-direction: column; align-items: stretch; gap: 2px; padding: 8px 12px; color: var(--ink); text-decoration: none; border-top: 1px solid var(--line-2); border-radius: 0; }
.pop a.bk:hover { background: var(--hover); text-decoration: none; } .bk.new { border-left: 3px solid var(--yellow); }
.bk-m { font-size: 12px; } .bk-err .bk-m { color: var(--danger); }
.bk-bar { display: block; width: 100%; height: 4px; border-radius: var(--pill); background: var(--line-2); overflow: hidden; } .bk-bar i { display: block; height: 100%; background: var(--accent); }
.bk-bar.ind i { animation: bkind 1.4s infinite ease-in-out; } @keyframes bkind { 0% { margin-left: -35%; } 100% { margin-left: 100%; } }
.bk-clear { margin: 8px 12px; }
.bell-runs:not(:first-child) { margin-top: 6px; border-top: 1px solid var(--line); }
.av { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; background: var(--blue); color: var(--white);
  font: 700 12px var(--display); letter-spacing: .03em; }
.tb-user { border-radius: 50%; padding: 2px; border: 0; background: none; cursor: pointer; }
.tb-user:hover .av { box-shadow: 0 0 0 2px var(--frame), 0 0 0 4px var(--accent-ink); }

/* rail */
#rail { position: fixed; top: var(--topbar); left: 0; bottom: 0; z-index: 42; width: var(--railw); display: flex; flex-direction: column; gap: 2px;
  padding: 8px 0 12px; background: var(--frame); border-right: 1px solid var(--frame-line); overflow-y: auto; scrollbar-width: none; }
#rail a { position: relative; display: flex; flex-direction: column; align-items: center; gap: 3px; margin: 0 5px; padding: 9px 1px 7px;
  border-radius: var(--radius-sm); color: var(--frame-m); font: 600 10.5px var(--display); line-height: 1.15; text-align: center; text-decoration: none; }
#rail a:hover { background: var(--frame-2); color: var(--frame-on); }
#rail a.on { background: var(--frame-2); color: var(--frame-on); }
#rail a.on::after { content: ''; position: absolute; left: 30%; right: 30%; bottom: 3px; height: 3px; background: var(--yellow); }
#rail .ic svg { width: 22px; height: 22px; }
#rail .lb { max-width: 100%; overflow: hidden; overflow-wrap: break-word; hyphens: auto; }
#rail .rail-sp { flex: 1; }

/* pane: the agents and the conversations (or the pages of a section), next to the rail */
#pane { position: fixed; top: var(--topbar); left: var(--railw); bottom: 0; z-index: 40; width: var(--panew); display: none; flex-direction: column;
  background: var(--surface); border-right: 1px solid var(--line); }
body.has-pane:not(.pane-off) #pane { display: flex; }
.pn-h { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 16px 16px 8px; }
.pn-h h2 { font-size: 18px; font-weight: 700; }
.pn-q { margin: 12px 12px 8px; }
.pn-q input { height: 34px; padding: 0 14px; border-radius: var(--pill); font-size: 13px; }
.pn-list { flex: 1; overflow-y: auto; padding: 2px 8px 24px; scrollbar-width: thin; }
.pn-hh { margin: 10px 6px 4px; padding-top: 10px; border-top: 1px solid var(--line-2); font: 700 10.5px var(--display); letter-spacing: .1em;
  text-transform: uppercase; color: var(--accent-ink); }
.pn-hh:first-child { border-top: 0; padding-top: 0; }
.pn-day { margin: 10px 6px 2px; font-size: 11.5px; font-weight: 600; color: var(--muted); }
.pn-list a { display: flex; align-items: center; gap: 10px; padding: 8px 12px; margin: 2px 0; border-radius: var(--pill); color: var(--ink);
  font-size: 13.5px; line-height: 1.25; text-decoration: none; }
.pn-list a:hover { background: var(--hover); text-decoration: none; }
.pn-list a.on { background: var(--accent); color: var(--on-accent); font-weight: 600; }
.pn-list a.on .ic svg { color: var(--on-accent); }
.pn-list a .ic svg { width: 17px; height: 17px; color: var(--muted); }
.pn-list .lb { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pn-none { padding: 6px 10px 8px; font-size: 12.5px; color: var(--muted); }
.pn-foot { flex: none; border-top: 1px solid var(--line); padding: 6px 8px 10px; }

/* main area: right of the rail (and of the pane when it is shown) */
#main { margin: var(--topbar) 0 0 var(--railw); padding: 24px 32px 60px; min-height: calc(100vh / var(--zf) - var(--topbar)); }
body.has-pane:not(.pane-off) #main { margin-left: calc(var(--railw) + var(--panew)); }
body.full #main { padding: 0; }
.phead { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 20px; }
.phead .ph-main { min-width: 0; }
.phead .ph-main p { margin: 6px 0 0; color: var(--muted); }
.phead .ph-act { display: flex; flex-wrap: wrap; gap: 8px; }

/* tabs (the agent page: Build · Test · Deploy · Monitor · Iterate) */
.tabs { display: flex; gap: 4px; margin: 0 0 20px; border-bottom: 1px solid var(--line-2); overflow-x: auto; scrollbar-width: none; }
.tabs a { position: relative; padding: 10px 14px 12px; color: var(--accent-ink); font: 600 14px var(--display); white-space: nowrap; text-decoration: none; }
.tabs a:hover { color: var(--ink); text-decoration: none; }
.tabs a.on { color: var(--ink); }
.tabs a.on::after { content: ''; position: absolute; left: 14px; right: 14px; bottom: 0; height: 3px; background: var(--yellow); }
.strip { display: flex; flex-wrap: wrap; gap: 8px; margin: -6px 0 18px; }
.strip span { display: inline-flex; align-items: center; gap: 6px; padding: 4px 12px; border: 0; border-radius: var(--pill); background: var(--accent-soft); font-size: 12px; font-weight: 600; color: var(--accent-ink); }
.strip span::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: var(--line); }
.strip span.done::before { background: var(--ok); }
.strip span.todo::before { background: var(--yellow); }

/* settings */
.set-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 520px), 1fr)); gap: 0 20px; align-items: start; }
.set-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line-2); }
.set-row:last-child { border-bottom: 0; }
.set-row > div > small { display: block; color: var(--muted); }
.seg button:disabled { cursor: default; opacity: .65; }
/* Settings → Workspace (issue #27): the brand logo as uploaded (processing: issue #14) */
.ws-logo-box { align-items: center; }
.lg-name { display: inline-flex; align-items: center; gap: 10px; } .lg-thumb { max-width: 96px; max-height: 32px; padding: 3px; } /* the logo catalogue (issue #14) */
.ws-form { margin: 0 0 8px; }
.ws-form label { flex: 1 0 100%; }
.inline-form input.ws-num { flex: 0 0 140px; }
.ws-logo { display: block; max-width: 220px; max-height: 64px; padding: 6px; background: var(--white); border: 1px solid var(--line); border-radius: var(--radius-xs); } /* light ground in both themes: logos are made for paper */

/* phones: the sections in a bottom tab bar, the pane as a sheet opened from the top bar */
#tabbar { display: none; }
@media (max-width: 782px) {
  html { --railw: 0px; }
  html, body { overflow-x: clip; }
  #rail, .tb-ws, .tb-brand .tb-prod { display: none !important; }
  .tb-pane { width: auto; padding-left: 6px; }
  #pane { left: 0; right: 0; width: auto; bottom: calc(60px + env(safe-area-inset-bottom)); box-shadow: var(--shadow-pop); }
  body.has-pane:not(.pane-off) #pane { display: none; }
  body.pane-sheet #pane { display: flex !important; }
  #main, body.has-pane:not(.pane-off) #main { margin-left: 0; padding: 16px 16px calc(84px + env(safe-area-inset-bottom)); }
  body.full #main { padding: 0 0 calc(64px + env(safe-area-inset-bottom)); }
  #tabbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 55; display: flex; padding: 4px 4px env(safe-area-inset-bottom);
    background: var(--frame); border-top: 1px solid var(--frame-line); }
  #tabbar a { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 7px 2px 6px; color: var(--frame-m);
    font-size: 10.5px; font-weight: 600; text-decoration: none; position: relative; }
  #tabbar a .lb { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  #tabbar .ic svg { width: 22px; height: 22px; }
  #tabbar a.on { color: var(--frame-on); }
  #tabbar a.on::before { content: ''; position: absolute; top: -4px; left: 28%; right: 28%; height: 3px; background: var(--yellow); }
  #toasts { bottom: calc(76px + env(safe-area-inset-bottom)); left: 16px; right: 16px; }
  h1 { font-size: 22px; }
}

/* forms in dialogs and the API keys page (issue #28) */
.fld { display: block; margin: 0 0 12px; padding: 0; border: 0; font-size: 13px; font-weight: 700; }
.fld > input, .fld > select { display: block; margin-top: 5px; font-weight: 500; }
.fld > input[type=date] { width: 100%; }
.fld > small { display: block; margin-top: 3px; font-weight: 500; color: var(--muted); }
.fld > legend { padding: 0; margin-bottom: 4px; }
.chk { display: flex; gap: 8px; align-items: center; margin: 4px 0; font-size: 13.5px; font-weight: 400; }
.chk-list { max-height: 180px; overflow: auto; padding-left: 22px; }
.code { font-family: var(--mono); font-size: 12.5px; word-break: break-all; }
input.code { width: 100%; }
