/* ============================
   DevTrack — main.css
   ============================ */

:root {
    --bg: #0f1117;
    --surface: #1a1d27;
    --surface-2: #222534;
    --border: #2e3146;
    --text: #e8eaf0;
    --text-muted: #7b82a0;
    --accent: #6c8ef7;
    --accent-hover: #859bff;
    --green: #4caf7d;
    --yellow: #f5a623;
    --red: #e05252;
    --blue: #4a90d9;
    --radius: 8px;
    --font: 'Inter', system-ui, -apple-system, sans-serif;
    --mono: 'JetBrains Mono', 'Fira Code', monospace;
    --sidebar-w: 240px;
    --sidebar-collapsed-w: 64px;
    --topbar-h: 52px;
}

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

html { font-size: 15px; }

body {
    background: var(--bg);
    color: var(--text);
    font-family: var(--font);
    line-height: 1.6;
    min-height: 100vh;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); text-decoration: underline; }

/* ============================
   Sidebar
   ============================ */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebar-w);
    height: 100vh;
    background: var(--surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    z-index: 200;
    transition: width 0.2s ease, transform 0.2s ease;
    overflow: hidden;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0 1.25rem;
    height: var(--topbar-h);
    border-bottom: 1px solid var(--border);
    text-decoration: none;
    flex-shrink: 0;
}

.sidebar-brand-icon {
    font-size: 1.2rem;
    color: var(--accent);
    flex-shrink: 0;
    width: 28px;
    text-align: center;
}

.sidebar-brand-text {
    font-size: 1rem;
    font-weight: 700;
    color: var(--accent);
    letter-spacing: -0.02em;
    white-space: nowrap;
    overflow: hidden;
}

.sidebar-nav {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 0.75rem 0;
    gap: 2px;
    overflow-y: auto;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0 1.25rem;
    height: 40px;
    color: var(--text-muted);
    font-size: 0.9rem;
    font-weight: 500;
    text-decoration: none;
    transition: color 0.15s, background 0.15s;
    white-space: nowrap;
    border-left: 3px solid transparent;
}

.sidebar-link:hover {
    color: var(--text);
    background: rgba(108, 142, 247, 0.06);
    text-decoration: none;
}

.sidebar-link.active {
    color: var(--accent);
    background: rgba(108, 142, 247, 0.08);
    border-left-color: var(--accent);
}

.sidebar-link-icon {
    width: 28px;
    text-align: center;
    font-size: 1rem;
    flex-shrink: 0;
}

.sidebar-link-text {
    overflow: hidden;
    white-space: nowrap;
}

.sidebar-spacer { flex: 1; }

.sidebar-divider {
    height: 1px;
    background: var(--border);
    margin: 0.5rem 1.25rem;
}

.sidebar-footer {
    padding: 0.75rem 0;
    border-top: 1px solid var(--border);
}

.sidebar-footer .btn-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0 1.25rem;
    height: 40px;
    width: 100%;
    font-size: 0.9rem;
}

/* ============================
   Main Layout
   ============================ */
.app-layout {
    margin-left: var(--sidebar-w);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    transition: margin-left 0.2s ease;
}

/* ============================
   Topbar
   ============================ */
.topbar {
    position: sticky;
    top: 0;
    z-index: 100;
    height: var(--topbar-h);
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.75rem;
    flex-shrink: 0;
}

.topbar-left { display: flex; align-items: center; gap: 0.75rem; }
.topbar-right { display: flex; align-items: center; gap: 1rem; }

.breadcrumb {
    font-size: 0.85rem;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 0.35rem;
}
.breadcrumb a { color: var(--text-muted); }
.breadcrumb a:hover { color: var(--accent); }
.breadcrumb-sep { color: var(--border); }

.mobile-toggle {
    display: none;
    background: none;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-size: 1.1rem;
    padding: 0.3rem 0.5rem;
    cursor: pointer;
    line-height: 1;
}
.mobile-toggle:hover { border-color: var(--accent); color: var(--accent); }

/* ============================
   Content
   ============================ */
.content {
    flex: 1;
    padding: 2rem 2rem;
    max-width: 1400px;
}

/* ============================
   Sidebar overlay (mobile)
   ============================ */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 199;
}

/* ============================
   Buttons
   ============================ */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.5rem 1rem;
    border-radius: var(--radius);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    border: 1px solid transparent;
    transition: all 0.15s;
    text-decoration: none;
}

.btn-primary {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}
.btn-primary:hover { background: var(--accent-hover); color: #fff; text-decoration: none; }

.btn-secondary {
    background: var(--surface-2);
    color: var(--text);
    border-color: var(--border);
}
.btn-secondary:hover { border-color: var(--accent); color: var(--text); text-decoration: none; }

.btn-danger {
    background: transparent;
    color: var(--red);
    border-color: var(--red);
}
.btn-danger:hover { background: var(--red); color: #fff; text-decoration: none; }

.btn-sm { padding: 0.3rem 0.7rem; font-size: 0.8rem; }
.btn-full { width: 100%; justify-content: center; }

.btn-link {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 0.9rem;
    cursor: pointer;
    font-family: var(--font);
    font-weight: 500;
    padding: 0;
}
.btn-link:hover { color: var(--text); }

.btn-icon {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 0.8rem;
    padding: 0.1rem 0.3rem;
    border-radius: 4px;
}
.btn-icon:hover { color: var(--red); background: rgba(224,82,82,0.1); }

/* ============================
   Badges
   ============================ */
.badge {
    display: inline-block;
    padding: 0.2rem 0.6rem;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    text-transform: uppercase;
}
.badge-idea         { background: rgba(107,114,128,0.2); color: #9ca3af; }
.badge-in_progress  { background: rgba(108,142,247,0.15); color: var(--accent); }
.badge-paused       { background: rgba(245,166,35,0.15); color: var(--yellow); }
.badge-done         { background: rgba(76,175,125,0.15); color: var(--green); }
.badge-archived     { background: rgba(46,49,70,0.5); color: var(--text-muted); }
.badge-planned      { background: rgba(107,114,128,0.2); color: #9ca3af; }

/* ============================
   Tags
   ============================ */
.tag {
    display: inline-block;
    background: var(--surface-2);
    border: 1px solid var(--border);
    color: var(--text-muted);
    padding: 0.15rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-family: var(--mono);
}

/* ============================
   Page header
   ============================ */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.75rem;
}
.page-header h1 { font-size: 1.6rem; font-weight: 700; letter-spacing: -0.02em; }

/* ============================
   Dashboard stats
   ============================ */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
    margin-bottom: 2.5rem;
}

.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.stat-num {
    font-size: 2.2rem;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -0.04em;
}
.stat-label { font-size: 0.8rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.04em; }
.accent-blue .stat-num { color: var(--accent); }
.accent-green .stat-num { color: var(--green); }
.accent-yellow .stat-num { color: var(--yellow); }

/* ============================
   Two-col
   ============================ */
.two-col {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
}

/* ============================
   Section header
   ============================ */
.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
}
.section-header h2 { font-size: 1rem; font-weight: 600; }

.link-small { font-size: 0.8rem; color: var(--text-muted); }
.link-small:hover { color: var(--accent); }

/* ============================
   Project row (dashboard)
   ============================ */
.project-list { display: flex; flex-direction: column; gap: 0.5rem; }
.project-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.65rem 0.85rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    text-decoration: none;
    color: var(--text);
    transition: border-color 0.15s;
    gap: 0.5rem;
}
.project-row:hover { border-color: var(--accent); text-decoration: none; color: var(--text); }
.project-name { font-weight: 500; margin-right: 0.5rem; }

/* ============================
   Log list
   ============================ */
.log-list { list-style: none; display: flex; flex-direction: column; gap: 0.75rem; }
.log-item { display: grid; grid-template-columns: 52px 1fr auto; gap: 0.5rem; align-items: start; }
.log-date { font-size: 0.75rem; color: var(--text-muted); font-family: var(--mono); padding-top: 1px; }
.log-note { font-size: 0.875rem; line-height: 1.5; color: var(--text); }
.log-project { font-size: 0.75rem; color: var(--accent); white-space: nowrap; }

/* ============================
   Project grid (list page)
   ============================ */
.filter-bar {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-bottom: 1.75rem;
}
.search-form { display: flex; gap: 0.5rem; }
.search-input {
    flex: 1;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    padding: 0.5rem 0.85rem;
    font-size: 0.875rem;
    font-family: var(--font);
}
.search-input:focus { outline: none; border-color: var(--accent); }

.status-filters { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.filter-chip {
    padding: 0.3rem 0.75rem;
    border-radius: 20px;
    font-size: 0.8rem;
    color: var(--text-muted);
    border: 1px solid var(--border);
    background: var(--surface);
    text-decoration: none;
    transition: all 0.15s;
}
.filter-chip:hover, .filter-chip.active {
    border-color: var(--accent);
    color: var(--accent);
    background: rgba(108,142,247,0.08);
    text-decoration: none;
}

.project-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1rem;
}

.project-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    transition: border-color 0.15s;
}
.project-card:hover { border-color: var(--accent); }

.card-top { display: flex; justify-content: space-between; align-items: center; }
.card-date { font-size: 0.75rem; color: var(--text-muted); }

.project-card h3 { font-size: 1rem; font-weight: 600; }
.project-card h3 a { color: var(--text); text-decoration: none; }
.project-card h3 a:hover { color: var(--accent); }

.card-desc { font-size: 0.85rem; color: var(--text-muted); line-height: 1.5; }
.card-tags { display: flex; flex-wrap: wrap; gap: 0.35rem; }
.card-footer { display: flex; gap: 1rem; margin-top: auto; padding-top: 0.5rem; }

/* ============================
   Project detail
   ============================ */
.project-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1rem;
}
.project-header h1 { font-size: 1.75rem; font-weight: 700; letter-spacing: -0.02em; }
.project-meta { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-top: 0.5rem; }
.project-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; flex-shrink: 0; }
.project-description {
    color: var(--text-muted);
    margin-bottom: 1.75rem;
    line-height: 1.7;
    max-width: 72ch;
}

.detail-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    margin-top: 1.75rem;
}

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
}

/* ============================
   Feature list
   ============================ */
.feature-list { list-style: none; display: flex; flex-direction: column; gap: 0.6rem; }
.feature-item {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.6rem 0;
    border-bottom: 1px solid var(--border);
}
.feature-item:last-child { border-bottom: none; }
.feature-item.done .feature-title { text-decoration: line-through; color: var(--text-muted); }

.feature-main { display: flex; align-items: flex-start; gap: 0.6rem; }
.feature-right { display: flex; align-items: center; gap: 0.5rem; flex-shrink: 0; }

.toggle-btn {
    background: none;
    border: 1px solid var(--border);
    color: var(--text-muted);
    cursor: pointer;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    font-size: 0.75rem;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    margin-top: 2px;
}
.toggle-btn:hover { border-color: var(--green); color: var(--green); }

.feature-title { font-size: 0.875rem; font-weight: 500; }
.feature-desc { font-size: 0.8rem; color: var(--text-muted); display: block; }

/* ============================
   Dev log
   ============================ */
.devlog-list { list-style: none; display: flex; flex-direction: column; gap: 0; }
.devlog-item {
    display: grid;
    grid-template-columns: 90px 1fr auto;
    gap: 0.75rem;
    align-items: start;
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--border);
}
.devlog-item:last-child { border-bottom: none; }
.devlog-date { font-size: 0.75rem; color: var(--text-muted); font-family: var(--mono); padding-top: 2px; }
.devlog-note { font-size: 0.875rem; line-height: 1.6; white-space: pre-wrap; }

.timestamps { font-size: 0.75rem; color: var(--text-muted); margin-top: 2rem; }

/* ============================
   Forms
   ============================ */
.form-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.75rem;
    max-width: 720px;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    margin-top: 1.5rem;
}

.field { display: flex; flex-direction: column; gap: 0.35rem; }
.field label { font-size: 0.85rem; font-weight: 500; color: var(--text-muted); }
.field small { font-weight: 400; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }

input[type="text"],
input[type="url"],
input[type="date"],
input[type="password"],
textarea,
select {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    padding: 0.55rem 0.85rem;
    font-size: 0.875rem;
    font-family: var(--font);
    width: 100%;
    transition: border-color 0.15s;
}

input:focus, textarea:focus, select:focus {
    outline: none;
    border-color: var(--accent);
}

textarea { resize: vertical; min-height: 100px; }
select option { background: var(--surface); }

.field-error { font-size: 0.8rem; color: var(--red); margin-top: 0.25rem; }

.form-actions { display: flex; justify-content: flex-end; gap: 0.75rem; padding-top: 0.5rem; }
.form-hint { color: var(--text-muted); font-size: 0.9rem; margin-top: 0.25rem; }

/* ============================
   Login page
   ============================ */
.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: var(--bg);
}

.login-box {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 2.5rem 2rem;
    width: 100%;
    max-width: 360px;
    display: flex;
    flex-direction: column;
    gap: 1.1rem;
}

.login-logo {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--accent);
    text-align: center;
}

.login-sub {
    text-align: center;
    color: var(--text-muted);
    font-size: 0.875rem;
    margin-top: -0.5rem;
}

.login-box .field { gap: 0.4rem; }

/* ============================
   Alerts
   ============================ */
.alert {
    padding: 0.65rem 1rem;
    border-radius: var(--radius);
    font-size: 0.875rem;
}
.alert-error { background: rgba(224,82,82,0.12); color: var(--red); border: 1px solid rgba(224,82,82,0.3); }
.alert-info { background: rgba(108,142,247,0.1); color: var(--accent); border: 1px solid rgba(108,142,247,0.2); }
.alert-success { background: rgba(76, 175, 125, 0.12); color: var(--green); border: 1px solid rgba(76, 175, 125, 0.3); }

/* ============================
   Import section
   ============================ */
.import-section { max-width: 720px; margin-top: 1.5rem; }
.import-toggle { cursor: pointer; font-size: 0.85rem; font-weight: 500; color: var(--accent); padding: 0.4rem 0; user-select: none; }
.import-toggle:hover { color: var(--accent-hover); }
.import-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.25rem; margin-top: 0.5rem; }
.import-hint { font-size: 0.8rem; color: var(--text-muted); margin-bottom: 0.75rem; }
.import-form { display: flex; align-items: flex-end; gap: 0.75rem; }
.import-field { flex: 1; }
.import-field input[type="file"] { font-size: 0.8rem; color: var(--text-muted); padding: 0.4rem 0; }
.import-field input[type="file"]::file-selector-button { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); color: var(--text); padding: 0.35rem 0.75rem; font-size: 0.8rem; cursor: pointer; margin-right: 0.5rem; font-family: var(--font); }
.import-field input[type="file"]::file-selector-button:hover { border-color: var(--accent); }

/* ============================
   AI Assistant
   ============================ */
.assistant-section { max-width: 720px; margin-top: 2rem; }
.assistant-header h2 { font-size: 1rem; font-weight: 600; margin-bottom: 0.75rem; }
.assistant-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.chat-messages { max-height: 320px; overflow-y: auto; padding: 1rem; display: flex; flex-direction: column; gap: 0.6rem; }
.chat-msg { padding: 0.5rem 0.85rem; border-radius: var(--radius); font-size: 0.85rem; line-height: 1.5; max-width: 85%; white-space: pre-wrap; }
.chat-msg.bot { background: var(--surface-2); color: var(--text); align-self: flex-start; }
.chat-msg.user { background: var(--accent); color: #fff; align-self: flex-end; }
.chat-msg.loading { opacity: 0.6; }
.chat-msg.error { color: var(--red); }
.chat-form { display: flex; gap: 0.5rem; padding: 0.75rem 1rem; border-top: 1px solid var(--border); }
.chat-form input { flex: 1; }

/* ============================
   Empty states
   ============================ */
.empty-state { color: var(--text-muted); font-size: 0.875rem; padding: 0.75rem 0; }
.empty-state-large {
    text-align: center;
    padding: 4rem 2rem;
    color: var(--text-muted);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
}

/* ============================
   Markdown rendered content
   ============================ */
.markdown-body {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 2rem;
    line-height: 1.75;
    color: var(--text);
}
.markdown-body h1 { font-size: 1.75rem; font-weight: 700; margin: 0 0 1rem; padding-bottom: 0.5rem; border-bottom: 1px solid var(--border); }
.markdown-body h2 { font-size: 1.35rem; font-weight: 600; margin: 1.75rem 0 0.75rem; padding-bottom: 0.4rem; border-bottom: 1px solid var(--border); }
.markdown-body h3 { font-size: 1.1rem; font-weight: 600; margin: 1.5rem 0 0.5rem; }
.markdown-body h4 { font-size: 1rem; font-weight: 600; margin: 1.25rem 0 0.5rem; }
.markdown-body p { margin: 0 0 1rem; }
.markdown-body ul, .markdown-body ol { margin: 0 0 1rem; padding-left: 1.75rem; }
.markdown-body li { margin-bottom: 0.35rem; }
.markdown-body code {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 0.15rem 0.4rem;
    font-family: var(--mono);
    font-size: 0.85em;
}
.markdown-body pre {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem 1.25rem;
    overflow-x: auto;
    margin: 0 0 1rem;
}
.markdown-body pre code {
    background: none;
    border: none;
    padding: 0;
    font-size: 0.85rem;
}
.markdown-body blockquote {
    border-left: 3px solid var(--accent);
    margin: 0 0 1rem;
    padding: 0.5rem 0 0.5rem 1rem;
    color: var(--text-muted);
}
.markdown-body a { color: var(--accent); }
.markdown-body a:hover { color: var(--accent-hover); }
.markdown-body hr { border: none; border-top: 1px solid var(--border); margin: 1.5rem 0; }
.markdown-body table { border-collapse: collapse; margin: 0 0 1rem; width: 100%; }
.markdown-body th, .markdown-body td { border: 1px solid var(--border); padding: 0.5rem 0.75rem; text-align: left; }
.markdown-body th { background: var(--surface-2); font-weight: 600; }
.markdown-body img { max-width: 100%; border-radius: var(--radius); }

/* ============================
   Docs layout + TOC
   ============================ */
.docs-layout {
    display: grid;
    grid-template-columns: 200px 1fr;
    gap: 2rem;
    align-items: start;
}

.docs-toc {
    position: sticky;
    top: calc(var(--topbar-h) + 1.5rem);
    max-height: calc(100vh - var(--topbar-h) - 3rem);
    overflow-y: auto;
    padding: 1rem 0;
}

.docs-toc-title {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    display: block;
    margin-bottom: 0.75rem;
}

.docs-toc ul {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

.docs-toc li a {
    display: block;
    padding: 0.3rem 0.6rem;
    font-size: 0.8rem;
    color: var(--text-muted);
    text-decoration: none;
    border-left: 2px solid transparent;
    border-radius: 0 var(--radius) var(--radius) 0;
    transition: all 0.15s;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.docs-toc li a:hover {
    color: var(--text);
    background: rgba(108, 142, 247, 0.06);
    text-decoration: none;
}

.docs-toc li.toc-level-1 a { font-weight: 600; color: var(--text); }
.docs-toc li.toc-level-3 a { padding-left: 1.2rem; }
.docs-toc li.toc-level-4 a { padding-left: 1.8rem; }

.docs-content-wrap { display: flex; flex-direction: column; gap: 1rem; }

.docs-search {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.4rem 0.75rem;
    position: sticky;
    top: calc(var(--topbar-h) + 0.75rem);
    z-index: 50;
}

.docs-search input {
    flex: 1;
    background: none;
    border: none;
    color: var(--text);
    font-size: 0.85rem;
    font-family: var(--font);
    padding: 0.2rem 0;
    outline: none;
    min-width: 0;
}

.docs-search-count {
    font-size: 0.75rem;
    color: var(--text-muted);
    white-space: nowrap;
    font-family: var(--mono);
}

.docs-search-btn {
    background: none;
    border: 1px solid var(--border);
    color: var(--text-muted);
    border-radius: 4px;
    width: 26px;
    height: 26px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 0.65rem;
    flex-shrink: 0;
}
.docs-search-btn:hover { border-color: var(--accent); color: var(--accent); }
.docs-search-clear:hover { border-color: var(--red); color: var(--red); }

.search-highlight {
    background: rgba(245, 166, 35, 0.3);
    color: inherit;
    border-radius: 2px;
    padding: 0 1px;
}
.search-highlight.search-active {
    background: rgba(108, 142, 247, 0.5);
    outline: 2px solid var(--accent);
    outline-offset: 1px;
}

/* ============================
   Responsive — Tablet
   ============================ */
@media (max-width: 1024px) {
    .sidebar {
        width: var(--sidebar-collapsed-w);
    }
    .sidebar-brand-text,
    .sidebar-link-text {
        display: none;
    }
    .sidebar-brand {
        justify-content: center;
        padding: 0;
    }
    .sidebar-link {
        justify-content: center;
        padding: 0;
        border-left: none;
        border-bottom: 3px solid transparent;
    }
    .sidebar-link.active {
        border-left-color: transparent;
        border-bottom-color: var(--accent);
    }
    .sidebar-divider { margin: 0.5rem 0.75rem; }
    .sidebar-footer .btn-link {
        justify-content: center;
        padding: 0;
    }
    .sidebar-footer .btn-link span { display: none; }

    .app-layout {
        margin-left: var(--sidebar-collapsed-w);
    }
}

/* ============================
   Responsive — Mobile
   ============================ */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
        width: var(--sidebar-w);
    }
    .sidebar.open {
        transform: translateX(0);
    }
    .sidebar.open ~ .sidebar-overlay {
        display: block;
    }
    .sidebar-brand-text,
    .sidebar-link-text {
        display: inline;
    }
    .sidebar-brand {
        justify-content: flex-start;
        padding: 0 1.25rem;
    }
    .sidebar-link {
        justify-content: flex-start;
        padding: 0 1.25rem;
        border-left: 3px solid transparent;
        border-bottom: none;
    }
    .sidebar-link.active {
        border-left-color: var(--accent);
        border-bottom-color: transparent;
    }
    .sidebar-divider { margin: 0.5rem 1.25rem; }
    .sidebar-footer .btn-link {
        justify-content: flex-start;
        padding: 0 1.25rem;
    }
    .sidebar-footer .btn-link span { display: inline; }

    .app-layout {
        margin-left: 0;
    }

    .mobile-toggle {
        display: flex;
    }

    .content {
        padding: 1.25rem 1rem;
    }

    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .two-col { grid-template-columns: 1fr; }
    .detail-grid { grid-template-columns: 1fr; }
    .field-row { grid-template-columns: 1fr; }
    .project-header { flex-direction: column; }
    .project-actions { flex-wrap: wrap; }
    .docs-layout { grid-template-columns: 1fr; }
    .docs-toc { position: static; max-height: none; padding: 0 0 1rem; border-bottom: 1px solid var(--border); }
    .docs-toc ul { flex-direction: row; flex-wrap: wrap; gap: 0.3rem; }
    .docs-toc li a { border-left: none; border-bottom: 2px solid transparent; padding: 0.25rem 0.5rem; font-size: 0.75rem; }
    .docs-toc li.toc-level-3 a, .docs-toc li.toc-level-4 a { padding-left: 0.5rem; }
    .docs-search { position: static; }
}

@media (max-width: 480px) {
    .stats-grid { grid-template-columns: 1fr 1fr; }
    .content { padding: 1rem 0.75rem; }
    .form-card { padding: 1.25rem; }
    .topbar { padding: 0 1rem; }
}
