/* GPTPaint Pages - Spectrum-based tokens, see DESIGN.md */
:root, html[data-theme="dark"] {
  --bg: #1d1d1d; --surface: #292929; --surface-2: #333333; --border: #444444;
  --text: #f2f2f2; --text-sub: #bdbdbd; --accent: #378ef0; --accent-hover: #4b9cf5;
  --accent-down: #2680eb; --danger: #f26d6d; --danger-bg: #d7373f; --ok: #3ec97e;
  --shadow: rgba(0,0,0,.5);
}
html[data-theme="light"] {
  --bg: #f2f2f2; --surface: #ffffff; --surface-2: #f7f7f7; --border: #d6d6d6;
  --text: #222222; --text-sub: #5f5f5f; --accent: #1473e6; --accent-hover: #0d66d0;
  --accent-down: #095aba; --danger: #d7373f; --danger-bg: #d7373f; --ok: #12805c;
  --shadow: rgba(0,0,0,.25);
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg); color: var(--text);
  font-family: -apple-system, "Segoe UI", "Noto Sans CJK SC", "Microsoft YaHei", sans-serif;
  font-size: 14px; line-height: 1.5;
}
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
svg { width: 18px; height: 18px; flex: none; }

/* ---------- login ---------- */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.login-card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 36px 32px; width: 340px; max-width: 100%; text-align: center; box-shadow: 0 12px 32px var(--shadow); }
.login-logo { color: var(--accent); display: flex; justify-content: center; }
.login-logo svg { width: 44px; height: 44px; }
.login-card h1 { font-size: 24px; margin: 12px 0 2px; }
.login-sub { color: var(--text-sub); margin: 0 0 20px; }
.login-card input { width: 100%; background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; }
.login-error { color: var(--danger); min-height: 21px; margin: 8px 0; text-align: left; }
.login-error:empty { margin: 0; min-height: 0; }

/* ---------- buttons ---------- */
.btn-primary { background: var(--accent); color: #fff; border: none; border-radius: 999px; padding: 10px 22px; font-weight: 600; cursor: pointer; transition: background .15s; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-primary:active { background: var(--accent-down); }
.btn-primary:disabled { opacity: .45; cursor: default; }
.btn-wide { width: 100%; }
.btn-secondary { background: var(--surface-2); color: var(--text); border: 1px solid var(--border); border-radius: 999px; padding: 9px 18px; font-weight: 600; cursor: pointer; }
.btn-secondary:hover { border-color: var(--text-sub); }
.btn-secondary.small { padding: 5px 14px; font-weight: 500; }
.btn-danger { background: var(--danger-bg); color: #fff; border: none; border-radius: 999px; padding: 9px 18px; font-weight: 600; cursor: pointer; }
.btn-ghost { display: inline-flex; align-items: center; gap: 6px; background: transparent; border: 1px solid transparent; color: var(--text); border-radius: 999px; padding: 6px 12px; cursor: pointer; }
.btn-ghost:hover { background: var(--surface-2); }
.btn-chip { background: var(--surface-2); border: 1px solid var(--border); color: var(--text); border-radius: 999px; padding: 3px 12px; font-size: 12.5px; cursor: pointer; }
.btn-chip:hover { border-color: var(--text-sub); }
.btn-icon { background: transparent; border: none; color: var(--text); cursor: pointer; display: inline-flex; padding: 6px; border-radius: 6px; }
.btn-icon:hover { background: var(--surface-2); }
.grow { flex: 1; }

/* ---------- app frame ---------- */
.topbar { height: 52px; display: flex; align-items: center; justify-content: space-between; padding: 0 16px; background: var(--surface); border-bottom: 1px solid var(--border); }
.brand { display: flex; align-items: center; gap: 8px; font-size: 17px; font-weight: 700; }
.brand svg { color: var(--accent); width: 22px; height: 22px; }
.top-actions { display: flex; gap: 4px; }
.tabs { display: flex; gap: 2px; padding: 0 12px; background: var(--surface); border-bottom: 1px solid var(--border); overflow-x: auto; }
.tab { position: relative; background: none; border: none; color: var(--text-sub); padding: 10px 14px; cursor: pointer; white-space: nowrap; font-weight: 500; }
.tab:hover { color: var(--text); }
.tab.active { color: var(--text); box-shadow: inset 0 -2px 0 var(--accent); }
.tab .dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); margin-left: 6px; vertical-align: middle; }

.layout { display: grid; grid-template-columns: 460px 1fr; gap: 14px; padding: 14px; align-items: start; }
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 18px; }

/* ---------- controls ---------- */
.field-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.field-head label, .field-label { font-weight: 600; }
.field-tools { display: flex; gap: 6px; }
.field-label { display: block; margin: 16px 0 6px; }
.field-label:first-child { margin-top: 0; }
textarea, select, input[type="text"], input[type="url"], input[type="password"], input[type="number"] {
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; padding: 9px 11px; width: 100%;
}
textarea { height: 140px; resize: vertical; }
textarea::placeholder, input::placeholder { color: var(--text-sub); }
.shared-note { margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--border); color: var(--text-sub); font-size: 12.5px; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.stepper { display: flex; align-items: stretch; }
.stepper button { width: 42px; background: var(--surface-2); border: 1px solid var(--border); color: var(--text); font-size: 18px; cursor: pointer; }
.stepper button:first-child { border-radius: 8px 0 0 8px; }
.stepper button:last-child { border-radius: 0 8px 8px 0; }
.stepper input { border-radius: 0; text-align: center; border-left: none; border-right: none; }
.gen-row { display: flex; gap: 10px; margin-top: 16px; }
.progress-track { height: 6px; background: var(--surface-2); border-radius: 3px; margin-top: 16px; overflow: hidden; }
.progress-bar { height: 100%; width: 0; background: var(--accent); border-radius: 3px; transition: width .3s; }
.status-line { color: var(--text-sub); min-height: 21px; margin: 8px 0 0; }
.status-line.error { color: var(--danger); }

/* ---------- results ---------- */
.results-head { display: flex; align-items: center; justify-content: space-between; }
.results-head h2 { font-size: 17px; margin: 0; }
.results-tools { display: flex; align-items: center; gap: 12px; margin: 12px 0 14px; }
.results-hint { color: var(--text-sub); font-size: 12.5px; }
.results-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px; }
.results-empty { color: var(--text-sub); text-align: center; padding: 42px 0; margin: 0; }
.card { background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.card-img-wrap { position: relative; aspect-ratio: 4/3; background: var(--bg); display: flex; align-items: center; justify-content: center; }
.card-img-wrap img { width: 100%; height: 100%; object-fit: cover; display: block; cursor: zoom-in; }
.card-del { position: absolute; top: 8px; right: 8px; width: 26px; height: 26px; border-radius: 50%; border: none; background: rgba(0,0,0,.55); color: #fff; cursor: pointer; display: flex; align-items: center; justify-content: center; padding: 0; }
.card-del svg { width: 14px; height: 14px; }
.card-del:hover { background: rgba(0,0,0,.8); }
.card-state { color: var(--text-sub); display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 12px; text-align: center; }
.spinner { width: 26px; height: 26px; border-radius: 50%; border: 3px solid var(--border); border-top-color: var(--accent); animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.card-meta { padding: 9px 12px; font-size: 12.5px; color: var(--text-sub); }
.card-meta .p { color: var(--text); display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- modal ---------- */
.modal-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.55); display: flex; align-items: flex-start; justify-content: center; padding: 48px 16px; z-index: 40; overflow-y: auto; }
.modal { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; width: 520px; max-width: 100%; box-shadow: 0 16px 40px var(--shadow); }
.modal-small { width: 380px; margin-top: 10vh; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px 0; }
.modal-head h3 { margin: 0; font-size: 17px; }
.modal-body { padding: 14px 20px 22px; }
.modal-body .field-label { margin-top: 12px; }
.modal-subtitle { margin: 22px 0 4px; font-size: 15px; }
.modal-note { color: var(--text-sub); margin: 6px 0; }
.channel-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; margin-top: 10px; }
.channel-name { font-weight: 600; }
.channel-sub { color: var(--text-sub); font-size: 12.5px; word-break: break-all; }
.badge { background: var(--accent); color: #fff; border-radius: 999px; padding: 2px 10px; font-size: 12px; flex: none; }
.channel-del { flex: none; }
.confirm-title { margin: 4px 0 6px; font-size: 16px; }
.confirm-row { display: flex; gap: 10px; margin-top: 18px; }

/* ---------- lightbox ---------- */
.lightbox { position: fixed; inset: 0; background: rgba(0,0,0,.88); z-index: 60; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 24px; }
.lightbox img { max-width: 100%; max-height: calc(100vh - 110px); object-fit: contain; border-radius: 6px; }
.lightbox-close { position: absolute; top: 14px; right: 14px; color: #fff; background: rgba(255,255,255,.12); }
.lightbox-caption { color: #ddd; margin: 12px 0 0; text-align: center; max-width: 900px; }

@media (max-width: 920px) {
  .layout { grid-template-columns: 1fr; }
  .top-actions .btn-ghost span { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation-duration: .01s !important; }
}
