:root {
    --base: #1877f2;
    --accent: #42b72a;
    --page-bg: #f0f2f5;
    --surface: #ffffff;
    --surface-soft: #f7f8fa;
    --text: #1c1e21;
    --muted: #65676b;
    --border: #dfe3e8;
    --danger: #d93025;
    --warning: #b06000;
    --shadow: 0 1px 2px rgba(0,0,0,.12);
    --radius: 10px;
    --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; background: var(--page-bg); color: var(--text); font-family: var(--font); line-height: 1.5; }
a { color: var(--base); }
img { max-width: 100%; }
button, input, textarea, select { font: inherit; }
.topbar { position: sticky; top: 0; z-index: 50; height: 58px; background: var(--surface); box-shadow: 0 1px 4px rgba(0,0,0,.16); display: flex; align-items: center; }
.topbar-inner { width: min(1240px, 96%); margin: auto; display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); text-decoration: none; min-width: 0; }
.brand-logo, .brand-mark { display: grid; place-items: center; flex: 0 0 auto; width: 42px; height: 42px; border-radius: 50%; background: var(--base); color: white; font-weight: 800; font-size: 22px; overflow: hidden; }
.brand-logo img { width: 100%; height: 100%; object-fit: contain; }
.brand-name { font-size: 20px; font-weight: 750; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top-actions { display: flex; align-items: center; gap: 8px; }
.nav-pill { display: inline-flex; align-items: center; justify-content: center; min-height: 40px; padding: 0 15px; border: 0; border-radius: 20px; text-decoration: none; background: #e4e6eb; color: var(--text); font-weight: 650; cursor: pointer; }
.nav-pill.primary { background: var(--base); color: #fff; }
.nav-pill:hover { filter: brightness(.97); }
.feed-layout { width: min(1180px, 96%); margin: 24px auto; display: grid; grid-template-columns: 250px minmax(0, 680px) 250px; gap: 24px; align-items: start; }
.sidebar-card, .feed-card, .panel, .auth-card { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); border: 1px solid rgba(0,0,0,.04); }
.sidebar-card { padding: 18px; position: sticky; top: 82px; }
.sidebar-card h2, .sidebar-card h3 { margin: 0 0 8px; }
.sidebar-card p { margin: 6px 0; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.feed-column { min-width: 0; }
.feed-card { margin-bottom: 18px; overflow: hidden; }
.post-head { padding: 16px 18px 10px; display: flex; align-items: flex-start; gap: 11px; }
.avatar { width: 42px; height: 42px; border-radius: 50%; background: color-mix(in srgb, var(--base) 18%, white); color: var(--base); display: grid; place-items: center; font-weight: 800; text-transform: uppercase; }
.post-author { font-weight: 720; }
.post-meta { color: var(--muted); font-size: .84rem; }
.post-main { padding: 0 18px 16px; }
.post-title { margin: 5px 0 8px; font-size: clamp(1.35rem, 3vw, 1.85rem); line-height: 1.2; }
.post-title a { color: var(--text); text-decoration: none; }
.post-title a:hover { text-decoration: underline; }
.post-excerpt { color: #303235; margin: 0; }
.post-content { font-size: 1.02rem; overflow-wrap: anywhere; }
.post-content > :first-child { margin-top: 0; }
.post-content > :last-child { margin-bottom: 0; }
.post-content blockquote { margin: 1rem 0; padding: .7rem 1rem; border-left: 4px solid var(--base); background: var(--surface-soft); }
.post-content pre { overflow: auto; background: #111827; color: #f8fafc; padding: 14px; border-radius: 8px; }
.post-content code { background: #eef0f3; padding: 2px 5px; border-radius: 4px; }
.post-content pre code { background: transparent; padding: 0; }
.post-cover { width: 100%; max-height: 620px; object-fit: cover; display: block; background: #eef0f3; }
.post-footer { border-top: 1px solid var(--border); padding: 10px 18px; color: var(--muted); display: flex; gap: 12px; flex-wrap: wrap; font-size: .9rem; }
.tag { display: inline-flex; border-radius: 999px; background: #e7f3ff; color: #0a58b0; padding: 3px 9px; font-size: .78rem; font-weight: 700; }
.video-wrap { position: relative; width: 100%; padding-top: 56.25%; background: #000; }
.video-wrap iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.pagination { display: flex; align-items: center; justify-content: center; gap: 10px; margin: 24px 0; }
.pagination a, .pagination span { background: var(--surface); border: 1px solid var(--border); padding: 8px 12px; border-radius: 8px; text-decoration: none; }
.site-footer { width: min(1180px, 96%); margin: 20px auto 40px; padding: 20px; text-align: center; color: var(--muted); }

.auth-page { min-height: 100vh; display: grid; place-items: center; padding: 30px 15px; }
.auth-shell { width: min(460px, 100%); }
.auth-shell.wide { width: min(820px, 100%); }
.auth-card { padding: 26px; }
.auth-card > .brand-mark { margin: 0 auto 12px; }
.auth-card h1 { text-align: center; margin: 0 0 8px; }
.auth-card > p { text-align: center; }

.app-shell { width: min(1320px, 96%); margin: 24px auto 50px; display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 22px; align-items: start; }
.app-nav { position: sticky; top: 82px; background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 10px; }
.app-nav a { display: block; padding: 11px 12px; border-radius: 8px; text-decoration: none; color: var(--text); font-weight: 650; }
.app-nav a:hover, .app-nav a.active { background: #e7f3ff; color: var(--base); }
.app-content { min-width: 0; }
.panel { padding: 20px; margin-bottom: 18px; }
.panel h1, .panel h2, .panel h3 { margin-top: 0; }
.panel-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 15px; }

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.form-grid .full { grid-column: 1 / -1; }
label { display: block; font-weight: 650; font-size: .92rem; }
input[type="text"], input[type="password"], input[type="email"], input[type="number"], input[type="url"], input[type="color"], textarea, select {
    width: 100%; margin-top: 6px; border: 1px solid #ccd0d5; background: #fff; color: var(--text); border-radius: 7px; padding: 10px 11px; outline: none;
}
input:focus, textarea:focus, select:focus, [contenteditable="true"]:focus { border-color: var(--base); box-shadow: 0 0 0 3px color-mix(in srgb, var(--base) 20%, transparent); }
textarea { min-height: 130px; resize: vertical; }
input[type="checkbox"] { accent-color: var(--base); }
.button { border: 0; border-radius: 7px; padding: 10px 15px; font-weight: 700; cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.button.primary { background: var(--base); color: white; }
.button.secondary { background: #e4e6eb; color: var(--text); }
.button.accent { background: var(--accent); color: white; }
.button.danger { background: var(--danger); color: white; }
.button.warning { background: #f5a623; color: #2b2000; }
.button.small { padding: 7px 10px; font-size: .84rem; }
.action-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.notice { padding: 12px 14px; border-radius: 8px; margin: 12px 0; }
.notice.success { background: #e7f6ec; color: #176b34; }
.notice.error { background: #fde8e7; color: #9c2118; }
.notice.warning { background: #fff3d5; color: #7a4a00; }

.editor-toolbar { display: flex; gap: 5px; flex-wrap: wrap; padding: 8px; border: 1px solid #ccd0d5; border-bottom: 0; border-radius: 8px 8px 0 0; background: #f7f8fa; }
.editor-toolbar button { border: 1px solid #d5d8dc; background: white; min-width: 34px; height: 32px; border-radius: 5px; cursor: pointer; }
.editor-area { min-height: 330px; border: 1px solid #ccd0d5; border-radius: 0 0 8px 8px; padding: 15px; background: white; outline: none; overflow-wrap: anywhere; }
.editor-area:empty::before { content: attr(data-placeholder); color: #8a8d91; }
.image-preview { margin-top: 10px; max-width: 360px; border-radius: 8px; display: none; }
.image-preview.visible { display: block; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { color: var(--muted); font-size: .82rem; text-transform: uppercase; letter-spacing: .03em; }
.status { display: inline-flex; padding: 3px 8px; border-radius: 999px; font-size: .77rem; font-weight: 700; background: #e4e6eb; }
.status.published { background: #dcf4e4; color: #176b34; }
.status.pending { background: #fff2cf; color: #815000; }
.status.rejected, .status.hidden { background: #fde2e0; color: #9c2118; }
.status.draft { background: #e8ebef; color: #4e545b; }
.log-box { background: #10131a; color: #dce3ed; padding: 14px; border-radius: 8px; max-height: 420px; overflow: auto; white-space: pre-wrap; font-family: Consolas, Monaco, monospace; font-size: .82rem; }
hr { border: 0; border-top: 1px solid var(--border); margin: 10px 0; }
.code-block { background: #10131a; color: #eef4ff; padding: 15px; border-radius: 8px; overflow: auto; font-family: Consolas, Monaco, monospace; }

@media (max-width: 1050px) {
    .feed-layout { grid-template-columns: 220px minmax(0, 1fr); }
    .feed-layout > aside:last-child { display: none; }
}
@media (max-width: 760px) {
    .feed-layout { display: block; width: min(680px, 96%); }
    .feed-layout > aside { display: none; }
    .app-shell { display: block; }
    .app-nav { position: static; display: flex; overflow-x: auto; margin-bottom: 15px; }
    .app-nav a { white-space: nowrap; }
    .form-grid { grid-template-columns: 1fr; }
    .form-grid .full { grid-column: auto; }
    .brand-name { max-width: 150px; }
    .top-actions .hide-mobile { display: none; }
}
