:root {
    --bg: #f4f6fb;
    --surface: #ffffff;
    --surface-alt: #eef2f9;
    --border: #d8e0ec;
    --text: #1b2430;
    --text-muted: #64748b;
    --primary: #2f6df6;
    --primary-hover: #1f56d0;
    --primary-contrast: #ffffff;
    --success: #128a5b;
    --success-bg: #e2f6ee;
    --danger: #c0392b;
    --danger-bg: #fdecea;
    --warning: #a06a00;
    --warning-bg: #fdf3dc;
    --accent: #7a5af8;
    --shadow: 0 1px 3px rgba(16, 24, 40, 0.08), 0 6px 18px rgba(16, 24, 40, 0.06);
}

[data-theme="dark"] {
    --bg: #10151d;
    --surface: #1a2130;
    --surface-alt: #222c3d;
    --border: #2e3a4e;
    --text: #e6ecf5;
    --text-muted: #94a3b8;
    --primary: #5b8dff;
    --primary-hover: #7aa2ff;
    --primary-contrast: #0b1016;
    --success: #4ade80;
    --success-bg: #14301f;
    --danger: #ff8b7d;
    --danger-bg: #3a1a17;
    --warning: #fbbf24;
    --warning-bg: #33280c;
    --accent: #a78bfa;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.5), 0 6px 18px rgba(0, 0, 0, 0.35);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 15px;
    line-height: 1.55;
}

a {
    color: var(--primary);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

.container {
    max-width: 1180px;
    margin: 0 auto;
    padding: 0 18px;
}

.site-header {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 20;
}

.site-header .inner {
    display: flex;
    align-items: center;
    gap: 18px;
    min-height: 62px;
}

.brand {
    font-size: 19px;
    font-weight: 700;
    color: var(--text);
    white-space: nowrap;
}

.brand span {
    color: var(--primary);
}

.nav {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    flex: 1;
}

.nav a {
    padding: 8px 12px;
    border-radius: 8px;
    color: var(--text-muted);
    font-weight: 500;
}

.nav a:hover {
    background: var(--surface-alt);
    text-decoration: none;
    color: var(--text);
}

.nav a.active {
    background: var(--primary);
    color: var(--primary-contrast);
}

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

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 9px 15px;
    border-radius: 8px;
    border: 1px solid transparent;
    background: var(--primary);
    color: var(--primary-contrast);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    transition: background 0.15s ease;
}

.btn:hover {
    background: var(--primary-hover);
    text-decoration: none;
}

.btn-secondary {
    background: var(--surface-alt);
    color: var(--text);
    border-color: var(--border);
}

.btn-secondary:hover {
    background: var(--border);
}

.btn-danger {
    background: transparent;
    color: var(--danger);
    border-color: var(--danger);
}

.btn-danger:hover {
    background: var(--danger-bg);
}

.btn-sm {
    padding: 6px 11px;
    font-size: 13px;
}

.btn-block {
    width: 100%;
}

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 20px;
    box-shadow: var(--shadow);
}

.section {
    margin: 22px 0;
}

.section-title {
    font-size: 21px;
    font-weight: 700;
    margin: 0 0 14px;
}

.muted {
    color: var(--text-muted);
}

.field {
    margin-bottom: 14px;
}

.field label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 5px;
    color: var(--text-muted);
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
select,
textarea {
    width: 100%;
    padding: 9px 11px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
    color: var(--text);
    font-size: 14px;
    font-family: inherit;
}

input:focus,
select:focus,
textarea:focus {
    outline: 2px solid var(--primary);
    outline-offset: -1px;
}

textarea {
    resize: vertical;
    min-height: 88px;
}

.catalog-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(255px, 1fr));
    gap: 16px;
}

.series-card {
    position: relative;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    box-shadow: var(--shadow);
}

.series-card h3 {
    margin: 0;
    font-size: 16px;
    line-height: 1.35;
}

.series-card .original {
    font-size: 12.5px;
}

.series-card .meta {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    font-size: 12.5px;
    color: var(--text-muted);
}

.series-card .description {
    font-size: 13.5px;
    color: var(--text-muted);
    margin: 0;
    flex: 1;
}

.card-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-top: auto;
}

.rating {
    font-weight: 700;
    color: var(--accent);
    font-size: 14px;
    white-space: nowrap;
}

.tags {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
}

.tag {
    display: inline-block;
    padding: 2px 9px;
    border-radius: 999px;
    background: var(--surface-alt);
    border: 1px solid var(--border);
    font-size: 12px;
    color: var(--text-muted);
}

.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
    border: 1px solid transparent;
}

.badge-watching {
    background: var(--primary);
    color: var(--primary-contrast);
}

.badge-completed {
    background: var(--success-bg);
    color: var(--success);
    border-color: var(--success);
}

.badge-dropped {
    background: var(--danger-bg);
    color: var(--danger);
    border-color: var(--danger);
}

.badge-planned {
    background: var(--warning-bg);
    color: var(--warning);
    border-color: var(--warning);
}

.filters {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 12px;
    align-items: end;
}

.filters .field {
    margin-bottom: 0;
}

.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin: 26px 0;
}

.pagination .page-info {
    font-size: 14px;
    color: var(--text-muted);
}

.pagination .disabled {
    opacity: 0.45;
    pointer-events: none;
}

.alert {
    padding: 11px 15px;
    border-radius: 8px;
    margin-bottom: 16px;
    font-size: 14px;
    border: 1px solid transparent;
}

.alert-success {
    background: var(--success-bg);
    color: var(--success);
    border-color: var(--success);
}

.alert-error {
    background: var(--danger-bg);
    color: var(--danger);
    border-color: var(--danger);
}

.alert-info {
    background: var(--surface-alt);
    color: var(--text-muted);
    border-color: var(--border);
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

th, td {
    text-align: left;
    padding: 11px 12px;
    border-bottom: 1px solid var(--border);
}

th {
    font-size: 12.5px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
}

.stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
    gap: 12px;
}

.stat {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 14px;
    text-align: center;
}

.stat .value {
    font-size: 24px;
    font-weight: 700;
    color: var(--primary);
}

.stat .label {
    font-size: 12.5px;
    color: var(--text-muted);
}

.detail-header {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    align-items: flex-start;
}

.detail-header .main {
    flex: 1;
    min-width: 280px;
}

.detail-header h1 {
    margin: 0 0 6px;
    font-size: 27px;
}

.side-panel {
    width: 320px;
    flex-shrink: 0;
}

@media (max-width: 760px) {
    .side-panel {
        width: 100%;
    }
}

.review {
    border-bottom: 1px solid var(--border);
    padding: 14px 0;
}

.review:last-child {
    border-bottom: none;
}

.review-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 6px;
}

.review-author {
    font-weight: 600;
}

.auth-wrapper {
    max-width: 430px;
    margin: 46px auto;
}

.auth-wrapper h1 {
    text-align: center;
    margin-bottom: 20px;
}

.auth-switch {
    text-align: center;
    margin-top: 16px;
    font-size: 14px;
    color: var(--text-muted);
}

.status-up {
    color: var(--success);
    font-weight: 700;
}

.status-down {
    color: var(--danger);
    font-weight: 700;
}

.status-dot {
    display: inline-block;
    width: 9px;
    height: 9px;
    border-radius: 50%;
    margin-right: 7px;
}

.status-dot.up {
    background: var(--success);
}

.status-dot.down {
    background: var(--danger);
}

.theme-toggle {
    background: var(--surface-alt);
    border: 1px solid var(--border);
    color: var(--text);
    border-radius: 8px;
    padding: 8px 11px;
    cursor: pointer;
    font-size: 14px;
    font-family: inherit;
}

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

.site-footer {
    margin-top: 46px;
    padding: 22px 0;
    border-top: 1px solid var(--border);
    color: var(--text-muted);
    font-size: 13.5px;
    text-align: center;
}

.empty-state {
    text-align: center;
    padding: 46px 20px;
    color: var(--text-muted);
}

.notice {
    font-size: 13px;
    color: var(--text-muted);
    margin-top: 8px;
}

/* ---------------------------------------------------------------- обложки */

.poster {
    width: 100%;
    height: auto;
    aspect-ratio: 2 / 3;
    object-fit: cover;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: var(--surface-alt);
    display: block;
}

.poster-link {
    display: block;
    line-height: 0;
}

.poster-small {
    width: 56px;
    border-radius: 6px;
}

.poster-large {
    width: 260px;
    flex-shrink: 0;
}

/* ------------------------------------------------------- ошибки полей формы */

.field-error {
    color: var(--danger);
    font-size: 12.5px;
    margin-top: 5px;
    line-height: 1.4;
}

input.invalid,
select.invalid {
    border-color: var(--danger);
    background: var(--danger-bg);
}

/* ------------------------------------------------------------------ вкладки */

.page-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
}

.page-head-title {
    display: flex;
    align-items: baseline;
    gap: 12px;
    flex-wrap: wrap;
}

.page-head-title .section-title {
    margin: 0;
}

.tabs {
    display: inline-flex;
    gap: 4px;
    padding: 4px;
    border-radius: 10px;
    background: var(--surface-alt);
    border: 1px solid var(--border);
}

.tab {
    padding: 7px 16px;
    border-radius: 7px;
    color: var(--text-muted);
    font-weight: 600;
    font-size: 14px;
}

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

.tab.active {
    background: var(--primary);
    color: var(--primary-contrast);
}

/* --------------------------------------------------------- формы дневника */

.meta-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    margin: 12px 0;
}

.diary-form {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
    gap: 12px;
    align-items: end;
}

.diary-form .field {
    margin-bottom: 0;
}

.diary-form .btn {
    width: 100%;
}

.diary-form-inline {
    margin-top: 10px;
    min-width: 220px;
}

.row-actions summary {
    cursor: pointer;
    font-size: 13px;
    color: var(--primary);
    font-weight: 600;
}

.overflow-x-auto {
    overflow-x: auto;
}

/* ------------------------------------------------------ админ: новый тайтл */

.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
    gap: 0 14px;
}

.poster-choice {
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 14px 16px;
    margin: 6px 0 18px;
}

.poster-choice legend {
    padding: 0 6px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
}

.radio-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 18px;
    margin-bottom: 14px;
    font-size: 14px;
}

.radio-row label {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    cursor: pointer;
}

input[type="file"] {
    width: 100%;
    padding: 8px 11px;
    border: 1px dashed var(--border);
    border-radius: 8px;
    background: var(--surface);
    color: var(--text);
    font-size: 14px;
    font-family: inherit;
}

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

/* ------------------------------------------------------ админ: иконки действий */

.admin-actions {
    position: absolute;
    top: 10px;
    right: 10px;
    z-index: 2;
    display: inline-flex;
    gap: 6px;
}

.admin-actions form {
    margin: 0;
    line-height: 0;
}

.admin-actions-inline {
    position: static;
    margin-left: auto;
    align-self: flex-start;
}

.detail-title-row {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 6px;
}

.detail-title-row h1 {
    margin: 0;
    flex: 1;
}

.icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    padding: 0;
    border: 1px solid rgba(255, 255, 255, 0.22);
    border-radius: 8px;
    background: rgba(15, 18, 24, 0.78);
    color: #fff;
    cursor: pointer;
    text-decoration: none;
    transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.icon-btn:hover {
    background: rgba(15, 18, 24, 0.95);
    border-color: rgba(255, 255, 255, 0.45);
    color: #fff;
}

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

/* ------------------------------------------------------ админ: обложка при редактировании */

.poster-editor {
    display: flex;
    gap: 18px;
    flex-wrap: wrap;
    align-items: flex-start;
}

.poster-preview {
    width: 120px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 12px;
    text-align: center;
}

.poster-preview img,
.poster-preview-empty {
    width: 120px;
    height: 170px;
    object-fit: cover;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--surface-alt);
}

.poster-preview-empty {
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
}

.poster-options {
    flex: 1;
    min-width: 240px;
}
