/* Sylvan Messenger. Colors come from CSS variables set by the Owner's appearance settings. */

@font-face { font-family: 'Cinzel'; font-weight: 600; font-display: swap; src: url('/static/fonts/cinzel-latin-600-normal.woff2') format('woff2'); }
@font-face { font-family: 'Cinzel'; font-weight: 700; font-display: swap; src: url('/static/fonts/cinzel-latin-700-normal.woff2') format('woff2'); }
@font-face { font-family: 'Source Sans 3'; font-weight: 400; font-display: swap; src: url('/static/fonts/source-sans-3-latin-400-normal.woff2') format('woff2'); }
@font-face { font-family: 'Source Sans 3'; font-weight: 600; font-display: swap; src: url('/static/fonts/source-sans-3-latin-600-normal.woff2') format('woff2'); }
@font-face { font-family: 'Source Sans 3'; font-weight: 700; font-display: swap; src: url('/static/fonts/source-sans-3-latin-700-normal.woff2') format('woff2'); }

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100vh; background: var(--bg); color: var(--ink);
  font-family: 'Source Sans 3', system-ui, -apple-system, 'Segoe UI', sans-serif; font-size: 16px; line-height: 1.5;
}
body.bg-gradient { background: linear-gradient(160deg, var(--bg) 0%, var(--bg2) 100%) fixed; }
body.bg-image { background-color: var(--bg); background-size: cover; background-position: center; background-attachment: fixed; }
body.bg-image::before { content: ''; position: fixed; inset: 0; background: rgba(0, 0, 0, var(--dim)); pointer-events: none; z-index: 0; }
body > * { position: relative; z-index: 1; }

a { color: var(--primary); }
a:hover { color: var(--ink); }
:focus-visible { outline: 3px solid var(--primary); outline-offset: 2px; }
h1, h2, .display { font-family: 'Cinzel', Georgia, serif; color: var(--accent); letter-spacing: 0.02em; }
h1 { font-size: 28px; margin: 0; line-height: 1.2; }
h2 { font-size: 21px; margin: 0; line-height: 1.25; }
h3 { font-size: 14px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); margin: 8px 0 0; }
p { margin: 0; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.mono { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 14px; }
.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: 8px; top: -60px; background: var(--primary); color: var(--on-primary); padding: 8px 14px; border-radius: 8px; z-index: 10; }
.skip:focus { top: 8px; }

/* ---------- top bar ---------- */
.topbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px 20px; padding: 12px 28px; background: var(--panel); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 12px; text-decoration: none; }
.brand img { height: 52px; width: auto; }
.brand span { font-family: 'Cinzel', Georgia, serif; font-weight: 700; font-size: 21px; color: var(--accent); letter-spacing: 0.04em; }
.nav { display: flex; flex-wrap: wrap; gap: 4px; }
.nav a { padding: 10px 14px; border-radius: 8px; text-decoration: none; font-weight: 600; color: var(--ink); min-height: 44px; display: inline-flex; align-items: center; }
.nav a:hover { background: var(--raised); }
.nav a[aria-current='page'] { background: var(--primary); color: var(--on-primary); }
.who { display: flex; align-items: center; gap: 12px; font-size: 14px; color: var(--muted); }
.who a { color: var(--muted); }
.linkbtn { background: none; border: none; padding: 0; color: var(--muted); text-decoration: underline; cursor: pointer; font: inherit; min-height: 44px; }

/* ---------- layout ---------- */
.wrap { max-width: 1360px; margin: 0 auto; padding: 28px; display: flex; flex-direction: column; gap: 24px; }
.cols { display: flex; flex-wrap: wrap; gap: 24px; align-items: flex-start; }
.main-col { flex: 999 1 620px; min-width: 0; display: flex; flex-direction: column; gap: 24px; }
.side-col { flex: 1 1 320px; min-width: 0; display: flex; flex-direction: column; gap: 24px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 24px; display: flex; flex-direction: column; gap: 16px; }
.row { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }
.between { justify-content: space-between; }
.stack { display: flex; flex-direction: column; gap: 6px; }
.grid-auto { display: grid; grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); gap: 10px; }
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 16px; }

/* ---------- forms ---------- */
label { font-weight: 600; }
input[type=text], input[type=email], input[type=password], input[type=search], input[type=number], input[type=url], select, textarea {
  width: 100%; padding: 12px 14px; border-radius: 10px; border: 1px solid var(--line-strong); background: var(--field); color: var(--ink); font: inherit; min-height: 46px;
}
textarea { resize: vertical; min-height: 130px; }
input[type=checkbox], input[type=radio] { width: 20px; height: 20px; accent-color: var(--primary); flex: none; }
input[type=color] { width: 52px; height: 44px; padding: 2px; border-radius: 10px; border: 1px solid var(--line-strong); background: var(--field); cursor: pointer; }
input[type=range] { accent-color: var(--primary); }
fieldset { border: none; margin: 0; padding: 0; }
.hint { font-size: 14px; color: var(--muted); font-weight: 400; }
.field-error { color: var(--warn-ink); background: var(--warn-bg); border-radius: 8px; padding: 8px 12px; font-size: 15px; font-weight: 600; }
.meter { height: 6px; border-radius: 3px; background: var(--field); overflow: hidden; }
.meter > span { display: block; height: 100%; background: var(--primary); width: 0; transition: width .15s; }
.meter.over > span { background: var(--warn-ink); }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 46px; padding: 0 20px; border-radius: 12px; border: 1px solid var(--line-strong); background: transparent; color: var(--ink); font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; }
.btn:hover { background: var(--raised); }
.btn-primary { background: var(--primary); color: var(--on-primary); border-color: transparent; font-weight: 700; }
.btn-primary:hover { background: var(--primary); filter: brightness(1.08); }
.btn-warn { background: var(--warn-ink); color: var(--bg); border-color: transparent; font-weight: 700; }
.btn-big { min-height: 54px; font-size: 17px; width: 100%; }
.btn:disabled, .btn[aria-disabled=true] { cursor: not-allowed; opacity: 0.55; filter: none; }
.btn-sm { min-height: 44px; padding: 0 14px; border-radius: 10px; }
form.inline { display: inline; }

.seg { display: inline-flex; padding: 4px; gap: 4px; border-radius: 10px; background: var(--field); border: 1px solid var(--line); }
.seg input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.seg label { min-height: 40px; padding: 0 16px; border-radius: 8px; display: inline-flex; align-items: center; cursor: pointer; font-weight: 600; }
.seg input:checked + label { background: var(--primary); color: var(--on-primary); font-weight: 700; }
.seg input:focus-visible + label { outline: 3px solid var(--primary); outline-offset: 2px; }

/* ---------- groups picker ---------- */
.gpick { display: flex; align-items: center; gap: 12px; min-height: 52px; padding: 12px 14px; border-radius: 10px; cursor: pointer; background: var(--field); border: 1px solid var(--line); font-weight: 400; }
.gpick:has(input:checked) { background: var(--raised); border-color: var(--primary); }
.gpick.blocked { cursor: not-allowed; opacity: 0.8; }
.gpick .gname { font-weight: 600; display: block; }
.gpick .gtext { flex: 1 1 auto; min-width: 0; }

.pill { display: inline-block; font-size: 12.5px; font-weight: 700; padding: 3px 10px; border-radius: 999px; white-space: nowrap; }
.pill-ok { background: var(--ok-bg); color: var(--ok-ink); }
.pill-warn { background: var(--warn-bg); color: var(--warn-ink); }
.pill-info { background: var(--info-bg); color: var(--info-ink); }
.pill-quiet { background: var(--field); color: var(--muted); border: 1px solid var(--line); }

/* ---------- notices ---------- */
.banner { padding: 12px 28px; font-weight: 600; }
.banner-warn { background: var(--warn-bg); color: var(--warn-ink); }
.banner-info { background: var(--info-bg); color: var(--info-ink); }
.flash { padding: 14px 16px; border-radius: 12px; font-weight: 600; }
.flash-ok { background: var(--ok-bg); color: var(--ok-ink); }
.flash-warn { background: var(--warn-bg); color: var(--warn-ink); }
.flash-info { background: var(--info-bg); color: var(--info-ink); }
.callout { display: flex; gap: 12px; align-items: flex-start; padding: 14px 16px; border-radius: 12px; background: var(--info-bg); color: var(--info-ink); }
.callout svg { flex: none; margin-top: 2px; }

/* ---------- budget / stats ---------- */
.big-number { font-size: 40px; font-weight: 700; line-height: 1; }
.bar { height: 12px; border-radius: 6px; background: var(--field); overflow: hidden; display: flex; }
.bar .used { background: var(--line-strong); }
.bar .proj { background: var(--primary); }
.bar .proj.over { background: var(--warn-ink); }
.kv { display: flex; justify-content: space-between; gap: 8px; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.stat { padding: 14px 16px; border-radius: 12px; background: var(--field); border: 1px solid var(--line); }
.stat b { display: block; font-size: 28px; line-height: 1.2; }
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; flex: none; }
.dot-ok { background: var(--ok-ink); box-shadow: 0 0 0 4px var(--ok-bg); }
.dot-warn { background: var(--warn-ink); box-shadow: 0 0 0 4px var(--warn-bg); }
.progress { height: 12px; border-radius: 6px; background: var(--field); overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--primary); transition: width .4s; }
.countdown { font-weight: 700; font-size: 18px; font-variant-numeric: tabular-nums; color: var(--primary); }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 14px; font-weight: 600; color: var(--muted); padding: 10px 12px; border-bottom: 1px solid var(--line-strong); }
td { padding: 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
td .reason { font-size: 14px; color: var(--muted); margin-top: 4px; }

/* ---------- settings ---------- */
.theme-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 10px; }
.theme-btn { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; padding: 14px; border-radius: 12px; cursor: pointer; text-align: left; background: var(--field); color: var(--ink); border: 1px solid var(--line); font: inherit; min-height: 44px; }
.theme-btn[aria-pressed=true] { border: 2px solid var(--primary); background: var(--raised); }
.swatches { display: flex; gap: 4px; }
.swatches i { width: 22px; height: 22px; border-radius: 50%; border: 1px solid var(--line-strong); display: block; }
.color-row { display: flex; flex-wrap: wrap; align-items: center; gap: 14px; padding: 10px 0; border-top: 1px solid var(--line); }
.color-row .label { flex: 1 1 200px; min-width: 0; }
.preview { border-radius: 14px; overflow: hidden; border: 1px solid var(--line-strong); min-height: 460px; position: relative; }
.preview .pv-bg { position: absolute; inset: 0; }
.preview .pv-dim { position: absolute; inset: 0; }
.preview .pv-inner { position: relative; }
.preview .pv-top { display: flex; align-items: center; gap: 10px; padding: 12px 16px; }
.preview .pv-top img { height: 34px; width: auto; }
.preview .pv-name { font-family: 'Cinzel', Georgia, serif; font-weight: 700; font-size: 17px; }
.preview .pv-chip { margin-left: auto; padding: 6px 12px; border-radius: 8px; font-size: 13px; font-weight: 700; }
.preview .pv-card { margin: 16px; border-radius: 12px; padding: 18px; display: flex; flex-direction: column; gap: 10px; }
.preview .pv-h { font-family: 'Cinzel', Georgia, serif; font-weight: 700; font-size: 18px; }
.preview .pv-field { padding: 10px 12px; border-radius: 8px; font-size: 14px; }
.preview .pv-btn { align-self: flex-start; padding: 10px 18px; border-radius: 10px; font-weight: 700; font-size: 14px; }
.upload-row { display: flex; flex-wrap: wrap; gap: 16px; align-items: center; }
.upload-thumb { width: 150px; height: 100px; border-radius: 10px; border: 1px solid var(--line-strong); background: var(--field); display: flex; align-items: center; justify-content: center; overflow: hidden; }
.upload-thumb img { max-width: 130px; max-height: 86px; }

/* ---------- sign-in pages ---------- */
.auth-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 40px 16px; }
.auth-box { width: 100%; max-width: 460px; display: flex; flex-direction: column; align-items: center; gap: 24px; }
.auth-box > img { width: 100%; max-width: 360px; height: auto; }
.auth-box .card { width: 100%; gap: 18px; padding: 32px; }
.qr { background: #fff; padding: 12px; border-radius: 12px; width: fit-content; }
.qr svg { display: block; width: 200px; height: 200px; }

@media (max-width: 640px) {
  .wrap { padding: 16px; }
  .topbar { padding: 10px 16px; }
  .brand img { height: 40px; }
  .card { padding: 18px; }
  .banner { padding: 12px 16px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
