/* ============================================================================
   Panelômetro — design system
   Dark "live telemetry instrument" aesthetic + warm civic-protest accent.
   System font stack (platform CSP blocks remote fonts); personality comes
   from weight, tracking, and a monospace telemetry readout.
   ========================================================================== */

:root {
  --bg: #0E0E11;
  --bg-2: #14141A;
  --surface: #1B1B22;
  --surface-2: #23232C;
  --border: #2A2A33;
  --border-2: #3A3A46;

  --text: #F2F1EC;
  --text-2: #B7B4AC;
  --text-3: #8E8C82;

  --accent: #FF4A1C;
  --accent-2: #FF6B3D;
  --ok: #3DDC97;
  --warn: #FFC53D;
  --danger: #FF4A1C;

  --radius: 14px;
  --radius-sm: 9px;
  --radius-lg: 20px;
  --radius-pill: 999px;

  --shadow-1: 0 1px 2px rgba(0,0,0,.4);
  --shadow-2: 0 10px 34px rgba(0,0,0,.45);

  --font-ui: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, "SF Mono", "JetBrains Mono", "Cascadia Code", Menlo, Consolas, monospace;

  --ease-spring: cubic-bezier(.22,.8,.3,1.25);
}

* { box-sizing: border-box; }
/* Author styles set explicit `display` values (e.g. .btn → inline-flex), which
   beat the UA stylesheet's [hidden]{display:none}.  Force the attribute to win. */
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  min-height: 100vh;
  background-image:
    radial-gradient(1200px 500px at 50% -10%, rgba(255,74,28,.05), transparent 60%);
}
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
h1, h2, h3, p { margin: 0; }

/* ------------------------------------------------------------------ Boot */
.boot {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 22px;
  align-items: center;
  justify-content: center;
}
.boot-mark { font-size: 42px; animation: boot-bob 1.4s var(--ease-spring) infinite; }
.boot-bar {
  width: 120px; height: 3px; border-radius: 3px;
  background: var(--surface-2); overflow: hidden;
}
.boot-bar span {
  display: block; width: 40%; height: 100%;
  background: var(--accent); border-radius: 3px;
  animation: boot-slide 1.1s ease-in-out infinite;
}
@keyframes boot-slide { 0%{transform:translateX(-120%)} 100%{transform:translateX(320%)} }
@keyframes boot-bob { 0%,100%{transform:translateY(0)} 50%{transform:translateY(-7px)} }

/* ---------------------------------------------------------------- Topbar */
.topbar {
  position: sticky; top: 0; z-index: 50;
  background: rgba(14,14,17,.78);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
}
.topbar-inner {
  max-width: 860px; margin: 0 auto;
  display: flex; align-items: center; justify-content: space-between;
  gap: 14px; padding: 12px 16px;
}
.brand { display: inline-flex; align-items: center; gap: 9px; min-height: 44px; }
.brand-emoji { font-size: 22px; }
.brand-name {
  font-weight: 800; font-size: 18px; letter-spacing: -.02em;
}
.brand-name::after { content: ""; display: none; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }

/* Language switch */
.lang-switch {
  display: inline-flex; gap: 2px; padding: 3px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-pill);
}
.lang-btn {
  appearance: none; border: 0; background: transparent; color: var(--text-2);
  font-size: 12px; font-weight: 700; letter-spacing: .03em;
  padding: 6px 11px; min-height: 32px; border-radius: var(--radius-pill);
  transition: background .15s, color .15s;
}
.lang-btn:hover { color: var(--text); }
.lang-btn.active { background: var(--surface-2); color: var(--text); }

/* --------------------------------------------------------------- Buttons */
.btn {
  appearance: none; border: 0; border-radius: var(--radius-pill);
  font-weight: 700; font-size: 14.5px; letter-spacing: -.01em;
  padding: 0 18px; min-height: 44px;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  transition: transform .1s var(--ease-spring), background .15s, border-color .15s, opacity .15s;
  white-space: nowrap;
}
.btn:active { transform: scale(.97); }
.btn-primary { background: var(--accent); color: #150C06; box-shadow: 0 6px 20px rgba(255,74,28,.28); }
.btn-primary:hover { background: var(--accent-2); }
.btn-ghost {
  background: transparent; color: var(--text-2);
  border: 1px solid var(--border-2); min-height: 36px; padding: 0 14px; font-size: 13.5px;
}
.btn-ghost:hover { color: var(--text); border-color: var(--text-3); background: var(--surface); }
.btn-icon {
  width: 40px; height: 40px; min-height: 40px; padding: 0;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm);
  color: var(--text-2);
}
.btn-icon:hover { color: var(--text); border-color: var(--border-2); }
.btn:disabled { opacity: .55; cursor: default; transform: none; }

.ic { display: inline-flex; width: 18px; height: 18px; flex: none; }
.ic svg { width: 100%; height: 100%; }

/* ------------------------------------------------------------ Layout wrap */
.wrap { max-width: 860px; margin: 0 auto; padding: 28px 16px 72px; }

/* --------------------------------------------------------- Home — hero */
.hero { padding: 22px 0 6px; }
.kicker {
  font-family: var(--font-mono); font-size: 12px; font-weight: 700;
  letter-spacing: .14em; text-transform: uppercase; color: var(--accent);
  display: inline-flex; align-items: center; gap: 7px;
}
.kicker::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 0 rgba(255,74,28,.5); animation: pulse 2s infinite; }
@keyframes pulse { 0%{box-shadow:0 0 0 0 rgba(255,74,28,.5)} 70%{box-shadow:0 0 0 7px rgba(255,74,28,0)} 100%{box-shadow:0 0 0 0 rgba(255,74,28,0)} }

.hero-row { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-top: 14px; }
.hero-title {
  font-size: clamp(28px, 6.5vw, 44px); font-weight: 800;
  line-height: 1.05; letter-spacing: -.03em; max-width: 16ch;
  text-wrap: pretty;
}
.hero-sub { color: var(--text-2); font-size: 15.5px; margin-top: 12px; max-width: 46ch; }
.hero .btn-primary { flex: none; }

/* ----------------------------------------------------- Home — list head */
.panel-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  margin: 34px 0 12px;
}
.panel-title {
  font-family: var(--font-mono); font-size: 12px; font-weight: 700;
  letter-spacing: .14em; text-transform: uppercase; color: var(--text-3);
}

/* ----------------------------------------------------------- Topic list */
.topic-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.topic-row {
  display: grid; grid-template-columns: 40px 52px 1fr; gap: 14px; align-items: center;
  width: 100%; text-align: left;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px 16px; color: var(--text);
  transition: border-color .15s, background .15s, transform .1s;
}
.topic-row:hover { border-color: var(--border-2); background: var(--surface-2); }
.topic-row:active { transform: scale(.995); }

.rank {
  font-family: var(--font-mono); font-size: 20px; font-weight: 700; color: var(--text-3);
  text-align: center;
}
.topic-row:nth-child(1) .rank { color: var(--accent); }
.topic-emoji {
  width: 52px; height: 52px; border-radius: 50%;
  display: grid; place-items: center; font-size: 26px;
  background: rgba(var(--accent-rgb, 255,74,28), .13);
  border: 1px solid rgba(var(--accent-rgb, 255,74,28), .28);
}
.topic-main { min-width: 0; }
.topic-title { font-size: 16.5px; font-weight: 700; letter-spacing: -.01em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topic-chant { color: var(--text-3); font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topic-meter-row { display: flex; align-items: center; gap: 10px; margin-top: 9px; }
.mini-meter { display: flex; gap: 2px; flex: 1; height: 6px; min-width: 0; }
.mini-seg { flex: 1; height: 6px; border-radius: 2px; background: var(--surface-2); transition: background .1s; }
.mini-seg.lit { box-shadow: 0 0 6px hsla(var(--hue), 90%, 55%, .5); }
.beating { display: inline-flex; align-items: baseline; gap: 4px; font-family: var(--font-mono); font-size: 11px; font-weight: 700; color: var(--text-3); white-space: nowrap; font-variant-numeric: tabular-nums; }
.beating-n { color: var(--text); font-size: 12px; }

/* ----------------------------------------------------- Empty / skeleton */
.empty { text-align: center; padding: 64px 20px; color: var(--text-2); }
.empty-emoji { font-size: 44px; margin-bottom: 14px; }
.empty-title { font-size: 19px; font-weight: 800; color: var(--text); }
.empty-body { margin-top: 6px; font-size: 15px; }
.empty .btn { margin-top: 20px; }

.skeleton { display: flex; flex-direction: column; gap: 10px; }
.sk {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  height: 80px; position: relative; overflow: hidden;
}
.sk::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(100deg, transparent 20%, rgba(255,255,255,.04) 50%, transparent 80%);
  transform: translateX(-100%); animation: shimmer 1.5s infinite;
}
@keyframes shimmer { 100% { transform: translateX(100%); } }

.error-state { text-align: center; padding: 60px 20px; color: var(--text-2); }
.error-state .btn { margin-top: 18px; }

/* ================================================================== Pot */
.pot-page { margin-top: -14px; }
.pot-topbar { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 4px; }
.pot-topbar .group { display: flex; align-items: center; gap: 8px; min-width: 0; }
.pot-topbar .group-left { flex: 1; min-width: 0; }

.pot-title {
  flex: 1; min-width: 0;
  font-size: clamp(18px, 4.6vw, 24px); font-weight: 800; letter-spacing: -.02em;
  line-height: 1.1; text-align: left;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.pot-desc { color: var(--text-2); font-size: 13.5px; margin: 0; text-align: left; }

.btn-share { min-height: 36px; padding: 0 12px; font-size: 13px; gap: 6px; }

.chant {
  margin: 10px auto 0; padding: 4px 16px; text-align: center;
  font-weight: 800; font-size: 16px; letter-spacing: -.01em;
  color: rgba(var(--accent-rgb, 255,74,28), 1);
  text-shadow: 0 0 24px rgba(var(--accent-rgb, 255,74,28), .35);
  min-height: 1.1em;
}

/* Pot stage — the big clickable pot */
.stage-wrap { display: grid; place-items: center; padding: 6px 0 10px; }
.pot-stage {
  --accent: #FF4A1C; --accent-rgb: 255, 74, 28;
  position: relative; appearance: none; border: 0;
  width: min(46vw, 200px); aspect-ratio: 1; border-radius: 50%;
  display: grid; place-items: center; padding: 0;
  background:
    radial-gradient(circle at 50% 32%, rgba(var(--accent-rgb), .18), transparent 64%),
    radial-gradient(circle at 50% 55%, var(--surface-2), var(--bg-2));
  border: 1px solid rgba(var(--accent-rgb), .32);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.05), 0 24px 70px rgba(0,0,0,.55);
  transition: box-shadow .35s, border-color .35s, transform .1s;
  touch-action: manipulation; -webkit-tap-highlight-color: transparent;
  overflow: visible;
}
.pot-stage:hover { border-color: rgba(var(--accent-rgb), .55); }
.pot-stage.is-loud {
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,.06),
    0 0 0 2px rgba(var(--accent-rgb), .28),
    0 0 72px rgba(var(--accent-rgb), .28),
    0 24px 70px rgba(0,0,0,.55);
}
.pot-stage.shaking { animation: shake .5s ease; }

.pot-inner { display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; }
.pot-emoji { font-size: clamp(54px, 14vw, 80px); line-height: 1; filter: drop-shadow(0 8px 18px rgba(0,0,0,.5)); }
.pot-cta {
  font-family: var(--font-mono); font-size: 10px; font-weight: 800; letter-spacing: .1em;
  text-transform: uppercase; color: var(--text);
  background: rgba(var(--accent-rgb), .18); border: 1px solid rgba(var(--accent-rgb), .35);
  padding: 5px 12px; border-radius: var(--radius-pill);
  white-space: nowrap;
}
.pot-stage.banging .pot-emoji { animation: bang .3s var(--ease-spring); }
@keyframes bang {
  0% { transform: scale(1) rotate(0); }
  35% { transform: scale(.9) rotate(-3deg); }
  70% { transform: scale(1.07) rotate(2.5deg); }
  100% { transform: scale(1) rotate(0); }
}
@keyframes shake {
  0%,100%{transform:translate(0,0) rotate(0)} 20%{transform:translate(-3px,2px) rotate(-.5deg)}
  40%{transform:translate(3px,-2px) rotate(.5deg)} 60%{transform:translate(-2px,-2px)}
  80%{transform:translate(2px,2px)}
}
.shockwave {
  position: absolute; inset: 0; border-radius: 50%;
  border: 2px solid rgba(var(--accent-rgb), .7); pointer-events: none;
  animation: ripple .55s ease-out forwards;
}
@keyframes ripple { from { transform: scale(.55); opacity: .9; } to { transform: scale(1.3); opacity: 0; } }

.pot-hint { color: var(--text-3); font-size: 12px; margin-top: 6px; text-align: center; }

/* ----------------------------------------------------------------- Meter */
.meter { margin: 2px 0 0; }
.meter-readout { display: flex; align-items: baseline; justify-content: center; gap: 10px; }
.meter-num {
  font-family: var(--font-mono); font-size: clamp(34px, 8.5vw, 44px); font-weight: 800;
  letter-spacing: -.04em; line-height: 1; font-variant-numeric: tabular-nums;
}
.meter-unit { font-family: var(--font-mono); color: var(--text-3); font-size: 13px; font-weight: 700; }
.meter-tier {
  font-weight: 800; font-size: 13px; letter-spacing: .02em; text-transform: uppercase;
  color: rgba(var(--accent-rgb, 255,74,28), 1); transition: color .3s;
  text-shadow: 0 0 20px rgba(var(--accent-rgb, 255,74,28), .35);
}

.meter-track { position: relative; max-width: 420px; margin: 8px auto 0; }
.meter-segments { display: flex; gap: 3px; height: 16px; }
.meter-seg { flex: 1; border-radius: 3px; background: var(--surface-2); transition: background .1s, box-shadow .1s; }
.meter-seg.lit { box-shadow: 0 0 8px hsla(var(--hue), 90%, 55%, .4); }
.meter-peak {
  position: absolute; top: -3px; bottom: -3px; width: 2px; border-radius: 2px;
  background: var(--text); transform: translateX(-1px); transition: left .08s linear;
}
/* Pot stats */
.pot-stats {
  display: flex; justify-content: center; gap: 8px; margin-top: 12px; flex-wrap: wrap;
}
.stat {
  min-width: 0; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 8px 14px; text-align: center;
}
.stat-value { font-family: var(--font-mono); font-size: 18px; font-weight: 800; font-variant-numeric: tabular-nums; }
.stat-label { color: var(--text-3); font-size: 10.5px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; margin-top: 1px; }

/* Permalink */
.permalink {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  margin: 12px auto 0; max-width: 460px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 12px 14px;
}
.permalink-label { font-family: var(--font-mono); font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--text-3); }
.permalink-url { flex: 1; min-width: 0; font-family: var(--font-mono); font-size: 12.5px; color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.permalink .btn { min-height: 36px; padding: 0 14px; font-size: 13px; }

/* ------------------------------------------------------------- Customize */
.customize {
  margin-top: 28px; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 20px;
}
.customize-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.customize-title { font-size: 16px; font-weight: 800; letter-spacing: -.01em; }
.field { margin-bottom: 18px; }
.field-label { display: block; font-size: 12.5px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--text-2); margin-bottom: 8px; }

.emoji-picker { display: flex; flex-wrap: wrap; gap: 8px; }
.emoji-opt {
  width: 48px; height: 48px; font-size: 24px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--surface-2);
  display: grid; place-items: center; transition: border-color .15s, background .15s, transform .1s;
}
.emoji-opt:hover { border-color: var(--border-2); }
.emoji-opt.active { border-color: var(--accent); background: rgba(255,74,28,.14); }
.emoji-opt:active { transform: scale(.94); }

.swatches { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.swatch {
  width: 34px; height: 34px; border-radius: 50%; border: 2px solid transparent;
  outline: 2px solid transparent; outline-offset: 2px; padding: 0;
  transition: outline-color .15s, transform .1s;
}
.swatch.active { outline-color: var(--text-3); }
.swatch:active { transform: scale(.92); }
.color-input {
  width: 34px; height: 34px; padding: 0; border: 1px solid var(--border);
  border-radius: 50%; background: var(--surface-2); cursor: pointer;
}

.field-input, .field-textarea {
  width: 100%; background: var(--bg-2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); color: var(--text);
  padding: 11px 13px; font-size: 16px; font-family: inherit;
  transition: border-color .15s;
}
.field-textarea { resize: vertical; min-height: 76px; }
.field-input:focus, .field-textarea:focus { outline: none; border-color: var(--accent); }
.field-input::placeholder, .field-textarea::placeholder { color: var(--text-3); }

.customize-actions { display: flex; justify-content: flex-end; gap: 10px; }

/* ----------------------------------------------------------------- Modal */
.overlay {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(6,6,8,.7); backdrop-filter: blur(4px);
  display: grid; place-items: center; padding: 20px;
  animation: fade .18s ease;
}
@keyframes fade { from { opacity: 0; } }
.modal {
  width: 100%; max-width: 460px; max-height: 88vh; overflow: auto;
  background: var(--surface); border: 1px solid var(--border-2);
  border-radius: var(--radius-lg); padding: 22px; box-shadow: var(--shadow-2);
  animation: rise .22s var(--ease-spring);
}
@keyframes rise { from { opacity: 0; transform: translateY(10px) scale(.98); } }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 20px; }
.modal-title { font-size: 19px; font-weight: 800; letter-spacing: -.01em; }
.modal-close { width: 36px; height: 36px; border-radius: var(--radius-sm); background: var(--surface-2); border: 1px solid var(--border); color: var(--text-2); font-size: 18px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 4px; }
.form-error { color: var(--danger); font-size: 13.5px; margin-top: 12px; display: flex; align-items: center; gap: 6px; }

/* ----------------------------------------------------------------- Toast */
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(20px);
  z-index: 120; background: var(--surface-2); color: var(--text);
  border: 1px solid var(--border-2); border-radius: var(--radius-pill);
  padding: 11px 20px; font-size: 14px; font-weight: 600;
  box-shadow: var(--shadow-2); opacity: 0; pointer-events: none;
  transition: opacity .2s, transform .2s;
  max-width: 90vw;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ------------------------------------------------------------ Focus ring */
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
.pot-stage:focus-visible { outline: 3px solid var(--accent); outline-offset: 4px; }

/* ----------------------------------------------------------- Responsive */
@media (min-width: 641px) {
  .topbar-inner { padding: 14px 22px; }
  .wrap { padding: 34px 22px 88px; }
  .brand-name { font-size: 19px; }
  .topic-row { padding: 16px 18px; grid-template-columns: 44px 56px 1fr; }
  .topic-emoji { width: 56px; height: 56px; font-size: 28px; }
  .topic-title { font-size: 17px; }
  .stat { min-width: 0; padding: 10px 18px; }
}

@media (max-width: 480px) {
  .hero-row { flex-direction: column; align-items: stretch; }
  .hero-row .btn-primary { width: 100%; }
  .btn { min-height: 44px; }
  .topic-row { grid-template-columns: 30px 46px 1fr; gap: 11px; padding: 13px 13px; }
  .topic-emoji { width: 46px; height: 46px; font-size: 23px; }
  .rank { font-size: 17px; }
  .stat { flex: 1 1 40%; min-width: 0; }
}

@media (max-width: 359px) {
  .topic-chant, .pot-hint { display: none; }
  .brand-name { font-size: 16px; }
  .btn-share .share-label { display: none; }
}

/* ---------------------------------------------------------- Reduced motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
  }
  .kicker::before { animation: none; box-shadow: none; }
  .pot-stage.shaking, .pot-stage.banging .pot-emoji { animation: none; }
}
