:root {
  color-scheme: light;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Microsoft YaHei", sans-serif;
  color: #15213a;
  background: #f2f6ff;
  --blue: #1559e8;
  --blue-dark: #0e42b3;
  --line: #dce6f8;
  --muted: #677690;
  --danger: #b42318;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 15% 0%, #dce9ff 0, transparent 32rem),
    #f2f6ff;
}

button, input, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: wait; opacity: .65; }
.hidden { display: none !important; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: max(14px, env(safe-area-inset-top)) max(18px, env(safe-area-inset-right)) 14px max(18px, env(safe-area-inset-left));
  color: white;
  background: linear-gradient(120deg, #123ea4, #1765f2);
  box-shadow: 0 8px 30px rgba(27, 72, 156, .22);
}

.brand { display: flex; align-items: center; gap: 12px; }
.brand div { display: grid; gap: 3px; }
.brand strong { font-size: 19px; }
.brand span { font-size: 12px; color: #dbe8ff; }

main {
  width: min(760px, calc(100% - 28px));
  margin: 28px auto;
}

.panel {
  padding: clamp(20px, 4vw, 34px);
  border: 1px solid var(--line);
  border-radius: 22px;
  background: rgba(255, 255, 255, .96);
  box-shadow: 0 18px 60px rgba(40, 71, 130, .12);
}

h1 { margin: 0 0 10px; font-size: clamp(24px, 5vw, 32px); }
.muted { margin: 0; color: var(--muted); line-height: 1.65; }

.tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 24px 0 18px;
  padding: 5px;
  border-radius: 14px;
  background: #eef3fc;
}

.tab, .ghost {
  min-height: 42px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: #41506b;
}

.tab.active { background: white; color: var(--blue); box-shadow: 0 3px 12px rgba(37, 76, 150, .12); }
.ghost { padding: 0 16px; color: white; border: 1px solid rgba(255, 255, 255, .45); }

form { display: grid; gap: 16px; }
label { display: grid; gap: 7px; font-weight: 650; }
small { color: var(--muted); font-weight: 400; }

.captcha-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 10px;
}
.captcha-question {
  display: inline-flex;
  min-height: 34px;
  align-items: center;
  padding: 6px 12px;
  border: 1px dashed #9db5e6;
  border-radius: 10px;
  background: #f4f7ff;
  color: var(--blue-dark);
  font-weight: 750;
  letter-spacing: .04em;
}
.captcha-refresh {
  min-width: 84px;
  height: 48px;
  color: var(--blue);
  border-color: #b8c9ea;
}

input, textarea {
  width: 100%;
  border: 1px solid #cdd9ee;
  border-radius: 12px;
  outline: 0;
  background: white;
  color: #15213a;
}

input { height: 48px; padding: 0 14px; }
textarea { resize: vertical; min-height: 72px; padding: 13px 14px; line-height: 1.5; }
input:focus, textarea:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(21, 89, 232, .13); }

.password-field {
  position: relative;
  display: block;
}
.password-field input { padding-right: 68px; }
.password-toggle {
  position: absolute;
  top: 5px;
  right: 6px;
  min-width: 52px;
  height: 38px;
  border: 0;
  border-radius: 9px;
  background: #eef3fc;
  color: var(--blue);
  font-weight: 650;
}
.password-toggle:hover { background: #dfe9fb; }
.password-toggle:focus-visible { outline: 3px solid rgba(21, 89, 232, .25); }

.primary {
  min-height: 48px;
  padding: 0 20px;
  border: 0;
  border-radius: 12px;
  color: white;
  background: var(--blue);
  font-weight: 750;
}
.primary:hover { background: var(--blue-dark); }
.message { min-height: 24px; margin: 14px 0 0; color: var(--danger); }

.chat-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.quota { flex: none; padding: 9px 12px; border-radius: 999px; background: #eaf1ff; color: var(--blue); font-weight: 750; }
.notice { margin: 20px 0; padding: 12px 14px; border-left: 4px solid #f2a900; background: #fff8e6; color: #66521e; line-height: 1.55; }

.messages {
  display: flex;
  flex-direction: column;
  gap: 13px;
  height: min(52vh, 480px);
  overflow-y: auto;
  padding: 12px 4px 18px;
}

.bubble {
  max-width: 90%;
  padding: 13px 15px;
  border-radius: 16px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  line-height: 1.65;
}
.bubble.assistant { align-self: flex-start; background: #eef3fc; border-bottom-left-radius: 5px; }
.bubble.user { align-self: flex-end; color: white; background: var(--blue); border-bottom-right-radius: 5px; }
.bubble.waiting { color: var(--muted); }

.composer { gap: 8px; padding-top: 14px; border-top: 1px solid var(--line); }
.composer-footer { display: flex; justify-content: space-between; align-items: center; color: var(--muted); font-size: 13px; }
.composer-footer .primary { min-height: 42px; }

footer { padding: 4px 20px max(24px, env(safe-area-inset-bottom)); text-align: center; color: var(--muted); font-size: 12px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

@media (max-width: 520px) {
  main { width: 100%; margin: 0; }
  .panel { min-height: calc(100vh - 78px); border: 0; border-radius: 0; box-shadow: none; }
  .brand span { display: none; }
  .chat-heading { align-items: center; }
  .bubble { max-width: 94%; }
  .captcha-row { grid-template-columns: 1fr; }
  .captcha-refresh { width: 100%; }
}
