:root {
  color-scheme: light;
  --bg: #f5f9fd;
  --surface: #ffffff;
  --surface-blue: #f2f8fd;
  --line: rgba(0, 133, 208, .18);
  --line-strong: rgba(0, 133, 208, .34);
  --text: #18304b;
  --muted: #667f98;
  --blue: #0085d0;
  --blue-deep: #006da9;
  --cyan: #19a8ce;
  --green: #13885d;
  --amber: #c67818;
  --red: #c83f52;
  --radius: 18px;
  font-family: Inter, "SF Pro Display", "Segoe UI", "PingFang SC", "Microsoft YaHei UI", sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { min-width: 320px; min-height: 100%; background: #ffffff; }
body {
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  background:
    radial-gradient(circle at 78% -8%, rgba(0, 133, 208, .11), transparent 33rem),
    radial-gradient(circle at -8% 46%, rgba(25, 168, 206, .07), transparent 28rem),
    linear-gradient(155deg, #ffffff, var(--bg) 58%, #ffffff);
}
body::before {
  position: fixed;
  inset: 0;
  z-index: -1;
  content: "";
  opacity: .26;
  background-image:
    linear-gradient(rgba(0, 133, 208, .055) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0, 133, 208, .055) 1px, transparent 1px);
  background-size: 58px 58px;
  mask-image: linear-gradient(to bottom, #000, transparent 84%);
}

button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
a { color: #0079be; text-decoration: none; }
code { font-family: Consolas, "SFMono-Regular", monospace; }
.page-shell { width: min(1460px, calc(100% - 44px)); margin: 0 auto; padding: 28px 0 30px; }

.page-shell, .topbar > *, .hero > *, .section-heading > *, .form-footer > *, .create-footer > * { min-width: 0; }

.topbar { display: flex; align-items: center; justify-content: space-between; gap: 24px; padding: 3px 4px 25px; border-bottom: 1px solid var(--line); }
.identity { display: flex; align-items: center; gap: 13px; color: var(--text); }
.identity small, .identity strong { display: block; }
.identity small { margin-bottom: 2px; color: #5f7f9d; font-size: 10px; letter-spacing: .19em; }
.identity strong { font-size: 16px; }
.logo { display: grid; width: 45px; height: 45px; place-items: center; color: #fff; border-radius: 14px; background: linear-gradient(145deg, var(--blue), var(--cyan)); box-shadow: 0 10px 28px rgba(0, 133, 208, .2); font-weight: 800; }
.top-actions { display: flex; align-items: center; gap: 9px; }

.hero { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 32px; padding: 46px 5px 31px; }
.hero h1 { margin: 7px 0 12px; font-size: clamp(31px, 4.1vw, 53px); line-height: 1.12; letter-spacing: -.045em; }
.hero p:not(.eyebrow) { max-width: 820px; margin: 0; color: var(--muted); font-size: 16px; line-height: 1.75; }
.eyebrow, .step-label { margin: 0 0 5px; color: var(--blue); font-size: 10px; font-weight: 800; letter-spacing: .18em; }
.status-pill { display: inline-flex; align-items: center; gap: 8px; padding: 10px 14px; color: var(--muted); border: 1px solid var(--line); border-radius: 999px; background: #fff; font-size: 12px; white-space: nowrap; }
.status-pill i { width: 8px; height: 8px; border-radius: 50%; background: #8ca0b5; }
.status-online { color: var(--green); border-color: rgba(19, 136, 93, .24); }
.status-online i { background: #18a674; box-shadow: 0 0 12px rgba(24, 166, 116, .48); }

.card { min-width: 0; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: 0 18px 48px rgba(35, 83, 116, .09); }
.connection-card, .creation-card, .task-card, .ledger-card { padding: 25px; }
.section-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; margin-bottom: 21px; }
.section-heading.compact { align-items: center; }
.section-heading h2 { margin: 0; font-size: 21px; letter-spacing: -.025em; }

.mode-tabs { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-bottom: 20px; }
.mode-tab { position: relative; display: grid; grid-template-columns: auto 1fr; gap: 3px 11px; min-width: 0; padding: 17px 19px; color: var(--text); text-align: left; border: 1px solid var(--line); border-radius: 14px; background: #fff; transition: border-color .15s, box-shadow .15s, transform .15s; }
.mode-tab:hover { transform: translateY(-1px); border-color: var(--line-strong); }
.mode-tab > span { grid-row: span 2; align-self: center; padding: 6px 8px; color: var(--blue); border-radius: 7px; background: rgba(0, 133, 208, .08); font-size: 10px; font-weight: 800; }
.mode-tab strong { font-size: 15px; }
.mode-tab small { overflow: hidden; color: var(--muted); font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.mode-tab-active { border-color: rgba(0, 133, 208, .42); background: linear-gradient(125deg, rgba(0, 133, 208, .09), rgba(25, 168, 206, .04)); box-shadow: 0 9px 28px rgba(0, 133, 208, .09); }
.mode-tab-active::after { position: absolute; right: 13px; top: 13px; width: 7px; height: 7px; content: ""; border-radius: 50%; background: var(--blue); }

.config-panel { padding-top: 2px; }
.config-grid { display: grid; grid-template-columns: minmax(300px, 1.4fr) minmax(190px, .65fr) minmax(260px, 1fr); gap: 13px; }
.relay-grid { grid-template-columns: minmax(320px, 1.45fr) minmax(300px, 1fr); }
.server-key-panel { display: flex; min-width: 0; align-items: center; gap: 11px; min-height: 45px; padding: 8px 12px; color: var(--muted); border: 1px solid rgba(0, 133, 208, .17); border-radius: 11px; background: #f7fbfe; }
.server-key-panel i { width: 9px; height: 9px; flex: 0 0 auto; border-radius: 50%; background: #9aabba; }
.server-key-panel > span, .server-key-panel strong, .server-key-panel small { display: block; min-width: 0; }
.server-key-panel strong { overflow: hidden; color: #47657f; font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.server-key-panel small { margin-top: 2px; color: var(--muted); font-size: 9px; }
.server-key-ready { border-color: rgba(19, 136, 93, .2); background: #f3fbf8; }
.server-key-ready i { background: #18a674; box-shadow: 0 0 10px rgba(24, 166, 116, .38); }
.server-key-ready strong { color: var(--green); }
.field { display: flex; min-width: 0; flex-direction: column; gap: 8px; }
.field > span { color: #34536e; font-size: 12px; font-weight: 700; }
.field small { color: #7088a0; font-size: 10px; line-height: 1.45; }
input, select, textarea { width: 100%; color: var(--text); border: 1px solid rgba(0, 133, 208, .2); border-radius: 11px; outline: none; background: #fff; transition: border-color .15s, box-shadow .15s; }
input, select { height: 45px; padding: 0 12px; }
textarea { min-height: 320px; padding: 15px; resize: vertical; font-size: 13px; line-height: 1.7; }
input[readonly] { color: #51718d; background: #f6fafd; }
input:focus, select:focus, textarea:focus { border-color: rgba(0, 133, 208, .58); box-shadow: 0 0 0 3px rgba(0, 133, 208, .09); }
.secret-input { position: relative; }
.secret-input input { padding-right: 62px; }
.secret-toggle { position: absolute; top: 7px; right: 7px; height: 31px; padding: 0 10px; color: var(--blue-deep); border: 0; border-radius: 7px; background: rgba(0, 133, 208, .07); font-size: 10px; }
.form-footer, .create-footer { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-top: 18px; }
.security-note, .create-footer p { margin: 0; color: #6d85a0; font-size: 11px; line-height: 1.55; }
.message { min-height: 18px; margin: 11px 0 0; color: var(--muted); font-size: 11px; line-height: 1.55; }
.message-success { color: var(--green); }
.message-error { color: var(--red); }
.message-warning { color: var(--amber); }
.message-working { color: var(--blue-deep); }

.button, .icon-button { display: inline-flex; align-items: center; justify-content: center; color: var(--text); border: 1px solid transparent; border-radius: 10px; transition: transform .15s, opacity .15s, border-color .15s; text-decoration: none; }
.button { min-height: 42px; padding: 0 17px; font-size: 12px; font-weight: 700; }
.button:hover:not(:disabled), .icon-button:hover:not(:disabled) { transform: translateY(-1px); }
.button:disabled, .icon-button:disabled { cursor: not-allowed; opacity: .43; }
.button-primary { color: #fff; background: linear-gradient(115deg, var(--blue), var(--cyan)); box-shadow: 0 10px 24px rgba(0, 133, 208, .2); }
.button-secondary { color: var(--blue-deep); border-color: rgba(0, 133, 208, .28); background: rgba(0, 133, 208, .06); }
.button-ghost { color: #52708b; border-color: var(--line); background: #fff; }
.button-small { min-height: 35px; padding: 0 12px; font-size: 11px; }
.button-full { width: 100%; }
.icon-button { width: 34px; height: 34px; color: var(--blue); border-color: var(--line); background: rgba(0, 133, 208, .05); font-size: 17px; }

.workspace-grid { display: grid; grid-template-columns: minmax(0, 1.28fr) minmax(360px, .72fr); gap: 18px; margin-top: 18px; align-items: start; }
.side-column { display: grid; min-width: 0; gap: 18px; }
.charged-label { padding: 7px 10px; color: var(--amber); border: 1px solid rgba(198, 120, 24, .24); border-radius: 999px; background: #fff9ef; font-size: 10px; }
.prompt-field { margin-bottom: 17px; }
.parameter-grid { display: grid; grid-template-columns: .8fr .8fr .62fr 1.2fr; gap: 11px; }
.audio-option { display: grid; grid-template-columns: auto 1fr; grid-template-rows: auto; align-items: center; gap: 11px; min-height: 45px; padding: 8px 11px; border: 1px solid rgba(0, 133, 208, .17); border-radius: 11px; background: #f7fbfe; cursor: pointer; }
.audio-option input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.switch { position: relative; width: 35px; height: 20px; border-radius: 999px; background: #b8c8d7; transition: background .15s; }
.switch::after { position: absolute; top: 3px; left: 3px; width: 14px; height: 14px; content: ""; border-radius: 50%; background: #fff; box-shadow: 0 2px 5px rgba(27, 55, 81, .22); transition: transform .15s; }
.audio-option input:checked + .switch { background: var(--blue); }
.audio-option input:checked + .switch::after { transform: translateX(15px); }
.audio-option > span:last-child { display: flex; min-width: 0; flex-direction: column; gap: 2px; }
.audio-option strong { font-size: 11px; }
.audio-option small { overflow: hidden; color: var(--muted); font-size: 9px; text-overflow: ellipsis; white-space: nowrap; }

.task-status { display: inline-flex; padding: 6px 9px; color: #647d94; border: 1px solid var(--line); border-radius: 999px; background: #f7fafc; font-size: 10px; white-space: nowrap; }
.task-status-submitted, .task-status-pending, .task-status-queued, .task-status-running { color: var(--blue-deep); border-color: rgba(0, 133, 208, .25); background: #f1f8fd; }
.task-status-succeeded { color: var(--green); border-color: rgba(19, 136, 93, .23); background: #f1fbf7; }
.task-status-failed, .task-status-cancelled, .task-status-canceled, .task-status-expired { color: var(--red); border-color: rgba(200, 63, 82, .22); background: #fff4f5; }
.empty-state { display: grid; min-height: 228px; place-items: center; align-content: center; gap: 16px; color: var(--muted); text-align: center; }
.empty-state p { max-width: 270px; margin: 0; font-size: 11px; line-height: 1.6; }
.empty-orbit { position: relative; width: 64px; height: 64px; border: 1px solid rgba(0, 133, 208, .2); border-radius: 50%; }
.empty-orbit::before { position: absolute; inset: 12px; content: ""; border: 1px dashed rgba(0, 133, 208, .25); border-radius: 50%; }
.empty-orbit span { position: absolute; left: 26px; top: 26px; width: 10px; height: 10px; border-radius: 50%; background: var(--blue); box-shadow: 0 0 20px rgba(0, 133, 208, .45); }
.task-meta { margin: 0; }
.task-meta > div { display: grid; grid-template-columns: 76px minmax(0, 1fr); gap: 10px; padding: 9px 0; border-bottom: 1px solid rgba(0, 133, 208, .1); }
.task-meta dt { color: var(--muted); font-size: 10px; }
.task-meta dd { min-width: 0; margin: 0; overflow: hidden; color: #34536e; font: 10px Consolas, monospace; text-overflow: ellipsis; white-space: nowrap; }
.progress-track { height: 4px; margin: 16px 0; overflow: hidden; border-radius: 99px; background: rgba(0, 133, 208, .11); }
.progress-track span { display: block; width: 35%; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--blue), var(--cyan)); animation: progress 1.8s ease-in-out infinite alternate; }
@keyframes progress { from { transform: translateX(-30%); } to { transform: translateX(220%); } }
.video-panel { margin: 15px 0; }
.video-panel video { display: block; width: 100%; max-height: 360px; margin-bottom: 10px; border: 1px solid var(--line); border-radius: 11px; background: #eef5fa; }
.video-panel p { margin: 8px 0 0; color: var(--muted); font-size: 9px; text-align: center; }
.usage-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 16px; }
.usage-grid > div { min-width: 0; padding: 11px; border: 1px solid rgba(0, 133, 208, .12); border-radius: 10px; background: #f7fbfe; }
.usage-grid span { display: block; margin-bottom: 7px; color: var(--muted); font-size: 9px; }
.usage-grid strong { display: block; overflow: hidden; color: #274b68; font-size: 15px; text-overflow: ellipsis; }
.usage-grid .cost-cell { background: rgba(0, 133, 208, .07); }
.usage-grid .cost-cell strong { color: var(--blue-deep); }
.detail-note { min-height: 16px; margin: 12px 0 0; color: var(--muted); font-size: 10px; line-height: 1.55; }

.ledger-total { padding: 17px; border: 1px solid rgba(0, 133, 208, .18); border-radius: 12px; background: linear-gradient(125deg, rgba(0, 133, 208, .09), rgba(25, 168, 206, .04)); }
.ledger-total span { display: block; margin-bottom: 8px; color: var(--muted); font-size: 10px; }
.ledger-total strong { color: var(--blue-deep); font-size: 23px; letter-spacing: -.03em; }
.ledger-list { margin: 15px 0 0; }
.ledger-list > div { display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 9px 2px; border-bottom: 1px solid rgba(0, 133, 208, .1); }
.ledger-list dt { color: var(--muted); font-size: 10px; }
.ledger-list dd { margin: 0; color: #35536d; font-size: 11px; font-weight: 700; }
.ledger-note { margin: 13px 0 0; color: #738aa2; font-size: 9px; line-height: 1.55; }
.page-footer { display: flex; justify-content: space-between; gap: 20px; padding: 26px 5px 0; color: #657d94; font-size: 10px; }

@media (max-width: 1100px) {
  .config-grid { grid-template-columns: 1fr 1fr; }
  .field-wide { grid-column: span 2; }
  .relay-grid { grid-template-columns: 1fr 1fr; }
  .relay-grid .field-wide { grid-column: auto; }
  .workspace-grid { grid-template-columns: 1fr; }
  .side-column { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 740px) {
  .page-shell { width: auto; max-width: none; margin: 0 11px; padding-top: 17px; }
  .topbar, .hero, .section-heading, .form-footer, .create-footer, .page-footer { align-items: stretch; grid-template-columns: 1fr; flex-direction: column; }
  .top-actions { width: 100%; min-width: 0; align-self: stretch; }
  .top-actions .button { min-width: 0; flex: 1 1 0; padding-right: 10px; padding-left: 10px; }
  .hero { gap: 18px; padding: 35px 2px 24px; }
  .hero h1 { max-width: 100%; font-size: clamp(29px, 8.8vw, 34px); overflow-wrap: anywhere; }
  .hero p, .security-note, .create-footer p, .page-footer { overflow-wrap: anywhere; }
  .status-pill { justify-self: start; }
  .connection-card, .creation-card, .task-card, .ledger-card { padding: 19px; }
  .mode-tabs, .config-grid, .relay-grid, .parameter-grid, .side-column { grid-template-columns: 1fr; }
  .mode-tab, .field, .server-key-panel { width: 100%; }
  .field-wide, .relay-grid .field-wide { grid-column: auto; }
  .mode-tab small { white-space: normal; }
  .form-footer .button, .create-footer .button { width: 100%; }
  textarea { min-height: 360px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
