:root {
    --md-ink: #1c1917;
    --md-muted: #78716c;
    --md-faint: #a8a29e;
    --md-paper: #f7f4ef;
    --md-surface: #ffffff;
    --md-line: #e7e5e4;
    --md-line-strong: #d6d3d1;
    --md-accent: #4f46e5;
    --md-accent-hover: #4338ca;
    --md-accent-soft: #eef2ff;
    --md-success: #0f766e;
    --md-danger: #be123c;
    --md-shadow: 0 18px 50px rgba(28, 25, 23, 0.08);
    --md-shadow-sm: 0 8px 24px rgba(28, 25, 23, 0.06);
    --md-radius: 16px;
    --md-radius-sm: 10px;
    --md-nav-h: 72px;
    --md-font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

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

html {
    scroll-behavior: smooth;
}

body {
    margin: 0;
    min-height: 100vh;
    font-family: var(--md-font);
    color: var(--md-ink);
    background:
        radial-gradient(1200px 480px at 8% -10%, rgba(79, 70, 229, 0.12), transparent 55%),
        radial-gradient(900px 420px at 100% 0%, rgba(14, 165, 233, 0.1), transparent 50%),
        linear-gradient(180deg, #fbf8f3 0%, var(--md-paper) 42%, #efeae3 100%);
    padding-top: var(--md-nav-h);
}

body.is-fullscreen {
    padding-top: 0;
    background: #fff;
}

/* ---------- Navbar ---------- */
.navbar {
    background: rgba(255, 255, 255, 0.82) !important;
    backdrop-filter: blur(16px) saturate(1.4);
    border-bottom: 1px solid rgba(231, 229, 228, 0.9);
    padding: 0.7rem 0;
    box-shadow: none;
    z-index: 1030;
    transition: background 0.25s ease, box-shadow 0.25s ease;
}

.navbar.scrolled {
    background: rgba(255, 255, 255, 0.94) !important;
    box-shadow: 0 8px 24px rgba(28, 25, 23, 0.06);
}

.navbar-brand {
    display: inline-flex;
    align-items: center;
    gap: 0.7rem;
    font-size: 1.15rem;
    font-weight: 700;
    letter-spacing: -0.03em;
    color: var(--md-ink) !important;
}

.brand-mark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: linear-gradient(145deg, #6366f1, #4338ca);
    color: #fff;
    font-size: 0.72rem;
    font-weight: 800;
    letter-spacing: 0.04em;
    box-shadow: 0 8px 18px rgba(79, 70, 229, 0.28);
}

.brand-text {
    font-family: var(--md-font);
}

.navbar-toggler {
    border: 1px solid var(--md-line);
    border-radius: 10px;
    padding: 0.4rem 0.55rem;
}

.navbar-toggler:focus {
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.15);
}

.navbar-toggler-icon {
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 30 30'%3e%3cpath stroke='rgba(28, 25, 23, 0.8)' stroke-linecap='round' stroke-miterlimit='10' stroke-width='2' d='M4 7h22M4 15h22M4 23h22'/%3e%3c/svg%3e");
}

.lang-switch {
    display: inline-flex;
    align-items: center;
    background: var(--md-ink);
    border: none;
    color: #fff;
    padding: 0.48rem 0.95rem;
    border-radius: 999px;
    font-size: 0.875rem;
    font-weight: 600;
    transition: transform 0.2s ease, background 0.2s ease, box-shadow 0.2s ease;
}

.lang-switch:hover,
.lang-switch:focus {
    background: #292524;
    color: #fff;
    transform: translateY(-1px);
    box-shadow: 0 8px 18px rgba(28, 25, 23, 0.18);
}

.dropdown-menu {
    border: 1px solid var(--md-line);
    border-radius: 12px;
    padding: 0.4rem;
    box-shadow: var(--md-shadow);
    min-width: 10rem;
}

.dropdown-item {
    border-radius: 8px;
    font-size: 0.9rem;
    padding: 0.45rem 0.7rem;
    color: var(--md-ink);
}

.dropdown-item:hover,
.dropdown-item:focus {
    background: var(--md-accent-soft);
    color: var(--md-accent);
}

/* ---------- Layout ---------- */
.main-content {
    padding: 1.75rem 0 2.5rem;
    min-height: calc(100vh - var(--md-nav-h) - 88px);
}

.ad-slot {
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    max-width: 100%;
    min-height: 90px;
    margin-bottom: 1.5rem;
    border-radius: var(--md-radius-sm);
    background: rgba(255, 255, 255, 0.45);
    border: 1px dashed var(--md-line);
}

.ad-slot-inline {
    overflow: hidden;
    margin: 1.25rem auto 0.5rem;
    max-width: 1140px;
    border-radius: var(--md-radius-sm);
}

.page-title {
    text-align: center;
    margin: 0 auto 1.75rem;
    max-width: 720px;
}

.page-title h1 {
    font-size: clamp(1.85rem, 4vw, 2.65rem);
    font-weight: 800;
    letter-spacing: -0.045em;
    line-height: 1.15;
    margin-bottom: 0.7rem;
    color: var(--md-ink);
}

.page-title p {
    margin: 0;
    font-size: 1.05rem;
    line-height: 1.65;
    color: var(--md-muted);
    font-weight: 400;
}

/* ---------- Editor card ---------- */
.editor-container {
    background: var(--md-surface);
    border-radius: var(--md-radius);
    padding: 1.15rem 1.15rem 1.25rem;
    border: 1px solid rgba(231, 229, 228, 0.9);
    box-shadow: var(--md-shadow);
}

.toolbar-actions {
    display: flex;
    gap: 0.55rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.btn-action,
.btn-outline-action {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: none;
    padding: 0.62rem 1.05rem;
    border-radius: 999px;
    font-weight: 600;
    font-size: 0.875rem;
    line-height: 1.2;
    transition: transform 0.18s ease, box-shadow 0.18s ease, background 0.18s ease, color 0.18s ease, border-color 0.18s ease;
}

.btn-action {
    background: var(--md-accent);
    color: #fff;
    box-shadow: 0 8px 18px rgba(79, 70, 229, 0.25);
}

.btn-action:hover,
.btn-action:focus {
    background: var(--md-accent-hover);
    color: #fff;
    transform: translateY(-1px);
    box-shadow: 0 12px 22px rgba(79, 70, 229, 0.3);
}

.btn-outline-action {
    background: #fff;
    border: 1px solid var(--md-line-strong);
    color: var(--md-ink);
}

.btn-outline-action:hover,
.btn-outline-action:focus {
    background: var(--md-accent-soft);
    border-color: #c7d2fe;
    color: var(--md-accent);
    transform: translateY(-1px);
}

#editor-container {
    height: 1200px;
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid var(--md-line);
    background: #fff;
}

.loading {
    display: none;
    text-align: center;
    color: var(--md-muted);
    padding: 1.5rem 0 0.5rem;
    font-size: 0.92rem;
}

.spinner {
    display: inline-block;
    width: 18px;
    height: 18px;
    border: 2px solid var(--md-line);
    border-radius: 50%;
    border-top-color: var(--md-accent);
    animation: spin 0.8s linear infinite;
    vertical-align: middle;
}

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

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

.fade-in-up {
    animation: fadeInUp 0.55s ease-out both;
}

/* ---------- Editor.md chrome ---------- */
.editormd {
    width: 100% !important;
    margin: 0 !important;
    border: none !important;
    border-radius: 12px !important;
    overflow: hidden;
    font-family: var(--md-font);
}

.editormd-toolbar {
    background: #fafaf9 !important;
    border-bottom: 1px solid var(--md-line) !important;
}

.editormd-menu > li > a {
    color: #57534e !important;
    border-color: transparent !important;
    border-radius: 8px !important;
}

.editormd-menu > li > a:hover,
.editormd-menu > li > a.active {
    background: var(--md-accent-soft) !important;
    border-color: transparent !important;
    color: var(--md-accent) !important;
}

.editormd-menu > li.divider {
    border-right-color: var(--md-line) !important;
}

.editormd .CodeMirror {
    border-right: 1px solid var(--md-line) !important;
    font-size: 14.5px;
    line-height: 1.7;
}

.editormd-preview {
    background: #fffcf8 !important;
}

.editormd-preview-container,
.editormd-html-preview {
    font-family: var(--md-font);
    color: var(--md-ink);
}

.editormd-preview-container a {
    color: var(--md-accent);
}

.editormd-preview-container pre,
.editormd-preview-container code {
    border-color: var(--md-line) !important;
    background: #f5f5f4 !important;
}

.editormd-dialog {
    border-radius: 14px !important;
    box-shadow: var(--md-shadow) !important;
}

/* ---------- FAQ ---------- */
.faq-section {
    background: transparent;
    border-top: none;
    padding-top: 1rem;
}

.faq-title {
    color: var(--md-ink);
    font-weight: 800;
    letter-spacing: -0.04em;
    margin-bottom: 1.75rem;
}

.accordion {
    --bs-accordion-border-width: 0;
    --bs-accordion-border-radius: 14px;
    --bs-accordion-inner-border-radius: 14px;
}

.accordion-item {
    border: 1px solid var(--md-line) !important;
    border-radius: 14px !important;
    margin-bottom: 0.75rem;
    overflow: hidden;
    background: var(--md-surface);
    box-shadow: none;
}

.accordion-item:first-of-type,
.accordion-item:last-of-type {
    border-radius: 14px !important;
}

.accordion-item + .accordion-item {
    margin-top: 0.75rem;
}

.accordion-button {
    background: var(--md-surface);
    color: var(--md-ink);
    font-weight: 600;
    padding: 1.1rem 1.25rem;
    font-size: 1.02rem;
    box-shadow: none !important;
}

.accordion-button::after {
    background-size: 1rem;
    opacity: 0.55;
}

.accordion-button:not(.collapsed) {
    background: var(--md-accent-soft);
    color: var(--md-accent);
}

.accordion-button:focus {
    box-shadow: none;
    border-color: transparent;
}

.accordion-body {
    padding: 0 1.25rem 1.25rem;
    background: var(--md-surface);
    color: var(--md-muted);
    line-height: 1.7;
}

.accordion-body p,
.accordion-body ul,
.accordion-body ol {
    color: #57534e;
    margin-bottom: 0.85rem;
}

.accordion-body ul li,
.accordion-body ol li {
    margin-bottom: 0.4rem;
}

/* ---------- Footer ---------- */
.footer {
    background: rgba(255, 255, 255, 0.55);
    border-top: 1px solid var(--md-line);
    color: var(--md-muted);
    padding: 0.25rem 0 0.5rem;
    font-size: 0.9rem;
    margin-top: 0.5rem;
}

.footer .footer-text {
    margin: 0;
    color: var(--md-muted);
}

.footer a {
    color: var(--md-muted);
    transition: color 0.2s ease;
}

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

/* ---------- Toast ---------- */
.toast-container {
    position: fixed;
    top: 88px;
    right: 20px;
    z-index: 9999;
}

.custom-toast {
    background: var(--md-ink);
    color: #fff;
    border: none;
    border-radius: 12px;
    box-shadow: 0 16px 40px rgba(28, 25, 23, 0.22);
    min-width: 240px;
}

.custom-toast .fa-check-circle {
    color: #5eead4;
}

.custom-toast .fa-exclamation-circle {
    color: #fda4af;
}

/* ---------- Fullscreen ---------- */
body.is-fullscreen .navbar,
body.is-fullscreen .page-title,
body.is-fullscreen .faq-section,
body.is-fullscreen .footer,
body.is-fullscreen .ad-slot,
body.is-fullscreen .ad-slot-inline,
body.is-fullscreen ins.adsbygoogle {
    display: none !important;
}

body.is-fullscreen .main-content {
    padding: 0;
    min-height: 100vh;
}

body.is-fullscreen .main-content > .container {
    max-width: none;
    padding: 0;
}

body.is-fullscreen .editor-container {
    margin: 0;
    border: none;
    border-radius: 0;
    box-shadow: none;
    padding: 0.75rem;
    min-height: 100vh;
}

body.is-fullscreen .toolbar-actions {
    position: fixed;
    right: 16px;
    bottom: 16px;
    left: auto;
    z-index: 9999;
    margin: 0;
    padding: 0.55rem 0.65rem;
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(12px);
    border: 1px solid var(--md-line);
    border-radius: 999px;
    box-shadow: var(--md-shadow);
}

body.is-fullscreen #editor-container {
    height: calc(100vh - 72px) !important;
}

/* ---------- Privacy ---------- */
.privacy-page {
    padding: 2.5rem 0 4rem;
}

@media (min-width: 992px) {
    .privacy-page {
        max-width: 800px;
    }
}

.privacy-page h1 {
    font-weight: 800;
    letter-spacing: -0.04em;
    margin-bottom: 0.5rem;
}

.privacy-page h2 {
    font-size: 1.2rem;
    font-weight: 700;
    margin-top: 1.75rem;
    margin-bottom: 0.7rem;
}

.privacy-page p,
.privacy-page li {
    color: #57534e;
    line-height: 1.7;
}

.privacy-page footer {
    margin-top: 2.5rem;
    color: var(--md-muted);
}

/* ---------- Responsive ---------- */
@media (max-width: 768px) {
    :root {
        --md-nav-h: 64px;
    }

    .main-content {
        padding-top: 1.1rem;
    }

    .editor-container {
        padding: 0.85rem;
        border-radius: 14px;
    }

    .toolbar-actions {
        justify-content: stretch;
    }

    .btn-action,
    .btn-outline-action {
        flex: 1 1 calc(50% - 0.55rem);
        min-width: 0;
        padding: 0.62rem 0.7rem;
    }

    #editor-container {
        height: 560px;
    }

    .page-title p {
        font-size: 0.95rem;
    }

    .toast-container {
        left: 12px;
        right: 12px;
        top: 76px;
    }
}
