:root {
    --bg: #f7f6f2;
    --fg: #1c1b18;
    --muted: #6b6a66;
    --accent: #6a4a2a;
    --accent-hover: #563a20;
    --card: #ffffff;
    --border: #e5e2da;
    --error: #a5301c;
    --note-bg: #fbf6ec;
    --danger: #a5301c;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
    background: var(--bg);
    color: var(--fg);
    line-height: 1.55;
}

a { color: var(--accent); }
a:hover { color: var(--accent-hover); }

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 24px;
    background: #fff;
    border-bottom: 1px solid var(--border);
}

.brand { font-weight: 600; text-decoration: none; color: var(--fg); }

.topbar nav a, .linklike {
    color: var(--fg);
    text-decoration: none;
    margin-left: 16px;
    background: none;
    border: none;
    cursor: pointer;
    font: inherit;
    padding: 0;
}
.linklike.danger { color: var(--danger); }

.container { max-width: 960px; margin: 32px auto; padding: 0 24px; }

.card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 16px;
}

.auth-card { max-width: 380px; margin: 64px auto; }
.auth-card form { display: flex; flex-direction: column; gap: 12px; }

label {
    display: flex;
    flex-direction: column;
    font-size: 0.9rem;
    color: var(--muted);
    margin-bottom: 12px;
}

input, select, textarea {
    margin-top: 4px;
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font: inherit;
    font-size: 1rem;
    background: #fff;
    color: var(--fg);
}
textarea { font-family: inherit; resize: vertical; }

button, .btn {
    display: inline-block;
    padding: 8px 14px;
    border: none;
    border-radius: 6px;
    background: var(--accent);
    color: #fff;
    font-size: 0.95rem;
    cursor: pointer;
    text-decoration: none;
}
button:hover, .btn:hover { background: var(--accent-hover); color: #fff; }

.btn.ghost {
    background: transparent;
    color: var(--fg);
    border: 1px solid var(--border);
}
.btn.ghost:hover { background: #efece5; color: var(--fg); }

.btn.danger { background: var(--danger); }
.btn.danger:hover { background: #862515; }

.btn-row { display: inline-flex; gap: 8px; }

.form-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 8px; }

.error {
    background: #fdecea;
    color: var(--error);
    border: 1px solid #f5c2ba;
    padding: 8px 10px;
    border-radius: 6px;
    font-size: 0.9rem;
}

.muted { color: var(--muted); font-size: 0.9rem; }

.chip {
    display: inline-block;
    background: #efece5;
    color: var(--muted);
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 0.75rem;
    margin-left: 6px;
}

.page-head { margin-bottom: 20px; }
.page-head h1 { margin: 0 0 4px; }
.page-head-row { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; }

.row-between { display: flex; justify-content: space-between; gap: 12px; }

.book-list { list-style: none; padding: 0; margin: 0; }
.book-list h2, .book-list h3 { margin: 0 0 4px; font-size: 1.1rem; }

.empty { text-align: center; color: var(--muted); }

.verse-notes { margin-top: 8px; padding-top: 8px; border-top: 1px dashed var(--border); }
.note-inline {
    background: var(--note-bg);
    padding: 6px 10px;
    border-radius: 6px;
    margin: 4px 0;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 8px;
}

.mini-form summary { cursor: pointer; color: var(--muted); font-size: 0.9rem; margin-top: 8px; }
.mini-form form { margin-top: 8px; padding: 8px; background: #faf9f5; border-radius: 6px; }

.preview { max-width: 720px; margin: 0 auto; background: #fff; padding: 40px; border-radius: 8px; border: 1px solid var(--border); }
.preview h1 { border-bottom: 2px solid var(--accent); padding-bottom: 8px; }
.preview h2 { margin-top: 32px; }
.preview h3 { margin-top: 24px; color: var(--accent); }
.preview .verse { background: #f9f8f4; padding: 12px 16px; border-left: 3px solid var(--accent); border-radius: 4px; }
.preview .note { background: var(--note-bg); border-left: 3px solid #c8a56a; padding: 12px 16px; margin: 12px 0; font-style: italic; color: #5a4c33; }

code { background: #f0eee8; padding: 1px 5px; border-radius: 3px; font-size: 0.9em; }

/* Outline editor */
.outline { display: flex; flex-direction: column; gap: 20px; }

.section-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 20px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.03);
}
.section-header {
    display: flex; justify-content: space-between; align-items: center;
    padding-bottom: 12px; margin-bottom: 12px; border-bottom: 1px solid var(--border);
}
.section-header h2 { margin: 0; font-size: 1.3rem; }
.section-header h2 a { color: var(--fg); text-decoration: none; }
.section-header h2 a:hover { color: var(--accent); }

.chip-preface { background: #eaf1e9; color: #4a6b48; }
.chip-appendix { background: #f1ebe1; color: #7a5f34; }

.topic-card {
    background: #fbfaf6;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 14px 16px;
    margin-bottom: 12px;
}
.topic-header {
    display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px;
}
.topic-header h3 { margin: 0; font-size: 1.05rem; }
.topic-header h3 a { color: var(--fg); text-decoration: none; }
.topic-header h3 a:hover { color: var(--accent); }

.verse-list { list-style: none; padding: 0; margin: 8px 0 10px; }
.verse-item {
    display: grid;
    grid-template-columns: 90px 1fr auto;
    gap: 10px; align-items: baseline;
    padding: 6px 0; border-bottom: 1px dashed var(--border);
    font-size: 0.92rem;
}
.verse-item:last-child { border-bottom: none; }
.verse-item .ref {
    font-family: "SF Mono", Consolas, monospace;
    color: var(--accent); font-weight: 600; font-size: 0.85rem;
}
.verse-item .text { color: var(--fg); line-height: 1.45; }
.verse-item .linklike { color: var(--danger); font-size: 1.1rem; padding: 0 4px; }

.inline-add {
    display: flex; gap: 6px; align-items: center; margin-top: 8px;
}
.inline-add input, .inline-add select {
    flex: 1; margin: 0; padding: 6px 10px; font-size: 0.9rem;
}
.inline-add button {
    flex-shrink: 0; padding: 6px 12px; font-size: 0.85rem; white-space: nowrap;
}
.inline-add.topic-add {
    padding: 10px; background: transparent; border: 1px dashed var(--border); border-radius: 6px;
}

.btn.small { padding: 4px 10px; font-size: 0.82rem; }

.add-section-card { border-style: dashed; background: transparent; }
.add-section-card h2 { margin: 0 0 12px; font-size: 1.1rem; color: var(--muted); }

.special-section { margin-top: 12px; }
.special-section summary {
    cursor: pointer; color: var(--muted); font-size: 0.88rem;
    padding: 6px 0;
}
.special-section[open] summary { margin-bottom: 8px; }
