:root {
  --accent: #6366f1;
  --accent-2: #818cf8;
  --bg: #f6f7fb;
  --surface: #ffffff;
  --surface-2: #f1f2f8;
  --border: #e2e4ee;
  --text: #1a1b26;
  --text-muted: #62667a;
  --radius: 10px;
  --sidebar-w: 250px;
  --header-h: 56px;
  --shadow: 0 1px 2px rgba(20, 20, 43, .06), 0 4px 16px rgba(20, 20, 43, .04);
}

:root[data-theme="dark"] {
  --bg: #0f1016;
  --surface: #171821;
  --surface-2: #1e2029;
  --border: #2a2c39;
  --text: #e7e8ef;
  --text-muted: #9497ab;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 4px 20px rgba(0, 0, 0, .35);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1016;
    --surface: #171821;
    --surface-2: #1e2029;
    --border: #2a2c39;
    --text: #e7e8ef;
    --text-muted: #9497ab;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 4px 20px rgba(0, 0, 0, .35);
  }
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  transition: background .2s ease, color .2s ease;
}

.visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}

.skip-link {
  position: absolute; left: -999px; top: 0; z-index: 1000;
  background: var(--accent); color: #fff; padding: 10px 16px; border-radius: 0 0 8px 0;
}
.skip-link:focus { left: 0; }

/* Header */
.site-header {
  height: var(--header-h);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 50;
}
.brand { display: flex; align-items: center; gap: 8px; }
.brand-mark { width: 28px; height: 28px; }
.brand-name { font-weight: 700; font-size: 1.15rem; letter-spacing: -.01em; }
.site-nav { display: flex; gap: 20px; }
.site-nav a {
  color: var(--text-muted); text-decoration: none; font-size: .92rem; font-weight: 500;
}
.site-nav a:hover { color: var(--accent); }

/* App shell */
.app-shell {
  display: flex;
  height: calc(100vh - var(--header-h));
  overflow: hidden;
}

.sidebar {
  width: var(--sidebar-w);
  flex: 0 0 var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 16px 14px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  overflow-y: auto;
  overscroll-behavior: contain;
}
.sidebar-title {
  font-size: .78rem; text-transform: uppercase; letter-spacing: .06em;
  color: var(--text-muted); margin: 4px 4px 0;
}
.tool-group {
  display: flex; flex-direction: column; gap: 4px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}
.tool-group:last-of-type { border-bottom: none; }

.tool-btn {
  display: flex; align-items: center; gap: 10px;
  width: 100%; text-align: left;
  padding: 9px 10px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 8px;
  color: var(--text);
  font-size: .88rem;
  cursor: pointer;
  transition: background .15s ease, border-color .15s ease;
}
.tool-btn svg {
  width: 17px; height: 17px; flex: 0 0 17px;
  fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
  color: var(--text-muted);
}
.tool-btn:hover { background: var(--surface-2); border-color: var(--border); }
.tool-btn:active { transform: translateY(1px); }
.tool-btn[aria-pressed="true"] { background: var(--accent); color: #fff; border-color: var(--accent); }
.tool-btn[aria-pressed="true"] svg { color: #fff; }

.sidebar-spacer { flex: 1; }

/* Ad slot: bottom-left of sidebar */
.ad-slot {
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  padding: 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  background: var(--surface-2);
}
.ad-slot-label {
  font-size: .68rem; text-transform: uppercase; letter-spacing: .08em;
  color: var(--text-muted);
  align-self: flex-start;
}
.ad-slot-placeholder {
  width: 100%;
  min-height: 250px;
  border-radius: 6px;
  background: repeating-linear-gradient(45deg, var(--surface), var(--surface) 10px, var(--surface-2) 10px, var(--surface-2) 20px);
  display: flex; align-items: center; justify-content: center;
  color: var(--text-muted);
  font-size: .78rem;
  text-align: center;
}

/* Workspace */
.workspace {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.workspace-toolbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}
.device-toggle { display: flex; gap: 4px; background: var(--surface-2); padding: 3px; border-radius: 8px; }
.device-btn {
  border: none; background: transparent; padding: 5px 12px; border-radius: 6px;
  font-size: .8rem; color: var(--text-muted); cursor: pointer;
}
.device-btn.is-active { background: var(--surface); color: var(--text); box-shadow: var(--shadow); font-weight: 600; }
.autosave-status { font-size: .78rem; color: var(--text-muted); }

.panes {
  flex: 1;
  display: flex;
  min-height: 0;
}
.pane {
  flex: 1 1 50%;
  min-width: 0;
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--border);
}
.pane:last-child { border-right: none; }
.pane-header {
  font-size: .72rem; text-transform: uppercase; letter-spacing: .06em;
  color: var(--text-muted);
  padding: 6px 14px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
}
.pane-editor { min-height: 0; }
.pane-editor .CodeMirror {
  height: 100%;
  font-family: "SF Mono", Menlo, Consolas, monospace;
  font-size: .88rem;
}
.pane-editor .CodeMirror-scroll {
  overscroll-behavior: contain;
}
.preview-frame-wrap {
  flex: 1;
  background: var(--surface-2);
  display: flex;
  justify-content: center;
  overflow: auto;
  overscroll-behavior: contain;
  padding: 0;
}
#preview {
  width: 100%;
  height: 100%;
  border: none;
  background: #fff;
  transition: width .2s ease;
}

.status-bar {
  display: flex; gap: 18px;
  padding: 6px 16px;
  font-size: .75rem;
  color: var(--text-muted);
  border-top: 1px solid var(--border);
  background: var(--surface);
}

/* Overlays */
.overlay {
  position: fixed; inset: 0; z-index: 200;
  background: var(--bg);
  display: flex; flex-direction: column;
}
.overlay[hidden] { display: none; }
.overlay-bar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 18px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  font-weight: 600;
}
.overlay-close {
  border: 1px solid var(--border); background: var(--surface-2); color: var(--text);
  padding: 6px 14px; border-radius: 8px; cursor: pointer; font-size: .85rem;
}
#overlay-preview-frame { flex: 1; border: none; width: 100%; background: #fff; }
.overlay-highlight-body {
  flex: 1; margin: 0; overflow: auto; padding: 20px 24px;
  font-family: "SF Mono", Menlo, Consolas, monospace; font-size: .88rem; line-height: 1.6;
}

/* SEO content sections */
.content-section {
  max-width: 980px;
  margin: 0 auto;
  padding: 56px 20px;
}
.content-section h2 {
  font-size: 1.6rem;
  letter-spacing: -.01em;
  margin-bottom: 10px;
}
.content-section > p {
  color: var(--text-muted);
  max-width: 760px;
  line-height: 1.65;
}
.feature-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 16px;
  margin-top: 28px;
}
.feature-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
}
.feature-card h3 { margin: 0 0 8px; font-size: 1rem; }
.feature-card p { margin: 0; color: var(--text-muted); font-size: .88rem; line-height: 1.55; }

.steps { line-height: 1.8; color: var(--text-muted); padding-left: 22px; }
.steps strong { color: var(--text); }

.faq-list { display: flex; flex-direction: column; gap: 10px; margin-top: 20px; }
.faq-list details {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
}
.faq-list summary { cursor: pointer; font-weight: 600; }
.faq-list p { color: var(--text-muted); margin: 10px 0 0; line-height: 1.6; }

.site-footer {
  text-align: center;
  padding: 24px;
  color: var(--text-muted);
  font-size: .82rem;
  border-top: 1px solid var(--border);
}

/* Responsive */
@media (max-width: 900px) {
  .site-header { flex-wrap: wrap; height: auto; padding: 10px 16px; gap: 8px; }
  .site-nav { gap: 12px; flex-wrap: wrap; }
  .app-shell { flex-direction: column; height: auto; overflow: visible; }
  .sidebar { width: 100%; flex: none; flex-direction: row; flex-wrap: wrap; border-right: none; border-bottom: 1px solid var(--border); overflow-y: visible; }
  .tool-group { flex-direction: row; flex-wrap: wrap; border-bottom: none; }
  .sidebar-spacer { display: none; }
  .ad-slot { width: 100%; }
  .panes { flex-direction: column; }
  .pane { border-right: none; border-bottom: 1px solid var(--border); }
  .pane-editor .CodeMirror { height: 320px; }
  .preview-frame-wrap { height: 320px; }
}
