:root {
  --ink: #11153d;
  --navy: #283574;
  --orange: #f39a2e;
  --orange-soft: #fde6c8;
  --bg: #f4f1ea;
  --panel: #fff;
  --muted: #646985;
  --line: #e2ddd2;
  --danger: #c2372b;
  --success: #1f7a4d;
  --radius: 16px;
  --display: 'Bricolage Grotesque', system-ui, sans-serif;
  --body: 'DM Sans', system-ui, sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--body); font-size: 15px; line-height: 1.5; -webkit-font-smoothing: antialiased; }
a { color: inherit; }
img { max-width: 100%; display: block; }
h1, h2 { font-family: var(--display); letter-spacing: -.03em; line-height: 1.1; margin: 0; }
h1 { font-size: 2.1rem; }
h2 { font-size: 1.05rem; letter-spacing: -.01em; }
p { margin: 0; }
hr { border: 0; height: 1px; background: var(--line); margin: 6px 0; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
:focus-visible { outline: 3px solid var(--orange); outline-offset: 2px; }

/* Topbar */
.topbar { display: flex; align-items: center; gap: 24px; padding: 10px 24px; background: var(--ink); color: #fff; }
.topbar-brand { display: flex; align-items: center; gap: 12px; text-decoration: none; }
.topbar-brand img { height: 38px; width: auto; background: #fff; border-radius: 10px; padding: 3px 8px; }
.topbar-brand span { font-family: var(--display); font-weight: 700; font-size: 1.05rem; }
.topbar-nav { display: flex; gap: 4px; margin-left: 12px; flex-wrap: wrap; }
.topbar-nav a { padding: 8px 14px; border-radius: 999px; text-decoration: none; font-weight: 600; color: #c9cde6; transition: background .2s, color .2s; }
.topbar-nav a:hover { background: rgba(255, 255, 255, .08); color: #fff; }
.topbar-nav a[aria-current="page"] { background: var(--orange); color: var(--ink); }
.topbar-logout { margin: 0 0 0 auto; }
.topbar-logout button { border: 1px solid rgba(255, 255, 255, .25); background: none; color: #fff; padding: 8px 16px; border-radius: 999px; font: inherit; font-weight: 600; cursor: pointer; }
.topbar-logout button:hover { background: rgba(255, 255, 255, .1); }

.admin-main { width: min(100% - 40px, 1240px); margin: 32px auto 80px; }
.page-title { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin-bottom: 26px; flex-wrap: wrap; }
.page-title p { margin-top: 6px; }
.page-title.compact { margin-bottom: 18px; }
.back { display: inline-block; margin-bottom: 8px; color: var(--muted); text-decoration: none; font-weight: 600; font-size: .9rem; }
.back:hover { color: var(--ink); }

/* Buttons */
.button { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 42px; padding: 9px 18px; border-radius: 999px; border: 1px solid var(--line); background: #fff; color: var(--ink); font: inherit; font-weight: 700; text-decoration: none; cursor: pointer; transition: background .2s, border-color .2s, transform .2s; white-space: nowrap; }
.button:hover { border-color: var(--ink); }
.button-primary { background: var(--ink); border-color: var(--ink); color: #fff; }
.button-primary:hover { background: var(--navy); }
.button-ghost { background: transparent; }
.button-danger { color: var(--danger); background: transparent; }
.button-danger:hover { background: var(--danger); border-color: var(--danger); color: #fff; }
.button-block { width: 100%; }

/* Notices */
.notice { margin-bottom: 20px; padding: 14px 18px; border-radius: 12px; font-weight: 600; border: 1px solid; }
.notice ul { margin: 0; padding-left: 18px; }
.notice-success { background: #e6f4ec; border-color: #b9e0c9; color: var(--success); }
.notice-error { background: #fbeae8; border-color: #f0c2bd; color: var(--danger); }

/* Fields */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.field > span { font-weight: 700; font-size: .86rem; }
.field input, .field textarea, .search { width: 100%; padding: 11px 14px; border-radius: 10px; border: 1px solid var(--line); background: #fff; font: inherit; color: var(--ink); transition: border-color .2s, box-shadow .2s; }
.field input:focus, .field textarea:focus, .search:focus { outline: none; border-color: var(--navy); box-shadow: 0 0 0 3px rgba(40, 53, 116, .14); }
.field input[type="file"] { padding: 9px; background: var(--bg); }
.field small { font-size: .8rem; }
.field .input-title { font-family: var(--display); font-size: 1.7rem; font-weight: 700; letter-spacing: -.02em; padding: 14px 16px; }
.check { display: flex; align-items: center; gap: 8px; margin: -6px 0 14px; font-weight: 600; font-size: .88rem; }
.stack { display: flex; flex-direction: column; }
.slug-field { display: flex; align-items: center; border: 1px solid var(--line); border-radius: 10px; background: #fff; overflow: hidden; }
.slug-field span { padding: 0 4px 0 12px; color: var(--muted); font-size: .9rem; }
.slug-field input { border: 0 !important; box-shadow: none !important; padding-left: 0 !important; }

/* Auth */
.admin-bare { background: var(--ink); background-image: radial-gradient(circle at 85% 10%, rgba(243, 154, 46, .35), transparent 40%), radial-gradient(circle at 10% 90%, rgba(40, 53, 116, .9), transparent 50%); min-height: 100vh; }
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 30px 16px; }
.auth-wrap > .notice { width: min(100%, 420px); }
.auth-card { width: min(100%, 420px); padding: 36px 32px; border-radius: 24px; background: #fff; box-shadow: 0 40px 80px -30px rgba(0, 0, 0, .5); }
.auth-card h1 { font-size: 1.9rem; margin-bottom: 8px; }
.auth-card > p { margin-bottom: 24px; }
.auth-logo { height: 64px; width: auto; margin-bottom: 22px; }
.auth-back { display: block; margin-top: 20px; text-align: center; color: var(--muted); font-weight: 600; text-decoration: none; }
.auth-back:hover { color: var(--ink); }

/* Dashboard */
.toolbar-row { display: flex; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.search { flex: 1; min-width: 220px; border-radius: 999px; padding-left: 18px; }
.segmented { display: inline-flex; padding: 4px; border-radius: 999px; background: #fff; border: 1px solid var(--line); }
.segmented button { border: 0; background: none; padding: 7px 14px; border-radius: 999px; font: inherit; font-weight: 600; color: var(--muted); cursor: pointer; }
.segmented button.active { background: var(--ink); color: #fff; }
.post-table { display: grid; gap: 10px; }
.post-row { display: grid; grid-template-columns: 84px minmax(0, 1fr) auto; gap: 18px; align-items: center; padding: 12px 16px 12px 12px; border-radius: var(--radius); background: var(--panel); border: 1px solid var(--line); }
.post-row[hidden] { display: none; }
.thumb { width: 84px; height: 60px; border-radius: 10px; overflow: hidden; background: linear-gradient(135deg, var(--navy), var(--ink)); }
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.info .title { display: block; font-family: var(--display); font-weight: 700; font-size: 1.12rem; letter-spacing: -.01em; text-decoration: none; margin-bottom: 4px; }
.info .title:hover { text-decoration: underline; }
.info .muted { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.actions { display: flex; gap: 8px; align-items: center; }
.actions form { margin: 0; }
.badge { display: inline-flex; padding: 2px 10px; border-radius: 999px; font-size: .75rem; font-weight: 700; }
.badge-published { background: #e6f4ec; color: var(--success); }
.badge-scheduled { background: #e7ebfb; color: var(--navy); }
.badge-draft { background: var(--orange-soft); color: #8a4b05; }
.empty { padding: 60px 30px; text-align: center; border: 2px dashed var(--line); border-radius: 20px; background: rgba(255, 255, 255, .5); }
.empty h2 { font-size: 1.6rem; margin-bottom: 8px; }
.empty p { margin-bottom: 20px; }
.empty-filter { padding: 20px; text-align: center; }

/* Panels */
.panel { padding: 20px; border-radius: var(--radius); background: var(--panel); border: 1px solid var(--line); margin-bottom: 16px; }
.panel h2 { margin-bottom: 14px; }
.panel.narrow { max-width: 520px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; }
.panel-head h2 { margin: 0; }
.panel-actions { display: grid; gap: 8px; }
.cover-preview { aspect-ratio: 16 / 10; border-radius: 12px; overflow: hidden; background: var(--bg); display: grid; place-items: center; margin-bottom: 14px; color: var(--muted); font-size: .88rem; border: 1px dashed var(--line); }
.cover-preview img { width: 100%; height: 100%; object-fit: cover; }

/* Editor */
.editor-layout { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 24px; align-items: start; }
.editor-side { position: sticky; top: 20px; }
.rte { border: 1px solid var(--line); border-radius: var(--radius); background: #fff; }
.rte-toolbar { position: sticky; top: 0; z-index: 5; display: flex; flex-wrap: wrap; gap: 4px; padding: 8px; border-bottom: 1px solid var(--line); border-radius: var(--radius) var(--radius) 0 0; background: #faf8f4; }
.rte-toolbar button { min-width: 36px; height: 34px; padding: 0 10px; border: 1px solid transparent; border-radius: 8px; background: none; font: inherit; font-size: .86rem; font-weight: 600; color: var(--ink); cursor: pointer; }
.rte-toolbar button:hover { background: #fff; border-color: var(--line); }
.rte-toolbar button.on { background: var(--ink); color: #fff; }
.rte-toolbar .sep { width: 1px; margin: 4px 4px; background: var(--line); }
.rte-area { position: relative; min-height: 480px; padding: 28px 32px; outline: none; }
.rte-area.uploading { opacity: .5; cursor: progress; }
.rte-area:empty::before, .rte-area > p:only-child:has(> br:only-child)::before { content: attr(data-placeholder); color: #a5a8bb; position: absolute; pointer-events: none; }
.rte-source { display: none; }
html:not(.js) .rte-source { display: block; width: 100%; min-height: 400px; border: 0; padding: 20px; font: 14px/1.5 ui-monospace, monospace; }
html:not(.js) .rte-toolbar, html:not(.js) .rte-area { display: none; }

.prose-admin { font-size: 1.06rem; line-height: 1.75; color: #2b2f52; }
.prose-admin > * { margin: 0 0 1em; }
.prose-admin h2 { font-size: 1.7rem; margin-top: 1.4em; }
.prose-admin h3 { font-family: var(--display); font-size: 1.3rem; letter-spacing: -.02em; margin-top: 1.2em; }
.prose-admin blockquote { margin-left: 0; padding-left: 20px; border-left: 4px solid var(--orange); font-style: italic; font-size: 1.2rem; }
.prose-admin a { color: var(--navy); text-decoration: underline; text-decoration-color: var(--orange); }
.prose-admin figure { margin: 1.2em 0; }
.prose-admin img { border-radius: 10px; }
.prose-admin hr { margin: 2em 0; }

@media (max-width: 980px) {
  .editor-layout { grid-template-columns: 1fr; }
  .editor-side { position: static; }
}
@media (max-width: 700px) {
  .topbar { flex-wrap: wrap; gap: 10px; padding: 10px 14px; }
  .topbar-nav { order: 3; width: 100%; margin: 0; }
  .admin-main { width: min(100% - 24px, 1240px); margin-top: 20px; }
  .post-row { grid-template-columns: 64px minmax(0, 1fr); }
  .thumb { width: 64px; height: 50px; }
  .actions { grid-column: 1 / -1; flex-wrap: wrap; }
  .rte-area { padding: 20px; min-height: 360px; }
}
