:root { --fg: #1b1f2a; --muted: #5d6677; --line: #e3e6ec; --accent: #2f5bea; --bg: #f7f8fb; --warn: #b45309; }
* { box-sizing: border-box; }
body { margin: 0; font-family: "Onest", system-ui, sans-serif; color: var(--fg); background: var(--bg); line-height: 1.5; }
.top { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .9rem 1.5rem; background: #fff; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.brand { font-weight: 700; font-size: 1.15rem; color: var(--fg); text-decoration: none; }
nav { display: flex; gap: .25rem; align-items: center; }
.top nav a { color: var(--muted); text-decoration: none; font-weight: 500; padding: .45rem .7rem; border-radius: .45rem; position: relative; white-space: nowrap; }
.top nav a:hover { color: var(--fg); background: rgb(47 91 234 / .08); }
.top nav a:focus-visible, .top nav button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.top nav a[aria-current="page"] { color: var(--fg); font-weight: 700; }
.top nav a[aria-current="page"]::after { content: ""; position: absolute; left: .7rem; right: .7rem; bottom: -.1rem; height: 2px; border-radius: 2px; background: var(--accent); }
.top nav form.inline { margin-left: .6rem; padding-left: .9rem; border-left: 1px solid var(--line); }
.top nav button.link { color: var(--muted); font-weight: 500; white-space: nowrap; }
.top nav button.link:hover { color: var(--fg); }
@media (max-width: 720px) {
  .top nav { flex: 1 0 100%; overflow-x: auto; scrollbar-width: none; margin: 0 -.25rem; padding-bottom: .15rem; }
  .top nav::-webkit-scrollbar { display: none; }
}
a { color: var(--accent); }
main { max-width: 56rem; margin: 2rem auto; padding: 0 1.5rem; }
footer { max-width: 56rem; margin: 3rem auto 2rem; padding: 0 1.5rem; color: var(--muted); font-size: .9rem; }
h1 { font-size: 1.7rem; margin-top: 0; }
.card { background: #fff; border: 1px solid var(--line); border-radius: .75rem; padding: 1.25rem 1.5rem; margin-bottom: 1.25rem; }
label { display: block; font-weight: 500; margin-bottom: .3rem; }
input[type=text], input[type=email] { width: 100%; max-width: 26rem; padding: .6rem .75rem; border: 1px solid var(--line); border-radius: .5rem; font: inherit; }
button, .button { display: inline-block; padding: .6rem 1.1rem; border: 0; border-radius: .5rem; background: var(--accent); color: #fff; font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; }
button.secondary { background: #fff; color: var(--accent); border: 1px solid var(--accent); }
button.link { background: none; color: var(--accent); padding: 0; font-weight: 500; }
form.inline { display: inline; margin: 0; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: .55rem .5rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
tr.current { background: #eef2ff; }
.muted { color: var(--muted); }
.warn { color: var(--warn); font-weight: 600; }
.notice { background: #ecfdf3; border: 1px solid #a6e9c0; border-radius: .5rem; padding: .75rem 1rem; margin-bottom: 1.25rem; }
.error { color: #b42318; }
.secret { font-family: ui-monospace, Consolas, monospace; word-break: break-all; background: #f1f3f8; padding: .6rem .8rem; border-radius: .5rem; }
.bar { height: .7rem; background: var(--line); border-radius: 1rem; overflow: hidden; margin: .4rem 0; }
.bar > span { display: block; height: 100%; background: var(--accent); }
select, textarea { width: 100%; max-width: 26rem; padding: .6rem .75rem; border: 1px solid var(--line); border-radius: .5rem; font: inherit; margin-bottom: .6rem; }
.widget-layout { display: grid; grid-template-columns: repeat(auto-fit, minmax(20rem, 1fr)); gap: 1.25rem; align-items: start; }
iframe.preview { width: 100%; height: 640px; border: 1px solid var(--line); border-radius: .5rem; background: #fff; }
pre.secret { white-space: pre-wrap; }
.bars { display: flex; align-items: flex-end; gap: 2px; height: 6rem; margin: .4rem 0; }
.bars .col { flex: 1; height: 100%; display: flex; align-items: flex-end; background: var(--bg); }
.bars .col i { display: block; width: 100%; min-height: 1px; background: var(--accent); }
ol.steps { list-style: none; margin: 0; padding: 0; }
ol.steps li { padding: .6rem .8rem; margin-bottom: .5rem; border: 1px solid var(--line); border-radius: .5rem; }
ol.steps li.done { color: var(--muted); }
ol.steps li.next { border-color: var(--accent); background: #eef2ff; }
ol.steps .what { margin: .2rem 0 .4rem; }


/* ---------- Widget studio (/app/widget). Everything is scoped under .studio so other portal pages keep their look. ---------- */
main:has(.studio) { max-width: 78rem; }
.studio {
  --s-bg: #f4f6fb; --panel: #fff; --s-fg: #1b1f2a; --s-muted: #5d6677; --s-line: #dde2ec; --soft: #eef2fb;
  --s-accent: #2f5bea; --on-accent: #fff; --ok: #15803d; --okbg: #e9f7ee; --s-warn: #9a4a07; --warnbg: #fdf3e4; --bad: #b42318; --stage: #dfe5f2;
  color: var(--s-fg);
}
@media (prefers-color-scheme: dark) {
  body:has(.studio) { background: #12151d; color: #e8ebf3; color-scheme: dark; }
  body:has(.studio) .top { background: #1a1e29; border-color: #2a3040; }
  body:has(.studio) .brand, body:has(.studio) .top nav a[aria-current="page"] { color: #e8ebf3; }
  body:has(.studio) .top nav a, body:has(.studio) .top nav button.link { color: #a3acbf; }
  body:has(.studio) .top nav a:hover { color: #e8ebf3; background: rgb(255 255 255 / .08); }
  body:has(.studio) footer a { color: #9db4ff; }
  body:has(.studio) footer { color: #9aa3b5; }
  .studio {
    --s-bg: #12151d; --panel: #1a1e29; --s-fg: #e8ebf3; --s-muted: #a3acbf; --s-line: #2e3547; --soft: #242a3a;
    --s-accent: #7d9bff; --on-accent: #0c1022; --ok: #4ade80; --okbg: #15291d; --s-warn: #f5b454; --warnbg: #2e2414; --bad: #ff8f7a; --stage: #0d1017;
  }
}
.studio * { box-sizing: border-box; }
.studio button { all: unset; box-sizing: border-box; cursor: pointer; font: inherit; color: inherit; }
.studio button:disabled { cursor: not-allowed; }
.studio :focus-visible { outline: 2px solid var(--s-accent); outline-offset: 2px; }
.studio a { color: var(--s-accent); }
.studio .sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.studio .head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: .5rem 1rem; margin-bottom: 1.25rem; }
.studio h1 { margin: 0; text-wrap: balance; }
.studio .head p { margin: 0; color: var(--s-muted); }
.studio .alert { background: var(--warnbg); color: var(--s-warn); border-radius: .6rem; padding: .6rem 1rem; margin-bottom: 1rem; font-weight: 600; }
.studio .alert p { margin: .15rem 0; }
.studio .grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr); gap: 1.5rem; align-items: start; }
@media (max-width: 960px) { .studio .grid { grid-template-columns: minmax(0, 1fr); } .studio .stage { position: static; } }

.studio .tabs { display: flex; gap: .25rem; padding: .25rem; background: var(--soft); border-radius: .7rem; margin-bottom: 1rem; }
@media (max-width: 640px) { .studio .tabs { overflow-x: auto; scrollbar-width: none; } .studio .tabs::-webkit-scrollbar { display: none; } }
.studio .tabs button { flex: 1 0 auto; padding: .55rem .9rem; border-radius: .5rem; color: var(--s-muted); font-weight: 600; white-space: nowrap; display: flex; align-items: center; gap: .45rem; justify-content: center; }
.studio .tabs button[aria-selected="true"] { background: var(--panel); color: var(--s-fg); box-shadow: 0 1px 2px rgb(0 0 0 / .1); }
.studio .dot { width: .5rem; height: .5rem; border-radius: 50%; background: var(--s-warn); }
.studio .dot[hidden], .studio [hidden] { display: none !important; }

.studio .panel { background: var(--panel); border: 1px solid var(--s-line); border-radius: .9rem; padding: 1.25rem 1.35rem; }
.studio .field { display: grid; gap: .45rem; padding-block: 1rem; border-top: 1px solid var(--s-line); }
.studio .field:first-child { border-top: 0; padding-top: 0; }
.studio .field:last-child { padding-bottom: 0; }
.studio .label { font-weight: 600; margin: 0; }
.studio .hint { color: var(--s-muted); font-size: .9rem; margin: 0; }
.studio .okmsg { color: var(--ok); }
.studio .badmsg, .studio .err { color: var(--bad); }
.studio .err { font-size: .9rem; margin: 0; }

.studio .swatches { display: flex; flex-wrap: wrap; gap: .7rem; padding: 4px; }
.studio .sw { width: 2.4rem; height: 2.4rem; border-radius: 50%; position: relative; background: var(--c); box-shadow: inset 0 0 0 1px rgb(0 0 0 / .18); display: block; }
.studio .sw[aria-checked="true"]::after, .studio .sw.custom:has(input[aria-checked="true"])::after { content: ""; position: absolute; inset: -5px; border-radius: 50%; border: 2px solid var(--s-fg); pointer-events: none; }
.studio .sw.custom { background: conic-gradient(#f43f5e, #f59e0b, #84cc16, #06b6d4, #6366f1, #d946ef, #f43f5e); }
.studio .sw.custom span { position: absolute; inset: 7px; border-radius: 50%; background: var(--c, var(--panel)); }
.studio .sw.custom input { position: absolute; inset: 0; opacity: 0; width: 100%; height: 100%; cursor: pointer; }
.studio .sw.custom:has(input:focus-visible), .studio .sw:focus-visible { outline: 2px solid var(--s-accent); outline-offset: 3px; }
.studio .colorrow { display: flex; flex-wrap: wrap; align-items: center; gap: .6rem 1rem; font-size: .9rem; color: var(--s-muted); }
.studio .colorrow strong { color: var(--s-fg); font-weight: 600; }
.studio .ghost { border: 1px solid var(--s-line); background: var(--panel); padding: .35rem .75rem; border-radius: .45rem; font-size: .88rem; }
.studio .ghost:hover { border-color: var(--s-muted); }
.studio .primary { background: var(--s-accent); color: var(--on-accent); padding: .55rem 1rem; border-radius: .5rem; font-weight: 600; }
.studio .danger { background: var(--bad); color: #fff; padding: .45rem .9rem; border-radius: .5rem; font-weight: 600; }

.studio .cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(9.5rem, 1fr)); gap: .6rem; }
.studio .choice { border: 1.5px solid var(--s-line); border-radius: .7rem; padding: .7rem; background: var(--panel); display: grid; gap: .45rem; align-content: start; text-align: left; }
.studio .choice[aria-checked="true"] { border-color: var(--s-accent); background: var(--soft); }
.studio .choice b { font-weight: 600; }
.studio .choice small { color: var(--s-muted); line-height: 1.35; font-size: .85rem; }
.studio .mini { display: block; height: 3.6rem; border-radius: .4rem; background: var(--soft); position: relative; }
.studio .choice[aria-checked="true"] .mini { background: var(--panel); }
.studio .mini i { position: absolute; bottom: .35rem; width: 1.6rem; height: .7rem; border-radius: .4rem; background: var(--s-accent); }

.studio .seg { display: inline-flex; flex-wrap: wrap; background: var(--soft); border-radius: .55rem; padding: .2rem; gap: .2rem; justify-self: start; }
.studio .seg button { padding: .4rem .85rem; border-radius: .4rem; font-weight: 600; color: var(--s-muted); }
.studio .seg button[aria-checked="true"] { background: var(--panel); color: var(--s-fg); box-shadow: 0 1px 2px rgb(0 0 0 / .1); }

.studio input[type=text], .studio input[type=email], .studio textarea { width: 100%; max-width: none; margin: 0; padding: .6rem .75rem; border: 1px solid var(--s-line); border-radius: .5rem; background: var(--panel); color: var(--s-fg); font: inherit; }
.studio textarea { resize: vertical; min-height: 5rem; }
.studio ::placeholder { color: var(--s-muted); opacity: .8; }
.studio .counter { justify-self: end; font-size: .8rem; color: var(--s-muted); font-variant-numeric: tabular-nums; }
.studio .chips { display: flex; flex-wrap: wrap; gap: .4rem; }
.studio .chip { border: 1px dashed var(--s-muted); border-radius: 999px; padding: .25rem .7rem; font-size: .85rem; color: var(--s-muted); }
.studio .chip:hover { color: var(--s-fg); border-color: var(--s-fg); }

.studio .list { display: grid; gap: .4rem; margin: 0; padding: 0; list-style: none; }
.studio .list li { display: flex; align-items: center; gap: .25rem; }
.studio .list li input { flex: 1; min-width: 0; }
.studio .icon { width: 2.2rem; height: 2.2rem; border-radius: .4rem; color: var(--s-muted); display: grid; place-items: center; flex: none; }
.studio .icon:hover:not(:disabled) { background: var(--soft); color: var(--s-fg); }
.studio .icon:disabled { opacity: .3; }
.studio .add { justify-self: start; color: var(--s-accent); font-weight: 600; padding: .3rem 0; }

.studio .pill { display: inline-flex; align-items: center; gap: .35rem; font-size: .82rem; font-weight: 600; padding: .2rem .6rem; border-radius: 999px; justify-self: start; }
.studio .pill.ok { background: var(--okbg); color: var(--ok); }
.studio .pill.wait { background: var(--warnbg); color: var(--s-warn); }
.studio .pill::before { content: ""; width: .45rem; height: .45rem; border-radius: 50%; background: currentColor; }

.studio .tags { display: flex; flex-wrap: wrap; gap: .4rem; padding: .45rem; border: 1px solid var(--s-line); border-radius: .5rem; background: var(--panel); }
.studio .tags:focus-within { outline: 2px solid var(--s-accent); outline-offset: 2px; }
.studio .tag { display: inline-flex; align-items: center; gap: .3rem; background: var(--soft); border-radius: .4rem; padding: .2rem .25rem .2rem .55rem; font-size: .9rem; }
.studio .tag button { color: var(--s-muted); padding: 0 .35rem; font-size: 1.1rem; line-height: 1.2; }
.studio .tag button:hover { color: var(--s-fg); }
.studio .tags input[type=text] { border: 0; flex: 1; min-width: 10rem; padding: .25rem; background: none; }
.studio .tags input:focus-visible { outline: none; }

.studio .switch { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.studio .switchside { display: flex; align-items: center; gap: .6rem; }
.studio .switch button { width: 2.8rem; height: 1.6rem; border-radius: 999px; background: var(--s-line); position: relative; flex: none; }
.studio .switch button::after { content: ""; position: absolute; top: .25rem; left: .25rem; width: 1.1rem; height: 1.1rem; border-radius: 50%; background: #fff; transition: transform .15s; box-shadow: 0 1px 2px rgb(0 0 0 / .3); }
.studio .switch button[aria-checked="true"] { background: var(--s-accent); }
.studio .switch button[aria-checked="true"]::after { transform: translateX(1.2rem); }
.studio .switch button:disabled { opacity: .55; }
.studio .lock { font-size: .82rem; color: var(--s-muted); }

.studio .code { position: relative; }
.studio .code pre { margin: 0; background: var(--soft); border-radius: .55rem; padding: .8rem 1rem 3.2rem; font: .82rem/1.5 ui-monospace, Consolas, "Cascadia Mono", monospace; white-space: pre-wrap; overflow-wrap: anywhere; }
.studio .code .copy { position: absolute; bottom: .6rem; right: .6rem; }
@media (min-width: 640px) { .studio .code pre { padding: .8rem 7rem .8rem 1rem; } .studio .code .copy { top: .5rem; bottom: auto; right: .5rem; } }
.studio .guide { margin: 0; padding-left: 1.3rem; display: grid; gap: .35rem; }
.studio .live { display: flex; gap: .7rem; align-items: center; flex-wrap: wrap; padding: .8rem .9rem; border-radius: .6rem; background: var(--warnbg); }
.studio .live.on { background: var(--okbg); }
.studio .live p { margin: 0; color: var(--s-fg); }
.studio .advanced summary { cursor: pointer; font-weight: 600; }
.studio .advanced > * + * { margin-top: .5rem; }
.studio .confirm { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; background: var(--warnbg); border-radius: .6rem; padding: .7rem .9rem; }
.studio .confirm p { flex-basis: 100%; margin: 0; color: var(--s-warn); font-weight: 600; }

.studio .stage { position: sticky; top: 1rem; display: grid; grid-template-columns: minmax(0, 1fr); gap: .7rem; }
.studio .stagebar { display: flex; flex-wrap: wrap; justify-content: space-between; gap: .5rem; align-items: center; }
.studio .screen { background: var(--stage); border-radius: 1rem; padding: 1rem; display: grid; grid-template-columns: minmax(0, 1fr); place-items: center; min-height: 42rem; }
.studio .frame { width: 100%; height: 40rem; border-radius: .7rem; overflow: hidden; box-shadow: 0 10px 30px rgb(15 23 42 / .18); transition: width .25s; background: #fff; }
.studio .frame { 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: 1.6rem; border: 8px solid #1f2430; }
@media (max-width: 480px) { .studio .screen { padding: .5rem; min-height: 0; } .studio .frame, .studio .frame.mobile { height: 36rem; } }

.studio .savebar { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(1rem + env(safe-area-inset-bottom, 0px)); background: var(--s-fg); color: var(--s-bg); padding: .55rem .6rem .55rem 1rem; border-radius: .8rem; display: flex; align-items: center; gap: .8rem; box-shadow: 0 10px 30px rgb(0 0 0 / .3); z-index: 5; max-width: calc(100% - 2rem); flex-wrap: wrap; justify-content: center; }
.studio .savebar .ghost { background: transparent; border-color: color-mix(in srgb, var(--s-bg) 40%, transparent); }
.studio .savebar .primary { background: var(--s-accent); color: var(--on-accent); }
@media (prefers-color-scheme: dark) { .studio .savebar .primary { background: var(--s-accent); } }
@media (prefers-reduced-motion: reduce) { .studio * { transition: none !important; animation: none !important; } }
.studio .ghost, .studio .primary, .studio .danger, .studio .add, .studio .chip { display: inline-block; text-align: center; }

.studio .okbanner { background: var(--okbg); color: var(--ok); border-radius: .6rem; padding: .6rem 1rem; margin-bottom: 1rem; font-weight: 600; }
.studio .logorow { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; }
.studio .logorow .hint { flex: 1 1 6rem; min-width: 0; }
.studio .logothumb { width: 2.4rem; height: 2.4rem; border-radius: .5rem; background: var(--soft) center / contain no-repeat; border: 1px solid var(--s-line); flex: none; }
.studio .filebtn { position: relative; cursor: pointer; }
.studio .filebtn input { position: absolute; inset: 0; opacity: 0; width: 100%; cursor: pointer; }
.studio .filebtn:focus-within { outline: 2px solid var(--s-accent); outline-offset: 2px; }

a.button.secondary { background: #fff; color: var(--accent); border: 1px solid var(--accent); }
