/* Cloud Ace demo shell. One stylesheet shared by every demo at demo.cloud-ace.id.
   Direction and the reason for each choice: DESIGN.md. Contrast for every token pair: DESIGN.md.
   Class prefix ds- so a demo's own styles never collide with the shell's. */

@font-face {
  font-family: "Plus Jakarta Sans";
  src: url("assets/fonts/PlusJakartaSans-variable.woff2") format("woff2");
  font-weight: 200 800;
  font-display: swap;
}

/* ---------- tokens ---------- */
:root {
  color-scheme: light;
  --bg: #f7f9fd;
  --surface: #ffffff;
  --surface-2: #eef3fb;
  --text: #0d1730;
  --text-muted: #47526b;
  --text-faint: #667087;
  --border: #e3e9f3;
  --border-2: #d3ddec;
  --border-strong: #7a8398;
  --primary: #1a66e6;
  --primary-hover: #0c47b4;
  --brand-ink: #0c47b4;
  --logo: #0061a6;
  --accent-soft: #eaf1fe;
  --btn-from: #1a66e6;
  --btn-to: #0c47b4;
  --on-primary: #ffffff;
  --error: #b42343;
  --error-soft: #fdeef1;
  --success: #0f7a55;
  --success-soft: #e7f6ef;
  --warning: #9a4a00;
  --warning-soft: #fff4de;
  --bar-bg: rgb(255 255 255 / 0.91);
  --veil: rgb(247 249 253 / 0.86);
  --shadow-sm: 0 1px 2px #0d17300a, 0 2px 8px #0d17300d;
  --shadow-float: 0 4px 14px #0d17300f, 0 18px 46px #0d173014;
  --shadow-brand: 0 14px 40px #1a66e638;

  --radius-chip: 8px;
  --radius-control: 10px;
  --radius-btn: 11px;
  --radius-card: 18px;
  --header-h: 64px;
  --maxw: 1440px;
  --gutter: 24px;
  --font: "Plus Jakarta Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0b1222;
  --surface: #121b30;
  --surface-2: #1a2540;
  --text: #e8eefa;
  --text-muted: #a9b4cc;
  --text-faint: #93a0ba;
  --border: #263350;
  --border-2: #33425f;
  --border-strong: #7684a3;
  --primary: #6aa3ff;
  --primary-hover: #9cc2ff;
  --brand-ink: #9cc2ff;
  --logo: #9cc2ff;
  --accent-soft: #17284a;
  --on-primary: #0b1222;
  --error: #ff9daf;
  --error-soft: #3a1b26;
  --success: #5fd3a2;
  --success-soft: #13302a;
  --warning: #fbbf24;
  --warning-soft: #3a2e12;
  --bar-bg: rgb(11 18 34 / 0.88);
  --veil: rgb(11 18 34 / 0.84);
  --shadow-sm: 0 1px 2px #0000004d, 0 2px 8px #00000040;
  --shadow-float: 0 4px 14px #00000059, 0 18px 46px #00000066;
  --shadow-brand: 0 14px 40px #1a66e64d;
}

@media (max-width: 599px) {
  :root { --gutter: 16px; }
}
@media (min-width: 1600px) {
  :root { --gutter: 32px; }
}

/* ---------- base ---------- */
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

/* Android draws a square blue flash over rounded controls; each control shows its own :active state instead. */
html { -webkit-text-size-adjust: 100%; -webkit-tap-highlight-color: transparent; }
body {
  margin: 0;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text-muted);
  font: 400 1rem/1.6 var(--font);
  -webkit-font-smoothing: antialiased;
}
/* Shown until shell.js has applied the visitor's language, so Indonesian visitors do not see
   English flash first. boot.js removes it after 1.5 s even if shell.js never runs. */
.ds-i18n-pending body { visibility: hidden; }

h1, h2, h3, h4 { margin: 0; color: var(--text); font-weight: 700; line-height: 1.2; letter-spacing: -0.02em; }
h1 { font-size: clamp(1.875rem, 1.2rem + 2.6vw, 2.875rem); font-weight: 800; line-height: 1.08; letter-spacing: -0.03em; }
h2 { font-size: clamp(1.25rem, 1.1rem + 0.6vw, 1.5rem); font-weight: 800; letter-spacing: -0.025em; }
h3 { font-size: 1.0625rem; }
p { margin: 0; }
legend { padding: 0; }
.ds-prose > * + * { margin-top: 0.75em; }
strong { color: var(--text); font-weight: 700; }
small { font-size: 0.875rem; }
img, svg, video, canvas { display: block; max-width: 100%; }
a { color: var(--primary); text-underline-offset: 3px; }
a:hover { color: var(--primary-hover); }
code, kbd { font-family: var(--mono); font-size: 0.875em; }
button, input, select, textarea { font: inherit; color: inherit; }

:focus-visible { outline: 2px solid var(--primary); outline-offset: 3px; border-radius: 4px; }

.ds-visually-hidden {
  position: absolute !important; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.ds-skip {
  position: absolute; left: var(--gutter); top: -100px; z-index: 100;
  padding: 10px 14px; border-radius: var(--radius-btn);
  background: var(--surface); color: var(--text); box-shadow: var(--shadow-float); font-weight: 700;
}
.ds-skip:focus-visible { top: 10px; }
/* Keyboard users only: a mouse click or the focus the captcha frame hands back never shows it, and
   behind the locked gate there is no content to skip to. */
:root[data-gate="locked"] .ds-skip { display: none; }

/* ---------- layout ---------- */
/* viewport-fit=cover: a notched phone in landscape keeps its content clear of the notch. */
.ds-container {
  width: 100%; max-width: calc(var(--maxw) + 2 * var(--gutter)); margin-inline: auto;
  padding-inline: max(var(--gutter), env(safe-area-inset-left)) max(var(--gutter), env(safe-area-inset-right));
}
.ds-main { flex: 1 0 auto; padding-block: 40px 64px; }
.ds-intro { max-width: 46rem; margin-bottom: 32px; }
.ds-intro__for { margin-bottom: 12px; color: var(--primary); font-size: 0.9375rem; font-weight: 700; }
.ds-intro h1 + .ds-lede { margin-top: 14px; }
.ds-lede { max-width: 60ch; font-size: 1.0625rem; }
.ds-stack > * + * { margin-top: var(--stack, 16px); }
.ds-split { display: grid; gap: 24px; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-items: start; }
.ds-split--wide-start { grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); }
@media (max-width: 899px) {
  .ds-main { padding-block: 24px 48px; }
  .ds-intro { margin-bottom: 24px; }
  .ds-split, .ds-split--wide-start { grid-template-columns: minmax(0, 1fr); }
}

/* ---------- header ---------- */
.ds-header {
  position: sticky; top: 0; z-index: 40;
  background: var(--bar-bg);
  -webkit-backdrop-filter: saturate(1.4) blur(14px);
  backdrop-filter: saturate(1.4) blur(14px);
  border-bottom: 1px solid var(--border);
}
.ds-header__in { min-height: var(--header-h); display: flex; align-items: center; gap: 16px; }
.ds-brand { display: flex; align-items: center; gap: 14px; flex: 1 1 auto; min-width: 0; min-height: 44px; color: var(--text); text-decoration: none; }
.ds-logo--mark { display: none; }
.ds-brand:hover { color: var(--text); }
.ds-logo { width: auto; height: 22px; flex: none; color: var(--logo); }
.ds-brand__name {
  padding-left: 14px; border-left: 1px solid var(--border-2);
  font-weight: 700; font-size: 0.9375rem; letter-spacing: -0.01em;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.ds-header__tools { display: flex; align-items: center; gap: 8px; flex: none; }

/* Model chips name what really runs; the dot is the live state from the server (ok / paused). */
.ds-models { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 8px 0 0; padding: 0; list-style: none; }
.ds-chip {
  display: inline-flex; align-items: center; gap: 7px; max-width: 100%;
  padding: 4px 10px; border: 1px solid var(--border-2); border-radius: var(--radius-chip);
  background: var(--surface); color: var(--text); font-size: 0.875rem; font-weight: 600; line-height: 1.4; white-space: nowrap;
}
.ds-chip__dot { width: 7px; height: 7px; flex: none; border-radius: 50%; background: var(--success); }
[data-status="paused"] .ds-chip__dot { background: var(--warning); }

.ds-lang { display: inline-flex; padding: 3px; gap: 2px; border: 1px solid var(--border-strong); border-radius: var(--radius-btn); background: var(--surface); }
.ds-lang button {
  min-width: 40px; height: 36px; padding: 0 8px; border: 0; border-radius: 8px;
  background: transparent; color: var(--text-muted); font-size: 0.875rem; font-weight: 700; cursor: pointer;
}
.ds-lang button[aria-pressed="true"] { background: var(--accent-soft); color: var(--brand-ink); }
.ds-lang button:hover:not([aria-pressed="true"]) { color: var(--text); }
.ds-icon-btn {
  width: 44px; height: 44px; display: inline-grid; place-items: center; flex: none;
  border: 1px solid var(--border-strong); border-radius: var(--radius-btn);
  background: var(--surface); color: var(--text); cursor: pointer;
}
.ds-icon-btn:hover { background: var(--surface-2); }
.ds-icon-btn svg { width: 20px; height: 20px; }
.ds-theme .ds-sun, :root[data-theme="dark"] .ds-theme .ds-moon { display: none; }
:root[data-theme="dark"] .ds-theme .ds-sun { display: block; }

/* Desktop: the header is pinned, so anchors and focused fields land below it, not under it. */
@media (min-width: 900px) { html { scroll-padding-top: calc(var(--header-h) + 16px); } }
/* A phone in landscape is wide enough for the pinned header but has ~400px of height: let it scroll away. */
@media (min-width: 900px) and (max-height: 500px) { .ds-header { position: static; } html { scroll-padding-top: 0; } }

@media (max-width: 899px) {
  /* A two-row header would hold a quarter of a phone screen if it stayed pinned. */
  .ds-header { position: static; }
  .ds-header__in { flex-wrap: wrap; row-gap: 0; padding-block: 10px; }
  .ds-models { order: 3; flex: 1 0 100%; margin: 8px 0 2px; }
}
/* Narrow phones: the cloud mark alone, so the demo's name and both toggles fit on one row. */
@media (max-width: 479px) {
  .ds-logo--full { display: none; }
  .ds-logo--mark { display: block; height: 26px; }
  .ds-brand { gap: 10px; }
  .ds-brand__name { padding-left: 10px; font-size: 0.875rem; }
  .ds-lang button { min-width: 42px; padding: 0 6px; }
}
/* Keep a 44px touch target on the language buttons, which are drawn smaller: 36 + 2x4 tall, 42 + 2x1 wide
   (each reaches 1px into the 2px gap, so the two targets meet without overlapping). */
.ds-lang button { position: relative; }
.ds-lang button::before { content: ""; position: absolute; inset: -4px -1px; }

/* ---------- footer ---------- */
.ds-footer { border-top: 1px solid var(--border); padding-block: 20px; font-size: 0.875rem; color: var(--text-muted); }
.ds-footer__in { display: flex; flex-wrap: wrap; gap: 6px 24px; justify-content: space-between; }

/* ---------- surfaces ---------- */
.ds-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-card); box-shadow: var(--shadow-sm); padding: 20px; min-width: 0; }
/* Cards that are themselves a control lift a little under the pointer. */
a.ds-card, button.ds-card, .ds-card--interactive { transition: transform 0.2s var(--ease), box-shadow 0.2s var(--ease), border-color 0.2s var(--ease); }
a.ds-card:hover, button.ds-card:hover, .ds-card--interactive:hover { transform: translateY(-2px); box-shadow: var(--shadow-float); border-color: var(--border-2); }
.ds-card__head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.ds-card__head h2, .ds-card__head h3 { font-size: 1.0625rem; font-weight: 700; letter-spacing: -0.015em; }
.ds-card__meta { color: var(--text-muted); font-size: 0.875rem; text-align: right; }
.ds-well { background: var(--surface-2); border-radius: 14px; }
@media (max-width: 599px) { .ds-card { padding: 16px; border-radius: 16px; } }

/* ---------- buttons ---------- */
.ds-btn {
  position: relative; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 0 18px; border: 1px solid transparent; border-radius: var(--radius-btn);
  font-weight: 700; font-size: 0.9375rem; line-height: 1.2; text-decoration: none; cursor: pointer;
  transition: background-color 0.15s var(--ease), box-shadow 0.15s var(--ease), transform 0.1s var(--ease);
}
.ds-btn svg { width: 18px; height: 18px; flex: none; }
.ds-btn:active:not(:disabled) { transform: translateY(1px); }
.ds-icon-btn:active, .ds-lang button:active:not([aria-pressed="true"]),
.ds-tabs [role="tab"]:active:not([aria-selected="true"]):not(:disabled) { background: var(--surface-2); }
.ds-btn:disabled, .ds-btn[aria-disabled="true"] { cursor: not-allowed; opacity: 0.5; box-shadow: none; }
/* The gradient is the brand's own button (id.cloud-ace.com), used only on the one main action. */
.ds-btn--primary { background: linear-gradient(120deg, var(--btn-from), var(--btn-to)); color: #ffffff; box-shadow: var(--shadow-brand); }
.ds-btn--primary:hover { color: #ffffff; filter: brightness(1.06); transform: translateY(-1px); box-shadow: 0 18px 44px #1a66e64d; }
.ds-btn--secondary { background: var(--surface); border-color: var(--border-strong); color: var(--text); }
.ds-btn--secondary:hover { background: var(--surface-2); color: var(--text); }
.ds-btn--quiet { background: transparent; color: var(--primary); padding-inline: 12px; }
.ds-btn--quiet:hover { background: var(--accent-soft); color: var(--brand-ink); }
.ds-btn--block { width: 100%; }
.ds-btn[aria-busy="true"]::after {
  content: ""; width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid currentColor; border-right-color: transparent; animation: ds-spin 0.8s linear infinite;
}
.ds-actions { display: flex; flex-wrap: wrap; gap: 10px; }

/* ---------- tabs (segmented) ---------- */
.ds-tabs { display: flex; padding: 4px; gap: 4px; border-radius: 12px; background: var(--surface-2); }
.ds-tabs [role="tab"] {
  flex: 1 1 0; min-height: 44px; padding: 0 12px; border: 0; border-radius: 9px;
  background: transparent; color: var(--text-muted); font-weight: 600; font-size: 0.875rem; cursor: pointer;
  transition: background-color 0.2s var(--ease), color 0.2s var(--ease), box-shadow 0.2s var(--ease);
}
.ds-tabs [role="tab"][aria-selected="true"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }
.ds-tabs [role="tab"]:hover:not([aria-selected="true"]) { color: var(--text); }
.ds-tabs [role="tab"]:disabled { opacity: 0.45; cursor: not-allowed; }

/* ---------- form fields ---------- */
.ds-field { display: grid; gap: 6px; min-width: 0; }
.ds-field > label, .ds-label { color: var(--text); font-weight: 600; font-size: 0.9375rem; }
.ds-hint { color: var(--text-muted); font-size: 0.875rem; }
.ds-input, .ds-select, .ds-textarea {
  width: 100%; min-height: 44px; padding: 10px 12px;
  border: 1px solid var(--border-strong); border-radius: var(--radius-control);
  background: var(--surface); color: var(--text);
}
.ds-textarea { min-height: 96px; resize: vertical; line-height: 1.5; }
.ds-input::placeholder, .ds-textarea::placeholder { color: var(--text-faint); }
.ds-input:focus-visible, .ds-select:focus-visible, .ds-textarea:focus-visible { outline-offset: 1px; border-color: var(--primary); }
.ds-field[data-invalid] .ds-input, .ds-field[data-invalid] .ds-textarea { border-color: var(--error); }
.ds-field__error { color: var(--error); font-size: 0.875rem; font-weight: 600; }

/* Option tiles: a pale blue fill plus a blue edge marks "this one is yours". */
.ds-option {
  display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 10px 12px;
  border: 1px solid var(--border-2); border-radius: 12px; background: var(--surface); color: var(--text); cursor: pointer; text-align: left;
}
.ds-option:hover { border-color: var(--border-strong); }
.ds-option[aria-pressed="true"], .ds-option[aria-checked="true"], .ds-option:has(input:checked) {
  background: var(--accent-soft); border-color: var(--primary); box-shadow: inset 0 0 0 1px var(--primary);
}

/* ---------- notices, states ---------- */
.ds-notice {
  display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: 12px;
  background: var(--accent-soft); color: var(--text); font-size: 0.9375rem;
}
.ds-notice svg { width: 20px; height: 20px; flex: none; margin-top: 1px; color: var(--primary); }
.ds-notice--error { background: var(--error-soft); }
.ds-notice--error svg { color: var(--error); }
.ds-notice--warning { background: var(--warning-soft); }
.ds-notice--warning svg { color: var(--warning); }
.ds-notice--success { background: var(--success-soft); }
.ds-notice--success svg { color: var(--success); }
.ds-notice__body { min-width: 0; }
.ds-notice__body > * + * { margin-top: 6px; }

.ds-state { display: grid; justify-items: center; gap: 10px; padding: 32px 16px; text-align: center; color: var(--text-muted); }
.ds-state svg { width: 28px; height: 28px; color: var(--text-faint); }
.ds-state strong { font-size: 1rem; }
.ds-state { animation: ds-fade 0.3s var(--ease) both; }
.ds-spinner { width: 22px; height: 22px; border-radius: 50%; border: 2.5px solid var(--border-2); border-top-color: var(--primary); animation: ds-spin 0.8s linear infinite; }

/* Loading placeholders. A skeleton shimmers where content is about to land; dots say "thinking";
   the bar runs while a long job has no percentage to show. */
.ds-skeleton {
  display: block; min-height: 1em; border-radius: 8px;
  background: linear-gradient(90deg, var(--border) 25%, var(--surface) 50%, var(--border) 75%) 0 0 / 300% 100%;
  animation: ds-shimmer 1.4s linear infinite;
}
.ds-dots { display: inline-flex; gap: 4px; align-items: center; }
.ds-dots::before, .ds-dots::after, .ds-dots > i { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; animation: ds-bounce 1.1s var(--ease) infinite; }
.ds-dots > i { animation-delay: 0.15s; }
.ds-dots::after { animation-delay: 0.3s; }
.ds-progress { position: relative; height: 4px; overflow: hidden; border-radius: 4px; background: var(--border); }
.ds-progress::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 40%; border-radius: inherit; background: linear-gradient(90deg, var(--btn-from), var(--btn-to)); animation: ds-slide 1.3s var(--ease) infinite; }

/* ---------- toast ---------- */
.ds-toasts { position: fixed; z-index: 60; left: 50%; bottom: max(16px, env(safe-area-inset-bottom)); transform: translateX(-50%); display: grid; gap: 8px; width: min(440px, calc(100% - 2 * var(--gutter))); pointer-events: none; }
.ds-toast {
  display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: 12px;
  background: var(--text); color: var(--bg); box-shadow: var(--shadow-float); font-size: 0.9375rem; font-weight: 600;
  pointer-events: auto; animation: ds-rise 0.2s var(--ease);
}
.ds-toast--error { background: var(--error); color: #ffffff; }
:root[data-theme="dark"] .ds-toast--error { color: #3a1b26; }

/* ---------- gate ----------
   Shown before anything else until this browser holds a pass. The page behind stays visible
   but inert, so a visitor sees what they are about to use. */
.ds-gate {
  position: fixed; inset: var(--gate-top, var(--header-h)) 0 0; z-index: 50;
  display: grid; place-items: start center; overflow-y: auto; padding: clamp(24px, 8vh, 96px) var(--gutter) 24px;
  background: var(--veil);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
}
:root:not([data-gate="locked"]) .ds-gate { display: none; }
@media (min-width: 900px) { :root[data-gate="locked"] body { overflow: hidden; } }
.ds-gate__card {
  animation: ds-rise 0.35s var(--ease) backwards;
  width: min(440px, 100%); padding: 28px 24px 24px; text-align: center;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-card); box-shadow: var(--shadow-float);
}
.ds-gate__card h2 { font-size: 1.375rem; }
.ds-gate__card > p { margin-top: 10px; }
.ds-gate__widget { display: flex; justify-content: center; min-height: 78px; margin-top: 20px; }
.ds-gate__status { min-height: 1.6em; margin-top: 12px; font-size: 0.875rem; }
.ds-gate__status[data-kind="error"] { color: var(--error); font-weight: 600; }
.ds-gate__retry { margin-top: 8px; }
.ds-gate__note { margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--border); font-size: 0.875rem; }
/* Phones: the header scrolls with the page, so the gate sits in the flow under it (language and
   theme stay reachable) and the locked page is simply not rendered yet. */
@media (max-width: 899px) {
  .ds-gate { position: static; padding-top: 24px; background: none; -webkit-backdrop-filter: none; backdrop-filter: none; }
  :root[data-gate="locked"] .ds-main { display: none; }
}
/* The reCAPTCHA box is a fixed 304px: below 400px the gate and card padding shrink so it fits a 360px phone
   (it overflowed by 10px, 2026-11-14). */
@media (max-width: 399px) { .ds-gate { padding-inline: 12px; } .ds-gate__card { padding-inline: 12px; } }

/* ---------- motion ---------- */
@keyframes ds-spin { to { transform: rotate(360deg); } }
@keyframes ds-rise { from { opacity: 0; transform: translateY(6px); } }
@keyframes ds-fade { from { opacity: 0; } }
@keyframes ds-shimmer { to { background-position: -300% 0; } }
@keyframes ds-bounce { 0%, 80%, 100% { transform: translateY(0); opacity: 0.45; } 40% { transform: translateY(-5px); opacity: 1; } }
@keyframes ds-slide { from { transform: translateX(-100%); } to { transform: translateX(250%); } }
/* The page settles in on load: each top-level block rises in turn. */
.ds-main > * { animation: ds-rise 0.45s var(--ease) backwards; } /* backwards, not both: a held transform would trap position:fixed children */
.ds-main > :nth-child(2) { animation-delay: 0.06s; }
.ds-main > :nth-child(3) { animation-delay: 0.12s; }
.ds-main > :nth-child(n + 4) { animation-delay: 0.18s; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; scroll-behavior: auto !important; }
}
@media (forced-colors: active) {
  .ds-btn, .ds-option, .ds-chip, .ds-icon-btn, .ds-lang { border: 1px solid ButtonText; }
}
