:root {
  --accent: #2C6E49;
  --canvas: #eceef1;
  --surface: #ffffff;
  --ink: #1f2933;
  --muted: #79838f;
  --line: #e1e6eb;
  --line-strong: #d2d9e0;
  --field-bg: #f6f8fa;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(20,30,40,.04), 0 8px 24px rgba(20,30,40,.06);
  --mono: ui-monospace, "JetBrains Mono", "SFMono-Regular", Menlo, Consolas, monospace;
  --ui: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: var(--ui);
  color: var(--ink);
  background: var(--canvas);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ---------- top bar ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px;
  padding: 10px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  flex: 0 0 auto;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand__mark {
  width: 26px; height: 26px; border-radius: 7px;
  background:
    linear-gradient(135deg, var(--accent), color-mix(in srgb, var(--accent) 55%, #000));
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.25);
  position: relative;
}
.brand__mark::after {
  content: ""; position: absolute; left: 6px; right: 6px; top: 8px; height: 2px;
  background: rgba(255,255,255,.85); border-radius: 2px;
  box-shadow: 0 4px 0 rgba(255,255,255,.55), 0 8px 0 rgba(255,255,255,.35);
}
.brand__text { display: flex; flex-direction: column; line-height: 1.2; }
.brand__text strong { font-size: 14px; letter-spacing: -.01em; }
.brand__text span { font-size: 11px; color: var(--muted); }

.topbar__actions { display: flex; align-items: center; gap: 8px; }

.btn {
  font: inherit; font-size: 13px; font-weight: 550;
  color: var(--ink); background: var(--surface);
  border: 1px solid var(--line-strong); border-radius: 8px;
  padding: 7px 12px; cursor: pointer;
  transition: background .12s, border-color .12s, transform .05s;
}
.btn:hover { background: #f3f5f7; }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn--accent {
  color: #fff; border-color: transparent;
  background: var(--accent);
}
.btn--accent:hover { background: color-mix(in srgb, var(--accent) 88%, #000); }
.btn--sm { padding: 5px 9px; font-size: 12px; }
.btn--ghost { background: transparent; border-color: var(--line); color: var(--muted); }

.status {
  font-size: 12px; font-weight: 550; color: var(--muted);
  padding: 4px 10px; border-radius: 999px;
  border: 1px solid var(--line);
  display: inline-flex; align-items: center; gap: 6px;
}
.status::before {
  content: ""; width: 7px; height: 7px; border-radius: 50%;
  background: var(--muted);
}
.status[data-state="rendering"] { color: #9a6b00; border-color: #f0e2bf; background: #fdf8ec; }
.status[data-state="rendering"]::before { background: #d89b13; animation: pulse 1s infinite; }
.status[data-state="ok"] { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 30%, #fff); }
.status[data-state="ok"]::before { background: var(--accent); }
.status[data-state="error"] { color: #b3261e; border-color: #f1c9c6; background: #fcefee; }
.status[data-state="error"]::before { background: #d3372e; }
@keyframes pulse { 50% { opacity: .35; } }

/* ---------- layout ---------- */
.layout {
  flex: 1 1 auto; min-height: 0;
  display: grid;
  grid-template-columns: 288px minmax(360px, 1fr) minmax(420px, 1.1fr);
  gap: 1px;
  background: var(--line);
}

/* ---------- control rail ---------- */
.rail {
  background: var(--surface);
  overflow-y: auto;
  padding: 14px;
  display: flex; flex-direction: column; gap: 18px;
}
.group { display: flex; flex-direction: column; gap: 9px; }
.group__title {
  font-size: 11px; text-transform: uppercase; letter-spacing: .09em;
  color: var(--muted); margin: 2px 0 2px; font-weight: 650;
}
.field { display: flex; flex-direction: column; gap: 5px; font-size: 12px; color: var(--muted); }
.field > span { font-weight: 550; }
.field input[type="text"], .field select {
  font: inherit; font-size: 13px; color: var(--ink);
  background: var(--field-bg); border: 1px solid var(--line);
  border-radius: 8px; padding: 7px 9px; width: 100%;
}
.field input:focus, .field select:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent);
  background: #fff;
}
.field--row { flex-direction: row; align-items: center; justify-content: space-between; }

.check { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--ink); cursor: pointer; }
.check input { accent-color: var(--accent); width: 15px; height: 15px; }

/* color */
.swatches { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.swatch {
  aspect-ratio: 1; border-radius: 6px; cursor: pointer; border: none;
  box-shadow: inset 0 0 0 1px rgba(0,0,0,.08);
  position: relative;
}
.swatch[aria-pressed="true"] {
  box-shadow: inset 0 0 0 1px rgba(0,0,0,.08), 0 0 0 2px #fff, 0 0 0 4px var(--accent);
}
.colorpick { display: flex; align-items: center; gap: 6px; }
.colorpick input[type="color"] {
  width: 30px; height: 30px; padding: 0; border: 1px solid var(--line);
  border-radius: 7px; background: none; cursor: pointer;
}
.colorpick input[type="text"] {
  width: 92px; font-family: var(--mono); font-size: 12px;
  background: var(--field-bg); border: 1px solid var(--line);
  border-radius: 7px; padding: 6px 8px; color: var(--ink); text-transform: uppercase;
}

/* logo */
.logo-row { display: flex; gap: 10px; align-items: center; }
.logo-thumb {
  width: 56px; height: 56px; border-radius: 9px; flex: 0 0 auto;
  border: 1px dashed var(--line-strong); background: var(--field-bg);
  display: flex; align-items: center; justify-content: center;
  font-size: 10px; color: var(--muted); text-align: center; overflow: hidden;
}
.logo-thumb[data-empty="false"] { border-style: solid; }
.logo-thumb img { width: 100%; height: 100%; object-fit: contain; }
.logo-actions { display: flex; flex-direction: column; gap: 6px; }

/* ---------- editor ---------- */
.editor, .preview { background: var(--surface); display: flex; flex-direction: column; min-height: 0; }
.pane-head {
  flex: 0 0 auto;
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 14px; border-bottom: 1px solid var(--line);
}
.pane-head h2 { margin: 0; font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--ink); }
.muted { color: var(--muted); font-size: 12px; }

#editor {
  flex: 1 1 auto; min-height: 0; resize: none; border: none; outline: none;
  padding: 16px 18px; font-family: var(--mono); font-size: 13px; line-height: 1.65;
  color: #2b3440; tab-size: 2; background: #fcfdfe;
}
#editor::selection { background: color-mix(in srgb, var(--accent) 22%, #fff); }

/* ---------- preview ---------- */
.preview__frame { position: relative; flex: 1 1 auto; min-height: 0; background: #f1f3f6; }
#preview { width: 100%; height: 100%; border: none; background: #f1f3f6; }
.preview__msg {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  text-align: center; padding: 24px; color: var(--muted); font-size: 13px;
  background: #f1f3f6;
}
.preview__msg.error { color: #b3261e; }

/* ---------- responsive ---------- */
@media (max-width: 1080px) {
  body { overflow: auto; }
  .layout { grid-template-columns: 1fr; grid-auto-rows: minmax(320px, auto); height: auto; }
  .rail { grid-template-columns: 1fr 1fr; }
}
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
