/* ── Reset & Base ────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --bg:        #0f0f1a;
    --surface:   #1a1a2e;
    --border:    #2a2a4a;
    --accent:    #7b8cde;
    --accent-h:  #9aaae8;
    --danger:    #e94560;
    --text:      #e0e0e0;
    --muted:     #aaa;
    --radius:    6px;
    --radius-lg: 10px;
}

body {
    background: var(--bg);
    color: var(--text);
    font-family: 'Segoe UI', sans-serif;
    font-size: 16px;
    line-height: 1.7;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

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

/* ── Navbar ──────────────────────────────────────── */
.navbar {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 0 2rem;
    position: sticky;
    top: 0;
    z-index: 100;
}

.nav-inner {
    max-width: 1100px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    gap: 1.5rem;
    height: 56px;
}

.nav-brand {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--text);
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.nav-brand:hover { color: var(--accent-h); }

.nav-logo { color: var(--accent); font-size: 1rem; }

.nav-search {
    flex: 1;
    display: flex;
    gap: 0.4rem;
    max-width: 420px;
}

.nav-search input {
    flex: 1;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.4rem 0.8rem;
    color: var(--text);
    font-size: 0.9rem;
    outline: none;
    transition: border-color 0.2s;
}
.nav-search input:focus { border-color: var(--accent); }
.nav-search input::placeholder { color: var(--muted); }

.nav-search button {
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: var(--radius);
    padding: 0.4rem 0.9rem;
    font-size: 0.85rem;
    cursor: pointer;
    transition: background 0.2s;
}
.nav-search button:hover { background: var(--accent-h); }

.nav-links {
    display: flex;
    align-items: center;
    gap: 1rem;
    white-space: nowrap;
}
.nav-links a { color: var(--muted); font-size: 0.9rem; }
.nav-links a:hover { color: var(--text); }

/* ── Container ───────────────────────────────────── */
.container {
    flex: 1;
    max-width: 1100px;
    width: 100%;
    margin: 0 auto;
    padding: 2.5rem 1.5rem;
}

/* ── Footer ──────────────────────────────────────── */
.footer {
    border-top: 1px solid var(--border);
    padding: 1.2rem 2rem;
    color: var(--muted);
    font-size: 0.85rem;
}
.footer-inner {
    max-width: 1100px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
}
.footer-inner a { color: var(--muted); }
.footer-inner a:hover { color: var(--accent); }

/* ── Buttons ─────────────────────────────────────── */
.btn-primary {
    display: inline-block;
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: var(--radius);
    padding: 0.5rem 1.2rem;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
    text-decoration: none;
}
.btn-primary:hover { background: var(--accent-h); color: #fff; }

.btn-outline {
    display: inline-block;
    background: transparent;
    color: var(--accent);
    border: 1px solid var(--accent);
    border-radius: var(--radius);
    padding: 0.5rem 1.2rem;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
    text-decoration: none;
}
.btn-outline:hover { background: var(--accent); color: #fff; }

.btn-lg { padding: 0.7rem 1.8rem; font-size: 1rem; }

.btn-sm {
    display: inline-block;
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: var(--radius);
    padding: 0.3rem 0.8rem;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
    text-decoration: none;
}
.btn-sm:hover { background: var(--accent-h); color: #fff; }

.btn-sm-ghost {
    display: inline-block;
    background: transparent;
    color: var(--muted);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.3rem 0.8rem;
    font-size: 0.8rem;
    cursor: pointer;
    transition: color 0.2s, border-color 0.2s;
    text-decoration: none;
}
.btn-sm-ghost:hover { color: var(--text); border-color: var(--muted); }

.btn-danger-sm {
    display: inline-block;
    background: var(--danger);
    color: #fff;
    border: none;
    border-radius: var(--radius);
    padding: 0.3rem 0.8rem;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.2s;
    text-decoration: none;
}
.btn-danger-sm:hover { opacity: 0.85; color: #fff; }

.btn-cancel {
    display: inline-block;
    background: transparent;
    color: var(--muted);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.5rem 1.2rem;
    font-size: 0.9rem;
    cursor: pointer;
    transition: color 0.2s, border-color 0.2s;
    text-decoration: none;
}
.btn-cancel:hover { color: var(--text); border-color: var(--muted); }

/* ── Hero ────────────────────────────────────────── */
.hero {
    position: relative;
    overflow: hidden;
    padding: 4rem 0 3rem;
    display: flex;
    align-items: center;
    min-height: 320px;
}

.hero-content {
    position: relative;
    z-index: 2;
    max-width: 600px;
}

.hero-badge {
    display: inline-block;
    background: rgba(123, 140, 222, 0.15);
    color: var(--accent);
    border: 1px solid rgba(123, 140, 222, 0.3);
    border-radius: 20px;
    padding: 0.2rem 0.9rem;
    font-size: 0.8rem;
    font-weight: 600;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    margin-bottom: 1rem;
}

.hero-title {
    font-size: 3rem;
    font-weight: 800;
    line-height: 1.15;
    color: var(--text);
    margin-bottom: 1rem;
}

.hero-accent { color: var(--accent); }

.hero-subtitle {
    color: var(--muted);
    font-size: 1.05rem;
    margin-bottom: 2rem;
    line-height: 1.7;
}

.hero-actions {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

.hero-decoration {
    position: absolute;
    right: -80px;
    top: 50%;
    transform: translateY(-50%);
    width: 420px;
    height: 420px;
    pointer-events: none;
}

.orb {
    position: absolute;
    border-radius: 50%;
    opacity: 0.18;
    filter: blur(60px);
    animation: orb-float 8s ease-in-out infinite;
}

.orb-1 {
    width: 320px;
    height: 320px;
    background: var(--accent);
    top: 10%;
    left: 10%;
    animation-delay: 0s;
}

.orb-2 {
    width: 200px;
    height: 200px;
    background: #b48cde;
    bottom: 5%;
    right: 15%;
    animation-delay: -3s;
    opacity: 0.12;
}

.orb-3 {
    width: 120px;
    height: 120px;
    background: var(--accent-h);
    top: 60%;
    left: 30%;
    animation-delay: -5s;
    opacity: 0.2;
}

@keyframes orb-float {
    0%, 100% { transform: translateY(0); }
    50%       { transform: translateY(-20px); }
}

/* ── Stats Strip ─────────────────────────────────── */
.stats-strip {
    display: flex;
    gap: 1px;
    background: var(--border);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    margin-bottom: 3rem;
}

.stat-card {
    flex: 1;
    background: var(--surface);
    padding: 1.5rem;
    text-align: center;
}

.stat-num {
    font-size: 2rem;
    font-weight: 800;
    color: var(--accent);
    line-height: 1;
    margin-bottom: 0.3rem;
}

.stat-label {
    color: var(--muted);
    font-size: 0.85rem;
}

/* ── Section Header ──────────────────────────────── */
.section-header {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    margin-bottom: 1.2rem;
}

.section-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text);
}

.section-link {
    font-size: 0.85rem;
    color: var(--accent);
}
.section-link:hover { color: var(--accent-h); }

/* ── Page Grid / Cards ───────────────────────────── */
.recent-section { margin-bottom: 3rem; }

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

.page-card {
    display: block;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.2rem 1.3rem;
    transition: border-color 0.2s, transform 0.15s;
    text-decoration: none;
    color: var(--text);
}
.page-card:hover {
    border-color: var(--accent);
    transform: translateY(-2px);
    color: var(--text);
}

.page-card-title {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 0.3rem;
}

.page-card-meta {
    font-size: 0.78rem;
    color: var(--muted);
    margin-bottom: 0.6rem;
}

.page-card-excerpt {
    font-size: 0.85rem;
    color: var(--muted);
    line-height: 1.5;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* ── Empty Hero ──────────────────────────────────── */
.empty-hero { padding: 3rem 0; }
.empty-hero-inner {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 3rem 2rem;
    text-align: center;
    max-width: 480px;
    margin: 0 auto;
}

.empty-icon {
    font-size: 2.5rem;
    color: var(--accent);
    margin-bottom: 1rem;
    opacity: 0.6;
}

.empty-hero-inner h2 {
    font-size: 1.3rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
}

.empty-hero-inner p {
    color: var(--muted);
    margin-bottom: 1.5rem;
}

/* ── Wiki Article ────────────────────────────────── */
.wiki-article {
    max-width: 820px;
}

.article-header {
    padding-bottom: 1.2rem;
    border-bottom: 1px solid var(--border);
    margin-bottom: 2rem;
}

.article-title {
    font-size: 2.2rem;
    font-weight: 800;
    color: var(--text);
    margin-bottom: 0.6rem;
    line-height: 1.2;
}

.article-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.8rem;
}

.article-date {
    color: var(--muted);
    font-size: 0.85rem;
}

.article-actions { display: flex; gap: 0.5rem; align-items: center; }

/* ── Wiki Content (markdown) ─────────────────────── */
.wiki-content { line-height: 1.8; }

.wiki-content h1,
.wiki-content h2,
.wiki-content h3,
.wiki-content h4 {
    color: var(--text);
    font-weight: 700;
    margin: 2rem 0 0.75rem;
    line-height: 1.3;
}
.wiki-content h1 { font-size: 1.9rem; }
.wiki-content h2 { font-size: 1.5rem; border-bottom: 1px solid var(--border); padding-bottom: 0.4rem; }
.wiki-content h3 { font-size: 1.2rem; }
.wiki-content h4 { font-size: 1rem; }

.wiki-content p { margin-bottom: 1rem; }

.wiki-content a { color: var(--accent); text-decoration: underline; }
.wiki-content a:hover { color: var(--accent-h); }

.wiki-content ul,
.wiki-content ol {
    margin: 0 0 1rem 1.6rem;
}
.wiki-content li { margin-bottom: 0.25rem; }

.wiki-content code {
    background: rgba(123, 140, 222, 0.12);
    color: var(--accent-h);
    border-radius: 4px;
    padding: 0.15em 0.45em;
    font-family: 'Courier New', monospace;
    font-size: 0.9em;
}

.wiki-content pre {
    background: #0a0a14;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.2rem 1.4rem;
    overflow-x: auto;
    margin-bottom: 1.2rem;
}

.wiki-content pre code {
    background: none;
    color: #c9d1d9;
    padding: 0;
    font-size: 0.9rem;
    line-height: 1.6;
}

.wiki-content blockquote {
    border-left: 3px solid var(--accent);
    margin: 0 0 1rem;
    padding: 0.5rem 1.2rem;
    color: var(--muted);
    background: rgba(123, 140, 222, 0.06);
    border-radius: 0 var(--radius) var(--radius) 0;
}

.wiki-content table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 1.2rem;
    font-size: 0.9rem;
}

.wiki-content th,
.wiki-content td {
    border: 1px solid var(--border);
    padding: 0.55rem 0.9rem;
    text-align: left;
}

.wiki-content th {
    background: var(--surface);
    font-weight: 700;
    color: var(--accent);
}

.wiki-content tr:nth-child(even) td { background: rgba(26, 26, 46, 0.5); }

.wiki-content hr {
    border: none;
    border-top: 1px solid var(--border);
    margin: 2rem 0;
}

.wiki-content img {
    max-width: 100%;
    border-radius: var(--radius);
    margin: 0.5rem 0;
}

/* ── Revision Banner ─────────────────────────────── */
.revision-banner {
    background: rgba(123, 140, 222, 0.1);
    border: 1px solid rgba(123, 140, 222, 0.3);
    border-radius: var(--radius-lg);
    padding: 0.75rem 1.2rem;
    margin-bottom: 2rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.8rem;
    color: var(--accent);
    font-size: 0.9rem;
}

.revision-banner-actions { display: flex; gap: 0.5rem; align-items: center; }

/* ── All Pages ───────────────────────────────────── */
.all-pages-header {
    margin-bottom: 2rem;
    padding-bottom: 1.2rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 1rem;
}

.all-pages-title {
    font-size: 1.8rem;
    font-weight: 800;
}

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

.alpha-group { margin-bottom: 2.2rem; }

.alpha-letter {
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--accent);
    margin-bottom: 0.6rem;
    padding-bottom: 0.3rem;
    border-bottom: 1px solid var(--border);
}

.alpha-list { list-style: none; }

.alpha-list li {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    padding: 0.45rem 0;
    border-bottom: 1px solid rgba(42, 42, 74, 0.5);
    gap: 1rem;
}

.alpha-list li:last-child { border-bottom: none; }

.alpha-list a {
    font-weight: 500;
    color: var(--text);
    flex: 1;
}
.alpha-list a:hover { color: var(--accent); }

.alpha-list .page-date {
    color: var(--muted);
    font-size: 0.8rem;
    white-space: nowrap;
}

.no-pages {
    text-align: center;
    padding: 4rem 0;
    color: var(--muted);
}
.no-pages p { margin-bottom: 1.2rem; font-size: 1.05rem; }

/* ── Search ──────────────────────────────────────── */
.search-header {
    margin-bottom: 2rem;
    padding-bottom: 1.2rem;
    border-bottom: 1px solid var(--border);
}

.search-title {
    font-size: 1.8rem;
    font-weight: 800;
    margin-bottom: 0.3rem;
}

.search-subtitle { color: var(--muted); font-size: 0.95rem; }
.search-subtitle strong { color: var(--accent); }

.search-results-list { list-style: none; }

.search-result {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.1rem 1.3rem;
    margin-bottom: 0.8rem;
    transition: border-color 0.2s;
}
.search-result:hover { border-color: var(--accent); }

.search-result-title {
    font-size: 1.05rem;
    font-weight: 700;
    margin-bottom: 0.25rem;
}
.search-result-title a { color: var(--text); }
.search-result-title a:hover { color: var(--accent); }

.search-result-meta {
    font-size: 0.8rem;
    color: var(--muted);
    margin-bottom: 0.5rem;
}

.search-result-excerpt {
    font-size: 0.88rem;
    color: var(--muted);
    line-height: 1.55;
}

.no-results {
    text-align: center;
    padding: 3rem 0;
    color: var(--muted);
}
.no-results p { margin-bottom: 0.5rem; }
.no-results .create-hint { font-size: 0.9rem; }

/* ── Edit Form ───────────────────────────────────── */
.edit-page { max-width: 860px; }

.edit-header {
    margin-bottom: 1.8rem;
    padding-bottom: 1.2rem;
    border-bottom: 1px solid var(--border);
}

.edit-header h1 {
    font-size: 1.8rem;
    font-weight: 800;
    margin-bottom: 0.3rem;
}

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

.error-banner {
    background: rgba(233, 69, 96, 0.1);
    border: 1px solid rgba(233, 69, 96, 0.4);
    border-radius: var(--radius);
    padding: 0.7rem 1rem;
    color: var(--danger);
    font-size: 0.9rem;
    margin-bottom: 1.2rem;
}

.edit-form { display: flex; flex-direction: column; gap: 1.2rem; }

.form-group { display: flex; flex-direction: column; gap: 0.4rem; }

.form-label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--muted);
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.form-input {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.6rem 0.9rem;
    color: var(--text);
    font-size: 1rem;
    font-family: 'Segoe UI', sans-serif;
    outline: none;
    transition: border-color 0.2s;
}
.form-input:focus { border-color: var(--accent); }

.md-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 0.3rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-bottom: none;
    border-radius: var(--radius) var(--radius) 0 0;
    padding: 0.5rem 0.6rem;
}

.md-btn {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--muted);
    font-family: 'Courier New', monospace;
    font-size: 0.8rem;
    padding: 0.2rem 0.55rem;
    cursor: pointer;
    transition: color 0.15s, border-color 0.15s;
    line-height: 1.4;
}
.md-btn:hover { color: var(--accent); border-color: var(--accent); }

.form-textarea {
    background: var(--surface);
    border: 1px solid var(--border);
    border-top: none;
    border-radius: 0 0 var(--radius) var(--radius);
    padding: 0.8rem 0.9rem;
    color: var(--text);
    font-size: 0.95rem;
    font-family: 'Courier New', monospace;
    line-height: 1.65;
    width: 100%;
    resize: vertical;
    min-height: 420px;
    outline: none;
    transition: border-color 0.2s;
}
.form-textarea:focus { border-color: var(--accent); border-top: none; }
.form-textarea:focus + .md-toolbar { border-color: var(--accent); }

.form-hint {
    font-size: 0.8rem;
    color: var(--muted);
}

.form-actions {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    padding-top: 0.5rem;
}

/* ── History ─────────────────────────────────────── */
.history-header {
    margin-bottom: 2rem;
    padding-bottom: 1.2rem;
    border-bottom: 1px solid var(--border);
}

.history-breadcrumb {
    font-size: 0.85rem;
    color: var(--muted);
    margin-bottom: 0.5rem;
}

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

.history-title {
    font-size: 1.8rem;
    font-weight: 800;
}

.history-list { list-style: none; }

.history-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 1rem;
    padding: 1rem 1.2rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    margin-bottom: 0.6rem;
    transition: border-color 0.2s;
}
.history-item:hover { border-color: var(--accent); }

.history-meta { display: flex; flex-direction: column; gap: 0.15rem; }

.history-date {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text);
}

.history-label { font-size: 0.8rem; color: var(--muted); }

.history-actions { display: flex; gap: 0.5rem; align-items: center; }

.no-history {
    text-align: center;
    padding: 2rem 0;
    color: var(--muted);
    font-size: 0.95rem;
}

/* ── 404 ─────────────────────────────────────────── */
.error-page {
    text-align: center;
    padding: 5rem 0;
}

.error-code {
    font-size: 6rem;
    font-weight: 900;
    color: var(--accent);
    opacity: 0.25;
    line-height: 1;
    margin-bottom: 0.5rem;
}

.error-page h2 {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 0.6rem;
}

.error-page p {
    color: var(--muted);
    margin-bottom: 0.4rem;
    font-size: 0.95rem;
}

.error-actions {
    display: flex;
    gap: 0.8rem;
    justify-content: center;
    flex-wrap: wrap;
    margin-top: 2rem;
}

/* ── Responsive ──────────────────────────────────── */
@media (max-width: 700px) {
    .nav-inner { gap: 0.8rem; }
    .nav-links .btn-primary { display: none; }
    .nav-search { max-width: none; }

    .hero { padding: 2.5rem 0 2rem; min-height: auto; }
    .hero-title { font-size: 2.1rem; }
    .hero-decoration { display: none; }

    .stats-strip { flex-direction: column; gap: 0; }

    .footer-inner { flex-direction: column; text-align: center; gap: 0.4rem; }

    .all-pages-header { flex-direction: column; gap: 0.4rem; }
    .history-item { flex-direction: column; align-items: flex-start; }

    .form-textarea { min-height: 300px; }
}
