/* Проза — оформление. Светлая тема по умолчанию, тёмная — по кнопке. */
:root {
  --bg: #f7f6f3;
  --panel: #ffffff;
  --text: #1d1c1a;
  --muted: #6f6b66;
  --line: #e2ded7;
  --accent: #2f6f5e;
  --accent-text: #ffffff;
  --danger: #a33a2f;
  --radius: 10px;
}

[data-theme="dark"] {
  --bg: #17181a;
  --panel: #202225;
  --text: #e8e6e3;
  --muted: #9a968f;
  --line: #32353a;
  --accent: #4e9c84;
  --accent-text: #10201b;
  --danger: #e07569;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 18px/1.6 Georgia, "Times New Roman", serif;
}

h1, h2, h3, button, input, label, textarea {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

h1 { font-size: 26px; margin: 0 0 4px; }
h2 { font-size: 22px; margin: 0; }

.muted { color: var(--muted); font-size: 15px; }
.small { font-size: 14px; }
.spacer { flex: 1; }
.center { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 20px; }
.wrap { max-width: 1000px; margin: 0 auto; padding: 24px 20px 60px; }
.row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }

header#topbar {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 16px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}

.brand { font-weight: 600; font-family: system-ui, sans-serif; letter-spacing: .3px; }
.bar-project { color: var(--muted); font-size: 15px; font-family: system-ui, sans-serif; }

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px;
}

.login { width: 100%; max-width: 380px; display: flex; flex-direction: column; gap: 10px; }
.login h1 { margin-bottom: 0; }

label { font-size: 15px; color: var(--muted); }

input {
  font-size: 17px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  min-width: 220px;
}

input:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; }

button {
  font-size: 16px;
  padding: 10px 16px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
  cursor: pointer;
}

button:hover { border-color: var(--accent); }
button.small { font-size: 14px; padding: 6px 10px; }
button.primary { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
button.ghost { background: transparent; }
button.danger { color: var(--danger); border-color: var(--line); }

.projects { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; margin-top: 18px; }

.project {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  display: flex; flex-direction: column; gap: 8px;
}

.project .title { font-size: 19px; font-weight: 600; font-family: system-ui, sans-serif; cursor: pointer; }
.project .title:hover { color: var(--accent); }
.project .meta { color: var(--muted); font-size: 14px; }
.project .acts { display: flex; gap: 8px; margin-top: auto; }

.error { color: var(--danger); font-size: 15px; }

/* ---------- Рабочее пространство ---------- */
.workspace {
  display: grid;
  grid-template-columns: 290px minmax(0, 1fr) 320px;
  gap: 0;
  height: calc(100vh - 46px);
}

.tree, .ai-panel {
  background: var(--panel);
  border-right: 1px solid var(--line);
  display: flex; flex-direction: column;
  min-height: 0;
}
.ai-panel { border-right: none; border-left: 1px solid var(--line); padding: 14px; }
.panel-head { font-family: system-ui, sans-serif; font-weight: 600; margin-bottom: 8px; }
.panel-actions { display: flex; gap: 8px; padding: 10px; border-bottom: 1px solid var(--line); }

.tree-box { overflow: auto; padding: 8px; flex: 1; }
.bible-note { padding: 10px; border-top: 1px solid var(--line); line-height: 1.4; }

.chapter { margin-bottom: 6px; border-radius: 8px; }
.chapter.drop-target { outline: 2px dashed var(--accent); }
.scene { margin-left: 14px; border-left: 2px solid var(--line); border-radius: 0 8px 8px 0; }
.scene.drop-target { outline: 2px dashed var(--accent); }

.node-row {
  display: flex; align-items: center; gap: 4px;
  padding: 5px 6px; border-radius: 8px; cursor: pointer;
  font-family: system-ui, sans-serif; font-size: 15px;
}
.node-row:hover { background: var(--bg); }
.chapter.active > .node-row, .scene.active > .node-row { background: var(--bg); font-weight: 600; }
.node-title { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.node-count { color: var(--muted); font-size: 12px; }
.node-btn {
  border: none; background: transparent; padding: 2px 5px; font-size: 14px; line-height: 1;
  color: var(--muted); border-radius: 6px;
}
.node-btn:hover { color: var(--accent); background: var(--panel); border: none; }

.editor-area { display: flex; flex-direction: column; min-height: 0; background: var(--bg); }
.editor-head {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 16px; border-bottom: 1px solid var(--line); background: var(--panel);
}
.node-title { font-family: system-ui, sans-serif; font-size: 16px; font-weight: 600; }
.save-state { font-size: 13px; color: var(--muted); font-family: system-ui, sans-serif; }
.save-state.err { color: var(--danger); }

.editor {
  flex: 1; min-height: 0; width: 100%;
  border: none; resize: none; outline: none;
  padding: 28px 8% 60px;
  background: var(--bg); color: var(--text);
  font: 19px/1.75 Georgia, "Times New Roman", serif;
}

.work-view {
  flex: 1; min-height: 0; overflow: auto;
  padding: 24px 8% 60px;
  font: 19px/1.75 Georgia, "Times New Roman", serif;
  white-space: pre-wrap;
}
.work-view h3 {
  font-family: system-ui, sans-serif; font-size: 20px; margin: 28px 0 10px;
  cursor: pointer;
}
.work-view h3:hover { color: var(--accent); }
.work-view h4 {
  font-family: system-ui, sans-serif; font-size: 16px; color: var(--muted);
  margin: 20px 0 8px; cursor: pointer;
}

.select-bar {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 16px; border-top: 1px solid var(--line); background: var(--panel);
  flex-wrap: wrap;
}

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 8px; padding: 10px 16px; max-width: 90vw;
  font-family: system-ui, sans-serif; font-size: 15px; z-index: 10;
}

@media (max-width: 900px) {
  .workspace { grid-template-columns: 1fr; height: auto; }
  .tree, .ai-panel { border: none; border-bottom: 1px solid var(--line); }
  .editor { min-height: 60vh; padding: 20px 18px 40px; }
}
