/* ==========================================================================
   API Doc v2 – Design System
   ========================================================================== */

:root {
    --bg: #f4efe7;
    --bg-alt: #efe8e1;
    --surface: #fff;
    --text: #1a1a2e;
    --text-muted: #6b7280;
    --accent: #0b7a75;
    --accent-hover: #095e5a;
    --border: #d6cfc6;
    --code-bg: #282a36;
    --code-text: #f8f8f2;

    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-mono: 'JetBrains Mono', 'Fira Code', 'Consolas', monospace;

    --header-h: 56px;
    --toc-w: 275px;
    --content-max: 1400px;
    --radius: 8px;
    --radius-sm: 4px;
}

/* ==========================================================================
   Themes
   ========================================================================== */

[data-theme="dark"] {
    --bg: #111827; --bg-alt: #1f2937; --surface: #1f2937; --text: #f3f4f6;
    --text-muted: #9ca3af; --accent: #34d399; --accent-hover: #6ee7b7;
    --border: #374151; --code-bg: #0d1117; --code-text: #e6edf3;
}
[data-theme="nord"] {
    --bg: #2e3440; --bg-alt: #3b4252; --surface: #3b4252; --text: #eceff4;
    --text-muted: #d8dee9; --accent: #88c0d0; --accent-hover: #8fbcbb;
    --border: #4c566a; --code-bg: #242933; --code-text: #d8dee9;
}
[data-theme="ocean"] {
    --bg: #0f172a; --bg-alt: #1e293b; --surface: #1e293b; --text: #e2e8f0;
    --text-muted: #94a3b8; --accent: #38bdf8; --accent-hover: #7dd3fc;
    --border: #334155; --code-bg: #0c1222; --code-text: #e2e8f0;
}
[data-theme="github"] {
    --bg: #f7f8fc; --bg-alt: #eef0f6; --surface: #ffffff; --text: #111827;
    --text-muted: #6b7280; --accent: #0d9488; --accent-hover: #0f766e;
    --border: #e2e8f0; --code-bg: #1e293b; --code-text: #e2e8f0;
}
[data-theme="solarized"] {
    --bg: #fdf6e3; --bg-alt: #eee8d5; --surface: #fdf6e3; --text: #073642;
    --text-muted: #586e75; --accent: #268bd2; --accent-hover: #2aa198;
    --border: #d3cbb7; --code-bg: #002b36; --code-text: #93a1a1;
}
[data-theme="rose"] {
    --bg: #1a1118; --bg-alt: #261c22; --surface: #261c22; --text: #fce7f3;
    --text-muted: #d4a0b9; --accent: #f472b6; --accent-hover: #fb7185;
    --border: #3d2a35; --code-bg: #130d10; --code-text: #fce7f3;
}
[data-theme="monokai"] {
    --bg: #272822; --bg-alt: #3e3d32; --surface: #3e3d32; --text: #f8f8f2;
    --text-muted: #a6a28c; --accent: #a6e22e; --accent-hover: #e6db74;
    --border: #49483e; --code-bg: #1e1f1c; --code-text: #f8f8f2;
}
[data-theme="cyberpunk"] {
    --bg: #0a0a0f; --bg-alt: #12121c; --surface: #16162a; --text: #e0e0ff;
    --text-muted: #7a7aad; --accent: #ff2a6d; --accent-hover: #ff6b9d;
    --border: #2a2a4a; --code-bg: #08080e; --code-text: #00ffc8;
}
[data-theme="sunset"] {
    --bg: #1a1019; --bg-alt: #2d1b2e; --surface: #2d1b2e; --text: #fde6d0;
    --text-muted: #c49a7c; --accent: #ff6b35; --accent-hover: #ff9f1c;
    --border: #4a2c3d; --code-bg: #120b11; --code-text: #fde6d0;
}
[data-theme="forest"] {
    --bg: #0c1a0e; --bg-alt: #142318; --surface: #1a2e1e; --text: #d4e7d6;
    --text-muted: #7daa82; --accent: #4ade80; --accent-hover: #86efac;
    --border: #2a4a2e; --code-bg: #080f09; --code-text: #a7f3d0;
}
[data-theme="lavender"] {
    --bg: #f0eaf8; --bg-alt: #e4daf0; --surface: #f8f4fc; --text: #2d1b4e;
    --text-muted: #7c6a99; --accent: #7c3aed; --accent-hover: #6d28d9;
    --border: #d4c4e8; --code-bg: #1e1033; --code-text: #e9d5ff;
}
[data-theme="copper"] {
    --bg: #1c1410; --bg-alt: #2a1f18; --surface: #2a1f18; --text: #f0dcc8;
    --text-muted: #b08d6e; --accent: #d97706; --accent-hover: #f59e0b;
    --border: #4a3628; --code-bg: #120d09; --code-text: #fde68a;
}
[data-theme="arctic"] {
    --bg: #eef4f8; --bg-alt: #dce8f0; --surface: #f4f9fc; --text: #0f2b3c;
    --text-muted: #5a7d94; --accent: #0284c7; --accent-hover: #0369a1;
    --border: #bdd4e2; --code-bg: #0c1e2e; --code-text: #bae6fd;
}
[data-theme="matrix"] {
    --bg: #000a00; --bg-alt: #001200; --surface: #001a00; --text: #00ff41;
    --text-muted: #00993d; --accent: #00ff41; --accent-hover: #66ff8c;
    --border: #003300; --code-bg: #000600; --code-text: #00ff41;
}
[data-theme="midnight"] {
    --bg: #110b1e; --bg-alt: #1a1230; --surface: #1f1638; --text: #e2daf0;
    --text-muted: #9985b5; --accent: #a78bfa; --accent-hover: #c4b5fd;
    --border: #302050; --code-bg: #0c0718; --code-text: #ddd6fe;
}
[data-theme="newspaper"] {
    --bg: #f5f2ed; --bg-alt: #eae5dc; --surface: #faf8f5; --text: #111111;
    --text-muted: #555555; --accent: #111111; --accent-hover: #333333;
    --border: #cccccc; --code-bg: #1a1a1a; --code-text: #d4d4d4;
}
[data-theme="ember"] {
    --bg: #1a0c0c; --bg-alt: #2a1414; --surface: #2a1414; --text: #fde2e2;
    --text-muted: #c57070; --accent: #ef4444; --accent-hover: #f87171;
    --border: #4a2222; --code-bg: #120808; --code-text: #fecaca;
}

/* ==========================================================================
   Theme Switcher UI
   ========================================================================== */

.theme-switcher { position: relative; }

.theme-toggle {
    display: flex; align-items: center; gap: 6px;
    font-size: 13px; font-weight: 500; color: var(--text-muted);
    background: none; border: 1px solid var(--border);
    border-radius: var(--radius); padding: 4px 10px;
    cursor: pointer; font-family: var(--font-sans); transition: all .15s;
}
.theme-toggle:hover { border-color: var(--accent); color: var(--accent); }
.theme-toggle svg { width: 14px; height: 14px; }

.theme-dropdown {
    display: none; position: absolute; top: calc(100% + 6px); right: 0;
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); box-shadow: 0 8px 24px rgba(0,0,0,.12);
    min-width: 180px; max-height: 420px; overflow-y: auto; z-index: 200; padding: 6px;
}
.theme-dropdown.is-open { display: block; }

.theme-option {
    display: flex; align-items: center; gap: 10px;
    width: 100%; padding: 8px 12px; font-size: 13px;
    font-family: var(--font-sans); color: var(--text);
    background: none; border: none; border-radius: var(--radius-sm);
    cursor: pointer; transition: background .12s; text-align: left;
}
.theme-option:hover { background: var(--bg-alt); }
.theme-option.is-active { color: var(--accent); font-weight: 600; }

.theme-swatch {
    width: 16px; height: 16px;
    border-radius: 50%; border: 2px solid var(--border); flex-shrink: 0;
}

/* ==========================================================================
   Reset & Base
   ========================================================================== */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
    font-family: var(--font-sans); font-size: 15px;
    line-height: 1.6; color: var(--text); background: var(--bg);
}
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }
img { max-width: 100%; height: auto; }

/* ==========================================================================
   Header
   ========================================================================== */

.site-header {
    position: sticky; top: 0; z-index: 100;
    height: var(--header-h);
    background: rgba(247, 248, 252, .88);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
}
.header-inner {
    max-width: var(--content-max); margin: 0 auto; padding: 0 24px;
    height: 100%; display: flex; align-items: center; justify-content: space-between;
}
.brand {
    display: flex; align-items: center; gap: 8px;
    font-weight: 600; font-size: 17px; color: var(--text);
}
.brand:hover { color: var(--accent); }
.brand svg { flex-shrink: 0; }
.header-nav { display: flex; align-items: center; gap: 16px; }
.nav-user { font-size: 13px; color: var(--text-muted); }
.nav-link { font-size: 13px; font-weight: 500; color: var(--text-muted); transition: color .15s; }
.nav-link:hover { color: var(--accent); }
.nav-btn { background: none; border: none; cursor: pointer; font: inherit; }
.inline-form { display: inline; }

/* ==========================================================================
   Buttons
   ========================================================================== */

.btn {
    display: inline-flex; align-items: center; justify-content: center;
    font-family: var(--font-sans); font-size: 14px; font-weight: 500;
    padding: 8px 20px; border-radius: var(--radius); border: 1px solid transparent;
    cursor: pointer; transition: all .15s ease; text-decoration: none;
    box-sizing: border-box; line-height: 1; vertical-align: middle;
    appearance: none; -webkit-appearance: none;
    margin: 0;
}
.btn-sm { padding: 5px 14px; font-size: 13px; height: 30px; }
.btn-primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: #fff; }
.btn-outline { background: transparent; color: var(--accent); border-color: var(--accent); }
.btn-outline:hover { background: var(--accent); color: #fff; }

/* ==========================================================================
   Badges
   ========================================================================== */

.badge {
    display: inline-block; font-size: 11px; font-weight: 600;
    text-transform: uppercase; letter-spacing: .04em;
    padding: 2px 8px; border-radius: var(--radius-sm);
}
.badge-api     { background: #dbeafe; color: #1e40af; }
.badge-doc     { background: #fef3c7; color: #92400e; }
.badge-private { background: #fce7f3; color: #9d174d; }
.badge-public  { background: #d1fae5; color: #065f46; }
.badge-openapi { background: #e0e7ff; color: #3730a3; }

/* ==========================================================================
   HTTP Method Badges (NEW in v2)
   ========================================================================== */

.method-badge {
    display: inline-block;
    font-size: 10px;
    font-weight: 700;
    font-family: var(--font-mono);
    letter-spacing: .03em;
    padding: 1px 6px;
    border-radius: 3px;
    vertical-align: middle;
    margin-right: 5px;
    color: #fff;
    flex-shrink: 0;
}
.method-get    { background: #2563eb; }
.method-post   { background: #16a34a; }
.method-put    { background: #d97706; }
.method-patch  { background: #7c3aed; }
.method-delete { background: #dc2626; }

/* TOC links with method badges */
.toc-link { display: flex; align-items: center; gap: 0; flex-wrap: nowrap; }

/* ==========================================================================
   Hero
   ========================================================================== */

.hero {
    padding: 48px 24px 40px; text-align: center;
    background: var(--bg-alt); border-bottom: 1px solid var(--border);
}
.hero h1 { font-size: 32px; font-weight: 600; margin-bottom: 8px; }
.hero-sub { font-size: 15px; color: var(--text-muted); }

.hero-detail { text-align: left; padding: 32px 24px 24px; }
.hero-inner { display: flex; align-items: flex-start; justify-content: space-between; gap: 24px; }
.hero-text h1 { font-size: 28px; margin-bottom: 6px; }
.hero-desc { font-size: 14px; color: var(--text-muted); max-width: 600px; }

/* ==========================================================================
   Language Tabs
   ========================================================================== */

.lang-tabs { display: flex; flex-wrap: wrap; gap: 6px; padding-top: 4px; }
.lang-tab {
    font-family: var(--font-sans); font-size: 13px; font-weight: 500;
    padding: 6px 14px; border-radius: var(--radius);
    border: 1px solid var(--border); background: var(--surface);
    color: var(--text-muted); cursor: pointer; transition: all .15s ease;
}
.lang-tab:hover { border-color: var(--accent); color: var(--accent); }
.lang-tab.is-active { background: var(--accent); border-color: var(--accent); color: #fff; }

/* ==========================================================================
   Document Grid (List Page)
   ========================================================================== */

.container { max-width: var(--content-max); margin: 0 auto; padding: 32px 24px; }

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

.doc-card {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: 12px; display: flex; flex-direction: column;
    overflow: hidden; transition: transform .2s ease, box-shadow .2s ease; position: relative;
}
.doc-card:hover { transform: translateY(-4px); box-shadow: 0 12px 32px rgba(0,0,0,.10); }

.doc-card-topbar { height: 4px; background: var(--accent); }
.doc-card-topbar.is-api  { background: linear-gradient(90deg, #3b82f6, #8b5cf6); }
.doc-card-topbar.is-doc  { background: linear-gradient(90deg, #f59e0b, #ef4444); }

.doc-card-body { padding: 20px 22px 22px; display: flex; flex-direction: column; flex: 1; }
.doc-card-header { display: flex; align-items: center; gap: 6px; margin-bottom: 14px; }

.doc-card-icon {
    width: 36px; height: 36px; border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
    font-size: 15px; font-weight: 700; flex-shrink: 0; color: #fff;
}
.doc-card-icon.is-api { background: linear-gradient(135deg, #3b82f6, #6366f1); }
.doc-card-icon.is-doc { background: linear-gradient(135deg, #f59e0b, #ef4444); }

.doc-card-badges { display: flex; gap: 5px; flex-wrap: wrap; margin-left: auto; }
.doc-card-title { font-size: 17px; font-weight: 600; margin-bottom: 6px; line-height: 1.3; }
.doc-card-project {
    font-size: 11px; font-weight: 600; text-transform: uppercase;
    letter-spacing: .06em; color: var(--accent); margin-bottom: 10px;
}
.doc-card-desc { font-size: 13px; color: var(--text-muted); line-height: 1.5; flex: 1; }

.doc-card-footer {
    display: flex; align-items: center; justify-content: space-between;
    padding: 14px 22px; border-top: 1px solid var(--border); background: var(--bg-alt);
}
.doc-card-meta { font-size: 11px; color: var(--text-muted); }
.doc-card-actions { display: flex; gap: 8px; }

.empty-state { text-align: center; padding: 64px 24px; color: var(--text-muted); font-size: 16px; }

/* ==========================================================================
   Document Workspace (Detail Page)
   ========================================================================== */

.doc-workspace { display: grid; grid-template-columns: var(--toc-w) 1fr; min-height: calc(100vh - var(--header-h)); }

.workspace-toc {
    position: sticky; top: var(--header-h); height: calc(100vh - var(--header-h));
    overflow-y: auto; padding: 24px 16px 24px 24px;
    border-right: 1px solid var(--border); background: var(--bg);
}
.toc-list, .toc-list ul { list-style: none; }
.toc-list ul { padding-left: 14px; }

.toc-link {
    display: flex; align-items: center;
    padding: 4px 8px; font-size: 13px; color: var(--text-muted);
    border-radius: var(--radius-sm); transition: all .15s;
    line-height: 1.4; margin-bottom: 2px;
}
.toc-link:hover, .toc-link.is-active { color: var(--accent); background: rgba(11, 122, 117, .06); }
.toc-h1 { font-weight: 600; font-size: 14px; }
.toc-h3 { font-size: 12px; }

.doc-content { padding: 40px 40px 80px; min-width: 0; }

/* ==========================================================================
   Document Section
   ========================================================================== */

.doc-section {
    display: grid; grid-template-columns: 1fr 1fr;
    gap: 40px; padding-bottom: 48px; margin-bottom: 48px;
    border-bottom: 1px solid var(--border);
}
.doc-section:last-child { border-bottom: none; }

.section-text { overflow-wrap: break-word; word-break: break-all; min-width: 0; }

.section-text h2 { font-size: 22px; font-weight: 700; color: var(--text); margin-bottom: 16px; margin-top: 0; padding-top: 4px; display: flex; align-items: center; line-height: 1.3; }
.section-text h3 { font-size: 18px; font-weight: 600; color: var(--text); margin-bottom: 12px; padding-top: 4px; display: flex; align-items: center; line-height: 1.3; }
.section-text h4 { font-size: 15px; font-weight: 600; color: var(--text); margin-bottom: 8px; display: flex; align-items: center; }

.section-teaser { font-size: 14px; color: var(--text-muted); margin-bottom: 18px; line-height: 1.7; }
.section-body { font-size: 14.5px; line-height: 1.85; }
.section-body p { margin-bottom: 16px; }
.section-body p:last-child { margin-bottom: 0; }
.section-body ul, .section-body ol { margin-bottom: 16px; padding-left: 22px; }
.section-body li { margin-bottom: 7px; line-height: 1.7; }
.section-body table { width: 100%; border-collapse: collapse; margin-bottom: 20px; font-size: 13.5px; }
.section-body th, .section-body td { padding: 10px 14px; border: 1px solid var(--border); text-align: left; }
.section-body th { background: var(--bg-alt); font-weight: 600; }
.section-body code { font-family: var(--font-mono); font-size: 13px; background: var(--bg-alt); padding: 2px 6px; border-radius: 3px; border: 1px solid var(--border); }
.section-body a { color: var(--accent); text-decoration: underline; }

/* ==========================================================================
   Code Cards
   ========================================================================== */

.section-code { position: relative; }
.code-card { display: none; margin: 0; border-radius: var(--radius); overflow: hidden; }
.code-card.is-visible { display: block; }

.code-card figcaption {
    font-family: var(--font-sans); font-size: 12px; font-weight: 600;
    text-transform: uppercase; letter-spacing: .04em;
    padding: 10px 16px; background: #1e1e2e; color: #a0a0b8;
    border-bottom: 1px solid #333348;
}
.code-card pre { margin: 0; padding: 16px; overflow-x: auto; background: var(--code-bg); font-size: 13px; line-height: 1.6; }
.code-card code { font-family: var(--font-mono); color: var(--code-text); }

.code-card.lang-python     { background: linear-gradient(135deg, #1e293b, #0f172a); }
.code-card.lang-php        { background: linear-gradient(135deg, #312e81, #1e1b4b); }
.code-card.lang-javascript,
.code-card.lang-js         { background: linear-gradient(135deg, #3f3413, #1c1917); }
.code-card.lang-typescript,
.code-card.lang-ts         { background: linear-gradient(135deg, #0f3a5c, #0a2236); }
.code-card.lang-java       { background: linear-gradient(135deg, #4a1d1f, #241113); }
.code-card.lang-csharp,
.code-card.lang-cs         { background: linear-gradient(135deg, #2f1f4d, #171127); }
.code-card.lang-bash,
.code-card.lang-shell      { background: linear-gradient(135deg, #0f2d25, #081914); }
.code-card.lang-json       { background: linear-gradient(135deg, #13293d, #0b1824); }
.code-card.lang-http       { background: linear-gradient(135deg, #13293d, #0b1824); }

.code-card.lang-python pre, .code-card.lang-php pre,
.code-card.lang-javascript pre, .code-card.lang-js pre,
.code-card.lang-typescript pre, .code-card.lang-ts pre,
.code-card.lang-java pre, .code-card.lang-csharp pre, .code-card.lang-cs pre,
.code-card.lang-bash pre, .code-card.lang-shell pre,
.code-card.lang-json pre, .code-card.lang-http pre { background: transparent; }

/* ==========================================================================
   Login Page
   ========================================================================== */

.login-wrap { display: flex; align-items: center; justify-content: center; min-height: calc(100vh - var(--header-h)); padding: 24px; }
.login-card { width: 100%; max-width: 380px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 32px; }
.login-card h2 { font-size: 22px; font-weight: 600; margin-bottom: 24px; }
.login-card label { display: block; font-size: 13px; font-weight: 500; margin-bottom: 4px; color: var(--text-muted); }
.login-card input[type="text"],
.login-card input[type="password"] {
    width: 100%; padding: 10px 12px; font-size: 14px;
    font-family: var(--font-sans); border: 1px solid var(--border);
    border-radius: var(--radius-sm); margin-bottom: 16px;
    background: var(--bg); transition: border-color .15s;
}
.login-card input:focus { outline: none; border-color: var(--accent); }
.login-card .btn { width: 100%; margin-top: 8px; }
.login-error { background: #fef2f2; color: #991b1b; font-size: 13px; padding: 10px 14px; border-radius: var(--radius-sm); margin-bottom: 16px; }

/* ==========================================================================
   Responsive
   ========================================================================== */

@media (max-width: 980px) {
    .hero-inner { flex-direction: column; }
    .doc-section { grid-template-columns: 1fr; }
}
@media (max-width: 820px) {
    .doc-workspace { grid-template-columns: 1fr; }
    .workspace-toc { display: none; }
    .doc-content { padding: 24px 16px 48px; }
}
@media (max-width: 640px) {
    .hero { padding: 32px 16px 28px; }
    .hero h1 { font-size: 24px; }
    .container { padding: 24px 16px; }
    .document-grid { grid-template-columns: 1fr; }
}

/* ==========================================================================
   Company Grid
   ========================================================================== */

.company-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 20px;
}

.company-card {
    display: block;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    text-decoration: none;
    color: var(--text);
    transition: transform .2s ease, box-shadow .2s ease;
    overflow: hidden;
}

.company-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 32px rgba(0,0,0,.10);
    color: var(--text);
}

.company-card-inner {
    padding: 32px 24px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    text-align: center;
}

.company-logo {
    width: 72px;
    height: 72px;
    object-fit: contain;
    border-radius: 8px;
}

.company-initials {
    width: 72px;
    height: 72px;
    border-radius: 12px;
    background: linear-gradient(135deg, var(--accent), var(--accent-hover));
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 26px;
    font-weight: 700;
    letter-spacing: .02em;
}

.company-name {
    font-size: 17px;
    font-weight: 600;
}

.company-email {
    font-size: 12px;
    color: var(--text-muted);
}

/* ==========================================================================
   Login banner
   ========================================================================== */

.login-banner {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 20px;
    margin-bottom: 24px;
    background: var(--surface);
    border: 1px solid var(--accent);
    border-radius: var(--radius);
    font-size: 14px;
    color: var(--text);
}

.login-banner svg {
    flex-shrink: 0;
    color: var(--accent);
}

.login-banner span { flex: 1; }

/* ==========================================================================
   Breadcrumb
   ========================================================================== */

.breadcrumb {
    margin-bottom: 8px;
}

.breadcrumb a {
    font-size: 13px;
    color: var(--text-muted);
    text-decoration: none;
    transition: color .15s;
}

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

/* ==========================================================================
   Print
   ========================================================================== */

/* ==========================================================================
   Manage section
   ========================================================================== */

.mg-wrap {
    max-width: 1200px;
    margin: 0 auto;
    padding: 32px 24px 64px;
}

.mg-wrap--narrow {
    max-width: 640px;
}

.mg-topbar {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 28px;
}

.mg-topbar-actions {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
    padding-top: 6px;
}

.mg-back {
    font-size: 13px;
    color: var(--text-muted);
    text-decoration: none;
    display: block;
    margin-bottom: 4px;
    transition: color .15s;
}
.mg-back:hover { color: var(--accent); }

.mg-title {
    font-size: 26px;
    font-weight: 700;
    margin: 0;
}

/* Stats */
.mg-stats {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 14px;
    margin-bottom: 36px;
}

@media (max-width: 640px) { .mg-stats { grid-template-columns: repeat(2, 1fr); } }

.mg-stat {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 18px 20px;
    display: flex;
    align-items: center;
    gap: 14px;
    transition: box-shadow .15s, border-color .15s;
}

.mg-stat:hover {
    border-color: var(--accent);
    box-shadow: 0 4px 16px rgba(0,0,0,.06);
}

.mg-stat-icon {
    width: 42px;
    height: 42px;
    border-radius: 10px;
    background: var(--ic, #f0f0f0);
    color: var(--ic-c, #666);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.mg-stat-num {
    font-size: 26px;
    font-weight: 700;
    color: var(--text);
    line-height: 1;
    margin-bottom: 2px;
}

.mg-stat-label {
    font-size: 11px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: .06em;
    font-weight: 500;
}

/* Section */
.mg-section { margin-bottom: 40px; }

.mg-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border);
}

.mg-section-title {
    font-size: 15px;
    font-weight: 600;
    margin: 0;
    letter-spacing: -.01em;
}

.mg-empty {
    color: var(--text-muted);
    font-size: 14px;
    padding: 28px 0;
    text-align: center;
}

/* Table */
.mg-table-wrap {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    overflow: hidden;
}

.mg-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13.5px;
}

.mg-table th {
    text-align: left;
    padding: 9px 16px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .07em;
    color: var(--text-muted);
    background: var(--bg-alt);
    border-bottom: 1px solid var(--border);
}

.mg-table td {
    padding: 11px 16px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

.mg-table tbody tr:last-child td { border-bottom: none; }
.mg-table tbody tr { transition: background .1s; }
.mg-table tbody tr:hover { background: var(--bg-alt); }

.mg-doc-name {
    font-weight: 600;
    color: var(--accent);
    text-decoration: none;
    font-size: 14px;
}
.mg-doc-name:hover { text-decoration: underline; }

.mg-meta-primary {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--text);
}

.mg-meta-sub {
    display: block;
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 1px;
}

.mg-count-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 22px;
    height: 22px;
    padding: 0 7px;
    background: var(--bg-alt);
    border: 1px solid var(--border);
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
}

.mg-td-actions {
    white-space: nowrap;
    vertical-align: middle;
}

.mg-td-actions-inner {
    display: flex;
    gap: 4px;
    align-items: center;
    justify-content: flex-end;
}

.mg-td-actions-inner form { display: contents; }
.mg-table td form { margin: 0; padding: 0; }

/* Icon buttons */
.mg-icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border-radius: 6px;
    border: 1px solid transparent;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    transition: all .15s;
    text-decoration: none;
    box-sizing: border-box;
    appearance: none;
    -webkit-appearance: none;
    padding: 0;
}

.mg-icon-btn:hover {
    background: var(--bg-alt);
    border-color: var(--border);
    color: var(--text);
}

.mg-icon-btn--danger:hover {
    background: #fee2e2;
    border-color: #fca5a5;
    color: #dc2626;
}

/* Toggle publish */
.mg-toggle {
    font-size: 12px;
    font-weight: 600;
    padding: 3px 10px;
    border-radius: 20px;
    border: 1px solid var(--border);
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    transition: all .15s;
    white-space: nowrap;
}

.mg-toggle:hover { border-color: var(--text-muted); }

.mg-toggle--on {
    background: #dcfce7;
    border-color: #86efac;
    color: #16a34a;
}

.mg-toggle--on:hover {
    background: #bbf7d0;
    border-color: #4ade80;
}

[data-theme="dark"] .mg-toggle--on,
[data-theme="nord"] .mg-toggle--on,
[data-theme="ocean"] .mg-toggle--on {
    background: rgba(52,211,153,.15);
    border-color: #34d399;
    color: #34d399;
}

/* Danger button */
.btn-danger {
    background: #fee2e2;
    color: #dc2626;
    border: 1px solid #fca5a5;
}
.btn-danger:hover {
    background: #fecaca;
    color: #b91c1c;
}

/* Form layout */
.mg-form--doc {
    display: grid;
    grid-template-columns: 1fr 280px;
    gap: 20px;
    align-items: start;
}

@media (max-width: 768px) {
    .mg-form--doc { grid-template-columns: 1fr; }
}

.mg-form-main { display: flex; flex-direction: column; gap: 20px; }
.mg-form-side { display: flex; flex-direction: column; gap: 16px; }

.mg-form-side-actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.mg-btn-full { width: 100%; justify-content: center; }

.mg-form-actions {
    display: flex;
    gap: 10px;
    margin-top: 24px;
}

/* Card */
.mg-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px 22px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.mg-card-title {
    font-size: 13px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--text-muted);
    margin: 0 0 4px;
}

/* Fields */
.mg-field {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.mg-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
}

.mg-label {
    font-size: 13px;
    font-weight: 500;
    color: var(--text);
}

.mg-input,
.mg-select,
.mg-textarea {
    width: 100%;
    padding: 8px 12px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-size: 14px;
    font-family: inherit;
    outline: none;
    transition: border-color .15s;
    box-sizing: border-box;
}

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

.mg-textarea { resize: vertical; }

.mg-mono { font-family: var(--font-mono); font-size: 13px; }

.mg-file {
    font-size: 13px;
    color: var(--text-muted);
}

.mg-field--check { flex-direction: row; align-items: center; }

.mg-check-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    cursor: pointer;
    user-select: none;
}

.mg-check-label input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--accent);
    cursor: pointer;
}

.mg-help {
    font-size: 12px;
    color: var(--text-muted);
    margin: 0;
}

.mg-help--info {
    background: var(--bg-alt);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 10px 12px;
    line-height: 1.5;
}

.mg-error {
    font-size: 12px;
    color: #dc2626;
    margin: 0;
}

/* ==========================================================================
   Print
   ========================================================================== */

@media print {
    .site-header, .workspace-toc, .lang-tabs { display: none; }
    .doc-workspace { grid-template-columns: 1fr; }
    .code-card { display: block !important; break-inside: avoid; }
}

/* Tabs */
.mg-tabs {
    display: flex;
    gap: 2px;
    border-bottom: 2px solid var(--border);
    margin-bottom: 24px;
}

.mg-tab {
    padding: 10px 20px;
    font-size: 14px;
    font-weight: 500;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    color: var(--text-muted);
    cursor: pointer;
    transition: color .15s, border-color .15s;
    display: flex;
    align-items: center;
    gap: 7px;
    appearance: none;
}

.mg-tab:hover { color: var(--text); }

.mg-tab--active {
    color: var(--accent);
    border-bottom-color: var(--accent);
}

.mg-tab-badge {
    font-size: 11px;
    font-weight: 600;
    background: var(--accent);
    color: #fff;
    border-radius: 20px;
    padding: 1px 7px;
    line-height: 1.6;
}

/* Pages section in doc form */
.mg-pages-section { margin-top: 32px; }
.mg-page-indent { display: inline-block; }

.mg-label-hint {
    font-size: 11px;
    font-weight: 400;
    color: var(--text-muted);
}

.mg-field--sm { max-width: 140px; }

.mg-input--mono { font-family: var(--font-mono); font-size: 13px; }

.mg-share-row {
    display: flex;
    gap: 6px;
    align-items: center;
}

.mg-share-row .mg-input { flex: 1; min-width: 0; }

.mg-btn-regen--done { color: var(--accent) !important; }
.mg-btn-regen--done:hover { color: #fff !important; }

.mg-code-sample {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.mg-code-sample-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.mg-code-sample-label {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
}

.mg-check-label--small {
    font-size: 12px;
    color: var(--text-muted);
}

.mg-divider {
    border: none;
    border-top: 1px solid var(--border);
    margin: 4px 0;
}
