:root {
  color-scheme: dark light;
  --bg: #1a1f27;
  --panel: #232a34;
  --border: #36404d;
  --text: #e8ebf0;
  --muted: #98a2b0;
  --accent: #4f8cff;
  --accent-text: #fff;
  --danger: #e5484d;
  --ok: #2f9e62;
  --radius: 8px;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #f5f6f8;
    --panel: #fff;
    --border: #d9dde3;
    --text: #1a1e24;
    --muted: #5f6b7a;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.4rem; margin: 0; }
h2 { font-size: 1.1rem; margin: 0 0 .5rem; }
h3 { font-size: .95rem; margin: 1.25rem 0 .25rem; }
kbd {
  border: 1px solid var(--border);
  border-bottom-width: 2px;
  border-radius: 4px;
  padding: 0 .35em;
  font-size: .85em;
}

.muted { color: var(--muted); }
.mono { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: .9em; }

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: .75rem 1.25rem;
  border-bottom: 1px solid var(--border);
  background: var(--panel);
}
.brand { font-weight: 700; color: var(--text); font-size: 1.05rem; }
.site-header nav { display: flex; align-items: center; gap: 1rem; }

main { max-width: 1280px; margin: 0 auto; padding: 1.25rem; }

.page-head { display: flex; align-items: baseline; gap: .75rem; margin-bottom: 1rem; }

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  margin-bottom: 1.25rem;
}
.narrow { max-width: 420px; margin: 3rem auto; }
.narrow-form { max-width: 380px; }

.stack { display: flex; flex-direction: column; gap: .85rem; margin: 1rem 0; }
.stack label { display: flex; flex-direction: column; gap: .3rem; font-weight: 600; font-size: .9rem; }
.inline { display: inline; margin: 0; }

input, select {
  font: inherit;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: .5rem .6rem;
}
select { padding: .35rem .4rem; }
input:focus-visible, select:focus-visible, .btn:focus-visible, a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.btn {
  display: inline-block;
  font: inherit;
  font-size: .85rem;
  color: var(--text);
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: .35rem .7rem;
  cursor: pointer;
}
.btn:hover { border-color: var(--accent); text-decoration: none; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); font-size: .95rem; padding: .55rem .9rem; }
.btn-primary:hover { filter: brightness(1.1); }
.btn-danger { color: var(--danger); }
.btn-danger:hover { border-color: var(--danger); }
.btn.copied { color: var(--ok); border-color: var(--ok); }
button.link { font: inherit; color: var(--accent); background: none; border: 0; padding: 0; cursor: pointer; }
button.link:hover { text-decoration: underline; }
.js .js-hide { display: none; }

.flash { border-radius: var(--radius); padding: .6rem .9rem; margin: 0 0 1rem; border: 1px solid; }
.flash-ok { border-color: var(--ok); color: var(--ok); }
.flash-error { border-color: var(--danger); color: var(--danger); }

.grid {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1rem;
}
.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.thumb { display: block; aspect-ratio: 16 / 10; background: #000; }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.card-meta { display: flex; justify-content: space-between; align-items: center; gap: .5rem; padding: .5rem .75rem 0; font-size: .82rem; color: var(--muted); }
.card-actions { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem; padding: .6rem .75rem .75rem; }

.badge { font-size: .7rem; text-transform: uppercase; letter-spacing: .04em; border: 1px solid var(--border); border-radius: 999px; padding: .05rem .5rem; }
.badge-public { color: var(--ok); border-color: var(--ok); }
.badge-private { color: var(--danger); border-color: var(--danger); }

.pager { display: flex; justify-content: space-between; align-items: center; margin-top: 1.25rem; }

.viewer-bar { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: .75rem; margin-bottom: 1rem; }
.viewer-info, .viewer-actions { display: flex; flex-wrap: wrap; align-items: center; gap: .6rem; }
.viewer-image { display: block; text-align: center; }
.viewer-image img {
  max-width: 100%;
  height: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: repeating-conic-gradient(#8882 0% 25%, transparent 0% 50%) 50% / 20px 20px;
}

.token-row { display: flex; flex-wrap: wrap; gap: .5rem; margin: .75rem 0; }
.token-row input { flex: 1 1 320px; min-width: 0; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: .25rem 1rem; margin: .5rem 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }
pre { background: var(--bg); border: 1px solid var(--border); border-radius: 6px; padding: .75rem; overflow-x: auto; margin: .5rem 0 0; }

.connect-actions { display: flex; gap: .6rem; margin-top: 1.25rem; }
.download-cta { display: flex; flex-wrap: wrap; align-items: center; gap: .9rem; margin: 1.25rem 0; }
.steps { padding-left: 1.3rem; margin: .5rem 0; }
.steps li { margin: .55rem 0; }
details summary { cursor: pointer; }
code { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: .9em; }

/* ---- image editor ---- */
.editor-bar { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem 1rem; background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: .5rem .75rem; position: sticky; top: 0; z-index: 5; }
.editor-group { display: flex; align-items: center; gap: .3rem; }
.editor-end { margin-left: auto; gap: .5rem; }
.tool { display: inline-grid; place-items: center; width: 34px; height: 34px; color: var(--text); background: transparent; border: 1px solid transparent; border-radius: 6px; cursor: pointer; }
.tool:hover { border-color: var(--border); }
.tool.active { background: var(--accent); color: var(--accent-text); }
.tool:disabled { opacity: .35; cursor: default; }
.swatch { width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--border); cursor: pointer; padding: 0; }
.swatch.active { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent); }
#ed-custom-color { width: 28px; height: 26px; padding: 0; border: 1px solid var(--border); background: none; cursor: pointer; }
.editor-field { display: flex; align-items: center; gap: .35rem; font-size: .8rem; color: var(--muted); }
.editor-field input[type=range] { width: 90px; padding: 0; }
.editor-panel { display: flex; flex-wrap: wrap; gap: .3rem; background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: .5rem; margin-top: .5rem; max-height: 190px; overflow-y: auto; }
.editor-panel[hidden] { display: none; }
.emoji { font-size: 1.5rem; line-height: 1; background: none; border: 1px solid transparent; border-radius: 6px; padding: .2rem .3rem; cursor: pointer; }
.emoji:hover, .emoji.active { border-color: var(--accent); }
.sticker { width: 96px; height: 64px; padding: 0; border: 1px solid var(--border); border-radius: 6px; overflow: hidden; background: #000; cursor: pointer; }
.sticker:hover { border-color: var(--accent); }
.sticker img { width: 100%; height: 100%; object-fit: cover; display: block; }
.editor-status { margin: .6rem 0; font-size: .85rem; min-height: 1.3em; }
.editor-status.editor-error { color: var(--danger); }
.editor-stage { overflow: auto; max-height: calc(100vh - 210px); border: 1px solid var(--border); border-radius: var(--radius); background: repeating-conic-gradient(#8882 0% 25%, transparent 0% 50%) 50% / 20px 20px; }
.editor-canvas-wrap { position: relative; width: max-content; margin: 0 auto; line-height: 0; }
#ed-canvas { display: block; touch-action: none; visibility: hidden; }
.editor.ready #ed-canvas { visibility: visible; }
.editor-text-input { position: absolute; margin: 0; padding: 0; border: 1px dashed var(--accent); border-radius: 0; background: rgba(0, 0, 0, .15); outline: none; resize: none; overflow: hidden; white-space: pre; }

/* ---- brand, footer ---- */
.brand { display: inline-flex; align-items: center; gap: .45rem; }
.brand img { display: block; border-radius: 5px; }
.site-footer { max-width: 1280px; margin: 2rem auto 0; padding: 1.25rem; border-top: 1px solid var(--border); font-size: .85rem; }
.site-footer nav { display: flex; flex-wrap: wrap; gap: .4rem 1.2rem; margin-bottom: .5rem; }
.site-footer p { margin: 0; }

/* ---- landing page ---- */
.hero { text-align: center; padding: 3rem 1rem 2rem; max-width: 860px; margin: 0 auto; }
.hero h1 { font-size: clamp(1.8rem, 4.5vw, 2.8rem); line-height: 1.15; margin-bottom: 1rem; }
.hero-lead { font-size: 1.12rem; color: var(--muted); margin: 0 auto 1.5rem; max-width: 700px; }
.hero-lead strong { color: var(--text); }
.hero-cta { display: flex; flex-wrap: wrap; justify-content: center; gap: .75rem; margin: 0 0 .75rem; }
.btn-large { font-size: 1.05rem; padding: .75rem 1.3rem; }
.features { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 1rem; margin-bottom: 1.25rem; }
.features .panel { margin: 0; }
.features p, .faq p { color: var(--muted); margin: .4rem 0 0; }
.faq { border-top: 1px solid var(--border); padding: .75rem 0; }
.faq:first-of-type { border-top: 0; }
.faq summary { font-weight: 600; }
.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: .9rem; }
th, td { text-align: left; padding: .55rem .7rem; border-bottom: 1px solid var(--border); vertical-align: top; }
thead th { color: var(--muted); font-weight: 600; font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; }
tbody th { font-weight: 600; }
.compare td:nth-child(2) { color: var(--ok); font-weight: 600; }
td.num, th.num { text-align: right; white-space: nowrap; }

/* ---- legal + contact ---- */
.prose { max-width: 820px; margin-left: auto; margin-right: auto; }
.prose h1 { margin-bottom: .25rem; }
.prose h2 { margin-top: 1.75rem; }
.prose li { margin: .35rem 0; }
.narrow-wide { max-width: 640px; margin: 2rem auto; }
textarea { font: inherit; color: var(--text); background: var(--bg); border: 1px solid var(--border); border-radius: 6px; padding: .5rem .6rem; resize: vertical; }
textarea:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.stack select { padding: .5rem .6rem; }
.hp { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }
.flash-note { border-color: #ffc53d; color: var(--text); background: #ffc53d14; }
progress.usage { width: 100%; height: 12px; accent-color: var(--accent); margin: .25rem 0 1rem; }

/* ---- admin ---- */
.admin-tabs { display: flex; flex-wrap: wrap; gap: .25rem; border-bottom: 1px solid var(--border); margin-bottom: 1.25rem; }
.admin-tabs a { padding: .5rem .9rem; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.admin-tabs a:hover { color: var(--text); text-decoration: none; }
.admin-tabs a.active { color: var(--text); border-bottom-color: var(--accent); }
.pill { display: inline-block; min-width: 1.4em; text-align: center; font-size: .72rem; font-weight: 700; color: #fff; background: var(--danger); border-radius: 999px; padding: .05rem .4rem; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 1rem; margin-bottom: 1.5rem; }
.stat { display: flex; flex-direction: column; margin: 0; color: var(--text); }
a.stat:hover { border-color: var(--accent); text-decoration: none; }
.stat-value { font-size: 1.7rem; font-weight: 700; }
.section-title { margin: 1.75rem 0 .75rem; }
table.data { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); }
.messages { list-style: none; margin: 0; padding: 0; display: grid; gap: .75rem; }
.message { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem; }
.message.unread { border-left: 3px solid var(--accent); }
.message-head { display: flex; flex-wrap: wrap; align-items: center; gap: .6rem; margin-bottom: .5rem; }
.message-body { white-space: pre-wrap; overflow-wrap: anywhere; background: var(--bg); border: 1px solid var(--border); border-radius: 6px; padding: .75rem; margin: .75rem 0; }
.message .card-actions { padding: 0; }
.editor-offscreen { position: fixed; left: -10000px; top: 0; opacity: 0; }

/* ---- the Annotate call to action ---- */
.btn-glow {
  display: inline-flex; align-items: center; gap: .4rem;
  color: #fff; font-weight: 600;
  background: linear-gradient(135deg, #6aa5ff, #2f6fe8);
  border-color: #8bb8ff;
  box-shadow: 0 0 0 1px #4f8cff55, 0 0 14px 2px #4f8cff99;
  animation: annotate-glow 2.2s ease-in-out infinite;
}
.btn-glow:hover { border-color: #fff; filter: brightness(1.08); box-shadow: 0 0 0 1px #4f8cffaa, 0 0 22px 5px #4f8cffcc; animation: none; }
@keyframes annotate-glow {
  0%, 100% { box-shadow: 0 0 0 1px #4f8cff55, 0 0 10px 1px #4f8cff77; }
  50% { box-shadow: 0 0 0 1px #4f8cff99, 0 0 22px 5px #4f8cffcc; }
}
@media (prefers-reduced-motion: reduce) { .btn-glow { animation: none; } }

/* ---- callout boxes ---- */
.callout { border: 1px solid; border-left-width: 5px; border-radius: var(--radius); padding: 1.1rem 1.25rem; margin-bottom: 1.25rem; }
.callout-warn { border-color: var(--danger); background: #e5484d14; }
.callout h2 { display: flex; align-items: center; gap: .5rem; color: var(--danger); font-size: 1.05rem; margin-bottom: .6rem; }
.callout h2 svg { flex: none; }
.callout p { margin: .55rem 0; }
.callout ul { margin: .6rem 0 0; padding-left: 1.2rem; color: var(--muted); }
.callout li { margin: .3rem 0; }
.callout li strong { color: var(--text); }
.callout-steps { font-size: 1.02rem; }
.keycap { display: inline-block; border: 1px solid var(--border); border-bottom-width: 2px; border-radius: 5px; background: var(--panel); padding: 0 .45rem; font-weight: 600; white-space: nowrap; }

/* ---- two-factor ---- */
.qr { width: 220px; max-width: 100%; margin: .75rem 0; padding: 8px; background: #fff; border-radius: var(--radius); line-height: 0; }
.qr svg { width: 100%; height: auto; display: block; }
.secret { font-size: 1.05rem; letter-spacing: .06em; word-break: break-all; user-select: all; }
.backup-codes { list-style: none; padding: 1rem; margin: 1rem 0; display: grid; grid-template-columns: repeat(2, max-content); gap: .4rem 2.5rem; background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius); font-size: 1.1rem; user-select: all; }
.cf-turnstile { min-height: 65px; }

/* ---- gallery: search, day groups, selection, uploads ---- */
.gallery-tools { display: flex; flex-wrap: wrap; justify-content: space-between; gap: .75rem; margin-bottom: 1rem; }
.search { display: flex; gap: .4rem; flex: 1 1 360px; max-width: 560px; margin: 0; }
.search input { flex: 1; min-width: 0; }
.bulk { display: flex; gap: .4rem; margin: 0; }
.bulk button:disabled { opacity: .5; cursor: default; }
h2.day { font-size: .95rem; color: var(--muted); font-weight: 600; margin: 1.5rem 0 .6rem; }
.card { position: relative; }
.card.selected { outline: 2px solid var(--accent); outline-offset: -1px; }
.select { position: absolute; top: .5rem; left: .5rem; z-index: 2; background: #000a; border-radius: 6px; padding: .25rem .35rem; line-height: 0; cursor: pointer; opacity: 0; transition: opacity .1s; }
.card:hover .select, .card.selected .select, .select:focus-within { opacity: 1; }
@media (hover: none) { .select { opacity: 1; } }
.select input { width: 18px; height: 18px; margin: 0; cursor: pointer; accent-color: var(--accent); }
.card-title { padding: .55rem .75rem 0; font-weight: 600; font-size: .9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card-meta > span { display: inline-flex; align-items: center; gap: .35rem; }
.tags { display: flex; flex-wrap: wrap; gap: .3rem; padding: .45rem .75rem 0; }
.viewer-head .tags { padding: .5rem 0 0; }
.tag { font-size: .75rem; color: var(--accent); background: #4f8cff1a; border-radius: 999px; padding: .05rem .5rem; }
a.tag:hover { text-decoration: none; background: #4f8cff33; }
svg.lock { vertical-align: -2px; }
.badge-lock { display: inline-flex; align-items: center; gap: .25rem; color: #ffc53d; border-color: #ffc53d; }
.dropzone { border: 2px dashed var(--border); border-radius: var(--radius); padding: .9rem 1.1rem; margin-bottom: 1rem; text-align: center; transition: border-color .15s, background .15s; }
.dropzone p { margin: .2rem 0; }
.dropzone.dragging { border-color: var(--accent); background: #4f8cff14; }
.link-like { color: var(--accent); cursor: pointer; text-decoration: underline; }
.upload-error { color: var(--danger); }

/* ---- viewer: title, description, owner panels ---- */
.viewer-head { margin-bottom: .75rem; }
.viewer-head h1 { font-size: 1.3rem; }
.viewer-description { color: var(--muted); white-space: pre-wrap; overflow-wrap: anywhere; margin: .35rem 0 0; }
.owner-panels { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 1rem; margin-top: 1.25rem; }
.owner-panels .panel { margin: 0; }
.owner-panels textarea, .owner-panels input[type=text] { width: 100%; }
.inline-form { display: flex; flex-wrap: wrap; gap: .4rem; margin: .75rem 0 .5rem; }
.inline-form input { flex: 1 1 180px; min-width: 0; }
.kv.source { margin-top: 1rem; }

/* ---- settings ---- */
.danger-zone { border-color: #e5484d66; }
.danger-zone h2 { color: var(--danger); }
label.check { flex-direction: row !important; align-items: center; gap: .5rem !important; font-weight: 400 !important; }

/* ---- editor: crop ---- */
.editor-crop-hint { color: var(--accent); }

.stack label input, .stack label textarea, .stack label select { font-weight: 400; }

.site-footer .disclaimer { max-width: 900px; line-height: 1.5; }
.small { font-size: .82rem; }
