/* YYTSites — shared design system. No framework, no CDN. */

:root {
  --paper: #f4f0e6;
  --paper-2: #ebe6d8;
  --card: #fbf9f3;
  --ink: #1c1b18;
  --ink-2: #44413a;
  --muted: #7a7466;
  --line: #d8d1bf;
  --line-2: #c6bea8;
  --accent: #c8421b;
  --accent-ink: #fff;
  --ok: #2f6b3f;
  --warn: #8a5a00;
  --bad: #a3261a;
  --radius: 6px;
  --font-display: "Fraunces", "Iowan Old Style", Georgia, serif;
  --font-body: "Instrument Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: ui-monospace, "Cascadia Mono", Consolas, monospace;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 15px/1.55 var(--font-body);
  -webkit-font-smoothing: antialiased;
}
img, svg, iframe { display: block; max-width: 100%; }
a { color: inherit; }
h1, h2, h3, h4 { font-family: var(--font-display); font-weight: 500; letter-spacing: -0.015em; line-height: 1.1; margin: 0; }
p { margin: 0; }
code, .mono { font-family: var(--font-mono); font-size: 0.86em; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
[hidden] { display: none !important; }

.wrap { width: min(1180px, 100% - 40px); margin-inline: auto; }
.muted { color: var(--muted); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.icon { width: 16px; height: 16px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 9px 16px; border-radius: var(--radius);
  border: 1px solid var(--ink); background: var(--ink); color: var(--paper);
  font: 500 14px/1.2 var(--font-body); text-decoration: none; cursor: pointer;
  transition: background .15s, color .15s, border-color .15s;
}
.btn:hover { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.ghost { background: transparent; color: var(--ink); border-color: var(--line-2); }
.btn.ghost:hover { border-color: var(--ink); background: transparent; color: var(--ink); }
.btn.danger { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn.danger:hover { background: #7f1d14; border-color: #7f1d14; }
.btn.sm { padding: 6px 11px; font-size: 13px; }
.btn.icon-only { padding: 7px; }
.link { color: var(--ink); text-decoration: underline; text-decoration-color: var(--line-2); text-underline-offset: 3px; background: none; border: 0; padding: 0; font: inherit; cursor: pointer; }
.link:hover { text-decoration-color: var(--accent); color: var(--accent); }

/* ---------- Tags ---------- */
.tag { display: inline-block; padding: 1px 8px; border: 1px solid var(--line-2); border-radius: 99px; font-size: 12px; color: var(--ink-2); white-space: nowrap; }
.tag.db { border-color: var(--ink); color: var(--ink); }

/* ---------- Public: masthead / hero / grid ---------- */
.masthead { border-bottom: 1px solid var(--line); }
.masthead .wrap { display: flex; align-items: center; justify-content: space-between; height: 64px; }
.wordmark { font: 600 22px/1 var(--font-display); letter-spacing: -0.03em; text-decoration: none; }
.wordmark i { font-style: normal; color: var(--accent); }
.nav-inline { display: flex; gap: 24px; font-size: 14px; }
.nav-inline a { text-decoration: none; color: var(--ink-2); }
.nav-inline a:hover { color: var(--accent); }

.hero { padding: 72px 0 40px; display: grid; grid-template-columns: minmax(0, 1.7fr) minmax(0, 1fr); gap: 48px; align-items: end; }
.hero h1 { font-size: clamp(38px, 5.6vw, 68px); font-weight: 400; line-height: 1.02; }
.hero h1 em { font-style: italic; color: var(--accent); }
.hero p { color: var(--ink-2); max-width: 38ch; }
.hero .figures { margin-top: 20px; font: 13px var(--font-mono); color: var(--muted); }

.filters { display: flex; gap: 22px; overflow-x: auto; padding: 14px 0; border-block: 1px solid var(--line); margin-bottom: 36px; scrollbar-width: none; }
.filters::-webkit-scrollbar { display: none; }
.filters a { white-space: nowrap; text-decoration: none; font-size: 14px; color: var(--ink-2); padding-bottom: 2px; border-bottom: 2px solid transparent; }
.filters a sup { font: 11px var(--font-mono); color: var(--muted); margin-left: 3px; }
.filters a:hover { color: var(--accent); }
.filters a[aria-current="true"] { color: var(--ink); border-bottom-color: var(--accent); }

.grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 40px 28px; padding-bottom: 96px; }
.tpl { display: block; text-decoration: none; }
.thumb { position: relative; aspect-ratio: 16 / 10; overflow: hidden; background: var(--paper-2); border: 1px solid var(--line-2); border-radius: var(--radius); transition: border-color .2s, transform .2s; }
.thumb iframe { position: absolute; top: 0; left: 0; width: 1280px; max-width: none; height: 800px; border: 0; transform-origin: 0 0; pointer-events: none; background: #fff; opacity: 0; transition: opacity .4s; }
.thumb iframe.on { opacity: 1; }
.thumb .ph { position: absolute; inset: 0; display: grid; place-items: center; font: 400 54px var(--font-display); color: var(--line-2); }
.tpl:hover .thumb { border-color: var(--ink); transform: translateY(-3px); }
.tpl h3 { font-size: 21px; margin-top: 14px; }
.tpl .meta { margin-top: 6px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; font-size: 13px; color: var(--muted); }
.tpl .go { display: inline-flex; align-items: center; gap: 6px; margin-top: 10px; font-size: 13.5px; font-weight: 500; }
.tpl:hover .go { color: var(--accent); }

.empty { padding: 72px 0 120px; max-width: 46ch; }
.empty h3 { font-size: 28px; margin-bottom: 10px; }
.empty p { color: var(--ink-2); margin-bottom: 20px; }

.footer { border-top: 1px solid var(--line); padding: 22px 0; font-size: 13px; color: var(--muted); }

/* ---------- Admin shell ---------- */
.shell { display: grid; grid-template-columns: 232px minmax(0, 1fr); min-height: 100vh; }
.side { background: var(--paper-2); border-right: 1px solid var(--line); padding: 24px 20px; display: flex; flex-direction: column; gap: 28px; position: sticky; top: 0; height: 100vh; }
.side nav { display: flex; flex-direction: column; gap: 2px; }
.side nav a { display: block; padding: 8px 12px; margin-inline: -12px; text-decoration: none; color: var(--ink-2); border-left: 2px solid transparent; font-size: 14.5px; }
.side nav a:hover { color: var(--ink); background: rgba(0,0,0,.04); }
.side nav a[aria-current="page"] { color: var(--ink); border-left-color: var(--accent); font-weight: 600; }
.side .who { margin-top: auto; font-size: 13px; color: var(--muted); border-top: 1px solid var(--line-2); padding-top: 14px; }
.side .who strong { display: block; color: var(--ink); font-weight: 600; }
.main { padding: 36px clamp(20px, 4vw, 56px) 48px; min-width: 0; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 20px; flex-wrap: wrap; margin-bottom: 28px; padding-bottom: 20px; border-bottom: 1px solid var(--line); }
.page-head h1 { font-size: 34px; }
.page-head p { color: var(--muted); margin-top: 6px; max-width: 60ch; }
.admin-foot { margin-top: 56px; padding-top: 16px; border-top: 1px solid var(--line); font-size: 12.5px; color: var(--muted); display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; }

.flash { padding: 11px 14px; border: 1px solid; border-left-width: 4px; border-radius: var(--radius); margin-bottom: 22px; display: flex; justify-content: space-between; gap: 16px; background: var(--card); font-size: 14px; }
.flash.ok { border-color: var(--ok); }
.flash.err { border-color: var(--bad); }
.flash button { background: none; border: 0; font-size: 20px; line-height: 1; cursor: pointer; color: var(--muted); }

/* Figures row (replaces KPI cards) */
.figures-row { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); border-block: 1px solid var(--line); margin-bottom: 40px; }
.figure { padding: 20px 20px 20px 0; }
.figure + .figure { padding-left: 20px; border-left: 1px solid var(--line); }
.figure b { display: block; font: 400 46px/1 var(--font-display); letter-spacing: -0.03em; }
.figure span { display: block; margin-top: 8px; font-size: 13px; color: var(--muted); }

/* Tables */
.section-title { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 12px; }
.section-title h2 { font-size: 22px; }
.table-wrap { overflow-x: auto; }
table.t { width: 100%; border-collapse: collapse; font-size: 14px; }
table.t th { text-align: left; font: 600 12px var(--font-body); letter-spacing: .05em; text-transform: uppercase; color: var(--muted); padding: 10px 14px 10px 0; border-bottom: 1px solid var(--ink); white-space: nowrap; }
table.t td { padding: 14px 14px 14px 0; border-bottom: 1px solid var(--line); vertical-align: top; }
table.t tr:hover td { background: rgba(0,0,0,.02); }
table.t .name { font: 500 17px var(--font-display); }
table.t .sub { font: 12px var(--font-mono); color: var(--muted); margin-top: 2px; word-break: break-all; }
table.t .actions { white-space: nowrap; text-align: right; }
table.t .actions > * { margin-left: 4px; }

/* Forms */
.form { max-width: 760px; }
.form .block { padding: 26px 0; border-top: 1px solid var(--line); }
.form .block:first-child { border-top: 0; padding-top: 0; }
.form h2 { font-size: 20px; margin-bottom: 4px; }
.form .hint { font-size: 13px; color: var(--muted); margin-bottom: 16px; }
.row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.row.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.field { display: block; margin-bottom: 16px; }
.field > span, .field > .lbl { display: flex; justify-content: space-between; margin-bottom: 6px; font-size: 13px; font-weight: 600; color: var(--ink-2); }
.field small { font-size: 12px; color: var(--muted); font-weight: 400; }
input[type=text], input[type=password], input[type=search], select, textarea {
  width: 100%; padding: 10px 12px; background: var(--card); color: var(--ink);
  border: 1px solid var(--line-2); border-radius: var(--radius); font: inherit;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--ink); box-shadow: 0 0 0 3px rgba(200, 66, 27, .18); }
input.mono-in { font-family: var(--font-mono); font-size: 13.5px; }
.check { display: flex; gap: 12px; align-items: flex-start; cursor: pointer; }
.check input { margin-top: 4px; width: 17px; height: 17px; accent-color: var(--accent); }
.drop { position: relative; border: 1.5px dashed var(--line-2); border-radius: var(--radius); padding: 38px 24px; text-align: center; background: var(--card); transition: border-color .15s, background .15s; }
.drop:hover, .drop.over { border-color: var(--accent); background: #fff; }
.drop input { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; height: 100%; }
.drop strong { display: block; font: 500 20px var(--font-display); margin-bottom: 4px; }
.drop .picked { font-family: var(--font-mono); font-size: 13px; }
.sticky-actions { display: flex; justify-content: flex-end; gap: 10px; padding-top: 22px; border-top: 1px solid var(--ink); }

.toolbar { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; margin-bottom: 20px; }
.toolbar .field { margin: 0; flex: 1 1 180px; }

.result { border: 1px solid var(--ink); background: var(--card); padding: 28px; border-radius: var(--radius); }
.result h2 { font-size: 30px; margin: 6px 0 18px; }
.kv { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; padding: 16px 0; border-block: 1px solid var(--line); margin-bottom: 20px; font-size: 14px; }
.kv dt { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.kv dd { margin: 3px 0 0; font-weight: 500; word-break: break-word; }
.linkbox { display: flex; gap: 8px; flex-wrap: wrap; }
.linkbox code { flex: 1 1 260px; padding: 10px 12px; border: 1px solid var(--line-2); background: #fff; border-radius: var(--radius); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.report { margin-top: 20px; padding: 14px 16px; border-left: 3px solid var(--warn); background: #fff7e0; font-size: 13.5px; }
.report ul { margin: 8px 0 0; padding-left: 18px; }

/* Dialog */
dialog { border: 1px solid var(--ink); border-radius: 8px; background: var(--card); color: var(--ink); padding: 28px; width: min(440px, calc(100% - 32px)); box-shadow: 0 30px 80px -20px rgba(0,0,0,.35); }
dialog::backdrop { background: rgba(28, 27, 24, .45); }
dialog h3 { font-size: 24px; margin-bottom: 8px; }
dialog p { color: var(--ink-2); font-size: 14px; }
dialog .foot { display: flex; justify-content: flex-end; gap: 10px; margin-top: 22px; }
dialog .note { margin-top: 14px; padding: 10px 12px; background: #fbeae6; border-left: 3px solid var(--bad); font-size: 13px; }

/* Login */
.login { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.login .art { background: var(--ink); color: var(--paper); padding: 48px; display: flex; flex-direction: column; justify-content: space-between; }
.login .art h1 { font-size: clamp(34px, 4vw, 54px); font-weight: 400; line-height: 1.05; max-width: 14ch; }
.login .art h1 em { color: #f09a78; }
.login .art .wordmark i { color: #f09a78; }
.login .panel { display: grid; place-items: center; padding: 40px 24px; }
.login form { width: min(360px, 100%); }
.login form h2 { font-size: 30px; margin-bottom: 22px; }
.login .btn { width: 100%; justify-content: center; padding: 12px; }

/* ---------- Preview shell ---------- */
body.preview { height: 100vh; display: flex; flex-direction: column; overflow: hidden; background: var(--paper-2); }
.pbar { flex: none; height: 54px; display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 0 16px; background: var(--paper); border-bottom: 1px solid var(--line-2); }
.pbar .left, .pbar .right { display: flex; align-items: center; gap: 10px; min-width: 0; }
.pbar .title { font: 500 17px var(--font-display); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 30vw; }
.seg { display: inline-flex; border: 1px solid var(--line-2); border-radius: var(--radius); overflow: hidden; background: var(--card); }
.seg button { border: 0; background: transparent; padding: 7px 14px; font: 500 13px var(--font-body); color: var(--ink-2); cursor: pointer; }
.seg button + button { border-left: 1px solid var(--line-2); }
.seg button[aria-pressed="true"] { background: var(--ink); color: var(--paper); }
.stage { flex: 1; min-height: 0; display: flex; justify-content: center; align-items: stretch; padding: 0; transition: padding .3s; }
.stage.framed { padding: 22px; }
.device { position: relative; background: #fff; width: 100%; transition: width .3s cubic-bezier(.4,0,.2,1); overflow: hidden; border: 0; }
.stage.framed .device { border: 1px solid var(--ink); border-radius: 10px; box-shadow: 0 24px 60px -24px rgba(0,0,0,.35); }
.device iframe { width: 100%; height: 100%; border: 0; background: #fff; }
.loading { position: absolute; inset: 0; display: grid; place-items: center; background: var(--paper); font: italic 20px var(--font-display); color: var(--muted); transition: opacity .25s; }
.loading.done { opacity: 0; pointer-events: none; }
.cred { display: flex; justify-content: space-between; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); }
.cred:last-of-type { border-bottom: 0; }
.cred small { display: block; font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.cred span { font: 15px var(--font-mono); }
.contact-link { display: flex; justify-content: space-between; align-items: center; padding: 13px 0; border-bottom: 1px solid var(--line); text-decoration: none; }
.contact-link:hover strong { color: var(--accent); }
.contact-link strong { font: 500 18px var(--font-display); display: block; }
.contact-link span { font-size: 13px; color: var(--muted); }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 24px); opacity: 0; transition: .25s; background: var(--ink); color: var(--paper); padding: 10px 16px; border-radius: var(--radius); font-size: 13.5px; pointer-events: none; z-index: 50; }
.toast.show { transform: translate(-50%, 0); opacity: 1; }

/* Standalone notice pages (404, db error) */
.notice { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.notice .box { width: min(560px, 100%); }
.notice h1 { font-size: 40px; margin-bottom: 12px; }
.notice p { color: var(--ink-2); margin-bottom: 22px; }

/* ---------- Responsive ---------- */
@media (max-width: 960px) {
  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .hero { grid-template-columns: 1fr; gap: 20px; padding-top: 48px; }
  .figures-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .figure:nth-child(3) { border-left: 0; padding-left: 0; }
  .figure:nth-child(n+3) { border-top: 1px solid var(--line); }
  .login { grid-template-columns: 1fr; }
  .login .art { padding: 28px; min-height: 220px; }
}
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; gap: 10px 22px; padding: 14px 20px; border-right: 0; border-bottom: 1px solid var(--line); }
  .side nav { flex-direction: row; flex-wrap: wrap; gap: 0 4px; }
  .side nav a { margin: 0; border-left: 0; border-bottom: 2px solid transparent; padding: 6px 8px; }
  .side nav a[aria-current="page"] { border-bottom-color: var(--accent); }
  .side .who { margin: 0 0 0 auto; border: 0; padding: 0; }
  .row, .row.three, .kv { grid-template-columns: 1fr; }
}
@media (max-width: 620px) {
  .grid { grid-template-columns: 1fr; }
  .pbar .title, .pbar .hide-sm { display: none; }
  .stage.framed { padding: 0; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* ---------- Data editor ---------- */
.tabs { display: flex; gap: 6px 20px; flex-wrap: wrap; padding-bottom: 14px; margin-bottom: 26px; border-bottom: 1px solid var(--line); }
.tabs a { text-decoration: none; font: 13.5px var(--font-mono); color: var(--ink-2); padding-bottom: 2px; border-bottom: 2px solid transparent; }
.tabs a sup { color: var(--muted); margin-left: 3px; }
.tabs a:hover { color: var(--accent); }
.tabs a[aria-current="true"] { color: var(--ink); border-bottom-color: var(--accent); }
table.dbtable td { font-size: 13px; max-width: 280px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
table.dbtable th .kt { display: block; font: 400 10.5px var(--font-mono); text-transform: none; letter-spacing: 0; color: var(--muted); }
