/* ========== CSS Variables / Themes ========== */
:root {
    --bg-primary: #ffffff;
    --bg-secondary: #f6f8fa;
    --bg-tertiary: #e8ecf0;
    --text-primary: #1f2328;
    --text-secondary: #656d76;
    --text-muted: #8b949e;
    --border: #d0d7de;
    --border-hover: #0969da;
    --accent: #0969da;
    --accent-light: rgba(9, 105, 218, 0.1);
    --code-bg: #f6f8fa;
    --blockquote-border: #d0d7de;
    --blockquote-text: #656d76;
    --table-border: #d0d7de;
    --table-row-alt: #f6f8fa;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.08);
    --radius: 12px;
    --dropzone-dash: var(--border);
    --dropzone-dash-hover: var(--accent);
    --header-bg: rgba(255, 255, 255, 0.85);
}

[data-theme="dark"] {
    --bg-primary: #0d1117;
    --bg-secondary: #161b22;
    --bg-tertiary: #21262d;
    --text-primary: #e6edf3;
    --text-secondary: #8b949e;
    --text-muted: #6e7681;
    --border: #30363d;
    --border-hover: #58a6ff;
    --accent: #58a6ff;
    --accent-light: rgba(88, 166, 255, 0.1);
    --code-bg: #161b22;
    --blockquote-border: #30363d;
    --blockquote-text: #8b949e;
    --table-border: #30363d;
    --table-row-alt: #161b22;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.4);
    --dropzone-dash: #30363d;
    --dropzone-dash-hover: #58a6ff;
    --header-bg: rgba(13, 17, 23, 0.85);
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Noto Sans', Helvetica, Arial, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    transition: background 0.3s ease, color 0.3s ease;
    line-height: 1.6;
}

/* ========== Header ========== */
.header {
    position: sticky;
    top: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 24px;
    background: var(--header-bg);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
    transition: background 0.3s ease, border-color 0.3s ease;
}

.header__left {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.header__icon {
    color: var(--accent);
    flex-shrink: 0;
}

.header__title {
    font-size: 1.15rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    white-space: nowrap;
}

.header__filename {
    font-size: 0.85rem;
    color: var(--text-muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.header__right {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* ========== Theme Toggle ========== */
.theme-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--bg-secondary);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s ease;
}

.theme-toggle:hover {
    border-color: var(--accent);
    color: var(--accent);
    background: var(--accent-light);
}

/* Light theme: show moon, hide sun */
.theme-toggle__icon--sun { display: none; }
.theme-toggle__icon--moon { display: block; }

/* Dark theme: show sun, hide moon */
[data-theme="dark"] .theme-toggle__icon--sun { display: block; }
[data-theme="dark"] .theme-toggle__icon--moon { display: none; }

/* ========== Main ========== */
.main {
    max-width: 900px;
    margin: 0 auto;
    padding: 32px 24px 64px;
}

/* ========== Dropzone ========== */
.dropzone {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: calc(100vh - 200px);
    border: 3px dashed var(--dropzone-dash);
    border-radius: var(--radius);
    background: var(--bg-secondary);
    transition: all 0.3s ease;
    cursor: pointer;
    position: relative;
}

.dropzone--active {
    border-color: var(--dropzone-dash-hover);
    background: var(--accent-light);
    transform: scale(1.01);
    box-shadow: 0 0 0 4px var(--accent-light);
}

.dropzone__content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    padding: 48px;
    text-align: center;
}

.dropzone__icon {
    color: var(--text-muted);
    opacity: 0.6;
    transition: all 0.3s ease;
}

.dropzone--active .dropzone__icon {
    color: var(--accent);
    opacity: 1;
    transform: translateY(-4px);
}

.dropzone__text {
    font-size: 1.25rem;
    color: var(--text-secondary);
}

.dropzone__text strong {
    color: var(--accent);
}

.dropzone__subtext {
    font-size: 0.85rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

.dropzone__button {
    display: inline-flex;
    align-items: center;
    padding: 10px 24px;
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.dropzone__button:hover {
    filter: brightness(1.15);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px var(--accent-light);
}

/* ========== Rendered Content ========== */
.rendered__toolbar {
    margin-bottom: 24px;
}

.rendered__back {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    background: var(--bg-secondary);
    color: var(--text-secondary);
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 0.85rem;
    font-family: inherit;
    cursor: pointer;
    transition: border-color 0.2s ease, color 0.2s ease;
    text-decoration: none;
    white-space: nowrap;
    flex-shrink: 0;
}

.rendered__back:hover {
    border-color: var(--accent);
    color: var(--accent);
}

/* ========== Markdown Body ========== */
.markdown-body {
    font-size: 16px;
    line-height: 1.75;
    word-wrap: break-word;
    animation: fadeIn 0.4s ease;
}

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

/* Headings */
.markdown-body h1,
.markdown-body h2,
.markdown-body h3,
.markdown-body h4,
.markdown-body h5,
.markdown-body h6 {
    margin-top: 1.5em;
    margin-bottom: 0.5em;
    font-weight: 700;
    line-height: 1.3;
    color: var(--text-primary);
}

.markdown-body h1 {
    font-size: 2em;
    padding-bottom: 0.3em;
    border-bottom: 2px solid var(--border);
}

.markdown-body h2 {
    font-size: 1.5em;
    padding-bottom: 0.25em;
    border-bottom: 1px solid var(--border);
}

.markdown-body h3 { font-size: 1.25em; }
.markdown-body h4 { font-size: 1em; }
.markdown-body h5 { font-size: 0.875em; }
.markdown-body h6 { font-size: 0.85em; color: var(--text-muted); }

/* Paragraphs */
.markdown-body p {
    margin-bottom: 1em;
}

/* Links */
.markdown-body a {
    color: var(--accent);
    text-decoration: none;
    border-bottom: 1px solid transparent;
    transition: border-color 0.2s;
}

.markdown-body a:hover {
    border-bottom-color: var(--accent);
}

/* Bold / Italic */
.markdown-body strong { font-weight: 700; }
.markdown-body em { font-style: italic; }

/* Lists */
.markdown-body ul,
.markdown-body ol {
    margin-bottom: 1em;
    padding-left: 2em;
}

.markdown-body li {
    margin-bottom: 0.35em;
}

.markdown-body li > ul,
.markdown-body li > ol {
    margin-bottom: 0;
}

/* Blockquote */
.markdown-body blockquote {
    margin: 0 0 1em;
    padding: 0.5em 1em;
    border-left: 4px solid var(--blockquote-border);
    color: var(--blockquote-text);
    background: var(--bg-secondary);
    border-radius: 0 var(--radius) var(--radius) 0;
}

.markdown-body blockquote > :last-child {
    margin-bottom: 0;
}

/* Code inline */
.markdown-body code {
    padding: 0.2em 0.45em;
    background: var(--code-bg);
    border-radius: 6px;
    font-size: 0.88em;
    font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
}

/* Code block */
.markdown-body pre {
    margin-bottom: 1em;
    padding: 16px;
    background: var(--code-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow-x: auto;
    position: relative;
}

.markdown-body pre code {
    padding: 0;
    background: none;
    border-radius: 0;
    font-size: 0.88em;
    line-height: 1.6;
}

/* Table */
.markdown-body table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 1em;
    overflow-x: auto;
    display: block;
}

.markdown-body th,
.markdown-body td {
    padding: 8px 16px;
    border: 1px solid var(--table-border);
    text-align: left;
}

.markdown-body th {
    background: var(--bg-tertiary);
    font-weight: 600;
}

.markdown-body tr:nth-child(even) {
    background: var(--table-row-alt);
}

/* Horizontal rule */
.markdown-body hr {
    height: 3px;
    margin: 2em 0;
    background: var(--border);
    border: none;
    border-radius: 2px;
}

/* Images */
.markdown-body img {
    max-width: 100%;
    height: auto;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin: 1em 0;
}

/* Checkbox */
.markdown-body input[type="checkbox"] {
    margin-right: 6px;
    accent-color: var(--accent);
}

/* ========== Scrollbar ========== */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-secondary);
}

::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* ========== Features Section ========== */
.features {
    margin-top: 48px;
    animation: fadeIn 0.6s ease;
}

.features__grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
}

.features__item {
    padding: 24px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    transition: border-color 0.2s ease;
}

.features__item:hover {
    border-color: var(--accent);
}

.features__icon {
    color: var(--accent);
    margin-bottom: 12px;
}

.features__title {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 6px;
}

.features__desc {
    font-size: 0.85rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

.features__desc a {
    color: var(--accent);
    text-decoration: none;
}

.features__desc a:hover {
    text-decoration: underline;
}

.features__cta {
    text-align: center;
    margin-top: 32px;
}

.features__link {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 24px;
    color: var(--accent);
    border: 1px solid var(--accent);
    border-radius: 8px;
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.2s ease;
}

.features__link:hover {
    background: var(--accent);
    color: #fff;
}

/* ========== Share Label ========== */
.share-label {
    display: block;
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 6px;
}

.share-label--mt {
    margin-top: 20px;
}

/* ========== Hidden state fix ========== */
[hidden] {
    display: none !important;
}

/* ========== Header Logo Link ========== */
.header__logo {
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    color: inherit;
}

/* ========== Action Buttons ========== */
.action-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    background: var(--bg-secondary);
    color: var(--text-secondary);
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
    white-space: nowrap;
}

.action-btn:hover {
    border-color: var(--accent);
    color: var(--accent);
    background: var(--accent-light);
}

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

.action-btn--primary:hover {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
    filter: brightness(1.12);
}

.action-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.action-btn__label {
    font-weight: 500;
}

/* ========== Action Menu (dropdown) ========== */
.action-menu {
    position: relative;
    display: inline-flex;
}

.action-menu__dropdown {
    position: absolute;
    top: calc(100% + 4px);
    right: 0;
    min-width: 200px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    z-index: 50;
    padding: 4px;
    animation: fadeIn 0.15s ease;
}

.action-menu__item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 10px 12px;
    background: none;
    border: none;
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 0.85rem;
    cursor: pointer;
    transition: background 0.15s ease;
    text-decoration: none;
}

.action-menu__item:hover {
    background: var(--accent-light);
    color: var(--accent);
}

/* ========== Drag-over overlay (when a file is dragged onto rendered view) ========== */
.rendered--drag-over::before {
    content: 'Отпустите для замены документа';
    position: fixed;
    inset: 0;
    z-index: 500;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    font-weight: 600;
    color: var(--accent);
    background: rgba(9, 105, 218, 0.12);
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
    border: 2px dashed var(--accent);
    pointer-events: none;
}

[data-theme="dark"] .rendered--drag-over::before {
    background: rgba(88, 166, 255, 0.12);
}

/* ========== Rendered Toolbar ========== */
.rendered__toolbar {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 24px;
    flex-wrap: wrap;
}

.rendered__filename {
    font-size: 0.85rem;
    color: var(--text-muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
    min-width: 0;
}

.rendered__actions {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

/* ========== View page actions ========== */
.view-actions {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 24px;
}

/* ========== Modal ========== */
.modal {
    position: fixed;
    inset: 0;
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
}

.modal__overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
}

.modal__content {
    position: relative;
    width: 100%;
    max-width: 520px;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    animation: fadeIn 0.2s ease;
}

.modal__content--sm {
    max-width: 360px;
}

.modal__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 24px;
    border-bottom: 1px solid var(--border);
}

.modal__title {
    font-size: 1rem;
    font-weight: 600;
}

.modal__close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.5rem;
    cursor: pointer;
    border-radius: 6px;
    transition: all 0.15s ease;
}

.modal__close:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.modal__body {
    padding: 24px;
}

.modal__hint {
    color: var(--text-muted);
    font-size: 0.9rem;
}

/* ========== Share components ========== */
.share-uploading {
    text-align: center;
    padding: 24px 0;
    color: var(--text-muted);
}

.spinner {
    width: 32px;
    height: 32px;
    border: 3px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    margin: 0 auto 12px;
    animation: spin 0.8s linear infinite;
}

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

.share-link-group {
    display: flex;
    gap: 8px;
    align-items: flex-start;
}

.share-link-input {
    flex: 1;
    min-width: 0;
    padding: 10px 12px;
    background: var(--bg-secondary);
    color: var(--text-primary);
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 0.9rem;
    font-family: inherit;
    outline: none;
}

.share-link-input:focus {
    border-color: var(--accent);
}

.share-link-input--code {
    font-family: 'SFMono-Regular', Consolas, monospace;
    font-size: 0.78rem;
    resize: none;
    line-height: 1.5;
}

.share-email-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 12px;
}

.share-email-input,
.share-email-message {
    padding: 10px 12px;
    background: var(--bg-primary);
    color: var(--text-primary);
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 0.9rem;
    font-family: inherit;
    outline: none;
}

.share-email-input:focus,
.share-email-message:focus {
    border-color: var(--accent);
}

.share-email-toggle {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    margin-top: 16px;
    padding: 0;
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 0.82rem;
    cursor: pointer;
    font-family: inherit;
    transition: color 0.15s;
}

.share-email-toggle:hover {
    color: var(--accent);
}

/* ========== Toast ========== */
.toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 0.9rem;
    z-index: 1000;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    animation: fadeIn 0.3s ease;
    color: #fff;
}

.toast--success { background: #2ea043; }
.toast--error { background: #e74c3c; }
.toast--info { background: var(--accent); }

/* ========== Error page (404) ========== */
.error-page {
    text-align: center;
    padding: 80px 0;
}

.error-page__code {
    font-size: 5rem;
    font-weight: 800;
    color: var(--text-muted);
    opacity: 0.3;
    line-height: 1;
    margin-bottom: 16px;
}

.error-page__title {
    font-size: 1.5rem;
    margin-bottom: 12px;
}

.error-page__text {
    color: var(--text-muted);
    margin-bottom: 32px;
}

.error-page__link {
    display: inline-flex;
    padding: 10px 24px;
    background: var(--accent);
    color: #fff;
    border-radius: 8px;
    text-decoration: none;
    font-weight: 600;
    transition: filter 0.2s;
}

.error-page__link:hover {
    filter: brightness(1.15);
}

/* ========== Password form ========== */
.password-form {
    max-width: 400px;
    margin: 80px auto;
    text-align: center;
}

.password-form__icon {
    color: var(--text-muted);
    margin-bottom: 24px;
}

.password-form__title {
    font-size: 1.25rem;
    margin-bottom: 24px;
}

.password-form__error {
    color: #e74c3c;
    font-size: 0.9rem;
    margin-bottom: 16px;
}

.password-form__input {
    width: 100%;
    padding: 12px 16px;
    background: var(--bg-secondary);
    color: var(--text-primary);
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 1rem;
    font-family: inherit;
    outline: none;
    margin-bottom: 16px;
}

.password-form__input:focus {
    border-color: var(--accent);
}

.password-form__submit {
    width: 100%;
    padding: 12px;
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: filter 0.2s;
}

.password-form__submit:hover {
    filter: brightness(1.15);
}

/* ========== Responsive ========== */
@media (max-width: 768px) {
    .main {
        padding: 16px 12px 48px;
    }

    .header {
        padding: 10px 16px;
    }

    .header__title {
        font-size: 1rem;
    }

    .dropzone {
        min-height: calc(100vh - 160px);
    }

    .dropzone__content {
        padding: 24px;
    }

    .dropzone__text {
        font-size: 1rem;
    }

    .markdown-body {
        font-size: 15px;
    }

    .markdown-body h1 { font-size: 1.6em; }
    .markdown-body h2 { font-size: 1.3em; }
    .markdown-body pre { padding: 12px; }

    .rendered__toolbar {
        gap: 8px;
    }

    .action-btn__label {
        display: none;
    }

    .view-actions {
        flex-wrap: wrap;
    }

    .share-link-group {
        flex-direction: column;
    }

    .modal__content {
        max-width: 100%;
    }

    .error-page__code {
        font-size: 3rem;
    }

    .features__grid {
        grid-template-columns: 1fr;
    }

    .features {
        margin-top: 32px;
    }
}

/* ========== Header auth elements ========== */
.header__auth-link {
    font-size: 0.875rem;
    color: var(--text-secondary);
    text-decoration: none;
    padding: 4px 2px;
    transition: color 0.15s;
}

.header__auth-link:hover {
    color: var(--accent);
}

.header__user-link {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-secondary);
    text-decoration: none;
    padding: 4px 2px;
    transition: color 0.15s;
}

.header__user-link:hover {
    color: var(--accent);
}

.header__logout-form {
    display: inline-flex;
}

.header__logout-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px 6px;
    border-radius: 6px;
    transition: color 0.15s, background 0.15s;
}

.header__logout-btn:hover {
    color: var(--text-primary);
    background: var(--bg-secondary);
}

/* ========== Auth modal close (outside box) ========== */
.auth-modal-wrap {
    position: relative;
    width: 100%;
    max-width: 360px;
}

.auth-modal-close {
    position: absolute;
    top: -40px;
    right: -4px;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    background: rgba(255,255,255,0.15);
    border: none;
    color: #fff;
    cursor: pointer;
    border-radius: 50%;
    transition: background 0.15s;
    z-index: 1;
}

.auth-modal-close:hover {
    background: rgba(255,255,255,0.25);
}

/* ========== Auth modal tabs ========== */
.auth-modal-header {
    padding: 16px 20px 0;
}

.auth-tabs {
    display: flex;
    gap: 0;
    border-bottom: 2px solid var(--border);
    flex: 1;
}

.auth-tab {
    background: none;
    border: none;
    padding: 10px 18px;
    font-size: 0.925rem;
    font-weight: 500;
    color: var(--text-muted);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: color 0.15s, border-color 0.15s;
}

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

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

/* ========== Auth forms (register / login) ========== */
.auth-form {
    max-width: 440px;
    margin: 64px auto;
    padding: 0 16px;
}

/* Inside modal the form needs no outer margin */
.modal .auth-form__field:first-child { margin-top: 4px; }

.auth-form__title {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 28px;
    text-align: center;
}

.auth-form__form {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.auth-form__field {
    display: flex;
    flex-direction: column;
    margin-bottom: 18px;
}

.auth-form__label {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.auth-form__input {
    padding: 11px 14px;
    background: var(--bg-secondary);
    color: var(--text-primary);
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 1rem;
    font-family: inherit;
    outline: none;
    transition: border-color 0.15s;
}

.auth-form__input:focus {
    border-color: var(--accent);
}

.auth-form__input--error {
    border-color: #e74c3c;
}

.auth-form__error {
    color: #e74c3c;
    font-size: 0.8rem;
    margin-top: 5px;
}

.auth-form__hint {
    color: var(--text-muted);
    font-size: 0.8rem;
    margin-top: 5px;
}

.auth-form__alert {
    background: rgba(231, 76, 60, 0.1);
    color: #e74c3c;
    border: 1px solid rgba(231, 76, 60, 0.3);
    border-radius: 8px;
    padding: 10px 14px;
    font-size: 0.9rem;
    margin-bottom: 18px;
}

.auth-form__success {
    background: rgba(39, 174, 96, 0.1);
    color: #27ae60;
    border: 1px solid rgba(39, 174, 96, 0.3);
    border-radius: 8px;
    padding: 10px 14px;
    font-size: 0.9rem;
    margin-bottom: 18px;
}

.auth-form__row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 18px;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.auth-form__submit {
    width: 100%;
    padding: 12px;
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: filter 0.2s;
    margin-top: 4px;
}

.auth-form__submit:hover {
    filter: brightness(1.12);
}

.auth-form__submit--danger {
    background: #e74c3c;
}

.auth-form__footer {
    text-align: center;
    margin-top: 20px;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.auth-form__footer a {
    color: var(--accent);
    text-decoration: none;
}

.auth-form__footer a:hover {
    text-decoration: underline;
}

/* ========== Dashboard ========== */
.dashboard {
    max-width: 900px;
    margin: 0 auto;
    padding: 32px 16px 64px;
}

.dashboard__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
    flex-wrap: wrap;
    gap: 12px;
}

.dashboard__title {
    font-size: 1.5rem;
    font-weight: 700;
}

.dashboard__count {
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-bottom: 12px;
}

.dashboard__empty {
    text-align: center;
    padding: 64px 0;
    color: var(--text-muted);
}

.dashboard__table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.dashboard__table th {
    text-align: left;
    padding: 10px 12px;
    border-bottom: 2px solid var(--border);
    color: var(--text-secondary);
    font-weight: 600;
    white-space: nowrap;
}

.dashboard__table td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

.dashboard__table tr:last-child td {
    border-bottom: none;
}

.dashboard__table tr:hover td {
    background: var(--bg-secondary);
}

.dashboard__cell-title {
    max-width: 360px;
}

.dashboard__cell-title a {
    color: var(--text-primary);
    text-decoration: none;
    font-weight: 500;
}

.dashboard__cell-title a:hover {
    color: var(--accent);
    text-decoration: underline;
}

.dashboard__lock {
    color: var(--text-muted);
    vertical-align: -2px;
    margin-right: 4px;
}

.dashboard__cell-date {
    white-space: nowrap;
    color: var(--text-secondary);
}

.dashboard__cell-views {
    white-space: nowrap;
    color: var(--text-secondary);
    text-align: right;
}

.dashboard__cell-actions {
    white-space: nowrap;
    text-align: right;
}

.action-btn--small {
    padding: 5px 10px;
    font-size: 0.8rem;
    border-radius: 6px;
}

.action-btn--danger {
    background: rgba(231, 76, 60, 0.1);
    color: #e74c3c;
    border: 1px solid rgba(231, 76, 60, 0.3);
}

.action-btn--danger:hover {
    background: rgba(231, 76, 60, 0.2);
}

/* ========== Pagination ========== */
.page-nav {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    margin-top: 32px;
}

.page-nav__btn {
    display: inline-flex;
    padding: 8px 18px;
    background: var(--bg-secondary);
    color: var(--text-primary);
    border: 1px solid var(--border);
    border-radius: 8px;
    text-decoration: none;
    font-size: 0.9rem;
    transition: border-color 0.15s, background 0.15s;
}

.page-nav__btn:hover {
    border-color: var(--accent);
    background: var(--accent-light);
}

.page-nav__info {
    font-size: 0.9rem;
    color: var(--text-muted);
}

/* ========== Settings page ========== */
.settings-page {
    max-width: 600px;
    margin: 0 auto;
    padding: 32px 16px 64px;
}

.settings-page__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 32px;
    gap: 16px;
}

.settings-page__title {
    font-size: 1.5rem;
    font-weight: 700;
    margin: 0 0 4px;
}

.settings-page__email {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin: 0;
}

.settings-section {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    margin-bottom: 24px;
}

.settings-section--danger {
    border-color: rgba(231, 76, 60, 0.4);
}

.settings-section__title {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 16px;
}

.settings-section__title--danger {
    color: #e74c3c;
}

.settings-section__current {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 16px;
}

.settings-section__desc {
    font-size: 0.875rem;
    color: var(--text-muted);
    margin-bottom: 16px;
}

@media (max-width: 600px) {
    .dashboard__cell-date,
    .dashboard__cell-views {
        display: none;
    }

    .dashboard__cell-title {
        max-width: 180px;
    }
}
