:root {
  color-scheme: dark;
  --bg: #070a12;
  --bg-2: #0c1020;
  --panel: rgba(15, 23, 42, .82);
  --panel-strong: #111827;
  --text: #f8fbff;
  --muted: #97a7c2;
  --soft: #c6d3ea;
  --line: rgba(148, 163, 184, .22);
  --line-strong: rgba(148, 163, 184, .34);
  --accent: #66e3b4;
  --accent-2: #7aa2ff;
  --accent-3: #c084fc;
  --danger: #fb7185;
  --shadow: 0 30px 110px rgba(0,0,0,.36);
  --radius: 24px;
  --radius-sm: 14px;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  --sans: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: var(--sans);
  color: var(--text);
  background:
    radial-gradient(circle at 10% 0%, rgba(102, 227, 180, .18), transparent 34rem),
    radial-gradient(circle at 70% 4%, rgba(122, 162, 255, .18), transparent 34rem),
    radial-gradient(circle at 100% 35%, rgba(192, 132, 252, .11), transparent 26rem),
    linear-gradient(180deg, var(--bg), var(--bg-2));
  min-height: 100vh;
}

button, input, textarea, select { font: inherit; }
button { cursor: pointer; }

.app-shell {
  width: min(1680px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 34px 0 48px;
}

.topbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 28px;
  margin-bottom: 24px;
}

.eyebrow {
  margin: 0 0 12px;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: .14em;
  font-size: .76rem;
  font-weight: 900;
}

h1, h2, h3, p { margin-top: 0; }
h1 {
  margin-bottom: 14px;
  font-size: clamp(3.3rem, 6.2vw, 7.4rem);
  line-height: .84;
  letter-spacing: -.085em;
}
h2 { margin-bottom: 6px; font-size: 1.28rem; }
h3 { font-size: 1rem; margin-bottom: 8px; }
.lead {
  color: var(--soft);
  max-width: 860px;
  margin: 0;
  font-size: 1.08rem;
  line-height: 1.55;
}

.top-actions { display: flex; gap: 10px; flex-wrap: wrap; justify-content: flex-end; }

.workspace {
  display: grid;
  grid-template-columns: 280px minmax(440px, 620px) minmax(520px, 1fr);
  gap: 18px;
  align-items: start;
}

.panel {
  border: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(15,23,42,.90), rgba(15,23,42,.72));
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
}

.sidebar {
  position: sticky;
  top: 18px;
  padding: 18px;
}

.brand-card {
  display: flex;
  align-items: center;
  gap: 12px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,.035);
  border-radius: 18px;
  padding: 13px;
  margin-bottom: 16px;
}
.mark {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 14px;
  color: #04100c;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  font-weight: 950;
}
.brand-card strong { display:block; }
.brand-card small { display:block; color: var(--muted); margin-top: 2px; }

.quality {
  border: 1px solid var(--line);
  background: #0b1220;
  border-radius: 18px;
  padding: 14px;
  margin-bottom: 16px;
}
.quality-head { display:flex; justify-content:space-between; color: var(--soft); font-size:.9rem; }
.meter {
  height: 10px;
  border-radius: 999px;
  background: rgba(148,163,184,.18);
  margin: 12px 0 10px;
  overflow: hidden;
}
.meter span {
  display: block;
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent), var(--accent-2), var(--accent-3));
  border-radius: inherit;
  transition: width .2s ease;
}
.quality p { margin: 0; color: var(--muted); font-size: .85rem; line-height: 1.45; }

.tabs { display: grid; gap: 8px; margin-bottom: 18px; }
.tabs button,
.preset-list button,
.view-toggle button {
  border: 1px solid transparent;
  color: var(--soft);
  background: transparent;
  border-radius: 14px;
  padding: 11px 12px;
  text-align: left;
  font-weight: 800;
}
.tabs button:hover,
.preset-list button:hover,
.view-toggle button:hover { background: rgba(255,255,255,.05); }
.tabs button.active,
.view-toggle button.active {
  background: rgba(102, 227, 180, .11);
  border-color: rgba(102, 227, 180, .34);
  color: var(--text);
}

.preset-list {
  border-top: 1px solid var(--line);
  padding-top: 16px;
}
.preset-list h2 { font-size:.9rem; color:var(--muted); text-transform:uppercase; letter-spacing:.12em; margin-bottom:10px; }
.preset-list button { display:block; width:100%; margin-bottom:6px; color:var(--soft); background: rgba(255,255,255,.025); }

.editor { padding: 22px; min-height: 820px; }
.tab-panel { display: none; }
.tab-panel.active { display: block; }
.panel-head {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: flex-start;
  margin-bottom: 20px;
}
.panel-head p { color: var(--muted); margin: 0; line-height: 1.5; }
.pill {
  white-space: nowrap;
  color: #07110d;
  background: var(--accent);
  padding: 7px 10px;
  border-radius: 999px;
  font-size: .78rem;
  font-weight: 950;
}

.grid { display:grid; gap: 12px; }
.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }

label {
  display: block;
  color: var(--text);
  font-size: .9rem;
  font-weight: 850;
  margin-bottom: 14px;
}
small {
  display: block;
  color: var(--muted);
  margin-top: 6px;
  font-size: .76rem;
}
input, textarea, select {
  width: 100%;
  margin-top: 7px;
  border: 1px solid var(--line-strong);
  border-radius: 14px;
  background: #080d18;
  color: var(--text);
  padding: 12px 13px;
  outline: none;
  transition: border-color .15s ease, box-shadow .15s ease, background .15s ease;
}
textarea { resize: vertical; min-height: 48px; line-height: 1.45; }
input:focus, textarea:focus, select:focus {
  border-color: rgba(102,227,180,.72);
  box-shadow: 0 0 0 4px rgba(102,227,180,.10);
  background: #0a1020;
}
code { font-family: var(--mono); background: rgba(148,163,184,.14); border: 1px solid rgba(148,163,184,.16); border-radius: 7px; padding: 2px 5px; }

.component-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 18px;
}
.component-grid label {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255,255,255,.035);
  padding: 12px;
}
.component-grid input { width:auto; margin:0; accent-color: var(--accent); }

.action-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 20px;
}
button.primary,
button.secondary,
button.ghost {
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 12px 15px;
  font-weight: 950;
}
button.primary {
  color: #07110d;
  background: linear-gradient(135deg, var(--accent), #8ddcff);
  border-color: transparent;
}
button.secondary { color: var(--text); background: rgba(255,255,255,.055); }
button.ghost { color: var(--soft); background: rgba(255,255,255,.03); }
button.primary:hover, button.secondary:hover, button.ghost:hover { transform: translateY(-1px); }

.commit-box {
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 16px;
  background: rgba(255,255,255,.025);
}
.commit-box p { color: var(--muted); line-height: 1.5; }
.result {
  margin: 14px 0 0;
  min-height: 90px;
  white-space: pre-wrap;
  background: #060a12;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px;
  color: var(--muted);
  font-family: var(--mono);
  overflow: auto;
}

.preview {
  position: sticky;
  top: 18px;
  overflow: hidden;
  height: calc(100vh - 36px);
  min-height: 760px;
}
.preview-head {
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap: 16px;
  padding: 18px 18px 14px;
  border-bottom: 1px solid var(--line);
}
.preview-head h2 { margin:0 0 3px; }
.preview-head p { margin:0; color:var(--muted); }
.view-toggle {
  display:flex;
  gap: 6px;
  border: 1px solid var(--line);
  padding: 4px;
  border-radius: 16px;
  background: rgba(0,0,0,.18);
}
.view-toggle button { padding: 8px 11px; font-size: .82rem; text-align:center; }
.rendered-view,
.markdown-view { display:none; height: calc(100% - 76px); }
.rendered-view.active,
.markdown-view.active { display:block; }
#preview-frame {
  width: 100%;
  height: 100%;
  border: 0;
  background: #fff;
}
#markdown-output {
  display:block;
  width:100%;
  height:100%;
  border:0;
  border-radius:0;
  margin:0;
  padding: 20px;
  font-family: var(--mono);
  font-size: .88rem;
  line-height: 1.55;
  background: #060a12;
  color: #e5eefc;
  resize:none;
  outline:none;
}

@media (max-width: 1320px) {
  .workspace { grid-template-columns: 260px minmax(420px, 1fr); }
  .preview { position: relative; top: 0; grid-column: 1 / -1; height: 820px; }
}

@media (max-width: 880px) {
  .app-shell { width: min(100vw - 20px, 760px); padding-top: 20px; }
  .topbar { display:block; }
  .top-actions { justify-content: stretch; margin-top: 18px; }
  .top-actions button { flex: 1; }
  .workspace { grid-template-columns: 1fr; }
  .sidebar, .preview { position: relative; top: 0; }
  .two, .three, .component-grid, .action-grid { grid-template-columns: 1fr; }
  h1 { font-size: clamp(3rem, 18vw, 5rem); }
}
