:root {
  --bg: #ffffff;
  --card: #ffffff;
  --surface: #f7f7f7;
  --border: #e5e5e5;
  --text: #0a0a0a;
  --muted: #6b7280;
  --primary: #0a0a0a;
  --primary-text: #ffffff;
  --get: #dcfce7;
  --post: #dbeafe;
  --upload: #fce7f3;
  --error: #fee2e2;
  --success: #dcfce7;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.08);
  --radius: 14px;
  --bottom-nav-height: 76px;
  color-scheme: light;
}

html[data-theme="dark"] {
  --bg: #000000;
  --card: #0b0b0b;
  --surface: #111111;
  --border: #262626;
  --text: #ffffff;
  --muted: #a1a1aa;
  --primary: #ffffff;
  --primary-text: #000000;
  --get: #052e16;
  --post: #0c1e3a;
  --upload: #3a1020;
  --error: #3a0c0c;
  --success: #052e16;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.55;
  padding-bottom: calc(var(--bottom-nav-height) + 24px);
}
a { color: inherit; text-decoration: none; }
button, input, textarea, select { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: 0.55; }
img, svg { max-width: 100%; }
.skip-link { position: absolute; left: -9999px; top: 12px; background: var(--primary); color: var(--primary-text); padding: 10px 14px; border-radius: 10px; z-index: 100; }
.skip-link:focus { left: 12px; }

.top-header {
  position: sticky;
  top: 0;
  z-index: 40;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
.nav-inner { max-width: 1180px; margin: 0 auto; padding: 12px 18px; display: flex; align-items: center; gap: 12px; }
.logo-mark { width: 38px; height: 38px; border-radius: 10px; background: var(--primary); color: var(--primary-text); display: grid; place-items: center; border: 1px solid var(--border); flex: 0 0 auto; }
.brand { display: flex; flex-direction: column; min-width: 0; }
.brand strong { font-size: 15px; letter-spacing: 0.02em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand span { color: var(--muted); font-size: 12px; }
.nav-actions { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.icon-button { width: 40px; height: 40px; border-radius: 10px; border: 1px solid var(--border); background: var(--card); color: var(--text); display: grid; place-items: center; }
.btn { border: 1px solid var(--border); border-radius: 10px; background: var(--card); color: var(--text); padding: 10px 14px; min-height: 40px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; font-weight: 600; }
.btn-primary { background: var(--primary); color: var(--primary-text); border-color: var(--primary); }
.btn-secondary { background: var(--surface); }
.btn-danger { background: var(--error); color: var(--text); }
.btn-block { width: 100%; }
.btn-small { padding: 7px 10px; min-height: 34px; font-size: 13px; }

.sidebar-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.35); z-index: 50; opacity: 0; pointer-events: none; transition: opacity 160ms ease; }
.sidebar { position: fixed; top: 0; right: 0; width: min(360px, 88vw); height: 100vh; background: var(--bg); border-left: 1px solid var(--border); z-index: 60; transform: translateX(110%); transition: transform 180ms ease; padding: 18px; overflow-y: auto; }
.sidebar.is-open { transform: translateX(0); }
.sidebar.is-open + .sidebar-overlay { opacity: 1; pointer-events: auto; }
.sidebar-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.sidebar-nav { display: grid; gap: 6px; }
.sidebar-link { padding: 11px 12px; border-radius: 10px; color: var(--text); display: flex; align-items: center; gap: 10px; border: 1px solid transparent; }
.sidebar-link:hover { background: var(--surface); border-color: var(--border); }

.page { max-width: 1180px; margin: 0 auto; padding: 24px 18px 32px; }
.hero { padding: 48px 0 24px; display: grid; gap: 18px; }
.hero h1 { font-size: clamp(34px, 7vw, 58px); line-height: 1.02; margin: 0; letter-spacing: -0.04em; }
.hero p { color: var(--muted); max-width: 720px; margin: 0; font-size: 17px; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.section { margin-top: 34px; }
.section-head { display: flex; align-items: end; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.section-head h2 { margin: 0; font-size: 22px; }
.section-head p { margin: 4px 0 0; color: var(--muted); }

.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; }
.card-title { margin: 0 0 8px; font-size: 16px; }
.muted { color: var(--muted); }
.grid { display: grid; gap: 14px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.stat-card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; min-width: 0; }
.stat-card span { color: var(--muted); font-size: 12px; display: block; }
.stat-card strong { display: block; font-size: 24px; margin-top: 4px; overflow-wrap: anywhere; }

.badge { display: inline-flex; align-items: center; border-radius: 999px; padding: 3px 9px; font-size: 12px; font-weight: 700; border: 1px solid var(--border); }
.badge-get { background: var(--get); }
.badge-post { background: var(--post); }
.badge-upload { background: var(--upload); }
.badge-error { background: var(--error); }

.form { display: grid; gap: 12px; }
.form-row { display: grid; gap: 12px; }
.form-row.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
label { display: grid; gap: 6px; font-size: 13px; color: var(--muted); }
input, textarea, select { width: 100%; border: 1px solid var(--border); border-radius: 10px; background: var(--bg); color: var(--text); padding: 11px 12px; min-height: 42px; }
textarea { min-height: 110px; resize: vertical; }
input:focus, textarea:focus, select:focus, button:focus-visible, a:focus-visible { outline: 2px solid var(--text); outline-offset: 2px; }
.checkbox { display: flex; align-items: center; gap: 8px; color: var(--text); }
.checkbox input { width: auto; min-height: auto; }

.accordion { border: 1px solid var(--border); border-radius: var(--radius); background: var(--card); margin-bottom: 10px; overflow: hidden; }
.accordion summary { list-style: none; cursor: pointer; padding: 14px; display: flex; align-items: center; gap: 10px; }
.accordion summary::-webkit-details-marker { display: none; }
.accordion-body { padding: 0 14px 14px; border-top: 1px solid var(--border); }
.code-block { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 12px; overflow-x: auto; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 13px; }
.code-actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0; }

.bottom-nav { position: fixed; left: 50%; transform: translateX(-50%); bottom: 14px; width: min(560px, calc(100vw - 24px)); height: var(--bottom-nav-height); background: var(--card); border: 1px solid var(--border); border-radius: 22px; box-shadow: var(--shadow); z-index: 45; display: grid; grid-template-columns: repeat(5, 1fr); padding: 8px; gap: 6px; touch-action: manipulation; }
.bottom-nav a { border-radius: 14px; display: grid; place-items: center; gap: 3px; color: var(--muted); font-size: 11px; padding: 6px; transition: background 220ms ease, color 220ms ease, transform 220ms ease; -webkit-tap-highlight-color: transparent; will-change: transform; }
.bottom-nav a:hover { transform: translateY(-1px); background: var(--surface); color: var(--text); }
.bottom-nav a:active { transform: scale(0.96); }
.bottom-nav a.is-active { background: var(--primary); color: var(--primary-text); transform: translateY(-1px); }
.bottom-nav svg { width: 20px; height: 20px; transition: transform 220ms ease; }
.bottom-nav a.is-active svg { transform: scale(1.08); }
.scroll-reveal { opacity: 0; transform: translateY(24px); transition: opacity 620ms ease, transform 620ms ease; will-change: transform, opacity; }
.scroll-reveal.is-visible { opacity: 1; transform: translateY(0); }
.scroll-reveal.is-visible.scroll-up { transform: translateY(0); }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; scroll-behavior: auto !important; transition-duration: 0.001ms !important; } .scroll-reveal { opacity: 1; transform: none; } }

.chat-fab { position: fixed; right: 18px; bottom: calc(var(--bottom-nav-height) + 28px); width: 52px; height: 52px; border-radius: 50%; background: var(--primary); color: var(--primary-text); border: 1px solid var(--border); box-shadow: var(--shadow); z-index: 46; display: grid; place-items: center; }
.chat-panel { position: fixed; right: 18px; bottom: calc(var(--bottom-nav-height) + 92px); width: min(380px, calc(100vw - 24px)); max-height: min(560px, calc(100vh - 150px)); background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); z-index: 47; display: flex; flex-direction: column; }
.chat-panel[hidden] { display: none; }
.chat-header { padding: 12px 14px; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; }
.chat-log { padding: 12px; overflow-y: auto; display: grid; gap: 8px; }
.chat-message { border: 1px solid var(--border); border-radius: 12px; padding: 9px 10px; background: var(--surface); }
.chat-user { margin-left: 18px; background: var(--primary); color: var(--primary-text); }
.chat-assistant { margin-right: 18px; }
.chat-form { display: flex; gap: 8px; padding: 10px; border-top: 1px solid var(--border); }

.modal-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,0.45); z-index: 80; display: grid; place-items: center; padding: 18px; }
.modal { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; max-width: 440px; width: 100%; box-shadow: var(--shadow); }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 14px; }

.toast-region { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--bottom-nav-height) + 16px); z-index: 90; display: grid; gap: 8px; width: min(420px, calc(100vw - 24px)); }
.toast { background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 11px 12px; box-shadow: var(--shadow); }
.toast-error { background: var(--error); }
.toast-success { background: var(--success); }

.loading-spinner { width: 28px; height: 28px; border-radius: 50%; border: 3px solid var(--border); border-top-color: var(--text); animation: spin 800ms linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.empty-state, .error-state { border: 1px dashed var(--border); border-radius: var(--radius); padding: 22px; text-align: center; color: var(--muted); display: grid; gap: 6px; }
.error-state { background: var(--error); color: var(--text); }

.qr-image { width: min(260px, 100%); border: 1px solid var(--border); border-radius: 12px; background: #fff; padding: 8px; }
.proof-preview { max-width: 220px; border: 1px solid var(--border); border-radius: 10px; margin-top: 8px; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px; border-bottom: 1px solid var(--border); font-size: 13px; }
th { color: var(--muted); }
.footer { margin-top: 42px; border-top: 1px solid var(--border); padding-top: 18px; color: var(--muted); display: flex; flex-wrap: wrap; gap: 10px; justify-content: space-between; }
