/* Voice agents (Ciabatta) - list + builder. Builds on site.css tokens; no overrides of shared rules. */

/* ---- List ---- */
.ag-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }
.ag-card {
  position: relative; display: flex; flex-direction: column; gap: 14px; padding: 18px 18px 16px;
  border-radius: var(--radius); border: 1px solid var(--border); background: var(--panel);
  color: var(--text); text-decoration: none !important; transition: border-color .2s, background .2s, transform .2s;
}
.ag-card:hover { border-color: var(--border-strong); background: var(--panel-hover); transform: translateY(-1px); }
.ag-card-top { display: flex; gap: 12px; align-items: flex-start; }
.ag-avatar {
  flex: none; width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center;
  font: 700 17px var(--display); color: #1b1203; background: var(--grad); box-shadow: 0 6px 20px -8px rgba(245,181,68,.6);
}
.ag-avatar.alt { background: linear-gradient(135deg, #38d9ff, #1fb6ff); color: #04121f; box-shadow: 0 6px 20px -8px rgba(56,217,255,.6); }
.ag-name { font: 700 16px var(--display); letter-spacing: -0.01em; word-break: break-word; }
.ag-desc { margin-top: 2px; font-size: 13px; color: var(--muted); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.ag-tags { display: flex; flex-wrap: wrap; gap: 6px; }
.ag-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: auto; padding-top: 12px; border-top: 1px solid var(--border); font-size: 12.5px; color: var(--faint); }
.ag-price { font: 700 15px var(--display); color: var(--text); }
.ag-price small { font: 500 12px var(--sans); color: var(--faint); }
.ag-actions { position: absolute; top: 12px; right: 12px; display: flex; gap: 4px; opacity: 0; transition: opacity .15s; }
.ag-card:hover .ag-actions, .ag-card:focus-within .ag-actions { opacity: 1; }
.icon-btn {
  display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--panel-solid); color: var(--muted); cursor: pointer; padding: 0;
}
.icon-btn:hover { color: var(--text); border-color: var(--border-strong); }
.icon-btn.danger:hover { color: var(--danger); border-color: rgba(248,113,113,.4); }
.icon-btn svg { width: 15px; height: 15px; }
@media (hover: none) { .ag-actions { opacity: 1; } }

/* Empty state + templates */
.ag-hero {
  position: relative; overflow: hidden; padding: 36px; border-radius: 20px; border: 1px solid var(--border-strong);
  background: radial-gradient(1200px 300px at 0% 0%, rgba(245,181,68,.12), transparent 60%), radial-gradient(800px 260px at 100% 100%, rgba(56,217,255,.10), transparent 60%), var(--panel);
}
.ag-hero h2 { margin: 0 0 6px; font: 800 26px var(--display); letter-spacing: -0.02em; }
.ag-hero p { margin: 0 0 22px; color: var(--muted); max-width: 640px; }
.tpl-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; }
.tpl {
  display: flex; flex-direction: column; gap: 6px; padding: 14px; border-radius: 12px; border: 1px solid var(--border);
  background: rgba(0,0,0,.2); color: var(--text); cursor: pointer; text-align: left; font: inherit; transition: border-color .2s, background .2s;
}
.tpl:hover { border-color: var(--border-strong); background: var(--panel-hover); }
.tpl.selected { border-color: var(--accent); background: rgba(245,181,68,.08); box-shadow: inset 0 0 0 1px var(--accent); }
.tpl-title { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 14px; }
.tpl-title svg { width: 18px; height: 18px; color: var(--accent); flex: none; }
.tpl-blurb { font-size: 12.5px; color: var(--muted); line-height: 1.45; }
.tpl-meta { font-size: 11.5px; color: var(--faint); }
dialog.modal.wide { width: min(760px, calc(100vw - 32px)); }

/* ---- Builder layout ---- */
.ab-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.ab-back { color: var(--muted); font-size: 14px; text-decoration: none !important; }
.ab-back:hover { color: var(--text); }
.ab-status { font-size: 13px; color: var(--faint); display: flex; align-items: center; gap: 8px; }
.ab-status .dot.dirty { background: var(--warn); box-shadow: 0 0 10px var(--warn); }
.ab-layout { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 24px; align-items: start; }
.ab-side { position: sticky; top: 20px; display: grid; gap: 14px; }
@media (max-width: 1100px) {
  .ab-layout { grid-template-columns: minmax(0, 1fr); }
  .ab-side { position: static; }
}

/* Identity header */
.ab-ident { display: grid; grid-template-columns: auto minmax(0,1fr); gap: 16px; align-items: center; margin-bottom: 18px; }
.ab-ident .ag-avatar { width: 56px; height: 56px; font-size: 22px; border-radius: 16px; }
.ab-name {
  width: 100%; border: 0 !important; background: transparent !important; padding: 2px 0 !important; box-shadow: none !important;
  font: 800 26px var(--display) !important; letter-spacing: -0.02em; color: var(--text);
}
.ab-name:focus { outline: none; border-bottom: 1px dashed var(--border-strong) !important; }
.ab-descr { width: 100%; border: 0 !important; background: transparent !important; padding: 2px 0 !important; color: var(--muted) !important; font-size: 14px !important; box-shadow: none !important; }
.ab-descr:focus { outline: none; }

/* Section nav (chips) */
.ab-nav { position: sticky; top: 0; z-index: 5; display: flex; gap: 6px; overflow-x: auto; padding: 10px 0; margin-bottom: 8px; background: linear-gradient(var(--bg) 70%, transparent); scrollbar-width: none; }
.ab-nav::-webkit-scrollbar { display: none; }
.ab-nav a {
  flex: none; padding: 6px 12px; border-radius: 999px; border: 1px solid var(--border); color: var(--muted);
  font: 600 12.5px var(--sans); text-decoration: none !important; background: rgba(255,255,255,.02);
}
.ab-nav a:hover, .ab-nav a.active { color: var(--text); border-color: var(--border-strong); background: rgba(255,255,255,.07); }
.ab-nav a .n { display: inline-grid; place-items: center; min-width: 16px; height: 16px; margin-left: 6px; border-radius: 999px; background: var(--danger); color: #1a0505; font-size: 10.5px; }

/* Sections */
.ab-sec { scroll-margin-top: 64px; margin-bottom: 16px; }
.ab-sec > .card-head { margin-bottom: 6px; }
.ab-sec-sub { margin: 0 0 18px; color: var(--faint); font-size: 13.5px; }
.ab-sec h3 { display: flex; align-items: center; gap: 10px; }
.ab-sec h3 .sec-ic { display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 8px; background: rgba(245,181,68,.12); color: var(--accent); }
.ab-sec h3 .sec-ic svg { width: 16px; height: 16px; }
.ab-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 4px 22px; }
.ab-fields .af.wide { grid-column: 1 / -1; }
@media (max-width: 700px) { .ab-fields { grid-template-columns: minmax(0, 1fr); } }
details.ab-adv { margin-top: 6px; border-top: 1px dashed var(--border); padding-top: 10px; }
details.ab-adv > summary { cursor: pointer; color: var(--muted); font: 600 13px var(--sans); list-style: none; display: flex; align-items: center; gap: 6px; padding: 4px 0 10px; }
details.ab-adv > summary::-webkit-details-marker { display: none; }
details.ab-adv > summary::before { content: "+"; display: inline-grid; place-items: center; width: 18px; height: 18px; border-radius: 6px; border: 1px solid var(--border-strong); font-size: 13px; }
details.ab-adv[open] > summary::before { content: "-"; }

/* One field */
.af { padding: 8px 0 12px; min-width: 0; }
.af-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 7px; min-height: 20px; }
.af-label { font-size: 13px; font-weight: 600; color: var(--muted); display: inline-flex; align-items: center; gap: 7px; }
.af.is-set .af-label::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 8px var(--accent); }
.af-reset { display: none; border: 0; background: none; padding: 0; color: var(--faint); font: 600 12px var(--sans); cursor: pointer; }
.af-reset:hover { color: var(--accent); }
.af.is-set .af-reset { display: inline; }
.af .hint { margin: 6px 0 0; line-height: 1.45; }
.af-err { margin: 6px 0 0; font-size: 12.5px; color: var(--danger); }
.af.has-err input, .af.has-err textarea, .af.has-err .seg, .af.has-err .csel-btn { border-color: rgba(248,113,113,.6) !important; }
.af textarea.prompt { min-height: 190px; font: 14px/1.55 var(--sans); }
.af-count { font-size: 11.5px; color: var(--faint); font-variant-numeric: tabular-nums; }

/* Segmented control */
.seg { display: inline-flex; flex-wrap: wrap; gap: 3px; padding: 3px; border-radius: 11px; background: rgba(0,0,0,.3); border: 1px solid var(--border-strong); max-width: 100%; }
.seg button { border: 0; background: transparent; color: var(--muted); padding: 7px 12px; border-radius: 8px; font: 600 13px var(--sans); cursor: pointer; white-space: nowrap; }
.seg button:hover { color: var(--text); }
.seg button.active { background: rgba(255,255,255,.11); color: var(--text); box-shadow: inset 0 1px 0 rgba(255,255,255,.08); }

/* Slider */
.slider { display: flex; align-items: center; gap: 12px; }
.slider input[type=range] { flex: 1; min-width: 0; accent-color: var(--accent); height: 22px; background: transparent; }
.slider output { flex: none; min-width: 64px; text-align: right; font: 600 13px var(--mono); color: var(--text); font-variant-numeric: tabular-nums; }
.slider .ends { display: flex; justify-content: space-between; font-size: 11px; color: var(--faint); margin-top: 2px; }

/* Chip input */
.chips { display: flex; flex-wrap: wrap; gap: 6px; padding: 7px; min-height: 42px; border-radius: var(--radius-sm); border: 1px solid var(--border-strong); background: rgba(0,0,0,.35); align-items: center; }
.chips input { flex: 1; min-width: 120px; border: 0 !important; background: transparent !important; padding: 4px !important; box-shadow: none !important; }
.chips input:focus { outline: none; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 3px 4px 3px 10px; border-radius: 999px; background: rgba(255,255,255,.08); border: 1px solid var(--border); font-size: 12.5px; }
.chip button { border: 0; background: none; color: var(--faint); cursor: pointer; padding: 0 4px; font-size: 14px; line-height: 1; }
.chip button:hover { color: var(--danger); }
.chip.var { background: rgba(56,217,255,.1); border-color: rgba(56,217,255,.3); color: #bdeef7; font-family: var(--mono); padding-right: 10px; }

/* Model tiers */
.tiers { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin-bottom: 12px; }
@media (max-width: 700px) { .tiers { grid-template-columns: minmax(0, 1fr); } }
.tier {
  display: grid; gap: 4px; padding: 14px; border-radius: 12px; border: 1px solid var(--border); background: rgba(0,0,0,.2);
  text-align: left; color: var(--text); font: inherit; cursor: pointer; transition: border-color .2s, background .2s;
}
.tier:hover { border-color: var(--border-strong); }
.tier.active { border-color: var(--accent); background: rgba(245,181,68,.07); box-shadow: inset 0 0 0 1px var(--accent); }
.tier-k { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.tier-name { font: 700 15px var(--display); }
.tier-price { font: 600 13px var(--mono); color: var(--accent-3); }
.tier-sub { font-size: 12.5px; color: var(--muted); }
.tier-model { font-size: 12px; color: var(--faint); }
.meter { display: inline-flex; gap: 2px; vertical-align: middle; margin-left: 4px; }
.meter i { width: 4px; height: 9px; border-radius: 2px; background: rgba(255,255,255,.14); }
.meter i.on { background: var(--accent-2); }

/* Voices */
.vtools { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 10px; }
.vtools input[type=search] { max-width: 260px; }
.vgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 8px; max-height: 340px; overflow-y: auto; padding: 2px; }
.vopt {
  display: flex; align-items: center; gap: 10px; padding: 10px 10px 10px 12px; border-radius: 11px; border: 1px solid var(--border);
  background: var(--panel); cursor: pointer; color: var(--text); font: inherit; text-align: left; min-width: 0;
}
.vopt:hover { border-color: var(--border-strong); background: var(--panel-hover); }
.vopt.active { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); background: rgba(245,181,68,.07); }
.vopt .vname { font-weight: 600; font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.vopt .vmeta { font-size: 11.5px; color: var(--faint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.vopt .vtext { flex: 1; min-width: 0; }
.vplay { flex: none; display: grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; border: 1px solid var(--border-strong); background: rgba(255,255,255,.04); color: var(--text); cursor: pointer; }
.vplay:hover { border-color: var(--accent); color: var(--accent); }
.vplay.playing { background: var(--accent); color: #1b1203; border-color: var(--accent); }
.vplay svg { width: 12px; height: 12px; }

/* Engine cards */
.engines { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-bottom: 14px; }
@media (max-width: 700px) { .engines { grid-template-columns: minmax(0, 1fr); } }

/* Tools */
.tools { display: grid; gap: 10px; }
.tool { border: 1px solid var(--border); border-radius: 12px; background: rgba(0,0,0,.2); padding: 14px; }
.tool-head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.tool-head .badge { text-transform: uppercase; letter-spacing: .04em; font-size: 10.5px; }
.tool-head .grow { flex: 1; }
.tool .grid-2 { gap: 0 14px; }
.tool .field { margin-bottom: 10px; }
.tool textarea.json { font: 12.5px/1.5 var(--mono); min-height: 110px; }
.tool-add { display: flex; flex-wrap: wrap; gap: 8px; }

/* ---- Summary panel ---- */
.sum-card { padding: 18px; border-radius: var(--radius); border: 1px solid var(--border); background: var(--panel); }
.sum-card h4 { margin: 0 0 12px; font: 600 12px var(--sans); text-transform: uppercase; letter-spacing: .08em; color: var(--faint); }
.sum-price { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.sum-price .big { font: 800 32px/1 var(--display); letter-spacing: -0.02em; background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.sum-price .unit { color: var(--muted); font-size: 13px; }
.sum-break { margin-top: 10px; }
.sum-break .kv { font-size: 12.5px; }
.timeline { display: flex; height: 12px; border-radius: 999px; overflow: hidden; background: rgba(255,255,255,.05); margin: 10px 0 8px; }
.timeline span { height: 100%; }
.timeline .t-wait { background: rgba(159,176,204,.35); }
.timeline .t-think { background: var(--accent-2); }
.timeline .t-voice { background: var(--accent); }
.legend { display: grid; gap: 4px; font-size: 12.5px; color: var(--muted); }
.legend div { display: flex; align-items: center; gap: 8px; }
.legend i { width: 9px; height: 9px; border-radius: 3px; flex: none; }
.legend b { margin-left: auto; color: var(--text); font: 600 12.5px var(--mono); }
.sum-total { display: flex; justify-content: space-between; align-items: baseline; margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--border); font-size: 13px; color: var(--muted); }
.sum-total b { color: var(--text); font: 700 16px var(--display); }
.warn-list { display: grid; gap: 8px; margin: 0; padding: 0; list-style: none; }
.warn-list li { display: flex; gap: 8px; font-size: 12.5px; line-height: 1.45; color: #f5deb0; }
.warn-list li::before { content: ""; flex: none; width: 7px; height: 7px; margin-top: 6px; border-radius: 50%; background: var(--warn); }
.warn-list li.err { color: #fecaca; }
.warn-list li.err::before { background: var(--danger); }
.sum-ok { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--ok); }
.sum-actions { display: grid; gap: 8px; }
.sum-actions .row { gap: 8px; }
.sum-actions .row .btn { flex: 1; }
.sum-actions .linkish { border: 0; background: none; color: var(--faint); font: 600 12.5px var(--sans); cursor: pointer; padding: 4px; }
.sum-actions .linkish:hover { color: var(--danger); }
.ver-list { display: grid; gap: 8px; max-height: 360px; overflow-y: auto; }
.ver { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--border); background: rgba(0,0,0,.2); }
.ver .grow { flex: 1; min-width: 0; font-size: 13px; }
.ver .vnum { font: 700 14px var(--display); min-width: 34px; }
.ver .faint { font-size: 12px; }

/* Narrow screens: floating save bar (the summary column drops below the form) */
.ab-floatbar { display: none; }
@media (max-width: 1100px) {
  .ab-floatbar {
    position: sticky; bottom: 16px; z-index: 20; display: flex; align-items: center; gap: 12px; margin-top: 16px;
    padding: 10px 10px 10px 16px; border-radius: 14px; border: 1px solid var(--border-strong);
    background: rgba(11,22,48,.92); backdrop-filter: blur(10px); box-shadow: var(--shadow);
  }
  .fb-price { flex: none; font: 700 15px var(--display); }
  .fb-status { display: block; flex: 1 1 0; width: 0; min-width: 0; font-size: 12.5px; color: var(--faint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .fb-status .dot { display: inline-block; vertical-align: middle; margin: -2px 6px 0 0; }
  .ab-floatbar .btn { flex: none; }
}
@media (max-width: 900px) {
  .ab-floatbar { bottom: calc(84px + env(safe-area-inset-bottom)); }
}



