:root {
  color-scheme: light;
  --bg: #f4f7fb;
  --surface: #ffffff;
  --surface-soft: #f8fafc;
  --text: #172033;
  --muted: #667085;
  --line: #dfe5ee;
  --line-strong: #cbd5e1;
  --blue: #2563eb;
  --blue-dark: #1d4ed8;
  --blue-soft: #eff6ff;
  --green: #079455;
  --green-soft: #ecfdf3;
  --red: #d92d20;
  --red-soft: #fef3f2;
  --amber: #b54708;
  --amber-soft: #fffaeb;
  --shadow: 0 14px 40px rgba(15, 23, 42, 0.08);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-width: 320px;
  color: var(--text);
  background: linear-gradient(180deg, #f8fbff 0, var(--bg) 420px);
  font-size: 16px;
  line-height: 1.5;
}

button, input, textarea { font: inherit; }

button, a, summary, label { -webkit-tap-highlight-color: transparent; }

.page-shell { width: min(1280px, calc(100% - 40px)); margin: 0 auto; padding: 36px 0 56px; }

.hero { display: flex; align-items: end; justify-content: space-between; gap: 24px; padding: 0 2px 22px; }
.eyebrow { display: inline-flex; align-items: center; gap: 8px; color: var(--blue-dark); font-size: 14px; font-weight: 700; }
.eyebrow span { width: 8px; height: 8px; border-radius: 50%; background: var(--blue); box-shadow: 0 0 0 5px var(--blue-soft); }
.hero h1 { margin: 10px 0 3px; font-size: clamp(28px, 3vw, 40px); letter-spacing: -0.035em; line-height: 1.2; }
.hero p { margin: 0; color: var(--muted); }
.auth-hint { flex: none; padding: 10px 14px; border: 1px solid var(--line); border-radius: 10px; color: #475467; background: rgba(255,255,255,.78); font-size: 14px; box-shadow: 0 4px 16px rgba(15,23,42,.04); }

.workspace {
  display: grid;
  grid-template-columns: 1fr 1fr;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.panel { min-width: 0; padding: 30px 28px; }
.card-panel { border-right: 1px solid var(--line); }
.step-title { display: flex; align-items: flex-start; gap: 12px; margin-bottom: 22px; }
.step-number { display: grid; flex: none; width: 30px; height: 30px; place-items: center; border-radius: 9px; color: white; background: var(--blue); font-size: 14px; font-weight: 800; }
.step-title h2 { margin: 1px 0 3px; font-size: 20px; line-height: 1.3; }
.step-title p { margin: 0; color: var(--muted); font-size: 14px; }
.step-title a { color: var(--blue); font-weight: 650; text-decoration: none; }
.step-title a:hover { text-decoration: underline; }

label, legend { display: block; margin-bottom: 7px; font-size: 14px; font-weight: 700; color: #344054; }
input, textarea {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  color: var(--text);
  background: #fff;
  outline: none;
  transition: border-color .18s, box-shadow .18s, background .18s;
}
input { height: 46px; padding: 0 13px; }
textarea { min-height: 298px; padding: 13px; resize: vertical; line-height: 1.55; }
input::placeholder, textarea::placeholder { color: #98a2b3; }
input:focus, textarea:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(37,99,235,.13); }
input.invalid, textarea.invalid { border-color: var(--red); background: #fffafa; }

.format-box { display: grid; gap: 4px; margin-top: 14px; padding: 13px 15px; border: 1px solid #bfdbfe; border-radius: 10px; color: #1e40af; background: var(--blue-soft); font-size: 13px; }
.format-box strong { color: #1e3a8a; }
.format-box code { font: 13px/1.45 ui-monospace, SFMono-Regular, Consolas, monospace; }

.check-grid, .session-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; margin-top: 16px; }
.check-item, .session-card { min-width: 0; padding: 11px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-soft); }
.check-item { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.check-item span, .session-card span { color: #475467; font-size: 13px; }
.check-item b { font-size: 12px; white-space: nowrap; }
.session-card b { display: block; overflow: hidden; margin-top: 4px; font-size: 14px; text-overflow: ellipsis; white-space: nowrap; }
.waiting { color: var(--muted); }
.valid { color: var(--green); }
.invalid-state { color: var(--red); }

.plan-fieldset { min-width: 0; margin: 20px 0 0; padding: 0; border: 0; }
.plan-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.plan { position: relative; min-width: 0; margin: 0; padding: 13px 12px; border: 1px solid var(--line); border-radius: 11px; background: #fff; cursor: pointer; transition: border-color .18s, background .18s, box-shadow .18s; }
.plan:hover { border-color: #93b4f9; }
.plan.active { border-color: var(--blue); background: var(--blue-soft); box-shadow: inset 0 0 0 1px var(--blue); }
.plan input { position: absolute; opacity: 0; pointer-events: none; }
.plan strong, .plan span { display: block; }
.plan strong { margin-bottom: 2px; color: var(--text); font-size: 15px; }
.plan span { color: var(--muted); font-size: 12px; font-weight: 500; line-height: 1.4; }

.billing { margin-top: 20px; border-top: 1px solid var(--line); }
.billing summary { padding: 17px 0 13px; color: #344054; font-size: 14px; font-weight: 750; cursor: pointer; }
.billing summary span { margin-left: 8px; padding: 2px 7px; border-radius: 999px; color: var(--blue-dark); background: var(--blue-soft); font-size: 11px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 13px 12px; }
.form-grid .wide { grid-column: 1 / -1; }
.form-grid label { margin-bottom: 5px; font-size: 12px; }
.form-grid input { height: 42px; font-size: 14px; }
.region-note { margin: 10px 0 0; color: var(--muted); font-size: 12px; }

.session-grid { margin-top: 14px; }
.authorization { display: flex; align-items: flex-start; gap: 10px; margin: 18px 0 0; color: #344054; font-size: 13px; font-weight: 550; line-height: 1.55; cursor: pointer; }
.authorization input { flex: none; width: 17px; height: 17px; margin: 2px 0 0; accent-color: var(--blue); }
.privacy-note { display: flex; gap: 10px; margin-top: 14px; padding: 13px 14px; border: 1px solid var(--line); border-radius: 10px; color: #475467; background: var(--surface-soft); font-size: 13px; }
.privacy-note span { color: var(--blue); font-weight: 800; }
.privacy-note p { margin: 0; }

.task-panel { margin-top: 18px; padding: 16px; border: 1px solid #bfdbfe; border-radius: 12px; background: #f8fbff; }
.task-head, .task-summary { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.task-head div span { display: block; color: var(--muted); font-size: 12px; }
.task-head div strong { display: block; max-width: 340px; overflow: hidden; margin-top: 2px; font: 12px ui-monospace, SFMono-Regular, Consolas, monospace; text-overflow: ellipsis; }
.task-badge { padding: 4px 9px; border-radius: 999px; background: var(--blue-soft); color: var(--blue-dark); font-size: 12px; font-weight: 750; }
.task-badge.completed { color: var(--green); background: var(--green-soft); }
.task-badge.failed { color: var(--red); background: var(--red-soft); }
.task-badge.needs_review { color: var(--amber); background: var(--amber-soft); }
.progress-track { overflow: hidden; height: 8px; margin: 14px 0 9px; border-radius: 99px; background: #dbeafe; }
.progress-track span { display: block; width: 0; height: 100%; border-radius: inherit; background: var(--blue); transition: width .35s ease; }
.task-summary strong { font-size: 13px; }
.task-summary span { color: var(--blue-dark); font-size: 13px; font-weight: 750; }
.task-logs { display: grid; gap: 8px; max-height: 150px; overflow: auto; margin: 13px 0 0; padding: 12px 0 0 19px; border-top: 1px solid var(--line); color: #475467; font-size: 12px; }
.review-warning { margin-top: 12px; padding: 10px 11px; border: 1px solid #fedf89; border-radius: 8px; color: var(--amber); background: var(--amber-soft); font-size: 12px; font-weight: 650; }

.action-bar { grid-column: 1 / -1; display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 17px 24px; border-top: 1px solid var(--line); background: #fbfcfe; }
.action-bar strong { font-size: 14px; }
.action-bar p { margin: 2px 0 0; color: var(--muted); font-size: 12px; }
.actions { display: flex; gap: 9px; }
.button { min-height: 42px; padding: 0 17px; border-radius: 9px; font-weight: 750; cursor: pointer; transition: transform .12s, background .18s, border-color .18s; }
.button:active { transform: translateY(1px); }
.button:disabled { cursor: not-allowed; opacity: .45; }
.primary { border: 1px solid var(--blue); color: #fff; background: var(--blue); }
.primary:hover:not(:disabled) { border-color: var(--blue-dark); background: var(--blue-dark); }
.secondary { border: 1px solid var(--line-strong); color: #344054; background: #fff; }
.secondary:hover { border-color: #98a2b3; background: var(--surface-soft); }

.dialog { width: min(460px, calc(100% - 32px)); padding: 22px; border: 1px solid var(--line); border-radius: 15px; color: var(--text); background: #fff; box-shadow: 0 28px 90px rgba(15,23,42,.22); }
.dialog::backdrop { background: rgba(15,23,42,.42); backdrop-filter: blur(2px); }
.dialog-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; margin-bottom: 20px; }
.dialog-head h2 { margin: 0; font-size: 20px; }
.dialog-head p { margin: 4px 0 0; color: var(--muted); font-size: 13px; }
.dialog-head > button { border: 0; color: var(--muted); background: transparent; font-size: 27px; line-height: 1; cursor: pointer; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 9px; margin-top: 18px; }
.field-error { margin: 6px 0 0; color: var(--red); font-size: 12px; }
.history-dialog { width: min(780px, calc(100% - 32px)); }
.history-list { max-height: 58vh; overflow: auto; border: 1px solid var(--line); border-radius: 10px; }
.history-row { display: grid; grid-template-columns: minmax(160px,1.2fr) .6fr .6fr 1fr; gap: 12px; padding: 12px 14px; border-bottom: 1px solid var(--line); font-size: 13px; }
.history-row:last-child { border-bottom: 0; }
.history-row.header { position: sticky; top: 0; color: var(--muted); background: #f8fafc; font-size: 12px; font-weight: 700; }
.history-row span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.history-empty { padding: 42px 20px; color: var(--muted); text-align: center; }

.toast { position: fixed; right: 22px; bottom: 22px; z-index: 20; max-width: min(420px, calc(100% - 44px)); padding: 12px 15px; border: 1px solid var(--line); border-radius: 10px; color: #fff; background: #344054; box-shadow: 0 14px 35px rgba(15,23,42,.2); font-size: 14px; }
.toast.error { background: #b42318; }
.toast.success { background: #067647; }

@media (max-width: 920px) {
  .page-shell { width: min(720px, calc(100% - 28px)); padding-top: 24px; }
  .hero { align-items: flex-start; flex-direction: column; }
  .workspace { grid-template-columns: 1fr; }
  .card-panel { border-right: 0; border-bottom: 1px solid var(--line); }
  textarea { min-height: 240px; }
}

@media (max-width: 560px) {
  .page-shell { width: calc(100% - 18px); padding: 18px 0 30px; }
  .hero { gap: 14px; padding-inline: 7px; }
  .auth-hint { width: 100%; }
  .panel { padding: 23px 18px; }
  .plan-grid, .check-grid, .session-grid, .form-grid { grid-template-columns: 1fr; }
  .form-grid .wide { grid-column: auto; }
  .action-bar { align-items: stretch; flex-direction: column; padding: 16px 18px; }
  .actions { display: grid; grid-template-columns: 1fr 1fr; }
  .history-row { grid-template-columns: 1fr 1fr; }
  .history-row.header { display: none; }
}

@media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto !important; transition: none !important; } }
