:root {
  --bg: #f5f5f7;
  --card: #ffffff;
  --text: #1d1d1f;
  --secondary: #424245;
  --muted: #6e6e73;
  --accent: #0071e3;
  --accent-hover: #0067d2;
  --accent-soft: #0071e314;
  --line: #00000014;
  --soft: #f2f2f4;
  --ok: #2f8f6f;
  --warn: #b06b00;
  --danger: #c9342f;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background: radial-gradient(1200px 520px at 50% -80px, #e8eef6 0%, var(--bg) 58%);
  color: var(--text);
  font: 15px/1.6 "Noto Sans CJK SC", "PingFang SC", "Helvetica Neue", system-ui, "WenQuanYi Micro Hei", "Droid Sans Fallback", sans-serif;
  -webkit-font-smoothing: antialiased;
}

button, input, textarea { font: inherit; color: inherit; }

button { cursor: pointer; }

.wrap { max-width: 920px; margin: 0 auto; padding: 36px 24px 56px; }

.brand {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-bottom: 16px;
  color: var(--secondary);
  text-decoration: none;
}

.brand img { width: 28px; height: 28px; border-radius: 8px; display: block; }

.brand span { font-size: 15px; font-weight: 700; letter-spacing: 0.02em; }

h1 {
  margin: 0;
  text-align: center;
  font-size: 42px;
  font-weight: 750;
  letter-spacing: -0.035em;
  line-height: 1.15;
}

.sub { margin: 10px 0 0; text-align: center; color: var(--muted); font-size: 15px; }

.pills {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px;
  margin: 18px 0 28px;
}

.pills span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 999px;
  background: #fff;
  border: 1px solid var(--line);
  color: var(--secondary);
  font-size: 13px;
}

.pills svg { width: 14px; height: 14px; stroke: var(--accent); fill: none; stroke-width: 1.8; }

.portal {
  background: var(--card);
  border-radius: 17px;
  box-shadow: 0 24px 52px -32px #00000040, 0 0 0 1px var(--line);
  overflow: hidden;
}

.tabs {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  background: var(--soft);
  padding: 8px;
  gap: 4px;
}

.tab {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 46px;
  padding: 0;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: var(--secondary);
  font-weight: 600;
  font-size: 15px;
}

.tab:hover:not(.active) { background: #e8e8ed; }

.tab.active { background: var(--accent); color: #fff; }

.tab svg { width: 16px; height: 16px; stroke: currentColor; fill: none; stroke-width: 1.8; }

.body { padding: 32px 42px 28px; }

.steps {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  position: relative;
  margin: 8px 0 28px;
}

.steps:before {
  content: "";
  position: absolute;
  left: 12.5%;
  right: 12.5%;
  top: 17px;
  height: 2px;
  background: #e5e5ea;
  z-index: 0;
}

.step { position: relative; z-index: 1; text-align: center; }

.num {
  width: 34px;
  height: 34px;
  margin: 0 auto 8px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #fff;
  border: 2px solid #e5e5ea;
  color: var(--muted);
  font-weight: 700;
  font-size: 14px;
}

.step.active .num { background: var(--accent); border-color: var(--accent); color: #fff; }

.step.done .num { background: #fff; border-color: var(--accent); color: var(--accent); }

.step span { font-size: 13px; color: var(--muted); }

.step.active span, .step.done span { color: var(--text); font-weight: 600; }

.icon {
  width: 52px;
  height: 52px;
  margin: 8px auto 14px;
  border-radius: 14px;
  background: var(--accent-soft);
  display: flex;
  align-items: center;
  justify-content: center;
}

.icon svg { width: 24px; height: 24px; stroke: var(--accent); fill: none; stroke-width: 1.8; }

.icon.ok { background: #2f8f6f14; }
.icon.ok svg { stroke: var(--ok); }
.icon.bad { background: #c9342f14; }
.icon.bad svg { stroke: var(--danger); }
.icon.warn { background: #b06b0014; }
.icon.warn svg { stroke: var(--warn); }

.panel-title { text-align: center; font-size: 28px; font-weight: 750; letter-spacing: -0.03em; margin: 0; }

.panel-desc { text-align: center; color: var(--muted); margin: 8px 0 28px; font-size: 14px; }

label { display: block; font-weight: 650; margin-bottom: 8px; font-size: 14px; }

.field {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 50px;
  padding: 0 14px;
  border-radius: 12px;
  border: 1px solid #d2d2d7;
  background: #fafafa;
}

.field:focus-within { border-color: var(--accent); background: #fff; }

.field svg { width: 18px; height: 18px; stroke: var(--muted); fill: none; stroke-width: 1.8; flex: none; }

.field input {
  border: 0;
  outline: 0;
  background: transparent;
  width: 100%;
  height: 100%;
  font-size: 15px;
  color: var(--text);
}

.field input::placeholder { color: #8e8e93; }

.area {
  display: block;
  height: auto;
  padding: 12px 14px;
}

.area textarea {
  display: block;
  width: 100%;
  min-height: 148px;
  border: 0;
  outline: 0;
  resize: vertical;
  background: transparent;
  font-size: 14px;
  line-height: 1.55;
  color: var(--text);
}

.area textarea::placeholder { color: #8e8e93; }

.hint { margin: 8px 0 18px; color: var(--muted); font-size: 13px; }

.cta {
  height: 54px;
  padding: 0 16px;
  border: 0;
  border-radius: 12px;
  width: 100%;
  background: var(--accent);
  color: #fff;
  font-size: 16px;
  font-weight: 650;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  text-decoration: none;
}

.cta:hover:not(:disabled) { background: var(--accent-hover); }

.cta:disabled { opacity: 0.55; cursor: default; }

.cta svg { width: 18px; height: 18px; stroke: #fff; fill: none; stroke-width: 2; }

.actions { display: flex; gap: 10px; }

.actions .cta { flex: 1; }

.ghost {
  height: 54px;
  padding: 0 22px;
  border-radius: 12px;
  border: 1px solid #d2d2d7;
  background: #fff;
  color: var(--secondary);
  font-size: 16px;
  font-weight: 650;
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}

.ghost:hover:not(:disabled) { background: #f5f5f7; }

.ghost:disabled { opacity: 0.55; cursor: default; }

.linkish {
  display: block;
  margin: 12px auto 0;
  background: none;
  border: 0;
  color: var(--accent);
  font-weight: 600;
  font-size: 14px;
  padding: 4px 8px;
}

.lock { text-align: center; color: var(--muted); font-size: 12px; margin: 14px 0 0; }

.card-foot {
  border-top: 1px solid var(--line);
  padding: 14px;
  text-align: center;
  color: var(--muted);
  font-size: 12px;
  background: #fcfcfd;
}

.grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin: 28px 8px 0;
  text-align: center;
}

.grid .tile svg {
  width: 22px;
  height: 22px;
  stroke: var(--accent);
  fill: none;
  stroke-width: 1.7;
  margin-bottom: 8px;
}

.grid b { display: block; font-size: 14px; font-weight: 650; }

.grid p { margin: 4px 0 0; color: var(--muted); font-size: 12px; }

footer { margin-top: 36px; text-align: center; color: var(--muted); font-size: 12px; }

.alert {
  border-radius: 12px;
  padding: 12px 14px;
  font-size: 14px;
  margin: 0 0 16px;
  text-align: left;
}

.alert.error { background: #c9342f12; color: var(--danger); }
.alert.success { background: #2f8f6f12; color: var(--ok); }
.alert.warn { background: #b06b0012; color: var(--warn); }

.summary {
  display: grid;
  grid-template-columns: 96px 1fr;
  gap: 8px 12px;
  align-items: baseline;
  border: 1px solid var(--line);
  background: #fafafa;
  border-radius: 12px;
  padding: 14px 16px;
  margin: 0 0 18px;
  text-align: left;
}

.summary dt { margin: 0; color: var(--muted); font-size: 13px; font-weight: 500; }
.summary dd { margin: 0; font-weight: 650; }
.pid { margin-left: 6px; color: var(--muted); font-size: 13px; font-weight: 500; }

.email-box {
  text-align: center;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.02em;
  padding: 16px;
  border-radius: 12px;
  background: var(--accent-soft);
  color: var(--text);
  margin: 0 0 18px;
  word-break: break-all;
}

.email-preview { margin: 8px 0 18px; color: var(--text); font-size: 14px; font-weight: 650; }

.status-line {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: var(--secondary);
  font-size: 14px;
  margin: 0 0 16px;
}

.spinner {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid #d2d2d7;
  border-top-color: var(--accent);
  animation: spin 0.8s linear infinite;
  flex: none;
}

.request-id {
  margin: 14px 0 0;
  text-align: center;
  color: var(--muted);
  font-size: 12px;
  word-break: break-all;
}

.request-id code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }

.stack { display: flex; flex-direction: column; gap: 10px; }

.guide { display: flex; flex-direction: column; gap: 18px; text-align: left; margin: 0 0 22px; }

.guide article { display: flex; gap: 12px; align-items: flex-start; }

.guide .num { margin: 0; flex: none; background: var(--accent); border-color: var(--accent); color: #fff; }

.guide h3 { margin: 2px 0 4px; font-size: 16px; font-weight: 650; }

.guide p { margin: 0; color: var(--muted); font-size: 14px; }

.results { margin-top: 18px; text-align: left; }

.result {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}

.result:last-child { border-bottom: 0; }

.result b { display: block; font-size: 14px; font-weight: 650; }

.result p { margin: 2px 0 0; color: var(--muted); font-size: 12px; }
.result .queue-line { color: var(--accent); font-weight: 650; }

.badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 12px;
  font-weight: 650;
  flex: none;
}

.badge.ok { color: var(--ok); background: #2f8f6f14; }
.badge.warn { color: var(--warn); background: #b06b0014; }
.badge.bad { color: var(--danger); background: #c9342f14; }
.badge.used { color: var(--secondary); background: #0000000a; }

.empty { margin: 16px 0 0; text-align: center; color: var(--muted); font-size: 13px; }

.page { display: none; }
.page.show { display: block; }

.switcher { display: flex; justify-content: center; margin: 0 0 18px; }

.switch {
  display: inline-flex;
  padding: 4px;
  gap: 4px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 999px;
  box-shadow: 0 8px 24px -18px #00000059;
}

.switch button {
  appearance: none;
  border: 0;
  background: transparent;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-width: 124px;
  height: 36px;
  padding: 0 16px;
  border-radius: 999px;
  color: var(--secondary);
  font-size: 14px;
  font-weight: 650;
}

.switch button.active { background: var(--accent); color: #fff; }
.switch svg { width: 15px; height: 15px; stroke: currentColor; fill: none; stroke-width: 1.8; }

#page-gemini .step.done .num {
  background: #e8f1fc;
  border-color: var(--accent);
  color: var(--accent);
}

.quota {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin: 0 0 22px;
  padding: 12px 16px;
  border-radius: 12px;
  background: #248a3d14;
  color: #248a3d;
  font-size: 14px;
  font-weight: 600;
}

.quota b { font-weight: 750; }
.quota .rest { margin-left: auto; font-weight: 600; color: #2f6f3c; }

.choices { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 0 0 22px; }
#g-plans .choice:only-child { grid-column: 1 / -1; }

.choice {
  border: 1.5px solid #d2d2d7;
  background: #fff;
  border-radius: 14px;
  padding: 14px 16px;
  min-height: 92px;
  text-align: left;
  color: inherit;
  font: inherit;
  width: 100%;
}

.choice.active {
  border-color: var(--accent);
  background: var(--accent-soft);
  box-shadow: 0 0 0 3px #0071e314;
}

.choice .tag {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  vertical-align: 1px;
}

.choice h3 { margin: 0 0 6px; font-size: 15px; font-weight: 700; }
.choice p { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.45; }

.row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-bottom: 16px; }

.consent {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin: 4px 0 18px;
  color: var(--secondary);
  font-size: 13px;
  line-height: 1.5;
  font-weight: 500;
}

.consent input {
  width: 18px;
  height: 18px;
  margin-top: 2px;
  flex: none;
  accent-color: var(--accent);
}

.result-kicker {
  margin: 4px 0 6px;
  text-align: center;
  color: var(--accent);
  font-size: 13px;
  font-weight: 650;
  letter-spacing: 0.08em;
}
.result-kicker.success { color: #2f6f3c; }
.result-kicker.failure, .result-kicker.cancelled { color: var(--danger); }
.result-head {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-bottom: 8px;
}
.result-head .panel-title { margin: 0; }
.count-pill {
  display: inline-flex;
  align-items: center;
  height: 26px;
  padding: 0 10px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 13px;
  font-weight: 700;
}
.stage-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin: 18px 0 16px;
  text-align: left;
}
.stage-bar {
  height: 7px;
  border-radius: 7px;
  background: #e6e6ea;
  overflow: hidden;
  margin-bottom: 8px;
}
.stage-bar > span {
  display: block;
  height: 100%;
  width: 0;
  border-radius: 7px;
  background: #e6e6ea;
}
.stage-bar.done > span { background: #248a3d; }
.stage-bar.now > span { background: var(--accent); }
.stage-bar.bad > span { background: var(--danger); }
.stage-name { font-size: 14px; font-weight: 700; color: var(--text); }
.stage-meta { margin-top: 2px; font-size: 12px; color: var(--muted); }
.stage.done .stage-meta { color: #2f6f3c; }
.stage.now .stage-name, .stage.now .stage-meta { color: var(--accent); }
.stage.todo .stage-name, .stage.todo .stage-meta { color: #8e8e93; }
.stage.bad .stage-meta { color: var(--danger); }
.status-card {
  background: var(--accent-soft);
  border-radius: 14px;
  padding: 16px 18px;
  margin: 0 0 14px;
  text-align: left;
}
.status-card.ok { background: #248a3d14; }
.status-card.bad { background: #c9342f12; }
.status-card-top { display: flex; gap: 12px; align-items: flex-start; }
.status-title { font-size: 16px; font-weight: 750; letter-spacing: -0.02em; }
.status-msg { color: var(--secondary); font-size: 14px; }
.status-msg.queue { color: var(--text); font-weight: 650; }
.status-stage { margin-top: 8px; color: var(--muted); font-size: 13px; }
.stage-box {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px 16px 8px;
  margin: 0 0 12px;
  text-align: left;
}
.stage-box-title { font-weight: 700; font-size: 14px; margin-bottom: 4px; }
.stage-box ul { list-style: none; margin: 0; padding: 0; }
.stage-box li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 0;
  color: var(--muted);
  font-size: 14px;
}
.stage-box li.active, .stage-box li.bad { color: var(--text); font-weight: 700; }
.stage-box .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #d2d2d7;
  flex: none;
}
.stage-box li.done .dot { background: #248a3d; }
.stage-box li.active .dot { background: var(--accent); }
.stage-box li.bad .dot { background: var(--danger); }
.tag-now {
  margin-left: auto;
  background: var(--accent-soft);
  color: var(--accent);
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  padding: 2px 8px;
}
.tag-bad { background: #c9342f14; color: var(--danger); }
.stage-note {
  text-align: center;
  color: var(--muted);
  font-size: 13px;
  margin: 0 0 8px;
}

.link-box {
  border: 1px solid var(--line);
  background: #fafafa;
  border-radius: 12px;
  padding: 14px;
  margin: 0 0 16px;
  text-align: left;
}
.link-url {
  font-size: 13px;
  word-break: break-all;
  margin-bottom: 12px;
  color: var(--secondary);
}

#g-result-actions {
  margin: 16px 0 0;
}
#g-cancel + #g-result-actions {
  margin-top: 12px;
}
#g-result-actions .ghost {
  width: 100%;
}

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

[hidden] { display: none !important; }

@media (prefers-reduced-motion: reduce) {
  .spinner { animation: none; }
}

@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 720px) {
  .wrap { padding: 24px 16px 40px; }
  h1 { font-size: 32px; }
  .body { padding: 24px 16px 20px; }
  .grid { grid-template-columns: 1fr 1fr; gap: 18px 12px; margin-top: 24px; }
  .tab { font-size: 13px; gap: 4px; padding: 0 4px; }
  .steps span { font-size: 12px; }
  .panel-title { font-size: 24px; }
  .summary { grid-template-columns: 84px 1fr; }
  .actions { flex-direction: column; }
  .ghost { width: 100%; }
  .row, .choices { grid-template-columns: 1fr; }
  .switch button { min-width: 0; padding: 0 14px; }
  .stage-grid { gap: 8px; }
  .stage-name { font-size: 12px; }
  .stage-meta { font-size: 11px; }
  .status-card { padding: 14px; }
  .result-head { flex-wrap: wrap; }
}
