/* ============================================================
   AlderChat — application chrome
   (This styles the STUDIO itself, not the generated overlay CSS)
   ============================================================ */

:root {
  --bg: #17142B;
  --bg-2: #1E1A38;
  --bg-3: #262148;
  --panel: #211C40;
  --panel-2: #2B2554;
  --line: #383066;
  --text: #EDEBFF;
  --text-dim: #A49ECC;
  --accent: #6C5CE7;
  --accent-2: #3ABEF7;
  --good: #2ED573;
  --warn: #FFB020;
  --pink: #FF5FA2;
  --radius: 10px;
  --mono: "SF Mono", "Cascadia Code", Consolas, Menlo, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

/* ---------- top bar ---------- */
header {
  display: flex;
  align-items: center;
  flex-wrap: wrap;          /* narrow windows get a second row, not a crush */
  gap: 8px 12px;
  padding: 10px 16px;
  background: linear-gradient(90deg, #241E4E, #1B1738);
  border-bottom: 1px solid var(--line);
}

header h1 {
  font-size: 16px;
  font-weight: 700;
  margin: 0;
  letter-spacing: 0.3px;
  background: linear-gradient(90deg, #8F7BFF, #3ABEF7);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  white-space: nowrap;
}

.spacer { flex: 1; }

/* ---------- tool tabs (page switcher) ---------- */
.tool-tabs {
  display: inline-flex;
  background: var(--bg-3);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px;
}
.tool-tabs a {
  color: var(--text-dim);
  text-decoration: none;
  font-size: 13px;
  padding: 5px 14px;
  border-radius: 999px;
  white-space: nowrap;
}
.tool-tabs a.active {
  background: var(--accent-2);
  color: #06222E;
  font-weight: 600;
}

/* ---------- segmented control (widget target) ---------- */
.segmented {
  display: inline-flex;
  background: var(--bg-3);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px;
}

.segmented button {
  border: 0;
  background: transparent;
  color: var(--text-dim);
  font: inherit;
  font-size: 13px;
  padding: 5px 14px;
  border-radius: 999px;
  cursor: pointer;
  white-space: nowrap;
}

.segmented button.active {
  background: var(--accent);
  color: #fff;
  font-weight: 600;
}

/* ---------- buttons ---------- */
.btn {
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--text);
  font: inherit;
  font-size: 13px;
  padding: 7px 14px;
  border-radius: 8px;
  cursor: pointer;
  white-space: nowrap;
}
.btn:hover { background: var(--bg-3); }
.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 600;
}
.btn.primary:hover { filter: brightness(1.1); }
.btn.small { padding: 4px 10px; font-size: 12px; }
.btn.danger:hover { border-color: #E05555; color: #FF8080; }

/* ---------- main layout ---------- */
main {
  display: grid;
  grid-template-columns: 300px 1fr 400px;
  height: calc(100vh - 53px);
}

/* keep columns from growing past the viewport (grid min-height:auto trap) */
main > * { min-height: 0; min-width: 0; }
#css-out { min-height: 0; }
#preview-stage { min-height: 0; }

main.hide-css { grid-template-columns: 300px 1fr; }
main.hide-css #css-panel { display: none; }

@media (max-width: 1200px) {
  main:not(.show-css) { grid-template-columns: 280px 1fr; }
  main:not(.show-css) #css-panel { display: none; }
  main.show-css { grid-template-columns: 280px 1fr 380px; }
}

/* ---------- left: controls ---------- */
#controls {
  overflow-y: auto;
  border-right: 1px solid var(--line);
  background: var(--bg-2);
  padding: 12px;
}

.group {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  margin-bottom: 10px;
  overflow: hidden;
}

.group > summary {
  list-style: none;
  cursor: pointer;
  padding: 9px 12px;
  font-weight: 600;
  font-size: 13px;
  color: var(--text);
  user-select: none;
  display: flex;
  align-items: center;
}
.group > summary::-webkit-details-marker { display: none; }
.group > summary::after {
  content: "▾";
  margin-left: auto;
  color: var(--text-dim);
  transition: transform 0.15s;
}
.group:not([open]) > summary::after { transform: rotate(-90deg); }

.group-body { padding: 4px 12px 12px; }

.row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 8px 0;
}
.row.inactive { opacity: 0.4; }
.row.inactive, .row.inactive * { cursor: not-allowed; }
.row label {
  flex: 1;
  color: var(--text-dim);
  font-size: 13px;
}

input[type="range"] {
  flex: 1.2;
  accent-color: var(--accent);
}
.val {
  width: 42px;
  text-align: right;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text);
}

input[type="color"] {
  width: 34px;
  height: 26px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--bg-3);
  padding: 2px;
  cursor: pointer;
}

input[type="checkbox"] {
  accent-color: var(--accent);
  width: 16px;
  height: 16px;
}

select, input[type="text"] {
  background: var(--bg-3);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 7px;
  font: inherit;
  font-size: 13px;
  padding: 5px 8px;
  max-width: 160px;
}
select { cursor: pointer; }

/* ---------- rotator: slide editor ----------
   two lines per slide: icon + action buttons on top, then a full-width
   text input (a single line squeezed the text field to nothing) */
.slide-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 5px;
  margin: 10px 0 6px;
}
.slide-row .s-icon { flex: 1; min-width: 0; max-width: none; }
.slide-row .s-text { flex: 1 1 100%; min-width: 0; max-width: none; }
.slide-row .btn { padding: 4px 7px; font-size: 11px; flex: 0 0 auto; }

.slide-opts {
  margin: 0 0 8px 8px;
  padding: 2px 10px;
  border-left: 2px solid var(--accent);
  background: rgba(108, 92, 231, 0.06);
  border-radius: 0 8px 8px 0;
}
.slide-opts input[type="number"] {
  width: 64px;
  background: var(--bg-3);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 7px;
  font: inherit;
  font-size: 13px;
  padding: 4px 6px;
}

/* ---------- rotator: export boxes ---------- */
.export-box {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  border-bottom: 1px solid var(--line);
}
.export-box .panel-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--line);
}
.export-box .panel-head h2 { font-size: 13px; margin: 0; flex: 1; }
.export-box pre {
  flex: 1;
  min-height: 0;
  margin: 0;
  padding: 10px 12px;
  overflow: auto;
  font-family: var(--mono);
  font-size: 11px;
  line-height: 1.45;
  color: #C8E1FF;
  white-space: pre;
  user-select: text;
}

/* preset cards */
#preset-list {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}
.preset-card {
  border: 1px solid var(--line);
  background: var(--bg-3);
  border-radius: 8px;
  padding: 8px;
  cursor: pointer;
  text-align: left;
  color: var(--text);
  font: inherit;
}
.preset-card:hover { border-color: var(--accent); }
.preset-card.active {
  border-color: var(--accent);
  background: rgba(108, 92, 231, 0.18);
}
.preset-card .p-name { font-size: 12.5px; font-weight: 600; display: block; }
.preset-card .p-desc {
  font-size: 11px;
  color: var(--text-dim);
  display: block;
  margin-top: 2px;
  line-height: 1.3;
}

/* saved presets/designs rows (chat: #custom-presets, rotator: #custom-designs) */
.preset-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 6px 0;
}
.preset-row .btn { flex: 1; text-align: left; }
.preset-row .del {
  flex: 0 0 auto;
  padding: 4px 8px;
}

/* ---------- center: preview ---------- */
#preview-wrap {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.inline-check {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
}

#preview-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  border-bottom: 1px solid var(--line);
  background: var(--bg-2);
  font-size: 13px;
  color: var(--text-dim);
  flex-wrap: wrap;
}

#preview-stage {
  flex: 1;
  position: relative;
  overflow: hidden;
}

#preview-frame {
  width: 100%;
  height: 100%;
  border: 0;
  display: block;
}

/* ---------- right: CSS output ---------- */
#css-panel {
  display: flex;
  flex-direction: column;
  border-left: 1px solid var(--line);
  background: var(--bg-2);
  min-width: 0;
}

#css-panel .panel-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
}
#css-panel .panel-head h2 { font-size: 13px; margin: 0; flex: 1; }

#paste-hint {
  font-size: 12px;
  line-height: 1.5;
  color: var(--text-dim);
  background: rgba(58, 190, 247, 0.08);
  border-bottom: 1px solid var(--line);
  padding: 9px 12px;
}
#paste-hint b { color: var(--accent-2); }
#paste-hint code {
  font-family: var(--mono);
  font-size: 11px;
  background: var(--bg-3);
  padding: 1px 4px;
  border-radius: 4px;
}

#css-out {
  flex: 1;
  margin: 0;
  padding: 12px;
  overflow: auto;
  font-family: var(--mono);
  font-size: 11.5px;
  line-height: 1.5;
  color: #C8E1FF;
  white-space: pre;
  user-select: text;
}

/* ---------- toast ---------- */
#toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(80px);
  background: var(--good);
  color: #06220F;
  font-weight: 600;
  padding: 10px 20px;
  border-radius: 999px;
  transition: transform 0.25s ease;
  z-index: 50;
  pointer-events: none;
}
#toast.show { transform: translateX(-50%) translateY(0); }
#toast.warn { background: var(--warn); color: #2B1B00; }

/* ---------- help modal ---------- */
.studio-modal {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel);
  color: var(--text);
  max-width: 720px;
  width: calc(100vw - 60px);
  max-height: 82vh;
  padding: 0;
}
.studio-modal::backdrop { background: rgba(10, 8, 24, 0.72); }

.studio-modal .modal-head {
  display: flex;
  align-items: center;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(90deg, #2C2560, #1E1A38);
}
.studio-modal .modal-head h2 { margin: 0; font-size: 16px; flex: 1; }

.studio-modal .modal-body {
  padding: 16px 20px 22px;
  overflow-y: auto;
  max-height: calc(82vh - 60px);
  font-size: 13.5px;
  line-height: 1.6;
}
.studio-modal h3 { color: var(--accent-2); font-size: 14px; margin: 18px 0 6px; }
.studio-modal h3:first-child { margin-top: 0; }
.studio-modal code {
  font-family: var(--mono);
  font-size: 12px;
  background: var(--bg-3);
  padding: 1px 5px;
  border-radius: 4px;
}
.studio-modal .dim { color: var(--text-dim); font-size: 12.5px; }
.studio-modal .v-fsa { border-top: 1px solid var(--line); margin-top: 16px; padding-top: 4px; }
.studio-modal .v-safety-row { margin: 10px 0 0; font-size: 12.5px; color: var(--text-dim); }

/* the vault button grows a dot when the linked file needs one click to re-arm */
.btn.attention { position: relative; }
.btn.attention::after {
  content: "";
  position: absolute;
  top: -3px;
  right: -3px;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--warn);
}

.studio-modal .callout {
  border-left: 3px solid var(--warn);
  background: rgba(255, 176, 32, 0.08);
  padding: 8px 12px;
  border-radius: 0 8px 8px 0;
  margin: 10px 0;
}

/* Ko-fi tip button — a link dressed as a button, warm-colored */
.btn.kofi {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  text-decoration: none;
  color: var(--pink);
  border-color: rgba(255, 95, 162, 0.45);
}
.btn.kofi:hover { background: rgba(255, 95, 162, 0.12); }

/* ---------- landing page ---------- */
main.landing-wrap {
  display: block;
  height: auto;
  overflow-y: auto;
  max-width: 860px;
  margin: 0 auto;
  padding: 48px 24px 80px;
}
.landing-wrap .hero { text-align: center; }
.landing-wrap .hero h2 {
  font-size: clamp(26px, 4.5vw, 38px);
  line-height: 1.2;
  margin: 18px 0 14px;
  background: linear-gradient(90deg, #8F7BFF, #3ABEF7, #FF5FA2);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.landing-wrap .hero p {
  font-size: 15.5px;
  line-height: 1.7;
  color: var(--text-dim);
  max-width: 640px;
  margin: 0 auto;
}
.cta-row {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
  margin: 26px 0 8px;
}
.btn.big { font-size: 15px; padding: 12px 24px; text-decoration: none; display: inline-flex; }
.tool-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 12px;
  margin: 40px 0 0;
}
.tool-card {
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  text-decoration: none;
  color: var(--text);
}
.tool-card:hover { border-color: var(--accent); background: var(--panel-2); }
.tool-card b { font-size: 15px; color: var(--accent-2); }
.tool-card span { font-size: 13px; line-height: 1.55; color: var(--text-dim); }
.landing-foot {
  margin: 44px auto 0;
  max-width: 640px;
  text-align: center;
  font-size: 13.5px;
  line-height: 1.7;
  color: var(--text-dim);
  border-top: 1px solid var(--line);
  padding-top: 18px;
}
.landing-foot a { color: var(--accent-2); }

/* the wordmark is the other way home — keep the gradient text treatment */
header h1 a { color: inherit; text-decoration: none; }

/* ---------- landing: showcase examples ---------- */
.showcase { margin-top: 52px; text-align: center; }
.showcase h3 { font-size: 22px; margin: 0 0 6px; }
.showcase-sub { color: var(--text-dim); font-size: 14px; margin: 0 auto 18px; max-width: 560px; }
.showcase-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 14px;
  text-align: left;
}
.show-card {
  display: flex;
  flex-direction: column;
  gap: 4px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px;
  text-decoration: none;
  color: var(--text);
}
.show-card:hover { border-color: var(--accent); background: var(--panel-2); }
.show-card img { width: 100%; border-radius: 7px; display: block; }
.show-card b { margin-top: 8px; font-size: 14.5px; color: var(--text); }
.show-card span { font-size: 12.5px; line-height: 1.5; color: var(--text-dim); }
.show-card em { font-style: normal; font-size: 12.5px; font-weight: 700; color: var(--accent-2); margin-top: 4px; }
