/* style.css */
@font-face {
  font-family: "Kenney Future Narrow";
  src: url("https://assets.popchat.com/assets/kenney/ui-pack/Font/Kenney%20Future%20Narrow.ttf") format("truetype");
  font-display: swap;
}

:root {
  color-scheme: dark;
  --bg: #0e0d12;
  --bg-2: #17161e;
  --ink: #f3eee6;
  --muted: #b7b0a4;
  --accent: #e2b657;
  --accent-2: #6fd0e8;
  --danger: #d36a5c;
  --panel: rgba(20, 18, 26, 0.92);
  --bp-bg: #07131f;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  --font: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "Nunito", Roboto, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, "Share Tech Mono", "Cascadia Code", Menlo, Consolas, monospace;
  --display: system-ui, "Kenney Future Narrow", "Nunito", sans-serif;
}

@media (prefers-color-scheme: light) {
  :root {
    color-scheme: light;
    --bg: #e7dfd2;
    --bg-2: #f6f1e8;
    --ink: #1c1914;
    --muted: #5c564c;
    --panel: rgba(246, 241, 232, 0.94);
    --bp-bg: #d5e7f2;
  }
}

html[data-theme="light"], html[data-scheme="light"] {
  color-scheme: light;
  --bg: #e7dfd2;
  --bg-2: #f6f1e8;
  --ink: #1c1914;
  --muted: #5c564c;
  --panel: rgba(246, 241, 232, 0.94);
  --bp-bg: #d5e7f2;
}

html[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0e0d12;
  --bg-2: #17161e;
  --ink: #f3eee6;
  --muted: #b7b0a4;
  --panel: rgba(20, 18, 26, 0.92);
  --bp-bg: #07131f;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--ink);
  min-height: 100dvh;
}

#app {
  min-height: 100dvh;
  display: grid;
  grid-template-rows: auto auto minmax(220px, 1fr) auto;
  max-width: 980px;
  margin: 0 auto;
}

.topbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 16px;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px 6px;
  background: var(--panel);
}

.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand h1 {
  font-family: var(--display);
  font-size: 1.05rem;
  margin: 0;
  letter-spacing: 0.04em;
  font-weight: 800;
}
.brand p { margin: 0; color: var(--muted); font-size: 0.75rem; }

.stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(64px, 1fr));
  gap: 8px;
  flex: 1;
  min-width: 240px;
}
.stat {
  background: var(--bg-2);
  border-radius: 10px;
  padding: 6px 8px;
  min-height: 44px;
}
.stat .lbl { display: block; font-size: 0.65rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.08em; }
.stat strong { font-family: var(--mono); font-size: 0.92rem; }
.stat.bad strong { color: var(--danger); }

.layer-switch {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding: 8px 12px;
}
.layer-btn, .primary-btn, .tool, .chip, .icon-btn, .play-btn {
  min-height: 44px;
  min-width: 44px;
  border: 0;
  cursor: pointer;
  font-family: var(--font);
  font-weight: 800;
  color: var(--ink);
}
.layer-btn {
  border-radius: 12px;
  background-color: #2a3340;
  background-image: url("https://assets.popchat.com/assets/kenney/ui-pack/PNG/Blue/Default/button_rectangle_depth_border.png");
  background-size: 100% 100%;
  background-repeat: no-repeat;
  color: #f4f7ff;
  font-size: 0.92rem;
}
.layer-btn.is-on {
  background-image: url("https://assets.popchat.com/assets/kenney/ui-pack/PNG/Green/Default/button_rectangle_depth_gloss.png");
  color: #102014;
}

.stage-wrap { position: relative; min-height: 0; padding: 0 10px 8px; display: flex; flex-direction: column; gap: 6px; }
.stage {
  position: relative;
  flex: 1;
  min-height: 240px;
  perspective: 1400px;
  border-radius: 16px;
  overflow: hidden;
  box-shadow: var(--shadow);
  background: #110e18;
}
.flipper {
  position: absolute;
  inset: 0;
  transform-style: preserve-3d;
  transition: transform 0.7s cubic-bezier(0.22, 1, 0.36, 1);
}
.flipper.back-view { transform: rotateY(180deg); }
.face {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}
.face-back { transform: rotateY(180deg); }
.flipper.back-view .face-front { pointer-events: none; }
.flipper:not(.back-view) .face-back { pointer-events: none; }

.ticker {
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--muted);
  background: var(--panel);
  border-radius: 8px;
  padding: 8px 10px;
  min-height: 36px;
  line-height: 1.35;
}

.dock {
  background: var(--panel);
  padding: 8px 10px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.clock-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}
.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border-radius: 12px;
  background: var(--bg-2);
  padding: 6px 10px;
}
.icon-btn img { display: block; width: auto; height: 22px; }
.icon-btn.off { opacity: 0.45; }
.play-btn { background-image: url("https://assets.popchat.com/assets/kenney/ui-pack/PNG/Extra/Default/button_square_depth_line.png"); background-size: 100% 100%; padding-inline: 12px; }
.chip {
  border-radius: 999px;
  padding: 0 14px;
  background: var(--bg-2);
  font-size: 0.85rem;
}
.chip.warn { background: #5a2c28; color: #ffd4cc; }
.hidden { display: none !important; }

.tools {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 4px;
}
.tool {
  flex: 0 0 auto;
  min-width: 108px;
  border-radius: 12px;
  padding: 6px 10px;
  background-color: #243044;
  background-image: url("https://assets.popchat.com/assets/kenney/ui-pack/PNG/Blue/Default/button_rectangle_depth_border.png");
  background-size: 100% 100%;
  color: #eef3ff;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  line-height: 1.15;
}
.tool small { font-weight: 600; opacity: 0.8; font-family: var(--mono); font-size: 0.7rem; }
.tool.is-on {
  background-image: url("https://assets.popchat.com/assets/kenney/ui-pack/PNG/Green/Default/button_rectangle_depth_gloss.png");
  color: #102014;
}

.inspector {
  background: var(--bg-2);
  border-radius: 12px;
  padding: 10px 12px;
}
.inspector h2 { margin: 0 0 4px; font-size: 0.95rem; }
.inspector p { margin: 0; color: var(--muted); font-size: 0.82rem; line-height: 1.4; }
.insp-actions { margin-top: 8px; display: flex; gap: 8px; flex-wrap: wrap; }

.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  display: grid;
  place-items: center;
  padding: 16px;
  z-index: 20;
}
.modal-card {
  width: min(440px, 100%);
  background: var(--bg-2);
  color: var(--ink);
  border-radius: 16px;
  padding: 18px 16px 16px;
  box-shadow: var(--shadow);
}
.modal-card h2 { margin: 8px 0 10px; font-family: var(--display); }
.modal-body { font-size: 0.92rem; line-height: 1.45; color: var(--muted); }
.modal-body p { margin: 0 0 10px; }
.primary-btn {
  width: 100%;
  margin-top: 8px;
  border-radius: 12px;
  background-image: url("https://assets.popchat.com/assets/kenney/ui-pack/PNG/Green/Default/button_rectangle_depth_gloss.png");
  background-size: 100% 100%;
  color: #102014;
  font-size: 1rem;
}
.ui-deco { display: block; }

.is-back .ticker { color: #8de7ff; }

@media (min-width: 720px) {
  #app { grid-template-rows: auto auto minmax(320px, 1fr) auto; min-height: 100dvh; }
  .brand h1 { font-size: 1.25rem; }
  .stage { min-height: 360px; }
}

@media (max-width: 380px) {
  .stats { grid-template-columns: repeat(2, 1fr); }
  .layer-btn { font-size: 0.82rem; }
}
