:root {
  color-scheme: light;
  --ink: #17212b;
  --muted: #65717e;
  --line: #dbe2e8;
  --canvas: #f4f7f9;
  --blue: #0d7ce8;
  --blue-dark: #075eb8;
  --green: #17875d;
  --danger: #b42318;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--canvas); color: var(--ink); }
button, input, textarea, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
a { color: inherit; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
.muted { color: var(--muted); }
.eyebrow { margin: 0; color: #8de6c4; font-size: .72rem; font-weight: 800; letter-spacing: .24em; text-transform: uppercase; }
.eyebrow.blue { color: var(--blue); }
.stack-lg { display: grid; gap: 1.25rem; }

body[data-page="login"] { height: 100dvh; overflow: hidden; }
.login-shell { height: 100dvh; display: grid; grid-template-columns: minmax(320px,.85fr) minmax(420px,1.15fr); background: white; overflow: hidden; }
.login-brand { display: flex; flex-direction: column; justify-content: center; padding: clamp(2rem,4vw,4.5rem); color: white; background: radial-gradient(circle at 20% 20%, #1689ec 0, transparent 28%), linear-gradient(145deg,#092f57,#071f39); }
.login-logo { width: min(100%, 13rem); height: auto; margin: 0 0 1.35rem; padding: .55rem .7rem; border-radius: .7rem; background: white; }
.login-panel-logo { display: block; width: min(100%, 10.5rem); height: auto; margin: 0 0 1.2rem; }
.login-brand h1 { margin: .65rem 0; font-size: clamp(2.6rem,4.4vw,4rem); line-height: .95; }
.login-brand p:not(.eyebrow) { max-width: 34rem; font-size: .96rem; line-height: 1.6; color: rgba(255,255,255,.8); }
.login-brand ul { display: grid; gap: .45rem; margin: 1.15rem 0 0; padding-left: 1.2rem; color: rgba(255,255,255,.78); font-size: .9rem; }
.login-panel { display: flex; flex-direction: column; justify-content: center; gap: 1.35rem; width: min(100%, 32rem); margin: auto; padding: 2rem; }
.login-panel h2 { margin: .4rem 0; font-size: 2.15rem; }
label { display: grid; gap: .5rem; color: var(--ink); font-size: .86rem; font-weight: 700; }
input, textarea, select { width: 100%; border: 1px solid var(--line); border-radius: .8rem; background: white; color: var(--ink); padding: .78rem .9rem; outline: none; transition: border-color .15s, box-shadow .15s; }
input:focus, textarea:focus, select:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(13,124,232,.12); }
textarea { resize: vertical; }
.form-error { margin: 0; border: 1px solid #f2b8b5; border-radius: .8rem; background: #fff0ef; color: var(--danger); padding: .8rem 1rem; }

.button { display: inline-flex; min-height: 2.65rem; align-items: center; justify-content: center; gap: .5rem; border: 1px solid transparent; border-radius: .75rem; padding: .65rem 1.05rem; font-weight: 800; text-decoration: none; cursor: pointer; transition: transform .15s, background .15s, opacity .15s; }
.button:hover { transform: translateY(-1px); }
.button:disabled { cursor: not-allowed; opacity: .5; transform: none; }
.button.primary { background: var(--blue); color: white; }
.button.primary:hover { background: var(--blue-dark); }
.button.secondary { border-color: #b9d9f7; background: #eaf5ff; color: var(--blue-dark); }
.button.ghost { border-color: var(--line); background: white; color: var(--ink); }
.button.full { width: 100%; }

.admin-header { position: sticky; top: 0; z-index: 20; min-height: 4.5rem; display: flex; align-items: center; justify-content: space-between; gap: 1.5rem; padding: .75rem clamp(1rem,3vw,2.5rem); border-bottom: 1px solid var(--line); background: rgba(255,255,255,.96); backdrop-filter: blur(16px); }
.admin-header nav { display: flex; align-items: center; gap: .8rem; }
.brand { display: inline-flex; align-items: center; gap: .75rem; text-decoration: none; }
.brand-logo { display: block; width: 10.5rem; height: auto; }
.brand-mark { display: grid; width: 2.7rem; height: 2.7rem; place-items: center; border-radius: .75rem; background: linear-gradient(145deg,var(--blue),#43a6ff); color: white; font-size: 1.35rem; font-weight: 900; }
.brand span:last-child { display: grid; }
.brand small { color: var(--muted); }
.signed-in { color: var(--muted); font-size: .88rem; }
.admin-main { width: min(100% - 2rem, 88rem); margin: auto; padding: 2.5rem 0 5rem; }
.page-heading, .panel-heading { display: flex; align-items: end; justify-content: space-between; gap: 1.5rem; }
.page-heading h1 { margin: .45rem 0 .25rem; font-size: clamp(2.2rem,5vw,3.5rem); }
.page-heading p, .panel-heading p { margin: 0; }
.stats-grid { display: grid; grid-template-columns: repeat(4,1fr); gap: 1rem; margin: 2rem 0; }
.stat-card { display: grid; gap: .6rem; border: 1px solid var(--line); border-radius: 1rem; background: white; padding: 1.2rem; box-shadow: 0 14px 36px rgba(23,33,43,.05); }
.stat-card span { color: var(--muted); font-size: .78rem; font-weight: 800; text-transform: uppercase; letter-spacing: .12em; }
.stat-card strong { font-size: 2rem; }
.panel { border: 1px solid var(--line); border-radius: 1.2rem; background: white; padding: 1.2rem; box-shadow: 0 18px 50px rgba(23,33,43,.06); }
.panel-heading { padding: .4rem .4rem 1.2rem; }
.panel-heading h2 { margin: 0 0 .3rem; }
.compact-search { width: min(100%,18rem); }
.table-wrap { overflow-x: auto; }
.article-table { width: 100%; border-collapse: collapse; }
.article-table th, .article-table td { padding: 1rem .8rem; border-top: 1px solid var(--line); text-align: left; vertical-align: middle; }
.article-table th { color: var(--muted); font-size: .72rem; letter-spacing: .12em; text-transform: uppercase; }
.article-table td:first-child { display: grid; gap: .25rem; min-width: 18rem; }
.article-table td small { color: var(--muted); }
.actions { white-space: nowrap; }
.actions a, .actions button { border: 0; background: none; color: var(--blue-dark); padding: .2rem .4rem; cursor: pointer; font-weight: 750; }
.actions button { color: var(--danger); }
.status { display: inline-flex; border-radius: 999px; padding: .32rem .65rem; background: #edf1f4; font-size: .75rem; font-weight: 800; }
.status.published { background: #e2f6ed; color: #11643f; }
.status.scheduled { background: #fff4d7; color: #7a5600; }
.status.archived { color: #68737d; }
.empty-state { padding: 3rem !important; text-align: center !important; color: var(--muted); }

.editor-header { display: grid; grid-template-columns: 1fr auto 1fr; }
.editor-header nav { justify-content: flex-end; }
.save-state { display: flex; align-items: center; gap: .5rem; color: var(--muted); font-size: .82rem; }
.save-state span:first-child { width: .55rem; height: .55rem; border-radius: 50%; background: #aab2b9; }
.save-state.saving span:first-child { background: #f0a400; animation: pulse 1s infinite; }
.save-state.saved span:first-child { background: var(--green); }
@keyframes pulse { 50% { opacity: .35; } }
.editor-shell { display: grid; grid-template-columns: minmax(0,1fr) 22rem; gap: 1.5rem; width: min(100% - 2rem, 92rem); margin: auto; padding: 2rem 0 6rem; align-items: start; }
.editor-canvas { min-width: 0; display: grid; gap: 1.5rem; border: 1px solid var(--line); border-radius: 1.2rem; background: white; padding: clamp(1.2rem,4vw,3rem); box-shadow: 0 18px 50px rgba(23,33,43,.05); }
.title-field textarea { overflow: hidden; border: 0; border-bottom: 1px solid var(--line); border-radius: 0; padding: .5rem 0 1rem; font-size: clamp(2rem,5vw,3.6rem); font-weight: 800; line-height: 1.05; box-shadow: none; }
.content-heading { display: flex; align-items: end; justify-content: space-between; padding-top: 1rem; border-top: 1px solid var(--line); }
.content-heading h2 { margin: 0 0 .3rem; }
.content-heading p { margin: 0; }
.blocks-container { display: grid; gap: 1rem; }
.editor-block { position: relative; border: 1px solid var(--line); border-radius: 1rem; background: #fbfcfd; padding: 1rem; }
.block-topbar { display: flex; align-items: center; justify-content: space-between; gap: .8rem; margin-bottom: .8rem; }
.block-type { color: var(--blue-dark); font-size: .72rem; font-weight: 850; letter-spacing: .12em; text-transform: uppercase; }
.block-actions { display: flex; gap: .25rem; }
.block-actions button { display: grid; width: 2rem; height: 2rem; place-items: center; border: 1px solid var(--line); border-radius: .55rem; background: white; cursor: pointer; }
.block-actions button:last-child { color: var(--danger); }
.rich-toolbar { display: flex; flex-wrap: wrap; gap: .35rem; margin-bottom: .55rem; }
.rich-toolbar button { min-width: 2.1rem; border: 1px solid var(--line); border-radius: .5rem; background: white; padding: .35rem .55rem; cursor: pointer; font-weight: 800; }
.rich-editor { min-height: 8rem; border: 1px solid var(--line); border-radius: .75rem; background: white; padding: .9rem; font-size: 1rem; line-height: 1.75; outline: none; }
.rich-editor:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(13,124,232,.1); }
.block-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: .8rem; }
.block-picker { display: flex; flex-wrap: wrap; gap: .5rem; border: 1px dashed #b9c9d6; border-radius: 1rem; background: #f7fbff; padding: 1rem; }
.block-picker button { border: 1px solid #c6def5; border-radius: .7rem; background: white; color: var(--blue-dark); padding: .6rem .75rem; cursor: pointer; font-weight: 750; }
.image-block-preview { display: flex; align-items: center; gap: 1rem; min-height: 6rem; border: 1px dashed var(--line); border-radius: .8rem; padding: .8rem; }
.image-block-preview img { width: 7rem; height: 5rem; border-radius: .6rem; object-fit: cover; }
.editor-sidebar { display: grid; gap: 1rem; position: sticky; top: 6rem; }
.editor-sidebar details { border: 1px solid var(--line); border-radius: 1rem; background: white; box-shadow: 0 14px 36px rgba(23,33,43,.04); }
.editor-sidebar summary { cursor: pointer; padding: 1rem; font-weight: 850; }
.sidebar-fields { display: grid; gap: 1rem; padding: 0 1rem 1rem; }
.sidebar-fields small { color: var(--muted); font-weight: 500; }
.checkbox { display: flex; grid-template-columns: auto 1fr; align-items: center; gap: .65rem; }
.checkbox input { width: 1.05rem; height: 1.05rem; }
.search-preview { display: grid; gap: .3rem; border: 1px solid var(--line); border-radius: .8rem; padding: .85rem; }
.search-preview strong { color: #5d1bb3; font-size: 1.05rem; line-height: 1.25; }
.search-preview span { color: #4b6c53; font-size: .72rem; overflow-wrap: anywhere; }
.search-preview p { margin: .2rem 0 0; color: #545b63; font-size: .78rem; line-height: 1.5; }
.revision-list { display: grid; gap: .55rem; padding: 0 1rem 1rem; }
.revision-item { display: flex; align-items: center; justify-content: space-between; gap: .5rem; border-top: 1px solid var(--line); padding-top: .65rem; font-size: .75rem; }
.revision-item button { border: 0; background: none; color: var(--blue-dark); cursor: pointer; font-weight: 750; }

/* Editorial workspace */
body[data-page="editor"] { background: #eef3f7; }
.editor-header { min-height: 5rem; border-bottom-color: #d4dde5; box-shadow: 0 8px 30px rgba(20,40,60,.06); }
.editor-header .brand-logo { width: 11.5rem; }
.editor-shell { grid-template-columns: minmax(0,1fr) 23.5rem; gap: 1.75rem; padding-top: 1.75rem; }
.editor-canvas { gap: 1.75rem; border: 0; border-radius: 1rem; padding: clamp(1.5rem,4vw,3.25rem); box-shadow: 0 14px 45px rgba(27,49,70,.07); }
.editor-intro { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding-bottom: 1.25rem; border-bottom: 1px solid var(--line); }
.editor-intro > div { display: flex; align-items: center; gap: .8rem; }
.editor-intro-mark { width: .28rem; height: 2.6rem; border-radius: 1rem; background: linear-gradient(var(--blue),#55b6ef); }
.editor-intro strong, .editor-intro small { display: block; }
.editor-intro strong { font-size: .95rem; }
.editor-intro small { margin-top: .2rem; color: var(--muted); }
.editor-shortcut { border-radius: 999px; background: #e5f5ed; color: #176743; padding: .42rem .72rem; font-size: .72rem; font-weight: 800; }
.title-field textarea { min-height: 5.5rem; color: #142332; letter-spacing: -.035em; }
.content-heading { padding: 1.4rem 0 .2rem; }
.content-heading h2 { font-size: 1.45rem; }
.blocks-container { gap: 1.25rem; }
.editor-block { border: 0; border-left: 3px solid #d5e7f7; border-radius: .35rem .9rem .9rem .35rem; background: #f8fafc; padding: 1.15rem 1.25rem; box-shadow: inset 0 0 0 1px #e2e9ef; transition: border-color .18s, box-shadow .18s, background .18s; }
.editor-block:focus-within { border-left-color: var(--blue); background: white; box-shadow: inset 0 0 0 1px #bcd8ef, 0 10px 28px rgba(25,73,112,.07); }
.block-topbar { margin-bottom: 1rem; }
.block-type { color: #1875b9; letter-spacing: .16em; }
.block-actions button { color: #617181; border-color: #d7e0e7; }
.block-actions button:hover { border-color: #94bfe2; background: #edf7ff; color: var(--blue-dark); }
.rich-toolbar { padding-bottom: .7rem; border-bottom: 1px solid #e2e8ed; }
.rich-toolbar button { border: 0; background: #eaf2f8; color: #30485b; }
.rich-editor { min-height: 7rem; border-color: #d7e0e7; line-height: 1.85; }
.block-picker { position: sticky; bottom: 1rem; z-index: 5; gap: .55rem; border: 1px solid #c7dbe9; background: rgba(246,251,255,.94); padding: .85rem; box-shadow: 0 12px 35px rgba(34,70,98,.12); backdrop-filter: blur(12px); }
.block-picker button { border: 0; border-radius: 999px; background: white; box-shadow: 0 1px 0 rgba(22,56,82,.08); }
.block-picker button:hover { background: var(--blue); color: white; }
.editor-sidebar { top: 6.5rem; }
.editor-sidebar details { overflow: hidden; border-color: #d8e2e9; border-radius: .85rem; box-shadow: 0 8px 24px rgba(27,49,70,.05); }
.editor-sidebar summary { position: relative; padding: 1rem 1.1rem; background: #f8fafc; list-style: none; }
.editor-sidebar summary::-webkit-details-marker { display: none; }
.editor-sidebar summary::after { content: "+"; position: absolute; right: 1.1rem; color: var(--muted); }
.editor-sidebar details[open] summary::after { content: "−"; }
.editor-sidebar details[open] summary { border-bottom: 1px solid var(--line); background: white; }
.sidebar-fields { padding: 1rem 1.1rem 1.2rem; }
.sidebar-fields label > span:first-child, .featured-image-control > span:first-child { font-size: .78rem; letter-spacing: .02em; }
.search-preview { border: 0; border-left: 3px solid var(--blue); border-radius: .3rem; background: #f7fafc; }
.count-good { color: #168052; font-weight: 800; }
.count-warning { color: var(--muted); font-weight: 700; }

.media-dialog { width: min(92vw,72rem); max-height: 88vh; border: 0; border-radius: 1.2rem; padding: 0; box-shadow: 0 30px 100px rgba(0,0,0,.28); }
.media-dialog::backdrop { background: rgba(6,23,40,.65); backdrop-filter: blur(4px); }
.dialog-heading { position: sticky; top: 0; z-index: 2; display: flex; align-items: start; justify-content: space-between; gap: 1rem; border-bottom: 1px solid var(--line); background: white; padding: 1.2rem; }
.dialog-heading h2, .dialog-heading p { margin: 0 0 .2rem; }
.dialog-heading button { border: 0; background: none; font-size: 2rem; cursor: pointer; }
.media-upload-form { display: grid; grid-template-columns: 1.2fr 1fr 1fr auto; gap: .8rem; align-items: end; border-bottom: 1px solid var(--line); background: #f7fbff; padding: 1rem 1.2rem; }
.media-grid { display: grid; grid-template-columns: repeat(auto-fill,minmax(150px,1fr)); gap: .8rem; padding: 1.2rem; overflow-y: auto; }
.media-card { position: relative; overflow: hidden; border: 2px solid transparent; border-radius: .8rem; background: #f1f4f6; text-align: left; }
.media-card:hover { border-color: var(--blue); }
.media-select { display: block; width: 100%; border: 0; background: transparent; padding: 0; cursor: pointer; text-align: left; }
.media-card img { display: block; width: 100%; aspect-ratio: 4/3; object-fit: cover; }
.media-card span { display: block; padding: .55rem; padding-right: 3.8rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .72rem; }
.media-delete { position: absolute; right: .35rem; bottom: .32rem; border: 0; border-radius: .45rem; background: #fff0ef; color: var(--danger); padding: .3rem .48rem; cursor: pointer; font-size: .68rem; font-weight: 800; }
.media-delete:hover { background: var(--danger); color: white; }
.media-delete:disabled { cursor: wait; opacity: .55; }
.toast { position: fixed; z-index: 100; right: 1rem; bottom: 1rem; max-width: min(90vw,24rem); transform: translateY(2rem); opacity: 0; border-radius: .8rem; background: var(--ink); color: white; padding: .85rem 1rem; transition: .2s; pointer-events: none; }
.toast.show { transform: none; opacity: 1; }
.toast.error { background: var(--danger); }

@media (max-width: 900px) {
  .login-shell { display: block; height: 100dvh; }
  .login-brand { display: none; }
  .login-panel { height: 100dvh; padding: 1.5rem; }
  .stats-grid { grid-template-columns: repeat(2,1fr); }
  .editor-header { grid-template-columns: 1fr auto; }
  .editor-header .save-state { display: none; }
  .editor-shell { grid-template-columns: 1fr; }
  .editor-sidebar { position: static; }
  .media-upload-form { grid-template-columns: 1fr; }
}
@media (max-width: 620px) {
  .admin-header { align-items: flex-start; flex-wrap: wrap; }
  .editor-header nav { width: 100%; display: grid; grid-template-columns: repeat(3,1fr); }
  .signed-in { display: none; }
  .page-heading, .panel-heading { align-items: stretch; flex-direction: column; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .block-grid { grid-template-columns: 1fr; }
}
