* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --accent: #3a56d4;
  --accent-2: #7c4ddb;
  --accent-strong: #2c43ac;
  --accent-soft: #eef1fc;
  --ink: #0f1729;
  --muted: #5b6472;
  --faint: #8a91a0;
  --line: #e3e6ec;
  --surface: #ffffff;
  --surface-2: #f6f7f9;
  --bg: #eef0f4;
  --danger: #d64545;

  --sans: "IBM Plex Sans", "PingFang SC", "Microsoft YaHei", "Hiragino Sans GB",
    -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, "SFMono-Regular", "Cascadia Code",
    Consolas, monospace;
}

body {
  font-family: var(--sans);
  background:
    radial-gradient(900px 500px at 12% -8%, #dfe6ff 0%, rgba(223, 230, 255, 0) 55%),
    radial-gradient(900px 520px at 92% 4%, #efe2ff 0%, rgba(239, 226, 255, 0) 52%),
    radial-gradient(1000px 600px at 50% 108%, #dcf3ff 0%, rgba(220, 243, 255, 0) 55%),
    linear-gradient(160deg, #eef1fb 0%, #eef0f6 100%);
  background-attachment: fixed;
  min-height: 100vh;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 48px 24px;
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: 0 1px 2px rgba(16, 23, 41, 0.04), 0 18px 44px rgba(16, 23, 41, 0.08);
  padding: 30px 34px 34px;
  width: 600px;
  max-width: 96vw;
}

/* Header — colored band */
.header {
  display: flex;
  align-items: center;
  gap: 15px;
  margin: -30px -34px 24px;
  padding: 26px 34px;
  border-radius: 16px 16px 0 0;
  background: linear-gradient(135deg, #3a56d4 0%, #5b47d6 52%, #7c4ddb 100%);
  color: #fff;
  position: relative;
  overflow: hidden;
}

/* subtle sheen */
.header::after {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(420px 160px at 88% -30%, rgba(255, 255, 255, 0.22), transparent 70%);
  pointer-events: none;
}

.brand-mark {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.16);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 25px;
  font-weight: 600;
  flex-shrink: 0;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.28);
}

.eyebrow {
  font-family: var(--mono);
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.72);
  margin-bottom: 4px;
}

h1 {
  font-size: 21px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: #fff;
  line-height: 1.2;
}

.subtitle {
  font-size: 13px;
  color: rgba(255, 255, 255, 0.85);
  margin-top: 3px;
}

/* Disclaimer */
.disclaimer {
  background: #fffaf0;
  border: 1px solid #f2e2c4;
  border-left: 3px solid #e0a63a;
  border-radius: 10px;
  padding: 12px 14px;
  margin-bottom: 24px;
  color: #8a5a12;
  font-size: 12.5px;
  line-height: 1.6;
}

.disclaimer strong { color: #7a4c12; font-weight: 600; }
.disclaimer p { margin-top: 4px; }

/* Tabs — segmented control */
.tabs {
  display: flex;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 3px;
  margin-bottom: 26px;
  gap: 3px;
}

.tab-btn {
  flex: 1;
  padding: 9px 16px;
  background: none;
  border: none;
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  border-radius: 7px;
  transition: color 0.15s, background 0.15s, box-shadow 0.15s;
}

.tab-btn:hover { color: var(--ink); }
.tab-btn.active {
  color: var(--accent);
  background: var(--surface);
  box-shadow: 0 1px 2px rgba(16, 23, 41, 0.08), 0 0 0 1px var(--line);
}

.tab-content { display: none; }
.tab-content.active { display: block; }

/* Form */
.field { margin-bottom: 22px; }

label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
  margin-bottom: 7px;
  letter-spacing: -0.005em;
}

.optional {
  font-size: 12px;
  font-weight: 400;
  color: var(--faint);
}

.en-label {
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 400;
  color: var(--faint);
}

.req {
  color: var(--danger);
  font-weight: 700;
  margin-left: 2px;
}

input[type="text"],
textarea,
select {
  width: 100%;
  padding: 11px 13px;
  border: 1px solid var(--line);
  border-radius: 9px;
  font-family: inherit;
  font-size: 14px;
  color: var(--ink);
  background: var(--surface);
  transition: border-color 0.15s, box-shadow 0.15s;
}

select {
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%238a91a0' d='M6 8L0 0h12z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 38px;
}

textarea {
  resize: vertical;
  min-height: 120px;
  line-height: 1.6;
}

input[type="text"]:focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(58, 86, 212, 0.14);
}

input::placeholder,
textarea::placeholder { color: #aab0bd; }

.hint {
  font-size: 12px;
  color: var(--muted);
  margin-top: 6px;
  line-height: 1.55;
}

.hint code {
  font-family: var(--mono);
  font-size: 11.5px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 1px 5px;
}

.hint.center { text-align: center; margin-top: 12px; color: var(--faint); }

.hint.remark {
  color: #9a6a1a;
  background: #fffaf0;
  border: 1px solid #f2e2c4;
  border-radius: 7px;
  padding: 7px 10px;
}

/* Primary button */
.btn {
  width: 100%;
  padding: 13px;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-2) 100%);
  color: #fff;
  border: none;
  border-radius: 10px;
  font-family: inherit;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.01em;
  cursor: pointer;
  transition: filter 0.15s, transform 0.1s, box-shadow 0.15s;
  box-shadow: 0 1px 2px rgba(16, 23, 41, 0.12), 0 8px 20px rgba(88, 74, 214, 0.32);
}

.btn:hover { filter: brightness(1.07); box-shadow: 0 1px 2px rgba(16, 23, 41, 0.12), 0 10px 24px rgba(88, 74, 214, 0.4); }
.btn:active { transform: translateY(1px); }
.btn:disabled {
  background: #c3c9d6;
  cursor: not-allowed;
  box-shadow: none;
  filter: none;
}

/* Button row (manage tab) + variants */
.btn-row {
  display: flex;
  gap: 10px;
  margin-top: 4px;
}

.btn-row .btn { width: auto; flex: 1; }

.btn-ghost {
  background: var(--surface);
  color: var(--accent);
  border: 1px solid var(--line);
  box-shadow: none;
}
.btn-ghost:hover { background: var(--accent-soft); filter: none; box-shadow: none; }

.btn-danger {
  background: var(--danger);
  box-shadow: 0 1px 2px rgba(16, 23, 41, 0.12), 0 8px 20px rgba(214, 69, 69, 0.28);
}
.btn-danger:hover { background: #bf3a3a; }

/* Read-only persona prompt (built-in personas in the generate tab) */
textarea.readonly {
  background: var(--surface-2);
  color: var(--muted);
  cursor: default;
}

/* Two fields side by side (manage tab) */
.field-row { display: flex; gap: 14px; }
.field-row .field { flex: 1; margin-bottom: 22px; }

/* Read-only text inputs (fixed identity fields) */
input[type="text"][readonly] {
  background: var(--surface-2);
  color: var(--muted);
  cursor: default;
}

/* Checkbox label (manage tab) */
.check-label {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  margin-bottom: 0;
}

.check-label input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
  cursor: pointer;
}

/* Shared-base viewer (manage tab) */
.shared-base-view { margin-top: 10px; }
.shared-base-view summary {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
}
.shared-base-view textarea {
  margin-top: 8px;
  min-height: 130px;
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.6;
  background: var(--surface-2);
  color: var(--muted);
}

/* Persona prompt — code/console panel */
.prompt-view {
  margin-top: 12px;
  background: linear-gradient(180deg, #f3f2fe 0%, #eef3ff 100%);
  border: 1px solid #dcdcf4;
  border-radius: 10px;
  padding: 12px 13px;
}

.prompt-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink);
  margin-bottom: 8px;
}

.prompt-view textarea {
  min-height: 220px;
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.65;
  background: var(--surface);
}

.link-btn {
  background: none;
  border: none;
  color: var(--accent);
  font-family: var(--mono);
  font-size: 11.5px;
  font-weight: 500;
  cursor: pointer;
  padding: 0;
}

.link-btn:hover { color: var(--accent-strong); text-decoration: underline; }

/* Sample download */
.sample-download {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 14px 16px;
  margin-bottom: 18px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.sample-link {
  font-size: 14px;
  font-weight: 600;
  color: var(--accent);
  text-decoration: none;
}

.sample-link:hover { color: var(--accent-strong); text-decoration: underline; }
.sample-hint { font-size: 12px; color: var(--muted); }

/* Dropzone */
.dropzone {
  border: 1.5px dashed #cfd4de;
  border-radius: 12px;
  padding: 34px 24px;
  text-align: center;
  color: var(--muted);
  font-size: 13.5px;
  margin-bottom: 20px;
  cursor: pointer;
  background: var(--surface-2);
  transition: border-color 0.15s, background 0.15s;
}

.dropzone:hover,
.dropzone.dragover {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.dropzone .filename {
  color: var(--ink);
  font-weight: 600;
  margin-top: 10px;
  font-family: var(--mono);
  font-size: 12.5px;
}

/* Status box */
.status-box {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 16px 18px;
  margin-bottom: 20px;
  font-size: 13px;
  color: var(--ink);
  line-height: 2;
}

.status-box .label { color: var(--muted); }
.status-box .value { font-weight: 600; color: var(--ink); font-family: var(--mono); }

/* Progress bar */
.progress-wrap { display: none; margin-bottom: 20px; }
.progress-wrap.active { display: block; }

.progress-bar {
  height: 6px;
  background: var(--line);
  border-radius: 3px;
  overflow: hidden;
}

.progress-bar .fill {
  height: 100%;
  width: 0%;
  background: var(--accent);
  border-radius: 3px;
  transition: width 0.3s;
}

.progress-text {
  font-size: 12px;
  color: var(--muted);
  margin-top: 8px;
  text-align: center;
}

/* Loading overlay */
.overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 41, 0.6);
  backdrop-filter: blur(4px);
  z-index: 100;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  padding: 24px;
  text-align: center;
}

.overlay.active { display: flex; }

.spinner {
  width: 44px;
  height: 44px;
  border: 3px solid rgba(255, 255, 255, 0.25);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.overlay p { color: #fff; margin-top: 16px; font-size: 15px; font-weight: 600; }
.overlay .step { color: rgba(255, 255, 255, 0.82); font-size: 13px; margin-top: 8px; font-weight: 400; }
.overlay .step-note { color: rgba(255, 255, 255, 0.6); font-size: 12px; margin-top: 6px; font-weight: 400; }
.overlay .btn { width: auto; margin-top: 22px; padding: 10px 28px; }

/* Toast */
.toast {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--ink);
  color: #fff;
  padding: 12px 24px;
  border-radius: 10px;
  font-size: 13.5px;
  font-weight: 500;
  z-index: 200;
  opacity: 0;
  transition: opacity 0.25s;
  box-shadow: 0 10px 30px rgba(16, 23, 41, 0.28);
}

.toast.show { opacity: 1; }
.toast.error { background: var(--danger); }
.toast.success { background: #1f9d5b; }

/* Motion / a11y */
@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

@media (max-width: 640px) {
  body { padding: 24px 14px; }
  .card { padding: 24px 20px 28px; }
  .header { margin: -24px -20px 22px; padding: 22px 20px; }
}
