/* PLAY n FIT admin — light, high-contrast work UI with the site's green/lime brand accents. */
:root {
  --bg: #f4f6f3;
  --surface: #ffffff;
  --ink: #0e1a13;
  --muted: #56645a;
  --line: #d9e0da;
  --brand: #0e2418;
  --brand-2: #1f5a37;
  --lime: #c8ff3c;
  --focus: #2563eb;
  --ok-bg: #e7f6dc; --ok: #24601a;
  --warn-bg: #fff4d6; --warn: #7a5300;
  --err-bg: #fde8e8; --err: #a11b1b;
  --info-bg: #e6f0fb; --info: #1d4f86;
  --radius: 10px;
  --nav-w: 230px;
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  color-scheme: light;
}
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; } /* e.g. .field { display: flex } must not override hidden */
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font-size: 16px; line-height: 1.5; }
img { max-width: 100%; height: auto; }
a { color: var(--brand-2); }
h1 { font-size: clamp(1.5rem, 1.2rem + 1.2vw, 2rem); line-height: 1.2; margin: 0 0 .4em; }
h2 { font-size: 1.2rem; margin: 1.6em 0 .6em; }
code { background: #eef2ee; padding: .05em .35em; border-radius: 4px; font-size: .9em; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.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; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--surface); padding: 8px 12px; z-index: 50; }
.skip:focus { left: 8px; }
.muted, .hint { color: var(--muted); }
.hint { font-size: .875rem; margin: .3em 0 0; }
.lede { color: var(--muted); max-width: 70ch; margin-top: 0; }
.narrow { max-width: 560px; }

/* ---------- App shell ---------- */
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 16px; background: var(--brand); color: #fff; }
.brand { display: inline-flex; align-items: center; gap: 10px; color: inherit; text-decoration: none; font-weight: 700; letter-spacing: .01em; }
.brand small { font-weight: 500; opacity: .75; }
.brand__mark { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 8px; background: var(--lime); color: var(--brand); font-weight: 800; }
.brand--lg { font-size: 1.1rem; color: var(--brand); }
.topbar__user { display: flex; align-items: center; gap: 10px; min-width: 0; }
.topbar__name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: .9rem; }
.topbar form { margin: 0; }
.topbar .btn--ghost { color: #fff; border-color: rgb(255 255 255 / .4); background: transparent; }

.sidenav { background: var(--surface); border-bottom: 1px solid var(--line); }
.sidenav ul { list-style: none; margin: 0; padding: 6px 8px; display: flex; gap: 4px; overflow-x: auto; scrollbar-width: thin; }
.sidenav a { display: block; padding: 8px 12px; border-radius: 8px; color: var(--ink); text-decoration: none; white-space: nowrap; font-size: .95rem; }
.sidenav a:hover { background: #eef2ee; }
.sidenav a[aria-current="page"] { background: var(--brand); color: #fff; }
.main { padding: 20px 16px 48px; max-width: 1200px; }
.main:focus { outline: none; }

@media (min-width: 960px) {
  .sidenav { position: fixed; top: 56px; bottom: 0; left: 0; width: var(--nav-w); border-bottom: 0; border-right: 1px solid var(--line); overflow-y: auto; }
  .sidenav ul { flex-direction: column; padding: 12px; overflow: visible; }
  .sidenav__sep { margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--line); }
  .is-app .main { margin-left: var(--nav-w); padding: 28px 32px 64px; }
}

/* ---------- Auth pages ---------- */
.is-auth .main { max-width: none; min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.auth-card { width: 100%; max-width: 420px; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 28px 24px; box-shadow: 0 10px 40px -20px rgb(0 0 0 / .25); }
.auth-card--wide { max-width: 560px; }
.is-auth .alert { max-width: 420px; width: 100%; }

/* ---------- Buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 44px; padding: 8px 16px; border-radius: 8px; border: 1px solid transparent; font: inherit; font-weight: 600; text-decoration: none; cursor: pointer; line-height: 1.2; }
.btn--sm { min-height: 36px; padding: 6px 12px; font-size: .875rem; }
.btn--block { width: 100%; }
.btn--primary { background: var(--brand); color: #fff; }
.btn--primary:hover { background: var(--brand-2); }
.btn--secondary { background: var(--lime); color: var(--brand); border-color: #a9d92b; }
.btn--ghost { background: var(--surface); color: var(--ink); border-color: var(--line); }
.btn--ghost:hover { border-color: var(--muted); }
.btn--link { background: none; color: var(--brand-2); text-decoration: underline; padding-inline: 6px; }
.btn--danger { background: var(--err); color: #fff; }
.btn--danger-ghost { background: var(--surface); color: var(--err); border-color: #f0c2c2; }
.row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.row form { margin: 0; }
.row--tight { gap: 6px; flex-wrap: nowrap; }

/* ---------- Alerts / badges ---------- */
.alert { padding: 12px 14px; border-radius: var(--radius); margin: 0 0 16px; border: 1px solid transparent; }
.alert ul { margin: .4em 0 0; padding-left: 1.2em; }
.alert--success { background: var(--ok-bg); color: var(--ok); border-color: #c4e6ae; }
.alert--error { background: var(--err-bg); color: var(--err); border-color: #f3c0c0; }
.alert--info { background: var(--info-bg); color: var(--info); border-color: #c3d8f2; }
.alert a { color: inherit; font-weight: 600; }
.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: .78rem; font-weight: 700; white-space: nowrap; }
.badge--published { background: var(--ok-bg); color: var(--ok); }
.badge--draft { background: var(--warn-bg); color: var(--warn); }
.badge--admin { background: var(--lime); color: var(--brand); }
.badge--editor { background: #dfe7ff; color: #233a8a; }

/* ---------- Cards / tiles ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 20px; margin: 0 0 20px; }
.card--protected { border-color: #e9c86b; background: #fffdf5; }
.stack > * + * { margin-top: 14px; }
.page-head { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 8px; }
.crumbs { margin: 0 0 6px; font-size: .9rem; }
.tiles { list-style: none; padding: 0; margin: 16px 0; display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 210px), 1fr)); }
.tile { display: flex; flex-direction: column; gap: 6px; height: 100%; padding: 16px; border-radius: 14px; background: var(--surface); border: 1px solid var(--line); color: var(--ink); text-decoration: none; }
.tile:hover { border-color: var(--brand-2); box-shadow: 0 6px 20px -12px rgb(0 0 0 / .35); }
.tile__label { font-weight: 700; font-size: 1.05rem; }
.tile__meta, .tile__nums { color: var(--muted); font-size: .9rem; display: flex; flex-wrap: wrap; gap: 4px 14px; }
.tile__nums strong { color: var(--ink); }
.activity { list-style: none; padding: 0; margin: 0; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; }
.activity li { padding: 10px 14px; border-top: 1px solid var(--line); font-size: .92rem; }
.activity li:first-child { border-top: 0; }
.activity time { color: var(--muted); margin-right: 6px; }
.empty { padding: 28px; text-align: center; background: var(--surface); border: 1px dashed var(--line); border-radius: 14px; color: var(--muted); }

/* ---------- Forms ---------- */
.field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.field > label, fieldset > legend { font-weight: 600; }
legend { padding: 0 4px; font-weight: 700; font-size: 1.05rem; }
fieldset { margin: 0; }
input[type=text], input[type=email], input[type=password], input[type=url], input[type=search], input[type=number], input[type=date], input[type=datetime-local], select, textarea {
  width: 100%; min-height: 44px; padding: 9px 12px; border: 1px solid #b9c4bc; border-radius: 8px; background: #fff; color: var(--ink); font: inherit;
}
textarea { resize: vertical; min-height: 88px; }
input[type=file] { font: inherit; padding: 8px 0; max-width: 100%; }
.has-error input, .has-error select, .has-error textarea { border-color: var(--err); }
.error { color: var(--err); font-weight: 600; font-size: .9rem; margin: .2em 0 0; }
.req { color: var(--err); }
.check, .radio { display: flex; align-items: flex-start; gap: 8px; font-weight: 500; cursor: pointer; }
.check input, .radio input { width: 20px; height: 20px; margin-top: 2px; flex: none; }
.form-grid { display: grid; gap: 18px; grid-template-columns: 1fr; }
.form-grid > legend { margin-bottom: 4px; }
@media (min-width: 760px) {
  .form-grid { grid-template-columns: 1fr 1fr; }
  .form-grid .field--textarea, .form-grid .field--markdown, .form-grid .field--image, .form-grid .field--pdf, .form-grid .field--checkbox, .form-grid .publish-box, .form-grid .form-actions, .form-grid__full { grid-column: 1 / -1; }
}
.publish-box { border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; display: grid; gap: 8px; }
.form-actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; padding-top: 4px; }
.media-current { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; padding: 10px; border: 1px solid var(--line); border-radius: 10px; background: #fafcfa; }
.media-current img { width: 120px; height: 90px; object-fit: cover; border-radius: 6px; }
.char-count { font-size: .8rem; color: var(--muted); text-align: right; margin: 2px 0 0; }
.char-count.is-over { color: var(--err); font-weight: 700; }
.live-value { font-size: .85rem; color: var(--muted); margin: 4px 0 0; overflow-wrap: anywhere; }
.diff { margin: 0; padding-left: 1.2em; }
.diff del { color: var(--err); }
.diff ins { color: var(--ok); text-decoration: none; font-weight: 700; }

/* ---------- Toolbar / tables ---------- */
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0; }
.toolbar input[type=search] { flex: 1 1 220px; width: auto; }
.toolbar select { flex: 0 1 180px; width: auto; }
.table-wrap { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: .94rem; }
.table th, .table td { padding: 10px 12px; text-align: left; border-top: 1px solid var(--line); vertical-align: middle; }
.table thead th { border-top: 0; background: #f7f9f7; font-size: .82rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); white-space: nowrap; }
.table thead a { color: inherit; text-decoration: none; }
.table thead a.is-sorted { color: var(--ink); }
.table--compact td { font-size: .86rem; }
.cell-thumb img, .thumb-empty { display: block; width: 64px; height: 48px; object-fit: cover; border-radius: 6px; background: #e6ebe7; }
.cell-actions { white-space: nowrap; }
.cell-actions > *, .cell-actions form { display: inline-flex; margin: 2px; }
.cell-wrap { white-space: normal; overflow-wrap: anywhere; max-width: 320px; }
.inline-details { display: inline-block; }
.inline-details summary { list-style: none; }
.inline-details summary::-webkit-details-marker { display: none; }
.inline-details[open] form { margin-top: 6px; }
.pager { display: flex; flex-wrap: wrap; gap: 6px; margin: 16px 0; }
.pager a { display: inline-grid; place-items: center; min-width: 40px; min-height: 40px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); text-decoration: none; color: var(--ink); }
.pager a[aria-current="page"] { background: var(--brand); color: #fff; border-color: var(--brand); }

/* Phones: each table row becomes a card. */
@media (max-width: 719px) {
  .table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .table, .table tbody, .table tr, .table td { display: block; width: 100%; }
  .table tr { padding: 10px 12px; border-top: 1px solid var(--line); display: grid; grid-template-columns: auto 1fr; gap: 2px 12px; }
  .table tr:first-child { border-top: 0; }
  .table td { border: 0; padding: 3px 0; grid-column: 2; }
  .table td.cell-thumb { grid-column: 1; grid-row: 1 / span 3; }
  .table td[data-label]::before { content: attr(data-label) ': '; color: var(--muted); font-size: .8rem; }
  .table td.cell-actions { grid-column: 1 / -1; white-space: normal; padding-top: 8px; }
  .cell-wrap { max-width: none; }
  .row--tight { flex-wrap: wrap; }
  .topbar__name .badge { display: none; }
}

/* ---------- Preview ---------- */
.preview { max-width: 760px; }
.preview--article { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: clamp(18px, 4vw, 36px); }
.preview__img { display: block; width: 100%; max-height: 520px; object-fit: contain; background: #0e2418; border-radius: 10px; margin: 12px 0; }
.preview__video { position: relative; aspect-ratio: 16 / 9; margin: 12px 0; }
.preview__video iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; border-radius: 10px; }
.preview__title { margin-top: .3em; font-size: 1.5rem; }
.preview__meta { display: grid; grid-template-columns: minmax(110px, max-content) 1fr; gap: 6px 16px; margin: 0; }
.preview__meta dt { font-weight: 600; color: var(--muted); }
.preview__meta dd { margin: 0; overflow-wrap: anywhere; }
@media (max-width: 520px) { .preview__meta { grid-template-columns: 1fr; } .preview__meta dd { margin-bottom: 8px; } }
.kicker { text-transform: uppercase; letter-spacing: .08em; font-size: .78rem; font-weight: 700; color: var(--brand-2); margin: 0; }
.prose { font-size: 1.05rem; line-height: 1.7; overflow-wrap: anywhere; }
.prose blockquote { margin: 1em 0; padding: .4em 1em; border-left: 4px solid var(--lime); background: #f7faf2; }
.seo-preview { margin-top: 28px; padding: 14px; border: 1px dashed var(--line); border-radius: 10px; }
.seo-preview__title { color: #1a0dab; font-size: 1.15rem; margin: 0; }
.seo-preview__url { color: #006621; font-size: .85rem; margin: 2px 0; }
.seo-preview__desc { margin: 0; font-size: .92rem; color: #4d5156; }
