:root {
  --ink: #1d2a2a;
  --muted: #5d6b6a;
  --line: #dde3e1;
  --bg: #f6f7f5;
  --card: #fff;
  --brand: #1f5f5b;
  --brand-ink: #fff;
  --accent: #f3c969;
  --danger: #a83232;
  --event: #3b6fb6;
  --activity: #7a4fa3;
  --core: #2f8a5b;
  --radius: 10px;
  --link: #1f5f5b;
  --chip: #e8ecea;
  --input-bg: #fff;
  --input-border: #c4ccca;
  --drop-border: #b9c4c1;
  --drop-bg: #fbfcfb;
  --drop-over: #eef5f4;
  --tip-bg: #1d2a2a;
  color-scheme: light;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--ink);
  background: var(--bg);
}
* { box-sizing: border-box; }
body { margin: 0; }
a { color: var(--link); }
h1 { font-size: 1.5rem; margin: 0 0 1rem; }
h2 { font-size: 1.15rem; margin: 1.5rem 0 .75rem; }
.loading, .muted { color: var(--muted); }
.small { font-size: .85rem; }

/* layout */
.shell { display: grid; grid-template-columns: 220px 1fr; min-height: 100vh; }
nav.side { background: var(--brand); color: var(--brand-ink); padding: 1rem; display: flex; flex-direction: column; gap: .25rem; }
nav.side .brand { font-weight: 700; font-size: 1.1rem; margin-bottom: .25rem; }
nav.side .org { font-size: .85rem; opacity: .8; margin-bottom: 1rem; }
nav.side a { color: var(--brand-ink); text-decoration: none; padding: .5rem .75rem; border-radius: 8px; }
nav.side a:hover, nav.side a.active { background: rgba(255,255,255,.14); }
nav.side .spacer { flex: 1; }
nav.side .who { font-size: .85rem; opacity: .85; padding: .5rem .75rem; }
main { padding: 1.5rem 2rem; max-width: 1200px; width: 100%; }
nav.side .menu-btn { display: none; }
nav.side .links { display: flex; flex-direction: column; gap: .25rem; flex: 1; }
@media (max-width: 800px) {
  .shell { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  nav.side { padding: .6rem 1rem; gap: 0; }
  nav.side .top { display: flex; align-items: center; justify-content: space-between; }
  nav.side .brand { margin: 0; }
  nav.side .menu-btn { display: block; background: none; border: 1px solid rgba(255,255,255,.4); color: #fff; padding: .35rem .7rem; font-size: 1.1rem; line-height: 1; }
  nav.side .links { display: none; flex-direction: column; gap: .15rem; padding-top: .6rem; }
  nav.side.open .links { display: flex; }
  nav.side .spacer, nav.side .org { display: none; }
  nav.side .who { border-top: 1px solid rgba(255,255,255,.2); margin-top: .4rem; padding-top: .7rem; }
  main { padding: 1rem; }
}

/* components */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem 1.25rem; }
.row { display: flex; gap: .75rem; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.grid { display: grid; gap: 1rem; }
.stats { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
.stat .n { font-size: 1.8rem; font-weight: 700; }
.stat .l { color: var(--muted); font-size: .9rem; }

button, .btn {
  font: inherit; border: 1px solid var(--brand); background: var(--brand); color: var(--brand-ink);
  padding: .5rem .9rem; border-radius: 8px; cursor: pointer; text-decoration: none; display: inline-block;
}
button.secondary, .btn.secondary { background: var(--card); color: var(--link); border-color: var(--link); }
button.danger { background: var(--card); color: var(--danger); border-color: var(--danger); }
button.link { background: none; border: none; color: var(--link); padding: 0; text-decoration: underline; }
button:disabled { opacity: .5; cursor: default; }

form.stack { display: grid; gap: .9rem; max-width: 640px; }
form.card + form.card { margin-top: 1rem; }
.fields { display: grid; gap: .9rem; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
label { display: grid; gap: .3rem; font-weight: 600; font-size: .92rem; }
label.check { display: flex; gap: .5rem; align-items: flex-start; font-weight: 400; }
label .hint { font-weight: 400; color: var(--muted); font-size: .82rem; }
input, select, textarea { font: inherit; padding: .5rem .6rem; border: 1px solid var(--input-border); border-radius: 8px; background: var(--input-bg); color: var(--ink); width: 100%; }
label.check input { width: auto; margin-top: .2rem; }
textarea { min-height: 110px; resize: vertical; }
fieldset { border: 1px solid var(--line); border-radius: var(--radius); padding: .75rem 1rem; }
legend { font-weight: 600; padding: 0 .3rem; }
.radios { display: flex; gap: 1rem; flex-wrap: wrap; }
.radios label { display: flex; gap: .4rem; align-items: center; font-weight: 400; }
.radios input { width: auto; }
.hidden, [hidden] { display: none !important; }
.error { color: var(--danger); }

table { width: 100%; border-collapse: collapse; background: var(--card); }
th, td { text-align: left; padding: .55rem .6rem; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: .85rem; color: var(--muted); font-weight: 600; }
td.num, th.num { text-align: right; }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); }

.tag { display: inline-block; font-size: .78rem; padding: .1rem .5rem; border-radius: 999px; color: #fff; white-space: nowrap; }
.tag.event { background: var(--event); }
.tag.activity { background: var(--activity); }
.tag.core_service { background: var(--core); }
.tag.plain { background: var(--chip); color: var(--ink); }

.filters { display: flex; gap: .5rem; flex-wrap: wrap; margin-bottom: 1rem; }
.filters > * { width: auto; }

.eng-list { display: grid; gap: .75rem; }
.eng { display: grid; grid-template-columns: 96px 1fr auto; gap: 1rem; align-items: center; text-decoration: none; color: inherit; }
.eng:hover { border-color: var(--link); }
.eng .thumb { width: 96px; height: 72px; border-radius: 8px; background: var(--chip) center/cover no-repeat; object-fit: cover; }
.eng .title { font-weight: 600; }
.eng .figs { text-align: right; font-size: .88rem; color: var(--muted); }
@media (max-width: 600px) { .eng { grid-template-columns: 72px 1fr; } .eng .figs { grid-column: 1 / -1; text-align: left; } .eng .thumb { width: 72px; height: 56px; } }

.gallery { display: grid; gap: .75rem; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); }
.tile { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; display: flex; flex-direction: column; }
.tile .media { aspect-ratio: 4/3; background: #111; cursor: zoom-in; display: block; width: 100%; object-fit: cover; border: 0; padding: 0; }
.tile .media img, .tile .media video { width: 100%; height: 100%; object-fit: cover; display: block; }
.tile .meta { padding: .5rem .6rem; font-size: .82rem; display: grid; gap: .3rem; }
.badge { position: relative; }
.badge::after { content: "▶"; position: absolute; inset: 0; display: grid; place-items: center; color: #fff; font-size: 2rem; text-shadow: 0 0 8px #000; pointer-events: none; }

.dropzone { border: 2px dashed var(--drop-border); border-radius: var(--radius); padding: 1rem; background: var(--drop-bg); }
.dropzone.over { border-color: var(--brand); background: var(--drop-over); }
progress { width: 100%; }

.bars { display: grid; gap: .35rem; }
.bar { display: grid; grid-template-columns: 70px 1fr 60px; gap: .5rem; align-items: center; font-size: .85rem; }
.bar .track { background: var(--chip); border-radius: 4px; height: 14px; overflow: hidden; }
.bar .fill { background: var(--brand); height: 100%; width: 0; }

dialog#lightbox { border: none; padding: 0; background: transparent; max-width: 95vw; max-height: 95vh; }
dialog#lightbox::backdrop { background: rgba(0,0,0,.85); }
dialog#lightbox img, dialog#lightbox video { max-width: 95vw; max-height: 88vh; display: block; }
dialog#lightbox .close { position: fixed; top: 1rem; right: 1rem; font-size: 1.6rem; line-height: 1; background: #fff; color: #000; border: 0; border-radius: 50%; width: 2.4rem; height: 2.4rem; }
dialog#lightbox .lb-caption { color: #fff; padding: .5rem 0; }

#toast { position: fixed; bottom: 1.25rem; left: 50%; transform: translateX(-50%); background: var(--tip-bg); color: #fff; padding: .6rem 1rem; border-radius: 8px; opacity: 0; transition: opacity .2s; pointer-events: none; z-index: 10; }
#toast.show { opacity: 1; }
#toast.err { background: var(--danger); }

.login { min-height: 100vh; display: grid; place-items: center; padding: 1rem; }
.login .card { width: 100%; max-width: 380px; }
.history li { margin-bottom: .4rem; }
details summary { cursor: pointer; font-weight: 600; }
.copy { display: flex; gap: .4rem; }
.copy input { font-size: .8rem; }

/* showcase */
.showcase header { background: var(--brand); color: #fff; padding: 2rem 1.5rem; }
.showcase header h1 { margin: 0; font-size: 1.8rem; }
.showcase header p { margin: .3rem 0 0; opacity: .9; }
.showcase main { margin: 0 auto; }
.showcase .eng-card { margin-bottom: 1.5rem; }
.showcase .eng-card .desc { white-space: pre-wrap; }
.showcase .eng-card h2 { margin-top: 0; }
td.row { display: table-cell; }
td.row > * { margin-right: .75rem; }
.table-wrap + form, .table-wrap + .card { margin-top: .75rem; }
.logo { width: 1.6em; height: 1.6em; vertical-align: middle; margin-right: .35rem; }
nav.side .brand { display: flex; align-items: center; }
.brand-login { display: flex; align-items: center; }

/* hover / focus help labels */
.tip { position: relative; }
.tip::after {
  content: attr(data-tip); position: absolute; bottom: calc(100% + 8px); left: 0; z-index: 5;
  width: max-content; max-width: 260px; padding: .45rem .65rem; border-radius: 6px;
  background: var(--tip-bg); color: #fff; font-size: .8rem; font-weight: 400; line-height: 1.35;
  opacity: 0; pointer-events: none; transition: opacity .15s;
}
.tip:hover::after, .tip:focus-within::after { opacity: 1; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* dark theme */
html[data-theme="dark"] {
  --ink: #e4ebe9;
  --muted: #9aa9a6;
  --line: #2e3a39;
  --bg: #121817;
  --card: #1b2322;
  --brand: #1f5f5b;
  --danger: #e07a7a;
  --link: #7fcfc4;
  --chip: #2a3534;
  --input-bg: #151c1b;
  --input-border: #3a4847;
  --drop-border: #3d4b4a;
  --drop-bg: #161e1d;
  --drop-over: #1f3533;
  --tip-bg: #000;
  color-scheme: dark;
}
html[data-theme="dark"] nav.side { background: #163f3c; }
html[data-theme="dark"] .showcase header { background: #163f3c; }
html[data-theme="dark"] .tag.plain { color: var(--ink); }

/* theme switch */
.theme-switch { display: flex; gap: 2px; background: rgba(0,0,0,.18); border-radius: 8px; padding: 2px; margin: .25rem .75rem .5rem 0; }
.theme-switch button { flex: 1; white-space: nowrap; background: none; border: 0; color: var(--brand-ink); padding: .3rem .4rem; font-size: .8rem; border-radius: 6px; opacity: .8; }
.theme-switch button[aria-pressed="true"] { background: rgba(255,255,255,.2); opacity: 1; }
