/* ---------- tokens ---------- */
:root {
  --bg: #f7f5f0;
  --surface: #ffffff;
  --surface-2: #efece5;
  --ink: #1a1a1f;
  --ink-2: #55555f;
  --ink-3: #8a8a94;
  --line: #e3dfd6;
  --accent: #0f6e63;
  --accent-ink: #ffffff;
  --accent-soft: #d9ece8;
  --danger: #b3261e;
  --warn: #8a5a00;
  --warn-soft: #fbe9c6;
  --radius: 14px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(20, 20, 30, .05), 0 6px 20px -8px rgba(20, 20, 30, .15);
  --shadow-lg: 0 2px 6px rgba(20, 20, 30, .06), 0 24px 48px -16px rgba(20, 20, 30, .25);
  --font: "Heebo", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #131316;
    --surface: #1d1d22;
    --surface-2: #26262c;
    --ink: #f1f0ec;
    --ink-2: #b7b6b0;
    --ink-3: #7e7d78;
    --line: #2f2f36;
    --accent: #4fc3b3;
    --accent-ink: #0b1f1c;
    --accent-soft: #163a35;
    --warn-soft: #3d2f0d;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px -8px rgba(0, 0, 0, .5);
    --shadow-lg: 0 2px 6px rgba(0, 0, 0, .4), 0 24px 48px -16px rgba(0, 0, 0, .6);
    color-scheme: dark;
  }
}

/* ---------- base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.55;
  color: var(--ink);
  background: var(--bg);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
main { flex: 1; padding-block: 2rem 4rem; }
a { color: var(--accent); text-decoration: none; }
img { max-width: 100%; display: block; }
h1, h2, h3 { line-height: 1.2; margin: 0; font-weight: 600; letter-spacing: -0.01em; }
p { margin: 0 0 1em; }
[x-cloak] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.container { width: min(1120px, 100% - 2.5rem); margin-inline: auto; }
.muted { color: var(--ink-3); font-size: .9rem; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .85em; }
.inline { display: inline; }

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: saturate(160%) blur(12px);
  -webkit-backdrop-filter: saturate(160%) blur(12px);
  border-bottom: 1px solid var(--line);
}
.topbar__inner { display: flex; align-items: center; justify-content: space-between; gap: 1rem; height: 64px; }
.brand { font-weight: 700; font-size: 1.15rem; color: var(--ink); letter-spacing: -0.01em; }
.topbar__nav { display: flex; align-items: center; gap: .25rem; }
.navlink {
  color: var(--ink-2); padding: .45rem .8rem; border-radius: 999px; font-weight: 500; font-size: .95rem;
  transition: background .15s, color .15s;
}
.navlink:hover, .navlink--active { background: var(--surface-2); color: var(--ink); }
.navlink--admin { color: var(--accent); }
.navlink--button { background: none; border: 0; font: inherit; cursor: pointer; }
.footer { border-top: 1px solid var(--line); padding: 1.5rem 0; color: var(--ink-3); font-size: .85rem; }

/* ---------- hero ---------- */
.hero { max-width: 68ch; margin-bottom: 2.5rem; }
.hero--center { text-align: center; margin-inline: auto; padding-top: 3rem; }
.hero__title { font-size: clamp(1.9rem, 4vw, 2.75rem); font-weight: 700; margin-bottom: .75rem; }
.hero__text { font-size: 1.1rem; color: var(--ink-2); }

/* ---------- pills ---------- */
.pills { display: flex; flex-wrap: wrap; gap: .5rem; margin-bottom: 1.75rem; }
.pill {
  padding: .4rem .95rem; border-radius: 999px; border: 1px solid var(--line);
  background: var(--surface); color: var(--ink-2); font-weight: 500; font-size: .92rem;
  transition: all .15s;
}
.pill:hover { border-color: var(--ink-3); color: var(--ink); }
.pill--active { background: var(--ink); color: var(--bg); border-color: var(--ink); }

/* ---------- catalog grid ---------- */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 1.5rem; }
@media (max-width: 560px) { .grid { grid-template-columns: repeat(2, 1fr); gap: .9rem; } .card__body { padding: .7rem .8rem .8rem; } .card__title { font-size: .92rem; } }
.card {
  display: flex; flex-direction: column; color: inherit;
  background: var(--surface); border-radius: var(--radius); overflow: hidden;
  border: 1px solid var(--line); box-shadow: var(--shadow);
  transition: transform .2s ease, box-shadow .2s ease;
}
.card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); }
.card__thumb { aspect-ratio: 1 / 1.3; background: var(--surface-2); overflow: hidden; position: relative; }
.card__thumb img { width: 100%; height: 100%; object-fit: cover; object-position: top; }
.card__thumb::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(to bottom, transparent 70%, rgba(0,0,0,.08));
}
.card__body { padding: .9rem 1rem 1rem; display: flex; flex-direction: column; gap: .45rem; }
.card__title { font-size: 1rem; font-weight: 600; line-height: 1.3; }
.card__meta { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; font-size: .85rem; }
.badge {
  display: inline-block; padding: .15rem .6rem; border-radius: 999px; font-size: .78rem; font-weight: 600;
  background: var(--accent-soft); color: var(--accent);
}
.badge--warn { background: var(--warn-soft); color: var(--warn); }
.empty { color: var(--ink-3); text-align: center; padding: 4rem 0; font-size: 1.1rem; }

/* ---------- detail ---------- */
.backlink { display: inline-flex; align-items: center; gap: .4rem; color: var(--ink-2); font-weight: 500; margin-bottom: 1.5rem; }
.backlink:hover { color: var(--ink); }
.backlink__arrow::before { content: "←"; }
[dir="rtl"] .backlink__arrow::before { content: "→"; }
.detail { display: grid; grid-template-columns: minmax(220px, 340px) 1fr; gap: 2.5rem; align-items: start; margin-bottom: 3rem; }
.detail__cover {
  background: var(--surface); border-radius: var(--radius); overflow: hidden;
  box-shadow: var(--shadow-lg); border: 1px solid var(--line);
}
.detail__title { font-size: clamp(1.6rem, 3.2vw, 2.3rem); margin: .5rem 0 .6rem; font-weight: 700; }
.detail__meta { display: flex; align-items: center; gap: .6rem; color: var(--ink-3); font-size: .92rem; margin-bottom: 1.25rem; }
.dot { width: 4px; height: 4px; border-radius: 50%; background: var(--ink-3); display: inline-block; }
.detail__text { font-size: 1.05rem; color: var(--ink-2); max-width: 62ch; }
.actions { display: flex; flex-wrap: wrap; gap: .6rem; margin-top: 1.5rem; }
.preview__title { font-size: 1.1rem; color: var(--ink-2); margin-bottom: .75rem; font-weight: 500; }
.preview__frame {
  border-radius: var(--radius); overflow: hidden; border: 1px solid var(--line); background: var(--surface-2);
  height: min(80vh, 900px);
}
.preview__frame iframe { width: 100%; height: 100%; border: 0; }
@media (max-width: 720px) {
  .detail { grid-template-columns: 1fr; gap: 1.5rem; }
  .detail__cover { max-width: 260px; margin-inline: auto; }
  .preview { display: none; }
}

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  padding: .65rem 1.2rem; border-radius: 999px; font: inherit; font-weight: 600; font-size: .95rem;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink); cursor: pointer;
  transition: all .15s; text-decoration: none;
}
.btn:hover { border-color: var(--ink-3); transform: translateY(-1px); }
.btn--primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn--primary:hover { filter: brightness(1.08); border-color: var(--accent); }
.btn--danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 40%, var(--line)); }
.btn--danger:hover { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn--block { width: 100%; }

/* ---------- admin ---------- */
.pagehead { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1.5rem; flex-wrap: wrap; }
.pagehead__title { font-size: 1.6rem; font-weight: 700; }
.count { color: var(--ink-3); font-weight: 400; font-size: 1.1rem; margin-inline-start: .3rem; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.5rem; box-shadow: var(--shadow); margin-bottom: 1.5rem; }
.panel__title { font-size: 1.05rem; margin-bottom: 1rem; }
.form__grid { display: grid; grid-template-columns: 1fr 1.4fr; gap: 1.5rem; align-items: start; }
@media (max-width: 860px) { .form__grid { grid-template-columns: 1fr; } }
.field { display: flex; flex-direction: column; gap: .35rem; margin-bottom: 1rem; }
.field__label { font-size: .85rem; font-weight: 600; color: var(--ink-2); }
.field--sm { max-width: 110px; }
.input {
  width: 100%; padding: .6rem .8rem; font: inherit; color: var(--ink);
  background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius-sm);
  transition: border-color .15s, box-shadow .15s;
}
.input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
textarea.input { resize: vertical; min-height: 6rem; }
.fields-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
@media (max-width: 560px) { .fields-2 { grid-template-columns: 1fr; } }
.check { display: flex; align-items: center; gap: .6rem; font-weight: 500; }
.check input { width: 18px; height: 18px; accent-color: var(--accent); }
.field-error { color: var(--danger); font-weight: 500; }

.langtabs { display: inline-flex; background: var(--surface-2); padding: 3px; border-radius: 999px; margin-bottom: 1rem; }
.langtabs__tab { border: 0; background: none; font: inherit; font-weight: 500; font-size: .9rem; padding: .35rem .9rem; border-radius: 999px; color: var(--ink-2); cursor: pointer; }
.langtabs__tab--active { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }
.langcols { display: grid; gap: 1.25rem; }
.langcols--both { grid-template-columns: 1fr 1fr; }
@media (max-width: 720px) { .langcols--both { grid-template-columns: 1fr; } }

.dropzone {
  display: flex; align-items: center; justify-content: center; text-align: center; cursor: pointer;
  min-height: 170px; padding: 1.5rem; border: 2px dashed var(--line); border-radius: var(--radius);
  background: var(--bg); color: var(--ink-2); transition: all .15s;
}
.dropzone:hover, .dropzone--over { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.dropzone--has { border-style: solid; border-color: var(--accent); }
.dropzone__icon { font-size: 2rem; line-height: 1; margin-bottom: .5rem; }
.dropzone__file { font-weight: 600; color: var(--ink); word-break: break-all; }
.dropzone__meta { font-size: .85rem; }
.current-file { display: flex; gap: 1rem; align-items: center; margin-top: 1rem; font-size: .9rem; }
.current-file__thumb { width: 64px; border-radius: 6px; border: 1px solid var(--line); }

.savebar { position: sticky; bottom: 0; margin-top: .5rem; padding: .75rem 0; background: color-mix(in srgb, var(--bg) 85%, transparent); backdrop-filter: blur(10px); border-top: 1px solid var(--line); }
.savebar__inner { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.savebar .actions { margin: 0; }
.danger-zone { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-top: 2rem; padding: 1rem 1.25rem; border: 1px solid color-mix(in srgb, var(--danger) 30%, var(--line)); border-radius: var(--radius); color: var(--ink-2); }

.list { display: flex; flex-direction: column; gap: .6rem; }
.row {
  display: grid; grid-template-columns: 52px 1fr auto; gap: 1rem; align-items: center; color: inherit;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: .7rem .9rem;
  transition: border-color .15s, box-shadow .15s;
}
.row:hover { border-color: var(--ink-3); box-shadow: var(--shadow); }
.row__thumb { width: 52px; aspect-ratio: 1/1.3; border-radius: 6px; overflow: hidden; background: var(--surface-2); }
.row__thumb img { width: 100%; height: 100%; object-fit: cover; object-position: top; }
.row__title { font-weight: 600; }
.row__sub { color: var(--ink-3); font-size: .85rem; }
.row__side { display: flex; align-items: center; gap: .75rem; flex-wrap: wrap; justify-content: flex-end; }
@media (max-width: 640px) { .row { grid-template-columns: 52px 1fr; } .row__side { grid-column: 1 / -1; justify-content: flex-start; } }
.empty-state { text-align: center; padding: 4rem 1rem; color: var(--ink-3); }
.empty-state .btn { margin-top: 1rem; }

.catform { display: grid; grid-template-columns: 1fr 1fr 110px auto; gap: 1rem; align-items: end; }
.catform--row { grid-template-columns: 1fr 1fr 110px 1fr auto; padding: 1rem 0; border-top: 1px solid var(--line); }
.catform .field { margin-bottom: 0; }
.catform .actions { margin: 0; }
@media (max-width: 860px) { .catform, .catform--row { grid-template-columns: 1fr 1fr; } .catform .actions, .catform > .btn { grid-column: 1 / -1; } }

.flashes { margin-bottom: 1.25rem; }
.flash { display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: .75rem 1rem; border-radius: var(--radius-sm); background: var(--accent-soft); color: var(--accent); font-weight: 500; }
.flash--error { background: color-mix(in srgb, var(--danger) 12%, var(--surface)); color: var(--danger); }
.flash__close { background: none; border: 0; font-size: 1.3rem; line-height: 1; cursor: pointer; color: inherit; }

.login { display: grid; place-items: center; min-height: 60vh; }
.login__card { width: min(380px, 100%); }
