* {
    box-sizing: border-box;
}

:root {
    --bg: #f4f6fb;
    --surface: #ffffff;
    --surface-2: #f8fafc;
    --ink: #172033;
    --ink-2: #44516a;
    --muted: #73809a;
    --border: #e3e8f1;
    --border-strong: #cfd7e6;
    --primary: #2158e8;
    --primary-dark: #1745bd;
    --primary-soft: #eaf0ff;
    --green: #127a4b;
    --green-soft: #e7f7ef;
    --red: #b4233b;
    --red-soft: #fdecef;
    --amber: #8a5a00;
    --amber-soft: #fff5dc;
    --blue: #0b5a9e;
    --blue-soft: #e8f3ff;
    --radius: 14px;
    --radius-sm: 9px;
    --shadow: 0 10px 28px rgba(23, 32, 51, .06);
    --shadow-sm: 0 2px 8px rgba(23, 32, 51, .05);
    --font: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
}

html {
    min-height: 100%;
}

body {
    margin: 0;
    min-height: 100vh;
    background:
        radial-gradient(900px 420px at 15% -10%, #e8eeff 0%, rgba(232, 238, 255, 0) 70%),
        radial-gradient(700px 400px at 95% 0%, #e9fbf4 0%, rgba(233, 251, 244, 0) 65%),
        var(--bg);
    color: var(--ink);
    font-family: var(--font);
    font-size: 15px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

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

a:hover {
    text-decoration: underline;
}

h1, h2, h3 {
    margin: 0;
    line-height: 1.15;
    letter-spacing: -.02em;
}

h1 {
    font-size: clamp(1.6rem, 2.4vw, 2.1rem);
}

h2 {
    font-size: 1.06rem;
}

p {
    margin: 0;
}

code, .mono {
    font-family: var(--mono);
}

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

.small {
    font-size: .86rem;
}

.nowrap {
    white-space: nowrap;
}

.break-all {
    word-break: break-all;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    background: rgba(255, 255, 255, .88);
    border-bottom: 1px solid var(--border);
    backdrop-filter: blur(14px);
}

.topbar-inner {
    max-width: 1180px;
    margin: 0 auto;
    padding: 12px 22px;
    display: flex;
    align-items: center;
    gap: 22px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--ink);
    text-decoration: none !important;
    min-width: 220px;
}

.brand:hover {
    text-decoration: none;
}

.brand-icon {
    display: inline-grid;
    place-items: center;
    width: 38px;
    height: 38px;
    border-radius: 11px;
    background: linear-gradient(145deg, #3469ff, #143ec2);
    color: #fff;
    font-weight: 800;
    font-size: 1.15rem;
    box-shadow: 0 6px 16px rgba(33, 88, 232, .25);
    flex: 0 0 auto;
}

.brand-icon-lg {
    width: 52px;
    height: 52px;
    font-size: 1.5rem;
    border-radius: 15px;
}

.brand strong {
    display: block;
    font-size: .98rem;
    letter-spacing: -.01em;
}

.brand small {
    display: block;
    color: var(--muted);
    font-size: .76rem;
}

.main-nav {
    display: flex;
    align-items: center;
    gap: 4px;
    flex: 1;
}

.main-nav a {
    padding: 8px 13px;
    border-radius: 9px;
    color: var(--ink-2);
    font-size: .91rem;
    font-weight: 600;
}

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

.main-nav a.active {
    background: var(--primary-soft);
    color: var(--primary-dark);
}

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

.user-name {
    font-size: .86rem;
    color: var(--muted);
    font-weight: 600;
}

.container {
    max-width: 1180px;
    margin: 0 auto;
    padding: 30px 22px 60px;
}

.auth-container {
    display: grid;
    place-items: center;
    min-height: calc(100vh - 130px);
}

.page-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 22px;
}

.page-head p {
    margin-top: 4px;
}

.eyebrow {
    text-transform: uppercase;
    letter-spacing: .14em;
    font-size: .7rem;
    font-weight: 800;
    color: var(--primary);
    margin-bottom: 5px !important;
}

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    margin-bottom: 20px;
    overflow: hidden;
}

.card-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    padding: 18px 20px 0;
}

.card-title {
    margin: 0;
}

.card-body {
    padding: 18px 20px 20px;
}

.card-body > * + * {
    margin-top: 14px;
}

.grid {
    display: grid;
    gap: 20px;
}

.grid-2 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.grid-3 {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.grid-compose {
    grid-template-columns: minmax(280px, .9fr) minmax(0, 1.1fr);
}

.grid-post {
    grid-template-columns: minmax(280px, .85fr) minmax(0, 1.15fr);
}

.stat-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 16px;
    margin-bottom: 20px;
}

.stat-card {
    margin: 0;
    padding: 18px 18px 16px;
}

.stat-label {
    display: block;
    color: var(--muted);
    font-size: .8rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .06em;
}

.stat-value {
    display: block;
    font-size: 2rem;
    letter-spacing: -.04em;
    margin: 4px 0 2px;
}

.stat-inline {
    margin: 6px 0;
}

.stat-note {
    display: block;
    color: var(--muted);
    font-size: .8rem;
}

.setup-card {
    border-color: #cdd9ff;
    background: linear-gradient(180deg, #fff, #f7f9ff);
}

.checklist {
    display: grid;
    gap: 10px;
    margin-top: 12px;
}

.check-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
}

.check-row.done {
    background: var(--green-soft);
    border-color: #bfe8d3;
}

.check-row > div {
    flex: 1;
}

.check-row p {
    margin-top: 2px;
}

.check-mark {
    display: grid;
    place-items: center;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--primary-soft);
    color: var(--primary-dark);
    font-weight: 800;
    font-size: .85rem;
    flex: 0 0 auto;
}

.check-row.done .check-mark {
    background: #c9efdc;
    color: var(--green);
}

.button-row {
    display: flex;
    align-items: center;
    gap: 9px;
    flex-wrap: wrap;
}

.inline-form {
    display: inline;
    margin: 0;
}

.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 4px;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    min-height: 40px;
    padding: 9px 16px;
    border: 1px solid transparent;
    border-radius: 10px;
    font-family: inherit;
    font-size: .9rem;
    font-weight: 700;
    line-height: 1.1;
    cursor: pointer;
    transition: background .15s ease, border-color .15s ease, transform .05s ease, box-shadow .15s ease;
    text-decoration: none !important;
    white-space: nowrap;
}

.btn:active {
    transform: translateY(1px);
}

.btn-primary {
    background: var(--primary);
    color: #fff;
    box-shadow: 0 6px 14px rgba(33, 88, 232, .18);
}

.btn-primary:hover {
    background: var(--primary-dark);
}

.btn-secondary {
    background: var(--surface);
    border-color: var(--border-strong);
    color: var(--ink);
}

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

.btn-ghost {
    background: transparent;
    border-color: transparent;
    color: var(--ink-2);
}

.btn-ghost:hover {
    background: var(--surface-2);
}

.btn-success {
    background: var(--green);
    color: #fff;
}

.btn-success:hover {
    background: #0d623c;
}

.btn-danger {
    background: var(--red);
    color: #fff;
}

.btn-ghost-danger {
    background: transparent;
    border-color: #f2c8d0;
    color: var(--red);
}

.btn-ghost-danger:hover {
    background: var(--red-soft);
}

.btn-sm {
    min-height: 32px;
    padding: 6px 11px;
    font-size: .81rem;
    border-radius: 8px;
}

.btn-block {
    width: 100%;
}

.btn.is-loading {
    opacity: .7;
    cursor: wait;
}

.badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 9px;
    border-radius: 999px;
    font-size: .73rem;
    font-weight: 800;
    letter-spacing: .01em;
    white-space: nowrap;
}

.badge-success {
    background: var(--green-soft);
    color: var(--green);
}

.badge-danger {
    background: var(--red-soft);
    color: var(--red);
}

.badge-warning {
    background: var(--amber-soft);
    color: var(--amber);
}

.badge-info {
    background: var(--blue-soft);
    color: var(--blue);
}

.badge-neutral {
    background: #eef1f6;
    color: #53617a;
}

.alert {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 14px;
    padding: 13px 15px;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    margin-bottom: 18px;
    font-size: .91rem;
}

.alert-success {
    background: var(--green-soft);
    border-color: #bfe8d3;
    color: #0b5c39;
}

.alert-error {
    background: var(--red-soft);
    border-color: #f3c5ce;
    color: #8f1d32;
}

.alert-warning {
    background: var(--amber-soft);
    border-color: #f1ddae;
    color: #6f4900;
}

.alert-info {
    background: var(--blue-soft);
    border-color: #c9e2fa;
    color: #0b4e86;
}

.small-alert {
    margin: 0 0 12px;
    padding: 10px 12px;
    font-size: .84rem;
}

.alert-close {
    border: 0;
    background: transparent;
    color: inherit;
    font-size: 1.2rem;
    line-height: 1;
    cursor: pointer;
    opacity: .6;
    padding: 0;
}

.alert-close:hover {
    opacity: 1;
}

.error-list {
    margin: 6px 0 0;
    padding-left: 18px;
}

.field {
    display: grid;
    gap: 6px;
    margin-bottom: 14px;
}

.field:last-child {
    margin-bottom: 0;
}

.field label {
    font-size: .84rem;
    font-weight: 700;
    color: var(--ink-2);
}

input[type="text"],
input[type="url"],
input[type="password"],
input[type="file"],
select,
textarea {
    width: 100%;
    min-height: 42px;
    padding: 10px 12px;
    border: 1px solid var(--border-strong);
    border-radius: 9px;
    background: var(--surface);
    color: var(--ink);
    font: inherit;
    font-size: .92rem;
    outline: none;
    transition: border-color .15s ease, box-shadow .15s ease;
}

textarea {
    resize: vertical;
    min-height: 96px;
    font-family: var(--mono);
    font-size: .84rem;
}

input:focus,
select:focus,
textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(33, 88, 232, .12);
}

.help {
    color: var(--muted);
    font-size: .79rem;
    margin: 0;
}

.help.success-text {
    color: var(--green);
    font-weight: 600;
}

.info-box {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    padding: 11px 13px;
    border-radius: var(--radius-sm);
    background: var(--surface-2);
    border: 1px solid var(--border);
    color: var(--muted);
    font-size: .84rem;
}

.info-box strong {
    color: var(--ink-2);
}

.dropzone {
    position: relative;
    display: grid;
    place-items: center;
    min-height: 220px;
    padding: 18px;
    border: 2px dashed var(--border-strong);
    border-radius: var(--radius-sm);
    background: var(--surface-2);
    cursor: pointer;
    overflow: hidden;
    text-align: center;
}

.dropzone:hover {
    border-color: #a9bfff;
    background: #f7f9ff;
}

.dropzone.is-dragover {
    border-color: var(--primary);
    background: var(--primary-soft);
}

.dropzone input[type="file"] {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
}

.dropzone-empty {
    display: grid;
    justify-items: center;
    gap: 5px;
}

.dropzone-icon {
    display: grid;
    place-items: center;
    width: 46px;
    height: 46px;
    border-radius: 50%;
    background: var(--primary-soft);
    color: var(--primary);
    font-size: 1.6rem;
    font-weight: 500;
    margin-bottom: 4px;
}

.photo-preview {
    display: block;
    max-width: 100%;
    max-height: 380px;
    border-radius: 9px;
    object-fit: contain;
}

.post-photo {
    display: block;
    width: 100%;
    max-height: 420px;
    object-fit: contain;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
}

.meta-list {
    display: grid;
    gap: 0;
    margin: 0;
}

.meta-list > div {
    display: flex;
    justify-content: space-between;
    gap: 18px;
    padding: 9px 0;
    border-bottom: 1px solid var(--border);
}

.meta-list > div:last-child {
    border-bottom: 0;
}

.meta-list dt {
    color: var(--muted);
    font-size: .82rem;
    font-weight: 600;
}

.meta-list dd {
    margin: 0;
    text-align: right;
    font-size: .86rem;
    max-width: 62%;
    overflow-wrap: anywhere;
}

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

.table {
    width: 100%;
    border-collapse: collapse;
    font-size: .88rem;
}

.table th {
    text-align: left;
    padding: 11px 14px;
    background: var(--surface-2);
    border-top: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
    color: var(--muted);
    font-size: .73rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: .06em;
    white-space: nowrap;
}

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

.table tbody tr:last-child td {
    border-bottom: 0;
}

.table tbody tr:hover {
    background: #fbfcff;
}

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

.thumb {
    display: block;
    width: 54px;
    height: 42px;
    border-radius: 7px;
    object-fit: cover;
    background: var(--surface-2);
    border: 1px solid var(--border);
}

.truncate-cell {
    max-width: 300px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.empty {
    display: grid;
    justify-items: center;
    gap: 4px;
    padding: 28px 12px;
    text-align: center;
    color: var(--muted);
}

.empty strong {
    color: var(--ink-2);
}

.copy-row {
    display: flex;
    align-items: flex-start;
    gap: 9px;
}

.code-block {
    flex: 1;
    display: block;
    padding: 10px 12px;
    border-radius: 8px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    color: var(--ink-2);
    font-family: var(--mono);
    font-size: .8rem;
    word-break: break-all;
    white-space: pre-wrap;
}

.caption-preview {
    margin: 0;
    padding: 16px;
    border-radius: var(--radius-sm);
    background: #101727;
    color: #e6ecff;
    font-family: var(--mono);
    font-size: .84rem;
    line-height: 1.75;
    white-space: pre-wrap;
    word-break: break-all;
}

.status-line {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    background: var(--surface-2);
    border: 1px solid var(--border);
    font-size: .86rem;
}

.pagination {
    display: flex;
    gap: 5px;
    padding: 14px 20px 18px;
    flex-wrap: wrap;
}

.page-link {
    display: inline-grid;
    place-items: center;
    min-width: 34px;
    height: 34px;
    padding: 0 8px;
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--ink-2);
    font-size: .84rem;
    font-weight: 700;
}

.page-link:hover {
    background: var(--surface-2);
    text-decoration: none;
}

.page-link.active {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
}

.auth-shell {
    width: min(460px, 100%);
}

.auth-card {
    padding: 30px;
    box-shadow: var(--shadow);
}

.auth-card form {
    margin-top: 22px;
}

.auth-brand {
    display: flex;
    gap: 14px;
    align-items: flex-start;
}

.auth-brand h1 {
    font-size: 1.4rem;
    margin-bottom: 4px;
}

.auth-brand p {
    font-size: .87rem;
}

.auth-foot {
    margin-top: 20px;
    font-size: .78rem;
    text-align: center;
}

.error-shell {
    width: min(560px, 100%);
    margin: 8vh auto 0;
}

.error-card {
    padding: 30px;
}

.error-card h1 {
    margin-bottom: 10px;
}

.error-card .button-row {
    margin-top: 22px;
}

.site-footer {
    display: flex;
    justify-content: center;
    gap: 8px;
    padding: 20px;
    color: #98a3b8;
    font-size: .76rem;
}

.footer-dot {
    opacity: .6;
}

body.is-loading {
    cursor: progress;
}

@media (max-width: 900px) {
    .topbar-inner {
        flex-wrap: wrap;
        gap: 10px;
    }

    .brand {
        min-width: 0;
        flex: 1;
    }

    .main-nav {
        order: 3;
        width: 100%;
        overflow-x: auto;
        padding-bottom: 2px;
    }

    .grid-2,
    .grid-3,
    .grid-compose,
    .grid-post {
        grid-template-columns: 1fr;
    }

    .stat-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 620px) {
    .container {
        padding: 22px 14px 44px;
    }

    .topbar-inner {
        padding: 10px 14px;
    }

    .brand small {
        display: none;
    }

    .user-name {
        display: none;
    }

    .page-head {
        flex-direction: column;
    }

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

    .card-header,
    .card-body {
        padding-left: 15px;
        padding-right: 15px;
    }

    .auth-card,
    .error-card {
        padding: 22px;
    }

    .copy-row {
        flex-direction: column;
        align-items: stretch;
    }

    .form-actions {
        flex-direction: column-reverse;
    }

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