/* ==========================================================================
   SecureDocs.info Documentation Wiki — Design System
   wiki.css
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. CSS Custom Properties
   -------------------------------------------------------------------------- */

:root {
    /* Backgrounds */
    --bg:          #f7f9fb;
    --bg-warm:     #edf2f7;
    --bg-sidebar:  #101827;
    --bg-code:     #0f172a;

    /* Text */
    --text:        #1a1d24;
    --text-2:      #4e5564;
    --text-3:      #8b919f;

    /* Semantic Colors */
    --navy:        #1a3a5c;
    --blue:        #2e7bb5;
    --green:       #16a34a;
    --amber:       #e8941a;
    --red:         #dc2626;
    --purple:      #7c3aed;
    --teal:        #0d9488;

    /* Soft Variants (badge / callout backgrounds) */
    --navy-soft:   rgba(26, 58, 92, 0.08);
    --blue-soft:   rgba(46, 123, 181, 0.07);
    --green-soft:  rgba(22, 163, 74, 0.07);
    --amber-soft:  rgba(232, 148, 26, 0.08);
    --red-soft:    rgba(220, 38, 38, 0.07);
    --purple-soft: rgba(124, 58, 237, 0.07);
    --teal-soft:   rgba(13, 148, 136, 0.07);

    /* Typography Stacks */
    --font-display: 'Source Serif 4', Georgia, 'Times New Roman', serif;
    --font-body:    'Outfit', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-mono:    'JetBrains Mono', 'Fira Code', 'Cascadia Code', monospace;

    /* Layout */
    --banner-h:    104px;
    --sidebar-w:   256px;
    --toc-w:       190px;
    --article-max: 760px;
    --topbar-h:    52px;

    /* Radii */
    --radius-sm:   4px;
    --radius-md:   6px;
    --radius-lg:   10px;

    /* Shadows */
    --shadow-sm:   0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-md:   0 2px 8px rgba(0, 0, 0, 0.08);
    --shadow-lg:   0 4px 16px rgba(0, 0, 0, 0.12);
}


/* --------------------------------------------------------------------------
   2. Reset / Base
   -------------------------------------------------------------------------- */

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

html {
    -webkit-text-size-adjust: 100%;
    -moz-tab-size: 4;
    tab-size: 4;
    scroll-behavior: smooth;
}

body {
    background: var(--bg);
    color: var(--text);
    font-family: var(--font-body);
    font-size: 15px;
    font-weight: 400;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

img, svg, video {
    display: block;
    max-width: 100%;
}

a {
    color: var(--navy);
    text-decoration: underline;
    text-decoration-thickness: 1px;
    text-underline-offset: 2px;
    transition: color 0.15s ease, opacity 0.15s ease;
}

a:hover {
    opacity: 0.82;
}

ul, ol {
    padding-left: 1.4em;
}

hr {
    border: none;
    border-top: 1px solid rgba(0, 0, 0, 0.08);
    margin: 1.6rem 0;
}

::selection {
    background: var(--navy-soft);
    color: var(--text);
}


/* --------------------------------------------------------------------------
   3a. Layout — Top Banner
   -------------------------------------------------------------------------- */

.banner {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--banner-h);
    background: var(--bg);
    border-bottom: 1px solid rgba(0, 0, 0, 0.08);
    display: flex;
    align-items: stretch;
    justify-content: space-between;
    padding: 0 20px 0 0;
    z-index: 200;
}

.banner-brand {
    display: flex;
    align-items: center;
    text-decoration: none;
    flex-shrink: 0;
    height: 100%;
}

.banner-logo {
    height: 100%;
    width: auto;
    display: block;
}

.banner-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

/* Profile dropdown */
.banner-profile {
    position: relative;
}

.banner-profile-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    background: none;
    border: 1px solid transparent;
    border-radius: 50%;
    color: var(--text-2);
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
}

.banner-profile-btn:hover {
    background: var(--bg-warm);
    color: var(--navy);
}

.banner-dropdown {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    min-width: 200px;
    background: #fff;
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-4px);
    transition: opacity 0.15s ease, visibility 0.15s ease, transform 0.15s ease;
    z-index: 300;
}

.banner-dropdown.open {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.banner-dropdown-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    font-size: 13.5px;
    font-weight: 400;
    color: var(--text);
    text-decoration: none;
    transition: background 0.12s ease;
}

.banner-dropdown-item:hover {
    background: var(--bg-warm);
    color: var(--navy);
    opacity: 1;
}

.banner-dropdown-divider {
    height: 1px;
    background: rgba(0, 0, 0, 0.07);
    margin: 4px 0;
}


/* --------------------------------------------------------------------------
   3b. Layout — Sidebar
   -------------------------------------------------------------------------- */

.sidebar {
    position: fixed;
    top: var(--banner-h);
    left: 0;
    width: var(--sidebar-w);
    height: calc(100vh - var(--banner-h));
    background: var(--bg-sidebar);
    display: flex;
    flex-direction: column;
    z-index: 100;
    overflow: hidden;
    transition: transform 0.25s ease;
}

/* Brand */
.sb-brand {
    padding: 20px 20px 16px;
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

.sb-brand-name,
.sb-brand-text {
    font-family: var(--font-display);
    font-size: 1.2rem;
    font-weight: 700;
    color: #e2e8f0;
    letter-spacing: -0.01em;
    text-decoration: none;
}

.sb-brand-name:hover,
.sb-brand-text:hover {
    opacity: 1;
    color: #f1f5f9;
}

.sb-brand-icon {
    width: 26px;
    height: 26px;
    color: var(--blue);
    flex-shrink: 0;
}

/* Search */
.sb-search {
    padding: 0 16px 14px;
    flex-shrink: 0;
}

.sb-search input {
    width: 100%;
    padding: 8px 12px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: var(--radius-md);
    color: #cfd1d6;
    font-family: var(--font-body);
    font-size: 13px;
    outline: none;
    transition: background 0.15s ease, border-color 0.15s ease;
}

.sb-search input::placeholder {
    color: var(--text-3);
}

.sb-search input:focus {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.18);
}

/* Navigation */
.sb-nav {
    flex: 1 1 auto;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 4px 0 16px;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.1) transparent;
}

.sb-nav::-webkit-scrollbar {
    width: 5px;
}

.sb-nav::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
}

.sb-section {
    margin-bottom: 6px;
}

.sb-section-title {
    display: flex;
    align-items: center;
    gap: 0;
    padding: 6px 12px 6px 20px;
    font-size: 10.5px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-3);
    user-select: none;
}

.sb-section-link {
    display: flex;
    align-items: center;
    gap: 7px;
    flex: 1;
    min-width: 0;
    color: inherit;
    text-decoration: none;
    transition: color 0.15s ease;
}

.sb-section-link:hover {
    color: #d4d6db;
    opacity: 1;
}

.sb-section-edit {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    color: var(--text-3);
    opacity: 0;
    text-decoration: none;
    border-radius: var(--radius-sm);
    transition: opacity 0.15s ease, color 0.15s ease, background 0.15s ease;
    flex-shrink: 0;
}

.sb-section-title:hover .sb-section-edit {
    opacity: 0.6;
}

.sb-section-edit:hover {
    opacity: 1 !important;
    color: #d4d6db;
    background: rgba(255, 255, 255, 0.08);
}

.sb-section-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    background: none;
    border: none;
    color: inherit;
    cursor: pointer;
    flex-shrink: 0;
    padding: 0;
    border-radius: var(--radius-sm);
    transition: background 0.15s ease;
}

.sb-section-toggle:hover {
    background: rgba(255, 255, 255, 0.08);
}

.sb-section-title .sb-icon {
    width: 14px;
    height: 14px;
    opacity: 0.5;
    flex-shrink: 0;
}

.sb-section-title .sb-chevron {
    width: 12px;
    height: 12px;
    opacity: 0.35;
    transition: transform 0.2s ease;
}

.sb-section.collapsed .sb-chevron {
    transform: rotate(-90deg);
}

.sb-section.collapsed .sb-section-items {
    display: none;
}

.sb-section-items {
    padding: 2px 0;
}

.sb-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 20px 6px 38px;
    font-size: 13.5px;
    font-weight: 400;
    color: #a0a4af;
    text-decoration: none;
    border-left: 2px solid transparent;
    transition: color 0.12s ease, background 0.12s ease, border-color 0.12s ease;
}

.sb-item:hover {
    color: #d4d6db;
    background: rgba(255, 255, 255, 0.04);
    opacity: 1;
}

.sb-item.active {
    color: #f0f0f2;
    background: rgba(255, 255, 255, 0.06);
    border-left-color: var(--blue);
    font-weight: 500;
}

/* Footer */
.sb-footer {
    flex-shrink: 0;
    padding: 14px 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    color: var(--text-3);
    font-size: 11.5px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.sb-edit-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 10px;
    font-family: var(--font-body);
    font-size: 11.5px;
    font-weight: 500;
    color: var(--text-3);
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: var(--radius-sm);
    cursor: pointer;
    text-decoration: none;
    transition: color 0.15s ease, background 0.15s ease;
}

.sb-edit-btn:hover {
    color: #cfd1d6;
    background: rgba(255, 255, 255, 0.09);
    opacity: 1;
}


/* --------------------------------------------------------------------------
   4. Layout — Main Area
   -------------------------------------------------------------------------- */

.main {
    margin-left: var(--sidebar-w);
    margin-top: var(--banner-h);
    min-height: calc(100vh - var(--banner-h));
    display: flex;
    flex-direction: column;
}

/* Topbar */
.topbar {
    position: sticky;
    top: var(--banner-h);
    z-index: 50;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: var(--topbar-h);
    padding: 0 28px;
    background: var(--bg);
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

.sidebar-toggle {
    display: none;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    background: none;
    border: 1px solid rgba(0, 0, 0, 0.08);
    border-radius: var(--radius-sm);
    cursor: pointer;
    color: var(--text-2);
    transition: background 0.15s ease;
}

.sidebar-toggle:hover {
    background: var(--bg-warm);
}

.mobile-menu-btn {
    display: none;
    position: fixed;
    top: calc(var(--banner-h) + 10px);
    left: 12px;
    z-index: 150;
    width: 38px;
    height: 38px;
    align-items: center;
    justify-content: center;
    background: #fff;
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: var(--radius-md);
    cursor: pointer;
    color: var(--text-2);
    box-shadow: var(--shadow-sm);
    transition: background 0.15s ease;
}

.mobile-menu-btn:hover {
    background: var(--bg-warm);
}

/* Breadcrumb */
.breadcrumb {
    display: flex;
    align-items: center;
    list-style: none;
    padding: 0;
    margin: 0;
    font-size: 13px;
    color: var(--text-3);
}

.breadcrumb li {
    display: flex;
    align-items: center;
}

.breadcrumb li + li::before {
    content: '/';
    margin: 0 8px;
    color: var(--text-3);
    opacity: 0.5;
}

.breadcrumb a {
    color: var(--text-3);
    text-decoration: none;
    transition: color 0.15s ease;
}

.breadcrumb a:hover {
    color: var(--text);
    opacity: 1;
}

.breadcrumb .current {
    color: var(--text-2);
    font-weight: 500;
}

/* Content Wrap */
.content-wrap {
    display: flex;
    flex: 1;
    padding: 0 28px;
    gap: 32px;
}

/* Article */
.article {
    flex: 1 1 auto;
    max-width: var(--article-max);
    padding: 36px 0 80px;
    min-width: 0;
}

/* TOC */
.toc {
    width: var(--toc-w);
    flex-shrink: 0;
    position: sticky;
    top: calc(var(--topbar-h) + var(--banner-h) + 24px);
    align-self: flex-start;
    max-height: calc(100vh - var(--topbar-h) - var(--banner-h) - 48px);
    overflow-y: auto;
    padding: 36px 0 24px;
    scrollbar-width: thin;
    scrollbar-color: rgba(0, 0, 0, 0.08) transparent;
}

.toc::-webkit-scrollbar {
    width: 3px;
}

.toc::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.08);
    border-radius: 10px;
}

.toc-title {
    font-size: 10.5px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-3);
    padding-bottom: 10px;
    margin-bottom: 4px;
}

.toc-link {
    display: block;
    padding: 4px 0 4px 12px;
    font-size: 12.5px;
    color: var(--text-3);
    text-decoration: none;
    border-left: 2px solid transparent;
    transition: color 0.12s ease, border-color 0.12s ease;
    line-height: 1.5;
    cursor: pointer;
}

.toc-link:hover {
    color: var(--text-2);
    opacity: 1;
}

.toc-link.active {
    color: var(--navy);
    border-left-color: var(--navy);
    font-weight: 500;
}

.toc-link.toc-h3 {
    padding-left: 24px;
    font-size: 12px;
}


/* --------------------------------------------------------------------------
   5. Article Typography
   -------------------------------------------------------------------------- */

.article h1 {
    font-family: var(--font-display);
    font-size: 2.1rem;
    font-weight: 700;
    line-height: 1.22;
    letter-spacing: -0.02em;
    color: var(--text);
    margin-bottom: 8px;
}

.article-subtitle {
    font-family: var(--font-body);
    font-size: 1.02rem;
    font-weight: 300;
    color: var(--text-3);
    line-height: 1.55;
    margin-bottom: 28px;
}

.article h2 {
    font-family: var(--font-display);
    font-size: 1.35rem;
    font-weight: 600;
    line-height: 1.3;
    letter-spacing: -0.01em;
    color: var(--text);
    margin-top: 2.4rem;
    margin-bottom: 0.75rem;
    padding-bottom: 8px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
}

.article h3 {
    font-family: var(--font-body);
    font-size: 0.97rem;
    font-weight: 600;
    color: var(--text);
    margin-top: 1.8rem;
    margin-bottom: 0.55rem;
    letter-spacing: 0.005em;
}

.article h4 {
    font-family: var(--font-body);
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--text-2);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-top: 1.4rem;
    margin-bottom: 0.4rem;
}

.article p {
    line-height: 1.72;
    margin-bottom: 1rem;
    color: var(--text);
}

.article ul,
.article ol {
    margin-bottom: 1rem;
    line-height: 1.72;
}

.article li {
    margin-bottom: 0.3rem;
}

.article li > ul,
.article li > ol {
    margin-top: 0.3rem;
    margin-bottom: 0;
}

.article code {
    font-family: var(--font-mono);
    font-size: 0.855em;
    font-weight: 400;
    background: var(--bg-warm);
    padding: 2px 6px;
    border-radius: var(--radius-sm);
    color: var(--text);
    word-break: break-word;
}

.article img {
    max-width: 100%;
    height: auto;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    margin: 0.5rem 0 1rem;
}

.article strong {
    font-weight: 600;
}

.article blockquote {
    border-left: 3px solid rgba(0, 0, 0, 0.1);
    padding: 2px 0 2px 16px;
    color: var(--text-2);
    margin-bottom: 1rem;
}


/* --------------------------------------------------------------------------
   6. Meta Badges
   -------------------------------------------------------------------------- */

.meta-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    margin-bottom: 20px;
}

.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 9px;
    font-family: var(--font-body);
    font-size: 11px;
    font-weight: 500;
    border-radius: 100px;
    line-height: 1.4;
    white-space: nowrap;
}

.badge-db {
    background: var(--blue-soft);
    color: var(--blue);
}

.badge-prod {
    background: var(--green-soft);
    color: var(--green);
}

.badge-team {
    background: var(--purple-soft);
    color: var(--purple);
}

.badge-rust {
    background: var(--navy-soft);
    color: var(--navy);
}

.badge-teal {
    background: var(--teal-soft);
    color: var(--teal);
}

.badge-amber {
    background: var(--amber-soft);
    color: var(--amber);
}

.badge-red {
    background: var(--red-soft);
    color: var(--red);
}

.status-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.status-dot.live {
    background: var(--green);
    box-shadow: 0 0 0 3px var(--green-soft);
}

.status-dot.warn {
    background: var(--amber);
    box-shadow: 0 0 0 3px var(--amber-soft);
}

.status-dot.dead {
    background: var(--red);
    box-shadow: 0 0 0 3px var(--red-soft);
}


/* --------------------------------------------------------------------------
   7. Key-Value Tables
   -------------------------------------------------------------------------- */

.kv-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 1.4rem;
}

.kv-table th,
.kv-table td {
    padding: 9px 12px;
    text-align: left;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    vertical-align: top;
}

.kv-table th {
    width: 150px;
    font-family: var(--font-body);
    font-size: 11.5px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-3);
    white-space: nowrap;
}

.kv-table td {
    font-family: var(--font-mono);
    font-size: 13.5px;
    color: var(--text);
}

.kv-table td.prose {
    font-family: var(--font-body);
    font-size: 14px;
}

.kv-table tr:last-child th,
.kv-table tr:last-child td {
    border-bottom: none;
}


/* --------------------------------------------------------------------------
   8. Callouts
   -------------------------------------------------------------------------- */

.callout {
    border-left: 3px solid var(--navy);
    background: var(--bg-warm);
    padding: 14px 18px;
    border-radius: 0 var(--radius-md) var(--radius-md) 0;
    margin-bottom: 1.2rem;
}

.callout.callout-warn {
    border-left-color: var(--amber);
    background: var(--amber-soft);
}

.callout.callout-info {
    border-left-color: var(--blue);
    background: var(--blue-soft);
}

.callout.callout-success {
    border-left-color: var(--green);
    background: var(--green-soft);
}

.callout.callout-danger {
    border-left-color: var(--red);
    background: var(--red-soft);
}

.callout-label {
    display: flex;
    align-items: center;
    gap: 7px;
    font-weight: 600;
    font-size: 13.5px;
    margin-bottom: 6px;
}

.cl-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    flex-shrink: 0;
}

.callout .cl-dot              { background: var(--navy); }
.callout.callout-warn .cl-dot { background: var(--amber); }
.callout.callout-info .cl-dot { background: var(--blue); }
.callout.callout-success .cl-dot { background: var(--green); }
.callout.callout-danger .cl-dot  { background: var(--red); }

.callout p {
    font-size: 14px;
    line-height: 1.65;
    margin-bottom: 0;
}

.callout p + p {
    margin-top: 0.5rem;
}


/* --------------------------------------------------------------------------
   9. Code Blocks
   -------------------------------------------------------------------------- */

.code-block {
    background: var(--bg-code);
    border-radius: var(--radius-lg);
    overflow: hidden;
    margin-bottom: 1.4rem;
}

.code-block-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    font-family: var(--font-mono);
    font-size: 11.5px;
    color: var(--text-3);
}

.code-block-label {
    opacity: 0.7;
}

.code-copy-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 8px;
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: var(--radius-sm);
    color: var(--text-3);
    font-family: var(--font-body);
    font-size: 11px;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
}

.code-copy-btn:hover {
    background: rgba(255, 255, 255, 0.08);
    color: #cfd1d6;
}

.code-block pre {
    font-family: var(--font-mono);
    font-size: 13px;
    line-height: 1.65;
    padding: 16px 20px;
    overflow-x: auto;
    color: #abb2bf;
    margin: 0;
    background: transparent;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.08) transparent;
}

.code-block pre::-webkit-scrollbar {
    height: 5px;
}

.code-block pre::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.08);
    border-radius: 10px;
}

.code-block pre code {
    font-family: inherit;
    font-size: inherit;
    background: none;
    padding: 0;
    border-radius: 0;
    color: inherit;
}

/* Syntax Highlighting Tokens */
.kw  { color: #c678dd; }            /* keywords */
.str { color: #98c379; }            /* strings */
.cm  { color: #5c6370; font-style: italic; }  /* comments */
.num { color: #d19a66; }            /* numbers */
.fn  { color: #61afef; }            /* functions */
.op  { color: #56b6c2; }            /* operators */


/* --------------------------------------------------------------------------
   10. Diagram Frames
   -------------------------------------------------------------------------- */

.diagram-frame {
    border: 1px solid rgba(0, 0, 0, 0.08);
    border-radius: var(--radius-lg);
    margin-bottom: 1.4rem;
    overflow: hidden;
}

.diagram-frame-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-2);
    background: var(--bg-warm);
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
}

.diagram-body {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 28px 20px;
    min-height: 120px;
}

.diagram-body img,
.diagram-body svg {
    max-width: 100%;
    height: auto;
}


/* --------------------------------------------------------------------------
   11. Secrets Tables
   -------------------------------------------------------------------------- */

.secrets-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 1.4rem;
}

.secrets-table th,
.secrets-table td {
    padding: 9px 12px;
    text-align: left;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    vertical-align: middle;
}

.secrets-table th {
    font-family: var(--font-body);
    font-size: 11.5px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-3);
}

.secret-path {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-family: var(--font-mono);
    font-size: 13px;
    background: var(--bg-warm);
    border: 1px solid rgba(0, 0, 0, 0.06);
    padding: 3px 10px;
    border-radius: var(--radius-sm);
    position: relative;
}

.secret-path .copy-icon {
    opacity: 0;
    cursor: pointer;
    transition: opacity 0.15s ease;
    color: var(--text-3);
    flex-shrink: 0;
}

.secret-path:hover .copy-icon {
    opacity: 1;
}

.secret-rotation {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    font-size: 11px;
    font-weight: 500;
    border-radius: 100px;
}

.secret-rotation.ok {
    background: var(--green-soft);
    color: var(--green);
}

.secret-rotation.soon {
    background: var(--amber-soft);
    color: var(--amber);
}

.secret-rotation.overdue {
    background: var(--red-soft);
    color: var(--red);
}


/* --------------------------------------------------------------------------
   12. Dependency Chips
   -------------------------------------------------------------------------- */

.dep-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 1.2rem;
}

.dep-chip {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 5px 12px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-2);
    background: var(--bg);
    border: 1px solid rgba(0, 0, 0, 0.08);
    border-radius: 100px;
    text-decoration: none;
    transition: background 0.15s ease, border-color 0.15s ease;
}

.dep-chip:hover {
    background: var(--bg-warm);
    border-color: rgba(0, 0, 0, 0.14);
    opacity: 1;
}

.dep-chip::after {
    content: '\2192';
    font-size: 12px;
    opacity: 0.4;
    transition: opacity 0.15s ease;
}

.dep-chip:hover::after {
    opacity: 0.7;
}


/* --------------------------------------------------------------------------
   13. Changelog
   -------------------------------------------------------------------------- */

.changelog {
    margin-bottom: 1.4rem;
}

.cl-entry {
    display: flex;
    align-items: baseline;
    gap: 10px;
    padding: 7px 0;
    font-size: 13.5px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.04);
}

.cl-entry:last-child {
    border-bottom: none;
}

.cl-date {
    font-family: var(--font-mono);
    font-size: 12px;
    color: var(--text-3);
    flex-shrink: 0;
    min-width: 80px;
}

.cl-tag {
    display: inline-flex;
    align-items: center;
    padding: 1px 7px;
    font-size: 10.5px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    border-radius: var(--radius-sm);
    flex-shrink: 0;
}

.cl-tag.add {
    background: var(--green-soft);
    color: var(--green);
}

.cl-tag.edit {
    background: var(--amber-soft);
    color: var(--amber);
}

.cl-tag.remove {
    background: var(--red-soft);
    color: var(--red);
}

.cl-message {
    color: var(--text);
    line-height: 1.5;
}


/* --------------------------------------------------------------------------
   14. Modal
   -------------------------------------------------------------------------- */

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease, visibility 0.2s ease;
}

.modal-overlay.visible {
    opacity: 1;
    visibility: visible;
}

.modal {
    background: #fff;
    border-radius: var(--radius-lg);
    padding: 28px;
    max-width: 500px;
    width: calc(100% - 32px);
    box-shadow: var(--shadow-lg);
    transform: translateY(8px);
    transition: transform 0.2s ease;
}

.modal-overlay.visible .modal {
    transform: translateY(0);
}

.modal-title {
    font-family: var(--font-display);
    font-size: 1.2rem;
    font-weight: 600;
    margin-bottom: 12px;
}

.modal-body {
    font-size: 14px;
    color: var(--text-2);
    line-height: 1.65;
    margin-bottom: 20px;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}


/* --------------------------------------------------------------------------
   15. Toast
   -------------------------------------------------------------------------- */

.toast-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 1001;
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: none;
}

.toast {
    background: #fff;
    box-shadow: var(--shadow-md);
    border-radius: var(--radius-md);
    padding: 12px 18px;
    font-size: 13.5px;
    color: var(--text);
    border-left: 3px solid var(--text-3);
    pointer-events: auto;
    animation: slideIn 0.3s ease forwards;
    max-width: 340px;
}

.toast.toast-success {
    border-left-color: var(--green);
}

.toast.toast-error {
    border-left-color: var(--red);
}

.toast.toast-warn {
    border-left-color: var(--amber);
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateX(24px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.toast.removing {
    animation: slideOut 0.25s ease forwards;
}

@keyframes slideOut {
    from {
        opacity: 1;
        transform: translateX(0);
    }
    to {
        opacity: 0;
        transform: translateX(24px);
    }
}


/* --------------------------------------------------------------------------
   16. Loading Spinner
   -------------------------------------------------------------------------- */

.loading-spinner {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 60px 0;
}

.loading-spinner::after {
    content: '';
    width: 28px;
    height: 28px;
    border: 2.5px solid rgba(0, 0, 0, 0.08);
    border-top-color: var(--navy);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}


/* --------------------------------------------------------------------------
   17. Edit View
   -------------------------------------------------------------------------- */

.edit-container {
    width: 100%;
    margin-bottom: 1.4rem;
}

.edit-prompt {
    width: 100%;
    min-height: 180px;
    padding: 14px 16px;
    font-family: var(--font-mono);
    font-size: 13.5px;
    line-height: 1.6;
    color: var(--text);
    background: var(--bg);
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: var(--radius-md);
    resize: vertical;
    outline: none;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.edit-prompt:focus {
    border-color: var(--navy);
    box-shadow: 0 0 0 3px var(--navy-soft);
}

.edit-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 12px;
}

.edit-preview {
    padding: 20px;
    background: var(--bg-warm);
    border: 1px solid rgba(0, 0, 0, 0.06);
    border-radius: var(--radius-md);
    margin-top: 16px;
    min-height: 120px;
}

.edit-split {
    display: flex;
    gap: 16px;
    margin-top: 16px;
}

.edit-split > * {
    flex: 1;
    min-width: 0;
}


/* --------------------------------------------------------------------------
   18. Section Index
   -------------------------------------------------------------------------- */

.section-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 20px;
}

.section-page-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 12px;
    margin-bottom: 1.4rem;
}

.section-page-card {
    padding: 16px 18px;
    border: 1px solid rgba(0, 0, 0, 0.07);
    border-radius: var(--radius-md);
    background: #fff;
    text-decoration: none;
    color: var(--text);
    transition: box-shadow 0.2s ease, border-color 0.2s ease;
}

.section-page-card:hover {
    box-shadow: var(--shadow-sm);
    border-color: rgba(0, 0, 0, 0.12);
    opacity: 1;
}

.section-page-card-title {
    font-weight: 600;
    font-size: 14px;
    margin-bottom: 4px;
}

.section-page-card-desc {
    font-size: 12.5px;
    color: var(--text-3);
    line-height: 1.5;
}

/* Sortable Section Page List */
.section-page-list-sortable {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 1.4rem;
}

.section-page-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 14px;
    border: 1px solid rgba(0, 0, 0, 0.07);
    border-radius: var(--radius-md);
    background: #fff;
    transition: box-shadow 0.2s ease, border-color 0.2s ease, margin-left 0.2s ease, opacity 0.2s ease;
}

.section-page-item:hover {
    box-shadow: var(--shadow-sm);
    border-color: rgba(0, 0, 0, 0.12);
}

.section-page-item.dragging {
    opacity: 0.4;
    border-style: dashed;
}

.section-page-item.drag-over {
    border-color: var(--blue);
    box-shadow: 0 0 0 2px var(--blue-soft);
}

.page-item-drag-handle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    flex-shrink: 0;
    color: var(--text-3);
    cursor: grab;
    opacity: 0.4;
    transition: opacity 0.15s ease, color 0.15s ease;
}

.section-page-item:hover .page-item-drag-handle {
    opacity: 0.8;
}

.page-item-drag-handle:active {
    cursor: grabbing;
}

.page-item-content {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.page-item-title {
    font-weight: 600;
    font-size: 14px;
    color: var(--text);
    text-decoration: none;
    transition: color 0.15s ease;
}

.page-item-title:hover {
    color: var(--navy);
    opacity: 1;
}

.page-item-description {
    font-size: 12.5px;
    color: var(--text-3);
    line-height: 1.4;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.page-item-meta {
    font-size: 11.5px;
    color: var(--text-3);
    opacity: 0.7;
}

.page-item-actions {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
    opacity: 0;
    transition: opacity 0.15s ease;
}

.section-page-item:hover .page-item-actions {
    opacity: 1;
}

.page-item-indent-btn,
.page-item-action-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    background: none;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    color: var(--text-3);
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.page-item-indent-btn:hover,
.page-item-action-btn:hover {
    background: var(--bg-warm);
    border-color: rgba(0, 0, 0, 0.08);
    color: var(--text-2);
}

.page-item-action-danger:hover {
    background: var(--red-soft);
    border-color: rgba(220, 38, 38, 0.15);
    color: var(--red);
}


/* --------------------------------------------------------------------------
   19. Home Page
   -------------------------------------------------------------------------- */

.home-sections {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 14px;
    margin-bottom: 1.4rem;
}

.home-section-card {
    padding: 20px 22px;
    border: 1px solid rgba(0, 0, 0, 0.07);
    border-radius: var(--radius-lg);
    background: #fff;
    text-decoration: none;
    color: var(--text);
    transition: box-shadow 0.2s ease, border-color 0.2s ease, transform 0.2s ease;
}

.home-section-card:hover {
    box-shadow: var(--shadow-md);
    border-color: rgba(0, 0, 0, 0.12);
    transform: translateY(-1px);
    opacity: 1;
}

.home-section-icon {
    width: 36px;
    height: 36px;
    margin-bottom: 12px;
    color: var(--navy);
}

.home-section-title {
    font-family: var(--font-display);
    font-size: 1.08rem;
    font-weight: 600;
    margin-bottom: 4px;
}

.home-section-desc {
    font-size: 13px;
    color: var(--text-2);
    line-height: 1.55;
    margin-bottom: 10px;
}

.home-section-count {
    font-size: 11.5px;
    font-weight: 500;
    color: var(--text-3);
}


/* --------------------------------------------------------------------------
   20. Search Results
   -------------------------------------------------------------------------- */

.search-container {
    max-width: 640px;
    margin: 0 auto;
    padding: 36px 0 80px;
}

.search-input-large {
    width: 100%;
    padding: 14px 18px;
    font-family: var(--font-body);
    font-size: 16px;
    color: var(--text);
    background: #fff;
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: var(--radius-lg);
    outline: none;
    box-shadow: var(--shadow-sm);
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.search-input-large:focus {
    border-color: var(--navy);
    box-shadow: 0 0 0 3px var(--navy-soft), var(--shadow-sm);
}

.search-answer {
    border-left: 3px solid var(--blue);
    background: var(--blue-soft);
    padding: 16px 20px;
    border-radius: 0 var(--radius-md) var(--radius-md) 0;
    margin: 20px 0;
    font-size: 14px;
    line-height: 1.65;
    color: var(--text);
}

.search-results {
    margin-top: 20px;
}

.search-result-card {
    display: block;
    padding: 14px 18px;
    border: 1px solid rgba(0, 0, 0, 0.06);
    border-radius: var(--radius-md);
    margin-bottom: 8px;
    text-decoration: none;
    color: var(--text);
    transition: background 0.15s ease, border-color 0.15s ease;
}

.search-result-card:hover {
    background: var(--bg-warm);
    border-color: rgba(0, 0, 0, 0.1);
    opacity: 1;
}

.search-result-title {
    font-weight: 600;
    font-size: 14.5px;
    margin-bottom: 3px;
    color: var(--navy);
}

.search-result-path {
    font-size: 11.5px;
    color: var(--text-3);
    font-family: var(--font-mono);
    margin-bottom: 4px;
}

.search-result-excerpt {
    font-size: 13px;
    color: var(--text-2);
    line-height: 1.55;
}

.search-result-excerpt mark {
    background: var(--amber-soft);
    color: inherit;
    padding: 1px 2px;
    border-radius: 2px;
}


/* --------------------------------------------------------------------------
   21. Buttons
   -------------------------------------------------------------------------- */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 16px;
    font-family: var(--font-body);
    font-size: 13.5px;
    font-weight: 500;
    border: 1px solid transparent;
    border-radius: var(--radius-md);
    cursor: pointer;
    text-decoration: none;
    transition: background 0.15s ease, color 0.15s ease,
                border-color 0.15s ease, box-shadow 0.15s ease;
    line-height: 1.4;
    white-space: nowrap;
}

.btn:hover {
    opacity: 1;
}

.btn:active {
    transform: scale(0.98);
}

.btn-primary {
    background: var(--navy);
    color: #fff;
    border-color: var(--navy);
}

.btn-primary:hover {
    background: #15304d;
    border-color: #15304d;
    color: #fff;
}

.btn-secondary {
    background: transparent;
    color: var(--text);
    border-color: rgba(0, 0, 0, 0.12);
}

.btn-secondary:hover {
    background: var(--bg-warm);
    border-color: rgba(0, 0, 0, 0.18);
    color: var(--text);
}

.btn-danger {
    background: var(--red);
    color: #fff;
    border-color: var(--red);
}

.btn-danger:hover {
    background: #c52222;
    border-color: #c52222;
    color: #fff;
}

.btn-sm {
    padding: 5px 10px;
    font-size: 12px;
}

.btn-lg {
    padding: 11px 22px;
    font-size: 15px;
}


/* --------------------------------------------------------------------------
   22. Entrance Animations
   -------------------------------------------------------------------------- */

@keyframes fadeUp {
    from {
        opacity: 0;
        transform: translateY(12px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.article > * {
    animation: fadeUp 0.35s ease both;
}

.article > *:nth-child(1)  { animation-delay: 0.00s; }
.article > *:nth-child(2)  { animation-delay: 0.03s; }
.article > *:nth-child(3)  { animation-delay: 0.06s; }
.article > *:nth-child(4)  { animation-delay: 0.09s; }
.article > *:nth-child(5)  { animation-delay: 0.12s; }
.article > *:nth-child(6)  { animation-delay: 0.15s; }
.article > *:nth-child(7)  { animation-delay: 0.18s; }
.article > *:nth-child(8)  { animation-delay: 0.21s; }
.article > *:nth-child(9)  { animation-delay: 0.24s; }
.article > *:nth-child(10) { animation-delay: 0.27s; }
.article > *:nth-child(11) { animation-delay: 0.30s; }
.article > *:nth-child(12) { animation-delay: 0.33s; }
.article > *:nth-child(13) { animation-delay: 0.36s; }
.article > *:nth-child(14) { animation-delay: 0.39s; }
.article > *:nth-child(15) { animation-delay: 0.42s; }
.article > *:nth-child(n+16) { animation-delay: 0.45s; }


/* --------------------------------------------------------------------------
   23. Responsive Breakpoints
   -------------------------------------------------------------------------- */

/* TOC hidden below 1150px */
@media (max-width: 1150px) {
    .toc {
        display: none;
    }

    .content-wrap {
        padding: 0 24px;
    }

    .article {
        max-width: 100%;
    }
}

/* Sidebar hidden below 820px */
@media (max-width: 820px) {
    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.open {
        transform: translateX(0);
        box-shadow: var(--shadow-lg);
    }

    .sidebar-toggle {
        display: flex;
    }

    .mobile-menu-btn {
        display: flex;
    }

    .main {
        margin-left: 0;
    }

    .topbar {
        padding: 0 16px;
    }

    .content-wrap {
        padding: 0 16px;
    }

    .article {
        padding: 24px 0 60px;
    }

    .article h1 {
        font-size: 1.7rem;
    }

    .article h2 {
        font-size: 1.2rem;
    }

    .edit-split {
        flex-direction: column;
    }

    .section-page-list {
        grid-template-columns: 1fr;
    }

    .home-sections {
        grid-template-columns: 1fr;
    }

    .kv-table th {
        width: 110px;
    }
}

/* Extra small screens */
@media (max-width: 480px) {
    .topbar {
        height: 46px;
        padding: 0 12px;
    }

    .content-wrap {
        padding: 0 12px;
    }

    .article h1 {
        font-size: 1.45rem;
    }

    .breadcrumb {
        font-size: 11.5px;
    }

    .cl-entry {
        flex-wrap: wrap;
        gap: 4px;
    }

    .cl-date {
        min-width: auto;
    }

    .search-input-large {
        padding: 12px 14px;
        font-size: 15px;
    }
}


/* --------------------------------------------------------------------------
   24. Print Styles
   -------------------------------------------------------------------------- */

@media print {
    .banner,
    .sidebar,
    .topbar,
    .toc,
    .modal-overlay,
    .modal,
    .toast-container,
    .sb-edit-btn,
    .code-copy-btn,
    .sidebar-toggle,
    .edit-actions {
        display: none !important;
    }

    .main {
        margin-left: 0 !important;
        margin-top: 0 !important;
    }

    .article {
        max-width: 100% !important;
        padding: 0 !important;
    }

    .article > * {
        animation: none !important;
    }

    body {
        background: #fff;
        color: #000;
        font-size: 12pt;
    }

    .article h1 {
        font-size: 20pt;
    }

    .article h2 {
        font-size: 15pt;
        border-bottom: 1px solid #ccc;
    }

    a {
        color: #000;
        text-decoration: underline;
    }

    a[href]::after {
        content: ' (' attr(href) ')';
        font-size: 9pt;
        color: #666;
    }

    .code-block {
        background: #f5f5f5 !important;
        border: 1px solid #ddd;
        border-radius: 0;
    }

    .code-block pre {
        color: #333 !important;
    }

    .code-block-header {
        border-bottom-color: #ddd;
        background: #eee;
    }

    .callout {
        border-left-width: 4px;
        background: #f9f9f9 !important;
    }

    .badge {
        border: 1px solid #ccc;
        background: transparent !important;
    }

    .kv-table th,
    .kv-table td,
    .secrets-table th,
    .secrets-table td {
        border-bottom: 1px solid #ddd;
    }

    .content-wrap {
        display: block;
    }
}


/* --------------------------------------------------------------------------
   25. Utility Classes
   -------------------------------------------------------------------------- */

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.text-muted    { color: var(--text-3); }
.text-navy     { color: var(--navy); }
.text-blue     { color: var(--blue); }
.text-green    { color: var(--green); }
.text-amber    { color: var(--amber); }
.text-red      { color: var(--red); }
.text-purple   { color: var(--purple); }
.text-teal     { color: var(--teal); }

.font-mono     { font-family: var(--font-mono); }
.font-display  { font-family: var(--font-display); }
.font-body     { font-family: var(--font-body); }

.mt-0  { margin-top: 0; }
.mt-1  { margin-top: 0.5rem; }
.mt-2  { margin-top: 1rem; }
.mt-3  { margin-top: 1.5rem; }
.mt-4  { margin-top: 2rem; }
.mb-0  { margin-bottom: 0; }
.mb-1  { margin-bottom: 0.5rem; }
.mb-2  { margin-bottom: 1rem; }
.mb-3  { margin-bottom: 1.5rem; }
.mb-4  { margin-bottom: 2rem; }

.flex          { display: flex; }
.flex-col      { flex-direction: column; }
.items-center  { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-1         { gap: 0.25rem; }
.gap-2         { gap: 0.5rem; }
.gap-3         { gap: 0.75rem; }
.gap-4         { gap: 1rem; }


/* --------------------------------------------------------------------------
   26. Editor / Chat Layout
   -------------------------------------------------------------------------- */

/* Hide sidebar when editor is active */
body.editor-active .sidebar {
    transform: translateX(-100%);
}

body.editor-active .main {
    margin-left: 0;
}

body.editor-active .toc {
    display: none;
}

body.editor-active .content-wrap {
    padding: 0;
    max-width: 100%;
}

body.editor-active .article {
    max-width: 100%;
    padding: 0;
}

/* Editor split layout */
.editor-layout {
    display: flex;
    height: calc(100vh - var(--topbar-h) - var(--banner-h));
    overflow: hidden;
}

/* Chat pane (left) */
.editor-chat {
    width: 380px;
    min-width: 320px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    background: var(--bg-sidebar);
    color: #cfd1d6;
    border-right: 1px solid rgba(255, 255, 255, 0.06);
}

.editor-chat-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 16px 20px;
    font-size: 14px;
    font-weight: 600;
    color: #e8e9ec;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    flex-shrink: 0;
}

.editor-chat-header svg {
    color: var(--blue);
    flex-shrink: 0;
}

.editor-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.08) transparent;
}

.chat-msg {
    padding: 10px 14px;
    border-radius: 12px;
    font-size: 13.5px;
    line-height: 1.55;
    max-width: 92%;
    word-wrap: break-word;
}

.chat-msg-system {
    background: rgba(255, 255, 255, 0.04);
    color: var(--text-3);
    font-size: 13px;
    align-self: center;
    text-align: center;
    max-width: 100%;
    border-radius: 8px;
}

.chat-msg-user {
    background: var(--blue);
    color: #fff;
    align-self: flex-end;
    border-bottom-right-radius: 4px;
}

.chat-msg-ai {
    background: rgba(255, 255, 255, 0.08);
    color: #d1d3d8;
    align-self: flex-start;
    border-bottom-left-radius: 4px;
}

.chat-msg-loading {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--text-3);
}

.chat-dots {
    display: inline-flex;
    gap: 4px;
}

.chat-dots span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--text-3);
    animation: chatBounce 1.2s ease-in-out infinite;
}

.chat-dots span:nth-child(2) { animation-delay: 0.15s; }
.chat-dots span:nth-child(3) { animation-delay: 0.3s; }

@keyframes chatBounce {
    0%, 60%, 100% { opacity: 0.3; transform: translateY(0); }
    30% { opacity: 1; transform: translateY(-4px); }
}

/* Chat input area */
.editor-chat-input {
    padding: 12px 16px;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    display: flex;
    gap: 8px;
    align-items: flex-end;
    flex-shrink: 0;
}

.chat-input-wrap {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    transition: border-color 0.15s ease;
}

.chat-input-wrap:focus-within {
    border-color: var(--blue);
}

.chat-file-badge {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px 0;
    font-size: 12px;
    color: var(--teal);
}

.chat-file-badge svg {
    flex-shrink: 0;
}

.chat-file-badge span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.chat-file-remove {
    background: none;
    border: none;
    color: var(--text-3);
    cursor: pointer;
    font-size: 16px;
    line-height: 1;
    padding: 0 2px;
    flex-shrink: 0;
}

.chat-file-remove:hover {
    color: var(--red);
}

.editor-chat-input textarea {
    flex: 1;
    background: transparent;
    border: none;
    border-radius: 10px;
    padding: 10px 14px;
    color: #e8e9ec;
    font-family: var(--font-body);
    font-size: 13.5px;
    line-height: 1.5;
    resize: none;
    outline: none;
}

.editor-chat-input textarea::placeholder {
    color: rgba(255, 255, 255, 0.25);
}

.chat-input-buttons {
    display: flex;
    gap: 6px;
    flex-shrink: 0;
}

.chat-attach-btn {
    width: 40px;
    height: 40px;
    padding: 0;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.04);
    border-color: rgba(255, 255, 255, 0.1);
    color: var(--text-3);
}

.chat-attach-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #e8e9ec;
}

.editor-chat-input .btn-primary {
    width: 40px;
    height: 40px;
    padding: 0;
    border-radius: 10px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--blue);
    border-color: var(--blue);
}

.editor-chat-input .btn-primary:hover {
    background: #267aaa;
    border-color: #267aaa;
}

/* Preview pane (right) */
.editor-preview {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: var(--bg);
}

.editor-preview-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 24px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-2);
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
    flex-shrink: 0;
}

.editor-preview-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.editor-meta-fields {
    display: flex;
    gap: 12px;
    align-items: center;
}

.editor-meta-fields label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--text-3);
    font-weight: 500;
}

.edit-input-sm {
    padding: 4px 10px;
    font-family: var(--font-mono);
    font-size: 12px;
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: var(--radius-sm);
    background: #fff;
    color: var(--text);
    outline: none;
    width: 180px;
}

.edit-input-sm:focus {
    border-color: var(--navy);
    box-shadow: 0 0 0 2px var(--navy-soft);
}

/* Bootstrap-style form controls */
.form-control {
    display: block;
    width: 100%;
    padding: 0.375rem 0.75rem;
    font-size: 0.95rem;
    font-weight: 400;
    line-height: 1.5;
    color: var(--text);
    background-color: #fff;
    background-clip: padding-box;
    border: 1px solid #ced4da;
    border-radius: var(--radius-md);
    transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
    font-family: var(--font-body);
    box-sizing: border-box;
}

.form-control:focus {
    color: var(--text);
    background-color: #fff;
    border-color: var(--navy);
    outline: 0;
    box-shadow: 0 0 0 0.2rem var(--navy-soft);
}

.form-control:disabled {
    background-color: #e9ecef;
    color: var(--text-3);
    cursor: not-allowed;
}

.form-control::placeholder {
    color: var(--text-3);
    opacity: 0.65;
}

.form-group {
    margin-bottom: 1rem;
}

.form-group > label {
    display: block;
    margin-bottom: 0.375rem;
    font-weight: 500;
    font-size: 0.9rem;
    color: var(--text);
}

.form-group .form-text {
    display: block;
    margin-top: 0.25rem;
    font-size: 0.8rem;
    color: var(--text-3);
}

.editor-preview-content {
    flex: 1;
    overflow-y: auto;
    padding: 32px 48px 60px;
    max-width: 800px;
}

.editor-preview-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    min-height: 300px;
    gap: 16px;
    color: var(--text-3);
    font-size: 14px;
}

/* Drag and drop overlay */
.editor-chat.drag-over {
    position: relative;
}

.editor-chat.drag-over::after {
    content: 'Drop file here';
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(13, 148, 136, 0.15);
    border: 2px dashed var(--teal);
    border-radius: 8px;
    color: var(--teal);
    font-size: 15px;
    font-weight: 600;
    z-index: 10;
    pointer-events: none;
}

/* File message in chat */
.chat-msg-file {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12.5px;
    opacity: 0.85;
}

/* Responsive editor */
@media (max-width: 820px) {
    .editor-layout {
        flex-direction: column;
        height: auto;
    }

    .editor-chat {
        width: 100%;
        min-width: unset;
        max-height: 45vh;
    }

    .editor-preview-content {
        padding: 20px 16px 40px;
    }

    .editor-meta-fields {
        flex-direction: column;
        gap: 4px;
    }
}

/* ── 27. Setup Wizard & Login ─────────────────────────── */

body.setup-active .sidebar,
body.setup-active .mobile-menu-btn,
body.setup-active .topbar {
    display: none;
}

body.setup-active .main {
    margin-left: 0;
}

.setup-container {
    max-width: 640px;
    margin: 0 auto;
    padding: 2rem 1rem;
}

.setup-header {
    text-align: center;
    margin-bottom: 2rem;
}

.setup-logo {
    width: 64px;
    height: 64px;
    border-radius: 12px;
}

.setup-header h1 {
    margin: 0.75rem 0 0.25rem;
    font-family: var(--font-display);
    font-size: 1.75rem;
}

.setup-header p {
    margin: 0;
}

/* Step indicator */
.setup-steps {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0;
    margin-bottom: 2rem;
}

.setup-step {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    min-width: 80px;
}

.setup-step-num {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 600;
    background: var(--surface-2);
    color: var(--text-3);
    border: 2px solid var(--border);
    transition: all 0.2s;
}

.setup-step.active .setup-step-num {
    background: var(--teal);
    color: #fff;
    border-color: var(--teal);
}

.setup-step.completed .setup-step-num {
    background: var(--green);
    color: #fff;
    border-color: var(--green);
}

.setup-step-label {
    font-size: 12px;
    color: var(--text-3);
    font-weight: 500;
}

.setup-step.active .setup-step-label {
    color: var(--text-1);
}

.setup-step-line {
    flex: 1;
    height: 2px;
    background: var(--border);
    min-width: 40px;
    margin: 0 4px;
    margin-bottom: 22px;
}

/* Setup card */
.setup-card {
    background: var(--surface-1);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 2rem;
    margin-top: 1rem;
}

.setup-card h2 {
    margin: 0 0 0.5rem;
    font-family: var(--font-display);
    font-size: 1.25rem;
}

.setup-label {
    display: block;
    margin-top: 1rem;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-2);
}

.setup-label .edit-input {
    margin-top: 4px;
}

/* Repo list */
.setup-repo-list {
    margin-top: 1rem;
    max-height: 400px;
    overflow-y: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.setup-repo-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    cursor: pointer;
    border-bottom: 1px solid var(--border);
    transition: background 0.15s;
}

.setup-repo-card:last-child {
    border-bottom: none;
}

.setup-repo-card:hover {
    background: var(--surface-2);
}

.setup-repo-info {
    min-width: 0;
}

.setup-repo-info strong {
    font-size: 14px;
    color: var(--text-1);
}

/* Responsive setup */
@media (max-width: 480px) {
    .setup-container {
        padding: 1rem 0.5rem;
    }

    .setup-card {
        padding: 1.25rem;
    }

    .setup-steps {
        gap: 0;
    }

    .setup-step {
        min-width: 60px;
    }

    .setup-step-line {
        min-width: 20px;
    }
}
