/* Portal pages (keliqo.css holds tokens and shared components). Light only, logical properties only. */
main { padding-block: var(--space-6) var(--space-5); min-height: 60vh; }
main > h1 { margin-block-end: 8px; }
.lead { color: var(--muted); font-size: 1.18rem; line-height: 1.55; max-width: 34em; margin: 0 0 var(--space-5); }
main > p { max-width: 68ch; }
.card p, .card ul > li { max-width: 68ch; }
.status-line { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; }

/* Sign-in and confirmation pages: one narrow card. */
.narrow { max-width: 34rem; }
.narrow form > * + * { margin-block-start: var(--space-3); }
.home-actions { display: flex; flex-wrap: wrap; gap: var(--space-3); align-items: center; margin-block: var(--space-4); }
.legal h2 { margin-block-end: 8px; }

/* Tables are cards on phones: every cell carries its label. */
table { width: 100%; border-collapse: collapse; }
th, td { text-align: start; padding: 10px 8px; border-bottom: 1px solid var(--line); vertical-align: middle; overflow-wrap: break-word; }
td[dir="ltr"] { overflow-wrap: anywhere; }
th { font-size: .92rem; color: var(--muted); font-weight: 600; }
tr:last-child > td, tr:last-child > th { border-bottom: 0; }
td code { direction: ltr; unicode-bidi: isolate; }
.actions-cell { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; }
.actions-cell details { min-width: 0; }
.card .actions-cell details > summary { color: var(--ink); cursor: pointer; font-weight: 600; border-bottom: 2px solid var(--marker); display: inline-block; }
.actions-cell details form { display: flex; flex-wrap: wrap; gap: 8px; margin-block-start: 8px; }
.actions-cell details input { max-width: 16rem; }
@media (max-width: 720px) {
  table.stack thead { display: none; }
  table.stack, table.stack tbody, table.stack tr, table.stack td { display: block; width: 100%; }
  table.stack tr { padding-block: 14px; border-bottom: 1px solid var(--line); }
  table.stack tr:last-child { border-bottom: 0; }
  table.stack td { border: 0; padding: 3px 0; }
  /* A card shows only what is there: the "-" a table needs for an empty cell is noise on a phone. */
  table.stack td.empty { display: none; }
  table.stack td[data-label]::before { content: attr(data-label); display: block; font-size: .85rem; color: var(--muted); font-weight: 600; }
  table.stack td:empty { display: none; }
}
table.facts th { width: 55%; color: var(--ink); font-weight: 500; font-size: 1rem; }
table.facts td { font-variant-numeric: tabular-nums; font-weight: 600; }
.thumb { width: 48px; height: 48px; object-fit: contain; border-radius: var(--radius-sm); background: var(--paper); }
table.products td:first-child { width: 64px; }

/* Inline destructive confirmation (app.js): the question sits where the button was. */
.confirm-inline { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; background: var(--warn-bg); border: 1px solid var(--warn-line); color: var(--warn-ink); border-radius: var(--radius-md); padding: 8px 14px; font-weight: 600; }
.confirm-inline .linkbtn { color: var(--ink); }

/* Usage */
.bar { height: 10px; background: var(--violet-soft); border-radius: var(--radius-pill); overflow: hidden; margin: 10px 0; }
.bar > span { display: block; height: 100%; background: var(--violet); border-radius: var(--radius-pill); }
.big-number { font: 700 1.6rem/1 var(--display); letter-spacing: -0.02em; font-variant-numeric: tabular-nums; margin: 0 0 6px; }
[data-font="ar"] .big-number, [data-font="zh"] .big-number, [data-font="ja"] .big-number, [data-font="ko"] .big-number { letter-spacing: 0; }
.big-number small { font: 500 1rem/1.4 var(--body); color: var(--muted); letter-spacing: 0; }

/* Setup guide: five steps, vertical, the next one highlighted. */
ol.steps { list-style: none; margin: var(--space-3) 0 0; padding: 0; display: grid; gap: 10px; counter-reset: step; }
ol.steps li { display: grid; grid-template-columns: 34px minmax(0, 1fr); column-gap: 14px; align-items: start; padding: 14px 16px; border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--card); }
ol.steps li::before { counter-increment: step; content: counter(step); grid-row: 1 / span 3; width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: .95rem; background: var(--paper); border: 1px solid var(--line); }
ol.steps li.done::before { content: "\2713"; background: var(--card); border-color: var(--mint); color: var(--mint); }
ol.steps li.done { color: var(--muted); }
ol.steps li.next { background: var(--violet-soft); border-color: var(--violet-soft); }
ol.steps li.next::before { background: var(--violet); border-color: var(--violet); color: var(--on-violet); }
ol.steps strong { font-weight: 600; display: block; }
ol.steps .what { margin: 2px 0 10px; color: var(--muted); }
ol.steps li.done .what { margin-block-end: 0; }
ol.steps li > a:not(.button) { font-weight: 600; }

/* Plans: side by side, separated by hairlines, the current one on violet-soft. */
.plans { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr)); border: 1px solid var(--line); border-radius: var(--radius-lg); overflow: hidden; background: var(--card); }
.plans li { display: grid; gap: 6px; align-content: start; padding: var(--space-5); border-inline-end: 1px solid var(--line); border-block-end: 1px solid var(--line); margin-block-end: -1px; margin-inline-end: -1px; }
.plans li.current { background: var(--violet-soft); }
.plans h3 { font-size: 1.375rem; line-height: 1.2; }
.plans .price { font: 700 1.5rem/1.1 var(--display); letter-spacing: -0.02em; margin: 4px 0 0; }
.plans .price small { display: block; font: 400 .88rem/1.4 var(--body); color: var(--muted); letter-spacing: 0; margin-block-start: 4px; }
.plans .limit { font-weight: 500; margin: 0; }
.plans .plan-action { margin-block-start: 8px; }
.plans form { margin: 0; }

/* Analytics */
.range { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-block-end: var(--space-4); }
.range a { text-decoration: none; padding: 7px 16px; border-radius: var(--radius-pill); border: 1px solid var(--line); background: var(--card); color: var(--ink); font-weight: 500; font-size: .95rem; }
.range a:hover { border-color: var(--violet); }
.range a[aria-current] { background: var(--ink); color: var(--on-ink); border-color: var(--ink); font-weight: 600; }
.bars { display: flex; align-items: flex-end; gap: 3px; height: 7rem; margin: 10px 0; }
.bars .col { flex: 1; height: 100%; display: flex; align-items: flex-end; background: var(--paper); border-radius: 3px; }
.bars .col i { display: block; width: 100%; min-height: 2px; background: var(--violet); border-radius: 3px; }

/* Catalog */
.card > form > details { margin-block: var(--space-3); }
.card details > summary, .advanced summary { cursor: pointer; font-weight: 600; color: var(--violet); }
.empty { text-align: start; }

/* ---------- Widget studio (/app/widget): settings left, live preview right. ---------- */
.studio .head { margin-block-end: var(--space-5); }
.studio .head p { margin: 0; }
.studio .okbanner { background: var(--card); border: 1px solid var(--line); border-inline-start: 4px solid var(--mint); border-radius: var(--radius-md); padding: 12px 16px; margin-block-end: var(--space-4); font-weight: 600; }
.studio .grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr); gap: var(--space-5); align-items: start; }
@media (max-width: 960px) { .studio .grid { grid-template-columns: minmax(0, 1fr); } .studio .stage { position: static; } }
.studio .tabs { display: flex; flex-wrap: nowrap; margin-block-end: var(--space-3); width: 100%; overflow-x: auto; scrollbar-width: none; }
.studio .tabs::-webkit-scrollbar { display: none; }
.studio .tabs button { flex: 1 0 auto; }
/* Next to the preview the column is too narrow for five tabs and the row has no visible scrollbar; wrap instead of hiding tabs. */
@media (min-width: 961px) { .studio .tabs { flex-wrap: wrap; overflow-x: visible; } .studio .tabs button { flex: 0 0 auto; } }
.studio .field .seg { justify-self: start; }
.studio .langs { display: flex; flex-wrap: wrap; gap: 8px; }
.studio .langs button { all: unset; box-sizing: border-box; cursor: pointer; padding: 6px 14px; border: 1px solid var(--line); border-radius: var(--radius-pill); background: var(--card); color: var(--ink); font-size: .95rem; }
.studio .langs button:hover { border-color: var(--violet); }
.studio .langs button[aria-checked="true"] { background: var(--ink); color: var(--on-ink); border-color: var(--ink); font-weight: 600; }
.studio .langs button:focus-visible { outline: 3px solid var(--violet); outline-offset: 2px; }

.studio .tags { display: flex; flex-wrap: wrap; gap: 8px; padding: 8px; border: 1px solid var(--line); border-radius: var(--radius-md); background: var(--card); }
.studio .tags:focus-within { outline: 3px solid var(--violet); outline-offset: 3px; }
.studio .tag { display: inline-flex; align-items: center; gap: 4px; background: var(--violet-soft); border-radius: var(--radius-pill); padding: 3px 4px 3px 12px; font-size: .92rem; direction: ltr; }
.studio .tag button { all: unset; cursor: pointer; color: var(--muted); padding: 0 8px; font-size: 1.1rem; line-height: 1.2; }
.studio .tag button:hover { color: var(--ink); }
.studio .tags input[type=text] { border: 0; flex: 1; min-width: 10rem; min-height: 32px; padding: 4px; background: none; direction: ltr; }
.studio .tags input:focus-visible { outline: none; }

.studio .switch { display: flex; align-items: center; justify-content: space-between; gap: var(--space-4); }
.studio .switchside { display: flex; align-items: center; gap: 10px; }
.studio .switch button { all: unset; box-sizing: border-box; cursor: pointer; width: 46px; height: 26px; border-radius: var(--radius-pill); background: var(--line); position: relative; flex: none; }
.studio .switch button::after { content: ""; position: absolute; top: 4px; inset-inline-start: 4px; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: transform .15s; box-shadow: var(--shadow-raise); }
.studio .switch button[aria-checked="true"] { background: var(--violet); }
.studio .switch button[aria-checked="true"]::after { transform: translateX(20px); }
.studio .switch button[aria-checked="true"]:dir(rtl)::after { transform: translateX(-20px); }
.studio .switch button:disabled { opacity: .55; cursor: not-allowed; }
.studio .switch button:focus-visible { outline: 3px solid var(--violet); outline-offset: 3px; }
.studio .lock { font-size: .88rem; color: var(--muted); }

.studio .code { position: relative; }
.studio .code pre { margin: 0; background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius-md); padding: 14px 16px 56px; font: .85rem/1.55 var(--mono); white-space: pre-wrap; overflow-wrap: anywhere; direction: ltr; text-align: start; }
.studio .code .copy { position: absolute; inset-block-end: 10px; inset-inline-end: 10px; padding: 7px 16px; font-size: .92rem; }
@media (min-width: 640px) { .studio .code pre { padding-block: 14px; padding-inline: 16px 130px; } .studio .code .copy { inset-block: 10px auto; } }
.studio .guide { margin: 0; padding-inline-start: 1.3rem; display: grid; gap: 6px; }
.studio .live { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; padding: 12px 14px; border-radius: var(--radius-md); background: var(--warn-bg); border: 1px solid var(--warn-line); }
.studio .live.on { background: var(--card); border-color: var(--line); }
.studio .live p { margin: 0; color: var(--ink); }
.studio .advanced > * + * { margin-block-start: 10px; }
.studio .confirm { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; background: var(--warn-bg); border: 1px solid var(--warn-line); border-radius: var(--radius-md); padding: 12px 14px; }
.studio .confirm p { flex-basis: 100%; margin: 0; color: var(--warn-ink); font-weight: 600; }

/* Preview stage: the real widget.js over a sample shop, shown 1:1. */
.studio .stage { position: sticky; top: 84px; display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; }
.studio .stagebar { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 10px; align-items: center; }
.studio .screen { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius-xl); box-shadow: var(--shadow-stage); padding: var(--space-4); display: grid; grid-template-columns: minmax(0, 1fr); place-items: center; min-height: 42rem; }
.studio .frame { width: 100%; height: 40rem; border-radius: var(--radius-lg); overflow: hidden; border: 1px solid var(--line); transition: width .25s; background: #fff; position: relative; }
.studio .frame iframe { position: absolute; top: 0; bottom: 0; right: 0; width: 100%; height: 100%; border: 0; display: block; }
.studio .frame iframe.left { right: auto; left: 0; }
.studio .frame.mobile { width: 375px; max-width: 100%; height: 40rem; max-height: 100%; border-radius: 28px; border: 8px solid var(--ink); }
@media (max-width: 480px) { .studio .screen { padding: 8px; min-height: 0; } .studio .frame, .studio .frame.mobile { height: 36rem; } }

/* Save bar: floats at the bottom centre once something changed. */
.studio .savebar { position: fixed; inset-inline: 0; margin-inline: auto; width: max-content; bottom: calc(16px + env(safe-area-inset-bottom, 0px)); background: var(--ink); color: var(--on-ink); padding: 8px 10px 8px 20px; border-radius: var(--radius-lg); display: flex; align-items: center; gap: 12px; box-shadow: var(--shadow-menu); z-index: 5; max-width: calc(100% - 32px); flex-wrap: wrap; justify-content: center; }
.studio .savebar .ghost { background: transparent; color: var(--on-ink); border-color: rgba(255, 255, 255, .45); }
.studio .savebar .ghost:hover { background: transparent; border-color: #fff; color: var(--on-ink); }
.studio .savebar .primary:focus-visible, .studio .savebar .ghost:focus-visible { outline-color: var(--marker); }
.studio { padding-block-end: 88px; }
/* Behaviour tab: choice cards show a sample sentence; the right side is a sample chat plus a real "try". */
.studio .choice .sample { font-style: italic; }
.studio .rulesfoot { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.studio .list li input { min-height: 44px; }
.studio .behaviorstage { display: grid; gap: 12px; }
.studio .chatprev { --pv: var(--violet); --pv-ink: #fff; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius-xl); box-shadow: var(--shadow-stage); overflow: hidden; }
.studio .chathead { display: flex; align-items: center; gap: 10px; padding: 14px 18px; background: var(--pv); color: var(--pv-ink); }
.studio .chathead b { overflow-wrap: anywhere; }
.studio .chatdot { width: 10px; height: 10px; border-radius: 50%; background: currentColor; opacity: .7; flex: none; }
.studio .chatbody { display: grid; gap: 10px; padding: 18px; min-height: 16rem; align-content: start; }
.studio .bubble { max-width: 85%; padding: 10px 14px; border-radius: var(--radius-lg); line-height: 1.5; overflow-wrap: anywhere; }
.studio .bubble.me { justify-self: end; background: var(--pv); color: var(--pv-ink); border-end-end-radius: 4px; }
.studio .bubble.bot { justify-self: start; background: var(--paper); border-end-start-radius: 4px; }
.studio .chatbody .pill { justify-self: start; }
.studio .tryrow { display: grid; gap: 8px; }
.studio .tryrow .label { margin: 0; }
.studio .tryrow .hint { margin: 0; }
.studio .tryinput { display: flex; gap: 8px; }
.studio .tryinput input { flex: 1; min-width: 0; max-width: none; }
table.products td:last-child { text-align: end; white-space: nowrap; }
