@font-face {
  font-family: "JetBrains Mono";
  src: url("../fonts/JetBrainsMono-Regular.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "JetBrains Mono";
  src: url("../fonts/JetBrainsMono-Bold.woff2") format("woff2");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

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

:root {
  --bg-deep: #0a0a0c;
  --bg-panel: #0e0e12;
  --bg-card: #111116;
  --bg-hover: #16161c;
  --bg-input: #0c0c10;
  --border: #1e1e26;
  --border-active: #6c8cff;
  --text: #c0c0c8;
  --text-dim: #555560;
  --text-muted: #333340;
  --accent: #6c8cff;
  --accent-dim: #4a5a99;
  --success: #5af78e;
  --warning: #fbbf24;
  --danger: #ef4444;
  --radius: 6px;
  --radius-sm: 4px;
  --font-mono: "JetBrains Mono", ui-monospace, "Cascadia Code",
    "Fira Code", monospace;
}

html {
  font-size: 16px;
}

body {
  background: var(--bg-deep);
  color: var(--text);
  font-family: var(--font-mono);
  min-height: 100vh;
  overflow-x: hidden;
}

/* ── Header ─────────────────────────────────────────── */

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 24px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-panel);
}

.header-left {
  display: flex;
  align-items: baseline;
  gap: 12px;
}

.site-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: #e0e0e8;
  letter-spacing: 0.5px;
}

.title-dot {
  color: var(--accent);
}

.site-subtitle {
  font-size: 0.85rem;
  color: var(--text-dim);
  letter-spacing: 1px;
}

.header-right {
  display: flex;
  gap: 8px;
}

/* ── Buttons ────────────────────────────────────────── */

.btn {
  font-family: var(--font-mono);
  font-size: 0.9rem;
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: all 0.15s;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  letter-spacing: 0.5px;
}

.btn-ghost {
  background: transparent;
  color: var(--text-dim);
}

.btn-ghost:hover {
  color: var(--text);
  border-color: var(--text-dim);
}

.btn-primary {
  background: var(--accent);
  color: #000;
  border-color: var(--accent);
  font-weight: 700;
}

.btn-primary:hover {
  background: #8aa4ff;
  border-color: #8aa4ff;
}

.btn-tiny {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  background: transparent;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 3px;
}

.btn-tiny:hover {
  color: var(--text);
  background: var(--bg-hover);
}

/* ── Layout ─────────────────────────────────────────── */

.app-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
  height: calc(100vh - 50px);
  overflow: hidden;
}

.panel {
  overflow-y: auto;
  padding: 16px;
}

.panel-left {
  border-right: 1px solid var(--border);
}

.panel-section {
  margin-bottom: 20px;
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  flex-wrap: wrap;
  gap: 8px;
}

.section-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-dim);
  letter-spacing: 2px;
  text-transform: uppercase;
}

/* ── Select Controls ────────────────────────────────── */

.select-control {
  font-family: var(--font-mono);
  font-size: 1rem;
  background: var(--bg-input);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 7px 12px;
  cursor: pointer;
  outline: none;
}

.select-control:focus {
  border-color: var(--accent);
}

.builder-controls {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.control-group {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.control-label {
  font-size: 0.8rem;
  color: var(--text-dim);
  letter-spacing: 1px;
  text-transform: uppercase;
}

/* ── Filter Bar ─────────────────────────────────────── */

.filter-bar {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

.filter-btn {
  font-family: var(--font-mono);
  font-size: 0.95rem;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-dim);
  padding: 6px 14px;
  border-radius: 3px;
  cursor: pointer;
  letter-spacing: 0.5px;
  transition: all 0.15s;
}

.filter-btn:hover {
  color: var(--text);
  border-color: var(--text-dim);
}

.filter-btn.active {
  background: var(--accent);
  color: #000;
  border-color: var(--accent);
  font-weight: 700;
}

/* ── Code Block ─────────────────────────────────────── */

.code-block {
  background: #080810;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: auto;
  max-height: 300px;
}

.code-block pre {
  padding: 12px 16px;
  font-size: 0.82rem;
  line-height: 1.5;
  color: #777;
  white-space: pre;
  margin: 0;
}

.code-block code {
  font-family: var(--font-mono);
}

/* ── Modals ─────────────────────────────────────────── */

.modal {
  background: transparent;
  border: none;
  padding: 0;
  max-width: 560px;
  width: 90%;
}

.modal::backdrop {
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
}

.modal-content {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.modal-header h3 {
  font-size: 1rem;
  font-weight: 700;
  color: #e0e0e8;
  letter-spacing: 1px;
}

.modal-body {
  font-size: 0.9rem;
  line-height: 1.7;
  color: var(--text-dim);
}

.modal-body p {
  margin-bottom: 8px;
}

.modal-body code {
  background: var(--bg-card);
  padding: 1px 5px;
  border-radius: 3px;
  color: var(--accent);
  font-size: 0.85rem;
}

.modal-body pre {
  background: #080810;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  margin: 8px 0;
  overflow-x: auto;
  font-size: 0.85rem;
  line-height: 1.5;
}

.modal-body pre code {
  background: none;
  padding: 0;
  color: #888;
}

.modal-note {
  margin-top: 12px;
  padding: 8px 12px;
  background: rgba(108, 140, 255, 0.06);
  border: 1px solid rgba(108, 140, 255, 0.15);
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  color: var(--text-dim);
}

.share-url-wrap {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}

.share-url-input {
  flex: 1;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  color: var(--text);
  outline: none;
}

.share-url-input:focus {
  border-color: var(--accent);
}

/* ── Collapsible Sections ───────────────────────────── */

.collapsible-toggle {
  cursor: pointer;
  user-select: none;
}

.collapsible-toggle:hover .section-title {
  color: var(--text);
}

.collapse-arrow {
  display: inline-block;
  transition: transform 0.15s;
  font-size: 0.75rem;
  vertical-align: middle;
}

.collapsible:not(.collapsed) .collapse-arrow {
  transform: rotate(90deg);
}

.collapsible.collapsed .collapsible-body {
  display: none;
}

/* ── Export Controls ─────────────────────────────────── */

.export-controls {
  display: flex;
  gap: 6px;
}

/* ── Responsive ─────────────────────────────────────── */

@media (max-width: 900px) {
  .app-layout {
    grid-template-columns: 1fr;
    height: auto;
  }

  .panel-left {
    border-right: none;
    border-bottom: 1px solid var(--border);
  }

  .panel {
    overflow-y: visible;
  }

  .site-subtitle {
    display: none;
  }
}

@media (max-width: 768px) {
  /* ── Header ── */
  .site-header {
    flex-direction: column;
    gap: 8px;
    padding: 10px 14px;
    align-items: flex-start;
  }

  .site-title {
    font-size: 1.05rem;
  }

  .header-right {
    width: 100%;
  }

  .header-right .btn {
    flex: 1;
    justify-content: center;
    font-size: 0.85rem;
    padding: 6px 10px;
  }

  /* ── Layout ── */
  .app-layout {
    grid-template-columns: 1fr;
    height: auto;
    overflow: visible;
  }

  .panel {
    padding: 10px;
    overflow-y: visible;
  }

  .panel-left {
    border-right: none;
    border-bottom: 1px solid var(--border);
  }

  .section-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
  }

  .section-title {
    font-size: 0.95rem;
  }

  /* ── Filter bar: horizontal scroll ── */
  .filter-bar {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 4px;
    width: 100%;
  }

  .filter-btn {
    flex-shrink: 0;
    font-size: 0.85rem;
    padding: 5px 10px;
  }

  /* ── Preview: sticky so it stays visible ── */
  #section-preview {
    position: sticky;
    top: 0;
    z-index: 10;
    background: var(--bg-panel);
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 10px;
  }

  .terminal-body {
    padding: 10px 12px;
    font-size: 12px;
  }

  /* ── Builder controls: stack vertically ── */
  .builder-controls {
    flex-direction: column;
    width: 100%;
  }

  .control-group {
    width: 100%;
  }

  .select-control {
    width: 100%;
    font-size: 0.95rem;
  }

  /* ── Export ── */
  .export-controls {
    flex-direction: column;
    width: 100%;
    gap: 6px;
  }

  .export-controls .btn {
    width: 100%;
    justify-content: center;
  }

  .code-block {
    max-height: 200px;
  }

  .code-block pre {
    font-size: 0.75rem;
  }

  /* ── Modals ── */
  .modal {
    width: 96%;
  }

  .modal-content {
    padding: 14px;
  }

  .share-url-wrap {
    flex-direction: column;
  }

  .share-url-wrap .btn {
    width: 100%;
    justify-content: center;
  }
}
