:root {
  --bg: #090a0d;
  --panel: #12141a;
  --elevated: #1a1d25;
  --line: rgba(255, 255, 255, 0.08);
  --line-strong: rgba(255, 255, 255, 0.16);
  --text: #f4f1ea;
  --muted: #9b968c;
  --accent: #d7ff4a;
  --accent-ink: #16180c;
  --danger: #ff8d7a;
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.45);
  color-scheme: dark;
  font-family: "Instrument Sans", "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html, body {
  height: 100%;
  margin: 0;
  background:
    radial-gradient(900px 420px at 100% -10%, rgba(215, 255, 74, 0.08), transparent 55%),
    var(--bg);
  color: var(--text);
}
button, input, select, textarea { font: inherit; color: inherit; }
button, a.ghost { cursor: pointer; text-decoration: none; }
.hidden { display: none !important; }

.login {
  min-height: 100%;
  display: grid;
  place-items: center;
  padding: 24px;
}
.login-card {
  width: min(440px, 100%);
  background: rgba(18, 20, 26, 0.86);
  border: 1px solid var(--line);
  border-radius: 28px;
  padding: 32px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
  display: grid;
  gap: 14px;
}
.eyebrow {
  margin: 0;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  font-size: 11px;
  color: var(--accent);
}
.login-card h1 { margin: 0; font-size: 40px; letter-spacing: -0.04em; }
.muted { color: var(--muted); margin: 0; line-height: 1.5; }
label { display: grid; gap: 6px; font-size: 13px; color: var(--muted); }
input, select, textarea {
  background: #0c0e13;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px 14px;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
input:focus, select:focus, textarea:focus {
  border-color: rgba(215, 255, 74, 0.7);
  box-shadow: 0 0 0 4px rgba(215, 255, 74, 0.12);
}
button[type="submit"], #new-landing-btn {
  background: var(--accent);
  color: var(--accent-ink);
  border: 0;
  border-radius: 999px;
  padding: 10px 16px;
  font-weight: 600;
}
button[type="submit"]:hover, #new-landing-btn:hover { filter: brightness(1.05); }
.ghost, a.ghost {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 14px;
  color: var(--text);
}
.ghost:hover, a.ghost:hover { background: rgba(255, 255, 255, 0.05); }
.icon-btn { width: 38px; padding: 8px 0; }
.error { color: var(--danger); min-height: 1.2em; margin: 0; }

.app {
  height: 100%;
  display: grid;
  grid-template-rows: 64px minmax(180px, 1fr) 14px minmax(220px, 34vh);
}
.topbar {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 18px;
  border-bottom: 1px solid var(--line);
  background: rgba(9, 10, 13, 0.8);
  backdrop-filter: blur(16px);
}
.brand { display: flex; align-items: center; gap: 10px; letter-spacing: -0.03em; }
.mark {
  width: 18px;
  height: 18px;
  border-radius: 6px;
  background:
    linear-gradient(135deg, var(--accent), #7dffc3 70%);
  box-shadow: 0 0 0 4px rgba(215, 255, 74, 0.08);
}
.project-picker {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
}
.project-picker select { min-width: 240px; background: var(--elevated); }
.badge {
  font-size: 12px;
  padding: 5px 10px;
  border-radius: 999px;
  background: rgba(215, 255, 74, 0.1);
  color: var(--accent);
}
.toolbar-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
}
.topbar .ghost, .topbar button { white-space: nowrap; }
#pick-btn.active {
  background: var(--accent);
  color: var(--accent-ink);
  border-color: transparent;
}

.preview-pane {
  min-height: 0;
  padding: 16px 16px 8px;
}
.stage {
  height: 100%;
  display: grid;
  grid-template-rows: 42px 1fr;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: #050608;
  box-shadow: var(--shadow);
  overflow: hidden;
}
.stage-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 14px;
  background: #151821;
  border-bottom: 1px solid var(--line);
}
.dots { display: flex; gap: 6px; }
.dots i {
  width: 8px;
  height: 8px;
  border-radius: 99px;
  display: block;
  background: #3a3f4b;
}
.dots i:first-child { background: #ff6b6b; }
.dots i:nth-child(2) { background: #f2c14e; }
.dots i:nth-child(3) { background: #69d391; }
.stage-url {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 12px;
  color: var(--muted);
  background: #0c0e13;
  border-radius: 999px;
  padding: 6px 12px;
}
.stage-frame { position: relative; min-height: 0; background: white; }
.preview-pane iframe {
  width: 100%;
  height: 100%;
  border: 0;
  background: white;
}
.empty {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: #6d685f;
  background:
    radial-gradient(circle at 50% 40%, rgba(215, 255, 74, 0.08), transparent 42%),
    #0c0e13;
  padding: 24px;
  text-align: center;
}

.splitter {
  position: relative;
  cursor: ns-resize;
}
.splitter::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 46px;
  height: 4px;
  border-radius: 99px;
  background: var(--line-strong);
  transform: translate(-50%, -50%);
}
.splitter:hover::before { background: var(--accent); }

.chat-pane {
  display: grid;
  grid-template-rows: auto auto 1fr auto;
  min-height: 0;
  margin: 0 16px 16px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: rgba(18, 20, 26, 0.92);
  overflow: hidden;
}
.chat-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px 0;
  flex-wrap: wrap;
}
.chat-head-main {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}
.chat-head strong { letter-spacing: -0.03em; }
.chat-head .muted { font-size: 13px; }
.model-picker {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 11px;
  color: var(--muted);
  min-width: 180px;
}
.model-picker select {
  font: inherit;
  font-size: 13px;
  color: var(--text);
  background: var(--elevated);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 10px;
}
.messages {
  overflow: auto;
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.msg {
  max-width: min(720px, 82%);
  padding: 12px 14px;
  border-radius: 18px;
  line-height: 1.5;
  white-space: pre-wrap;
}
.msg.user {
  margin-left: auto;
  background: var(--accent);
  color: var(--accent-ink);
  border-bottom-right-radius: 6px;
}
.msg.bot {
  background: var(--elevated);
  border: 1px solid var(--line);
  border-bottom-left-radius: 6px;
}
.msg.system {
  color: var(--muted);
  font-size: 13px;
  background: transparent;
  padding: 0 4px;
}
.msg time {
  display: block;
  margin-top: 6px;
  font-size: 11px;
  opacity: 0.7;
}
.composer {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: end;
  padding: 8px 12px 12px;
}
.composer-main {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
}
.composer-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: stretch;
}
.composer-actions .icon-btn {
  min-width: 44px;
  padding: 10px 12px;
  font-size: 18px;
  line-height: 1;
}
.attachment-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.attachment-list.hidden {
  display: none;
}
.attachment-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 100%;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--elevated);
  font-size: 12px;
  color: var(--text);
}
.attachment-chip button {
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  padding: 0 2px;
  font-size: 14px;
  line-height: 1;
}
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
.composer textarea {
  resize: none;
  min-height: 56px;
  border-radius: 18px;
  background: #0c0e13;
}
.chip {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 10px 16px 0;
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(215, 255, 74, 0.1);
  color: var(--accent);
  font-size: 13px;
}
.chip button {
  margin-left: auto;
  background: none;
  border: 0;
  color: inherit;
  font-size: 18px;
}

.modal {
  width: min(760px, calc(100% - 24px));
  border: 1px solid var(--line);
  border-radius: 24px;
  background: #14171e;
  color: var(--text);
  padding: 0;
  box-shadow: var(--shadow);
}
.modal::backdrop { background: rgba(5, 6, 8, 0.72); }
.modal form {
  display: grid;
  gap: 14px;
  padding: 20px;
  max-height: min(86vh, 860px);
  overflow: auto;
}
.modal header, .modal footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}
.modal h3 {
  margin: 4px 0 0;
  font-size: 15px;
  letter-spacing: -0.02em;
}
.explain {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 8px;
}
.explain li {
  padding: 10px 12px;
  border-radius: 14px;
  background: #0c0e13;
  border: 1px solid var(--line);
  color: var(--muted);
  line-height: 1.45;
}
.explain strong { color: var(--text); }
.tabs { display: flex; gap: 8px; }
.tab {
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 7px 14px;
}
.tab.active {
  background: var(--accent);
  color: var(--accent-ink);
  border-color: transparent;
}
.kind-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.kind-card {
  text-align: left;
  background: #0c0e13;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 14px;
}
.kind-card small { display: block; color: var(--muted); margin-top: 4px; }
.kind-card.selected {
  border-color: rgba(215, 255, 74, 0.8);
  box-shadow: inset 0 0 0 1px rgba(215, 255, 74, 0.4);
}
.cms-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 8px;
}
.cms-card {
  text-align: left;
  background: #0c0e13;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 12px;
}
.cms-card small { display: block; color: var(--muted); margin-top: 4px; }
.cms-card.selected {
  border-color: rgba(215, 255, 74, 0.8);
  box-shadow: inset 0 0 0 1px rgba(215, 255, 74, 0.4);
}
.fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

@media (max-width: 900px) {
  .app { grid-template-rows: auto 46vh 14px 1fr; }
  .topbar { flex-wrap: wrap; height: auto; padding: 12px; }
  .toolbar-actions { width: 100%; margin-left: 0; overflow: auto; }
  .project-picker select { min-width: 0; width: 100%; }
  .fields { grid-template-columns: 1fr; }
  .preview-pane, .chat-pane { margin-left: 8px; margin-right: 8px; }
  .preview-pane { padding-left: 8px; padding-right: 8px; }
}
