:root {
  --bg: #f2efe9;
  --panel: #ffffff;
  --ink: #1b1b1b;
  --muted: #6d6a64;
  --accent: #184a9a;
  --accent-2: #c24b1a;
  --accent-3: #0f766e;
  --line: #e2ded6;
  --shadow: 0 18px 40px rgba(0,0,0,0.12);
  --font-mono: 'Cascadia Code', 'Fira Code', 'Consolas', 'Monaco', monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #101113;
    --panel: #1a1c20;
    --ink: #f4f4f4;
    --muted: #b4b4b4;
    --accent: #6aa1ff;
    --accent-2: #ff9155;
    --accent-3: #6ee7d7;
    --line: #2a2e35;
    --shadow: 0 18px 40px rgba(0,0,0,0.35);
  }
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body { height: 100%; }

body {
  font-family: "Source Sans 3", "Helvetica Neue", Arial, sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at 10% 10%, rgba(24,74,154,0.15), transparent 40%),
    radial-gradient(circle at 90% 20%, rgba(194,75,26,0.15), transparent 45%),
    radial-gradient(circle at 30% 90%, rgba(15,118,110,0.12), transparent 50%),
    var(--bg);
  overflow: hidden;
}

.container {
  display: flex;
  flex-direction: column;
  height: 100vh;
  max-width: 100vw;
}

/* ── Header ─────────────────────────────────── */
header {
  flex-shrink: 0;
  padding: 10px 18px 0;
}

.brand-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 4px;
}

.site-logo {
  height: 26px;
  width: auto;
  display: block;
}

.brand-divider {
  color: var(--muted);
  font-size: 16px;
}

.brand-text {
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-size: 12px;
  color: var(--muted);
}

.header-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.header-row h1 {
  margin: 0;
  font-size: 22px;
  letter-spacing: 0.02em;
  font-family: "Source Serif 4", "Iowan Old Style", "Georgia", serif;
}

.subtitle {
  margin: 2px 0 0;
  color: var(--muted);
  max-width: 600px;
  font-size: 13px;
}

.actions {
  display: flex;
  gap: 10px;
  flex-shrink: 0;
}

.actions button {
  border: none;
  border-radius: 999px;
  padding: 10px 20px;
  font-weight: 600;
  font-size: 14px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  font-family: inherit;
}

.actions button.secondary {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--ink);
}

.actions button:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 16px rgba(0,0,0,0.12);
}

/* ── Main area ──────────────────────────────── */
.main-area {
  display: flex;
  flex: 1;
  min-height: 0;
  padding: 8px 18px 12px;
  gap: 12px;
}

.editor-column {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
  min-height: 0;
  gap: 12px;
}

/* ── Pane ───────────────────────────────────── */
.editor-pane,
.preview-pane {
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
  min-height: 0;
}

.editor-pane {
  flex: 1;
}

.preview-pane {
  flex: 1;
  min-width: 0;
}

/* ── Pane header ────────────────────────────── */
.pane-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  cursor: pointer;
  user-select: none;
  flex-shrink: 0;
  transition: background 0.15s;
}

.pane-header:hover {
  background: color-mix(in srgb, var(--line) 30%, transparent);
}

.toggle-icon {
  font-size: 10px;
  color: var(--muted);
  transition: transform 0.2s;
  line-height: 1;
}

.pane-header.collapsed .toggle-icon {
  transform: rotate(-90deg);
}

.label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.line-count {
  margin-left: auto;
  font-size: 11px;
  color: var(--muted);
  font-family: var(--font-mono);
}

.open-new {
  font-size: 16px;
  color: var(--muted);
  text-decoration: none;
  line-height: 1;
  transition: color 0.15s;
  padding: 2px;
}

.open-new:hover {
  color: var(--accent);
}

/* ── Textarea ───────────────────────────────── */
.editor-pane textarea {
  flex: 1;
  background: var(--panel);
  color: var(--ink);
  border: none;
  outline: none;
  padding: 12px 14px;
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.6;
  resize: none;
  tab-size: 2;
  white-space: pre;
  overflow-wrap: normal;
  overflow-x: auto;
}

.editor-pane textarea:focus {
  box-shadow: inset 0 0 0 1.5px var(--accent);
}

.editor-pane textarea::placeholder {
  color: var(--muted);
  opacity: 0.6;
}

/* ── Collapsed state ────────────────────────── */
.editor-pane.collapsed textarea {
  display: none;
}

.preview-pane.collapsed iframe {
  display: none;
}

.editor-pane.collapsed,
.preview-pane.collapsed {
  flex: 0 0 auto;
}

/* ── Iframe ─────────────────────────────────── */
.preview-pane iframe {
  flex: 1;
  border: none;
  background: #fff;
  width: 100%;
  min-height: 0;
}

/* ── Responsive ─────────────────────────────── */
@media (max-width: 900px) {
  .header-row h1 {
    font-size: 22px;
  }

  .subtitle {
    font-size: 13px;
  }

  .actions button {
    padding: 7px 14px;
    font-size: 12px;
  }

  .editor-pane textarea {
    font-size: 12px;
  }
}

@media (max-width: 700px) {
  header {
    padding: 8px 12px 0;
  }

  .main-area {
    padding: 6px 12px 10px;
    flex-direction: column;
    gap: 10px;
  }

  .editor-column {
    flex: none;
    max-height: 55vh;
    overflow-y: auto;
  }

  .preview-pane {
    flex: 1;
    min-height: 200px;
  }

  .header-row {
    flex-wrap: wrap;
  }

  .header-row h1 {
    font-size: 18px;
  }

  .subtitle {
    font-size: 12px;
  }

  .actions button {
    padding: 6px 12px;
    font-size: 12px;
  }

  .label {
    font-size: 10px;
  }
}

@media (max-width: 480px) {
  header {
    padding: 6px 10px 0;
  }

  .main-area {
    padding: 4px 10px 8px;
  }

  .header-row h1 {
    font-size: 16px;
  }

  .brand-text {
    font-size: 10px;
  }

  .site-logo {
    height: 22px;
  }

  .actions {
    gap: 6px;
  }

  .actions button {
    padding: 6px 12px;
    font-size: 11px;
  }

  .editor-pane textarea {
    font-size: 11px;
    padding: 8px 10px;
  }

  .pane-header {
    padding: 6px 10px;
  }
}

@media (max-width: 380px) {
  .brand-divider,
  .brand-text {
    display: none;
  }
}
