/* Readmify v5 — design tokens + split-screen layout */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap');

:root {
  --background: #09090b; --foreground: #fafafa; --card: #121215; --border: #27272a;
  --muted: #71717a; --muted-bg: #18181b; --accent: #27272a; --primary: #fafafa;
  --primary-fg: #09090b; --danger: #ef4444; --ring: #52525b;
  --font-sans: 'Inter', system-ui, sans-serif; --font-mono: 'JetBrains Mono', monospace;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--background); color: var(--foreground); font-family: var(--font-sans);
  overflow: hidden; display: flex; flex-direction: column;
}
.hidden { display: none !important; }

/* ---------- Header ---------- */
header {
  height: 56px; flex-shrink: 0; display: flex; align-items: center; gap: 12px;
  padding: 0 16px; border-bottom: 1px solid var(--border); background: rgba(9,9,11,.95);
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 13px; flex: 1; }
.view-mode-toggle { display: none; background: var(--muted-bg); border: 1px solid var(--border); border-radius: 8px; padding: 2px; }
.view-mode-btn { background: none; border: none; color: var(--muted); padding: 5px 14px; font-size: 12px; border-radius: 6px; cursor: pointer; transition: background-color .15s ease, color .15s ease; }
.view-mode-btn.active { background: var(--background); color: var(--foreground); }
.header-actions { display: flex; align-items: center; gap: 8px; flex: 1; justify-content: flex-end; }
.save-indicator { font-size: 11px; color: var(--muted); display: flex; align-items: center; gap: 6px; margin-right: 4px; }
.save-dot { width: 6px; height: 6px; border-radius: 50%; background: #f59e0b; }
.save-dot.saved { background: #10b981; }

button { font-family: inherit; }
.btn-primary, .btn-secondary, .btn-ghost, .icon-btn {
  height: 32px; padding: 0 12px; border-radius: 6px; font-size: 12px; font-weight: 500;
  cursor: pointer; display: inline-flex; align-items: center; gap: 6px; border: 1px solid transparent;
  transition: background-color .15s ease, border-color .15s ease, color .15s ease, opacity .15s ease;
}
.btn-primary { background: var(--primary); color: var(--primary-fg); }
.btn-primary:hover { opacity: .88; }
.btn-secondary { background: var(--muted-bg); color: var(--foreground); border-color: var(--border); }
.btn-secondary:hover { background: var(--accent); }
.btn-ghost { background: none; color: var(--muted); }
.btn-ghost:hover { color: var(--foreground); background: var(--accent); }
.icon-btn { width: 32px; padding: 0; justify-content: center; background: none; color: var(--muted); }
.icon-btn:hover { color: var(--foreground); background: var(--accent); }

.menu-wrap { position: relative; }
.menu-dropdown {
  position: absolute; right: 0; top: 40px; background: var(--card); border: 1px solid var(--border);
  border-radius: 8px; padding: 4px; width: 200px; z-index: 50; box-shadow: 0 8px 24px rgba(0,0,0,.4);
}
.menu-dropdown button { display: block; width: 100%; text-align: left; padding: 8px 10px; background: none; border: none; color: var(--foreground); font-size: 12px; border-radius: 6px; cursor: pointer; }
.menu-dropdown button:hover { background: var(--accent); }
.menu-dropdown .danger { color: #fca5a5; }

/* ---------- Split screen ---------- */
main { flex: 1; display: flex; overflow: hidden; }
#editor-pane, #preview-pane { flex: 1 1 50%; min-width: 0; display: flex; flex-direction: column; overflow: hidden; }
#editor-pane { border-right: 1px solid var(--border); }
#editor-pane-body { flex: 1; overflow-y: auto; overflow-x: hidden; padding: 16px; display: flex; flex-direction: column; gap: 10px; scroll-behavior: smooth; }

.pane-toolbar { height: 44px; flex-shrink: 0; display: flex; align-items: center; gap: 10px; padding: 0 14px; border-bottom: 1px solid var(--border); background: var(--card); }
.pane-tabs { display: flex; gap: 4px; }
.pane-tab { background: none; border: none; color: var(--muted); font-size: 12px; padding: 6px 10px; border-radius: 6px; cursor: pointer; }
.pane-tab.active { background: var(--accent); color: var(--foreground); }
.health-badge { margin-left: auto; font-size: 11px; padding: 3px 8px; border: 1px solid var(--border); border-radius: 999px; }

#health-score-tips { list-style: none; margin: 0; padding: 8px 14px; font-size: 11px; color: var(--muted); border-bottom: 1px solid var(--border); background: var(--card); }
#health-score-tips:empty { display: none; }
#health-score-tips li { padding: 2px 0; }
#preview-body-wrap { flex: 1; overflow-y: auto; }
#preview-body { display: block; padding: 24px; min-height: 100%; }
#raw-view { flex: 1; width: 100%; border: none; resize: none; background: var(--background); color: var(--foreground); font-family: var(--font-mono); font-size: 12px; padding: 16px; outline: none; }

@media (max-width: 899px) {
  .view-mode-toggle { display: flex; }
  #editor-pane, #preview-pane { border-right: none; }
}

/* ---------- Section cards (the editor) ---------- */
.section-card { background: var(--card); border: 1px solid var(--border); border-radius: 10px; overflow: hidden; transition: box-shadow .2s, border-color .15s ease; flex-shrink: 0; }
.section-card:hover { border-color: #3f3f46; }
.section-card-body { animation: card-body-in .12s ease; }
@keyframes card-body-in { from { opacity: 0; } to { opacity: 1; } }
@media (prefers-reduced-motion: reduce) {
  .section-card-body { animation: none; }
}
.section-card.dragging { opacity: .4; }
.section-card.drop-target { box-shadow: 0 0 0 2px var(--foreground); }
.section-card-flash { box-shadow: 0 0 0 2px #3b82f6; }
.section-card-disabled { opacity: .5; }
.section-card-header { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-bottom: 1px solid var(--border); cursor: pointer; }
.section-card-header:hover { background: var(--accent); }
.card-collapse-btn { pointer-events: none; }
.drag-grip { cursor: grab; color: var(--muted); user-select: none; }
.card-collapse-btn { background: none; border: none; color: var(--muted); cursor: pointer; font-size: 11px; width: 16px; }
.card-title-input { flex: 1; background: none; border: none; color: var(--foreground); font-size: 13px; font-weight: 600; outline: none; min-width: 0; }
.card-enable-toggle input { cursor: pointer; }
.card-icon-btn { background: none; border: none; color: var(--muted); cursor: pointer; font-size: 13px; padding: 4px; border-radius: 4px; }
.card-icon-btn:hover { color: var(--foreground); background: var(--accent); }
.section-card-body { padding: 12px; display: flex; flex-direction: column; gap: 8px; }

.field-label { font-size: 11px; color: var(--muted); margin-top: 4px; }
.field-hint { font-size: 11px; color: var(--muted); margin: 2px 0; }
.field-input {
  background: var(--muted-bg); border: 1px solid var(--border); color: var(--foreground);
  border-radius: 6px; padding: 7px 9px; font-size: 12.5px; font-family: inherit; width: 100%; outline: none;
}
.field-input:focus { border-color: var(--ring); }
.field-mono { font-family: var(--font-mono); }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.field-row-inline { display: flex; gap: 6px; }
.field-row-inline .field-input { flex: 1; }
.field-check { display: flex; align-items: center; gap: 6px; font-size: 12px; cursor: pointer; }
.field-checks-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 12px; }

.list-editor { display: flex; flex-direction: column; gap: 6px; margin-top: 4px; }
.list-editor-row { display: flex; gap: 6px; align-items: flex-start; background: var(--muted-bg); padding: 8px; border-radius: 6px; }
.list-editor-row .field-input { flex: 1; }
.list-editor-check { flex: 0 0 auto; white-space: nowrap; }
.list-editor-remove { flex-shrink: 0; }

.image-dropzone { border: 2px dashed var(--border); border-radius: 8px; padding: 14px; text-align: center; }
.image-dropzone.drag-over { border-color: var(--foreground); background: var(--accent); }
.image-dropzone-filled { padding: 8px; }
.image-dropzone-preview { max-width: 100%; max-height: 140px; border-radius: 6px; margin-bottom: 8px; }
.image-dropzone-actions { display: flex; gap: 6px; justify-content: center; margin-top: 6px; }

.tech-chip-row { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0; }
.tech-chip { background: var(--muted-bg); border: 1px solid var(--border); border-radius: 999px; padding: 4px 8px 4px 10px; font-size: 11px; display: inline-flex; align-items: center; gap: 6px; }
.tech-chip-remove { background: none; border: none; color: var(--muted); cursor: pointer; font-size: 10px; }
.tech-picker-inline { margin-top: 8px; border: 1px solid var(--border); border-radius: 8px; padding: 10px; background: var(--muted-bg); }
.tech-picker-categories { display: flex; flex-wrap: wrap; gap: 4px; margin: 8px 0; }
.tech-cat-btn { background: var(--background); border: 1px solid var(--border); color: var(--muted); font-size: 10px; padding: 3px 8px; border-radius: 999px; cursor: pointer; }
.tech-picker-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); gap: 6px; max-height: 220px; overflow-y: auto; }
.tech-picker-item { background: var(--background); border: 1px solid var(--border); color: var(--foreground); font-size: 11px; padding: 6px; border-radius: 6px; cursor: pointer; }
.tech-picker-item-selected { background: var(--primary); color: var(--primary-fg); }

/* ---------- Modals ---------- */
.modal-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.6); display: flex; align-items: center; justify-content: center; z-index: 100; }
.modal-card { background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 20px; width: 90%; max-width: 560px; max-height: 80vh; overflow-y: auto; }
.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.modal-header h3 { margin: 0; font-size: 15px; }
.modal-close-btn { background: none; border: none; color: var(--muted); cursor: pointer; font-size: 14px; }
.section-library-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 10px; }
.section-library-item { background: var(--muted-bg); border: 1px solid var(--border); color: var(--foreground); text-align: left; padding: 10px; border-radius: 8px; cursor: pointer; font-size: 12px; }
.section-library-item:hover { background: var(--accent); }
.badge-muted { font-size: 9px; color: var(--muted); }

/* ---------- Command palette ---------- */
#cmd-palette-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.5); display: flex; align-items: flex-start; justify-content: center; padding-top: 12vh; z-index: 200; }
#cmd-palette { background: var(--card); border: 1px solid var(--border); border-radius: 10px; width: 90%; max-width: 480px; overflow: hidden; }
#cmd-palette-input { width: 100%; background: none; border: none; border-bottom: 1px solid var(--border); color: var(--foreground); padding: 14px; font-size: 13px; outline: none; }
#cmd-palette-list { max-height: 320px; overflow-y: auto; padding: 6px; }
.cmd-item { padding: 8px 10px; border-radius: 6px; font-size: 12.5px; cursor: pointer; }
.cmd-item.active, .cmd-item:hover { background: var(--accent); }
.cmd-item-empty { padding: 16px; text-align: center; color: var(--muted); font-size: 12px; }

/* ---------- Toasts (structure set inline by exportUtils.js) ---------- */
#readmify-toast-container { font-family: var(--font-sans); }

/* GitHub markdown preview theming comes entirely from the official github-markdown-css
   package (dark/light variant swapped by app.js) so the preview is pixel-accurate to GitHub. */
#preview-body-wrap.theme-dark { background: #0d1117; }
#preview-body-wrap.theme-light { background: #ffffff; }
