/* index.css — extracted from inline <style> blocks. Generated by scripts/h1-extract.mjs */
:root {
    --bg: #1a1b26;
    --panel: #16171f;
    --panel2: #22242e;
    --border: #2d2f3b;
    --text: #c0caf5;
    --muted: #6b7089;
    --accent: #7aa2f7;
    --accent-dim: #3d59a1;
    --danger: #f7768e;
    --warn: #e0af68;
    --ok: #9ece6a;
    --hover: #2a2d3a;
    --sidebar-w: 260px;
  }
  [data-theme="light"] {
    --bg: #fafbfc;
    --panel: #ffffff;
    --panel2: #f1f3f7;
    --border: #dce0e8;
    --text: #24283b;
    --muted: #848aa0;
    --accent: #2d5cd6;
    --accent-dim: #b8c8f0;
    --danger: #d24a60;
    --warn: #b57f22;
    --ok: #4a8c3a;
    --hover: #eef1f6;
  }
  * { box-sizing: border-box; margin: 0; padding: 0; }
  html, body { height: 100%; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; background: var(--bg); color: var(--text); overflow: hidden; }
  button { font-family: inherit; }
  input, textarea { font-family: inherit; }

  #app { display: grid; grid-template-columns: var(--sidebar-w) 6px 1fr 1fr; height: 100vh; }
  #app.sidebar-collapsed { grid-template-columns: 0 0 1fr 1fr; }
  #app.sidebar-collapsed #sidebar, #app.sidebar-collapsed #resizer { display: none; }

  /* Sidebar */
  #sidebar { background: var(--panel); border-right: 1px solid var(--border); display: flex; flex-direction: column; min-width: 0; }
  .sidebar-header { padding: 14px 16px 12px; border-bottom: 1px solid var(--border); }
  .title-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
  .title-row h1 { font-size: 15px; font-weight: 600; letter-spacing: 0.3px; color: var(--accent); }
  .icon-btn { background: none; border: none; color: var(--muted); cursor: pointer; padding: 4px 6px; border-radius: 4px; font-size: 14px; }
  .icon-btn:hover { background: var(--hover); color: var(--text); }
  .toolbar { display: flex; gap: 6px; margin-bottom: 10px; }
  .toolbar button { flex: 1; background: var(--panel2); color: var(--text); border: 1px solid var(--border); padding: 6px 8px; border-radius: 5px; font-size: 12px; cursor: pointer; transition: all 0.15s; }
  .toolbar button:hover { background: var(--hover); border-color: var(--accent-dim); }
  #search { width: 100%; background: var(--panel2); border: 1px solid var(--border); color: var(--text); padding: 7px 10px; border-radius: 5px; font-size: 13px; outline: none; }
  #search:focus { border-color: var(--accent); }

  #tree { flex: 1; overflow-y: auto; padding: 8px; }
  .tree-node { user-select: none; }
  .tree-item { display: flex; align-items: center; padding: 5px 8px; border-radius: 4px; cursor: pointer; font-size: 13px; gap: 6px; position: relative; }
  .tree-item:hover { background: var(--hover); }
  .tree-item.active { background: var(--accent-dim); color: #fff; }
  .tree-item.drop-target { outline: 2px dashed var(--accent); outline-offset: -2px; }
  .tree-item.drop-before { box-shadow: inset 0 2px 0 var(--accent); }
  .tree-item.drop-after { box-shadow: inset 0 -2px 0 var(--accent); }
  .tree-item.dragging { opacity: 0.4; }
  .tree-item .icon { width: 14px; text-align: center; flex-shrink: 0; font-size: 11px; color: var(--muted); }
  .tree-item.active .icon { color: #fff; }
  .tree-item .name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .tree-item .name.editing { background: var(--bg); color: var(--text); border: 1px solid var(--accent); border-radius: 3px; padding: 1px 4px; outline: none; white-space: nowrap; overflow: visible; }
  .tree-item .pin { color: var(--warn); font-size: 10px; margin-right: 2px; flex-shrink: 0; }
  .tree-item .actions { display: none; gap: 2px; }
  .tree-item:hover .actions { display: flex; }
  .tree-item .actions button { background: none; border: none; color: var(--muted); cursor: pointer; padding: 2px 4px; font-size: 11px; border-radius: 3px; }
  .tree-item .actions button:hover { background: var(--bg); color: var(--text); }
  .tree-children { margin-left: 14px; }
  .tree-children.collapsed { display: none; }
  .tree-section-label { padding: 10px 10px 4px; font-size: 10px; text-transform: uppercase; letter-spacing: 0.8px; color: var(--muted); font-weight: 600; }
  .empty-state { padding: 20px; text-align: center; color: var(--muted); font-size: 12px; }
  #tree.root-drop-target { background: var(--hover); outline: 2px dashed var(--accent); outline-offset: -6px; }

  /* Resizer */
  #resizer { background: var(--border); cursor: col-resize; transition: background 0.15s; }
  #resizer:hover, #resizer.dragging { background: var(--accent); }

  /* Editor & Preview */
  .pane { display: flex; flex-direction: column; min-width: 0; }
  .pane-header { padding: 10px 16px; border-bottom: 1px solid var(--border); font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.8px; background: var(--panel); display: flex; justify-content: space-between; align-items: center; gap: 10px; min-height: 42px; }
  .pane-header .title-input { background: transparent; border: none; color: var(--text); font-size: 13px; font-weight: 500; outline: none; flex: 1; text-transform: none; letter-spacing: normal; min-width: 0; }
  .pane-header .title-input:focus { color: var(--accent); }
  .pane-header .meta { font-size: 10px; color: var(--muted); text-transform: none; letter-spacing: normal; flex-shrink: 0; }
  #editor-pane { background: var(--panel); border-right: 1px solid var(--border); }
  #editor { flex: 1; background: var(--panel); color: var(--text); border: none; padding: 20px 24px; font-family: "Consolas", "Monaco", "Menlo", monospace; font-size: 14px; line-height: 1.6; resize: none; outline: none; tab-size: 2; }
  #editor::placeholder { color: var(--muted); }
  #editor:disabled { background: var(--panel); opacity: 0.6; }
  #preview-pane { background: var(--bg); }
  #preview { flex: 1; padding: 24px 32px; overflow-y: auto; line-height: 1.7; }
  #preview h1, #preview h2, #preview h3, #preview h4 { margin: 18px 0 10px; color: var(--accent); }
  #preview h1 { font-size: 26px; border-bottom: 1px solid var(--border); padding-bottom: 8px; }
  #preview h2 { font-size: 21px; }
  #preview h3 { font-size: 17px; }
  #preview h4 { font-size: 15px; }
  #preview p { margin: 10px 0; }
  #preview code { background: var(--panel2); padding: 2px 6px; border-radius: 3px; font-size: 0.9em; color: var(--danger); }
  #preview pre { background: var(--panel); border: 1px solid var(--border); padding: 14px; border-radius: 6px; overflow-x: auto; margin: 12px 0; }
  #preview pre code { background: none; color: var(--text); padding: 0; }
  #preview blockquote { border-left: 3px solid var(--accent); padding-left: 14px; margin: 12px 0; color: var(--muted); }
  #preview ul, #preview ol { margin: 10px 0 10px 24px; }
  #preview li { margin: 4px 0; }
  #preview a { color: var(--accent); }
  #preview table { border-collapse: collapse; margin: 12px 0; }
  #preview th, #preview td { border: 1px solid var(--border); padding: 8px 12px; }
  #preview th { background: var(--panel); }
  #preview hr { border: none; border-top: 1px solid var(--border); margin: 16px 0; }
  #preview img { max-width: 100%; border-radius: 6px; }
  #preview mark { background: var(--warn); color: #000; padding: 0 3px; border-radius: 2px; }
  #preview input[type="checkbox"] { margin-right: 6px; }

  .empty-editor { display: flex; align-items: center; justify-content: center; flex: 1; color: var(--muted); font-size: 14px; flex-direction: column; gap: 10px; padding: 20px; text-align: center; }
  .empty-editor .big { font-size: 42px; opacity: 0.4; }
  .empty-editor kbd { background: var(--panel2); border: 1px solid var(--border); border-radius: 3px; padding: 1px 6px; font-size: 11px; font-family: "Consolas", monospace; }

  /* Scrollbars */
  ::-webkit-scrollbar { width: 10px; height: 10px; }
  ::-webkit-scrollbar-track { background: var(--panel); }
  ::-webkit-scrollbar-thumb { background: var(--border); border-radius: 5px; }
  ::-webkit-scrollbar-thumb:hover { background: var(--accent-dim); }

  .status { padding: 6px 14px; font-size: 11px; color: var(--muted); border-top: 1px solid var(--border); background: var(--panel); display: flex; justify-content: space-between; gap: 8px; }
  .status .save-state { color: var(--ok); }
  .status .save-state.saving { color: var(--warn); }
  .status .save-state.error { color: var(--danger); }

  /* Toast */
  #toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%) translateY(20px); background: var(--panel2); color: var(--text); border: 1px solid var(--border); padding: 10px 18px; border-radius: 6px; font-size: 13px; box-shadow: 0 6px 20px rgba(0,0,0,0.35); opacity: 0; pointer-events: none; transition: all 0.2s; z-index: 1000; max-width: 80%; }
  #toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
  #toast.error { border-color: var(--danger); color: var(--danger); }
  #toast.ok { border-color: var(--ok); }

  /* Modal */
  .modal-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,0.55); display: none; align-items: center; justify-content: center; z-index: 100; }
  .modal-backdrop.show { display: flex; }
  .modal { background: var(--panel); border: 1px solid var(--border); border-radius: 8px; padding: 20px 24px; min-width: 320px; max-width: 90vw; box-shadow: 0 10px 40px rgba(0,0,0,0.5); }
  .modal h3 { color: var(--accent); font-size: 15px; margin-bottom: 12px; }
  .modal p { font-size: 13px; color: var(--muted); margin-bottom: 14px; line-height: 1.5; }
  .modal input { width: 100%; background: var(--panel2); border: 1px solid var(--border); color: var(--text); padding: 8px 10px; border-radius: 5px; font-size: 13px; outline: none; margin-bottom: 14px; }
  .modal input:focus { border-color: var(--accent); }
  .modal-buttons { display: flex; gap: 8px; justify-content: flex-end; }
  .modal-buttons button { background: var(--panel2); color: var(--text); border: 1px solid var(--border); padding: 7px 14px; border-radius: 5px; font-size: 13px; cursor: pointer; }
  .modal-buttons button:hover { background: var(--hover); }
  .modal-buttons button.primary { background: var(--accent-dim); border-color: var(--accent); color: #fff; }
  .modal-buttons button.primary:hover { background: var(--accent); }
  .modal-buttons button.danger { background: var(--danger); border-color: var(--danger); color: #fff; }

  .hidden { display: none !important; }

  /* Mobile */
  .mobile-tabs { display: none; }
  @media (max-width: 768px) {
    #app { grid-template-columns: 1fr !important; grid-template-rows: auto auto 1fr; }
    #app.sidebar-collapsed { grid-template-columns: 1fr !important; }
    #app.sidebar-collapsed #sidebar { display: flex; }
    #resizer { display: none; }
    #sidebar { max-height: 32vh; border-right: none; border-bottom: 1px solid var(--border); }
    .sidebar-header { padding: 10px 12px; }
    .title-row h1 { font-size: 14px; }
    .icon-btn { min-width: 44px; min-height: 44px; font-size: 16px; }
    .toolbar button { min-height: 44px; font-size: 13px; }
    #search { min-height: 44px; font-size: 14px; }
    .tree-item { min-height: 44px; font-size: 14px; padding: 8px 10px; }
    .tree-item .actions { display: flex; }
    .tree-item .actions button { min-width: 44px; min-height: 44px; font-size: 14px; }
    .title-input { min-height: 36px; font-size: 14px; }
    .mobile-tabs { display: flex; background: var(--panel); border-bottom: 1px solid var(--border); }
    .mobile-tabs button { flex: 1; min-height: 44px; background: var(--panel); color: var(--muted); border: none; border-right: 1px solid var(--border); font-size: 13px; cursor: pointer; }
    .mobile-tabs button:last-child { border-right: none; }
    .mobile-tabs button.active { color: var(--accent); background: var(--panel2); border-bottom: 2px solid var(--accent); }
    #editor-pane, #preview-pane { grid-column: 1; grid-row: 3; border-right: none; }
    #editor-pane.mobile-hidden, #preview-pane.mobile-hidden { display: none; }
    .pane-header { padding: 8px 12px; min-height: 44px; }
    #editor { padding: 12px 14px; font-size: 14px; }
    #preview { padding: 14px 16px; font-size: 14px; }
    #preview h1 { font-size: 22px; } #preview h2 { font-size: 18px; } #preview h3 { font-size: 16px; }
    .modal { min-width: 280px; padding: 16px 18px; }
    .modal-buttons button { min-height: 44px; padding: 10px 16px; }
  }

  @media (max-width: 480px) {
    #sidebar { max-height: 30vh; }
    .sidebar-header { padding: 8px 10px; }
    .title-row h1 { font-size: 13px; margin: 0; }
    .toolbar { gap: 4px; margin-bottom: 6px; }
    .toolbar button { font-size: 12px; padding: 8px 6px; }
    #search { font-size: 13px; padding: 10px; }
    .tree-item { font-size: 13px; padding: 8px; }
    .tree-section-label { padding: 6px 8px 2px; font-size: 10px; }
    .mobile-tabs button { font-size: 12px; }
    .pane-header { padding: 6px 10px; }
    .pane-header .meta { display: none; }
    #editor { padding: 10px 12px; font-size: 13px; }
    #preview { padding: 12px 14px; font-size: 13px; }
    #preview h1 { font-size: 19px; } #preview h2 { font-size: 16px; } #preview h3 { font-size: 14px; }
    #preview pre { padding: 10px; font-size: 12px; }
    .status { padding: 4px 10px; font-size: 10px; }
    .modal { min-width: 260px; padding: 14px; }
    .modal h3 { font-size: 14px; }
    .modal p, .modal input { font-size: 13px; }
    .empty-editor { font-size: 13px; padding: 12px; }
    .empty-editor .big { font-size: 36px; }
  }
