/* Cheesely — Lyricly family look: dark, Inter + Sarabun, flat surfaces, hairline borders,
   4px radius, one lavender accent. */
:root {
  color-scheme: dark;
  --bg: #101014;
  --surface: #18181f;
  --surface-2: #1f1f28;
  --border: rgba(255, 255, 255, 0.07);
  --border-strong: rgba(255, 255, 255, 0.13);
  --text: #f7f7fa;
  --text-2: #b4b4c0;
  --accent: #b6a0fc;
  --accent-strong: #8b5cf6;
  --accent-ink: #120c22;
  --lavender-soft: rgba(196, 181, 253, 0.12);
  --glow: rgba(167, 139, 250, 0.35);
  --danger: #fca5a5;
  --font: "Inter", "Sarabun", system-ui, -apple-system, sans-serif;
  --r: 4px;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
button, input { font: inherit; color: inherit; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

.top {
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(12px + var(--safe-top)) 16px 12px;
  max-width: 520px; margin: 0 auto;
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 20px; letter-spacing: -0.01em; }
.brand-mark {
  width: 18px; height: 18px; border: 2px solid var(--accent); border-radius: var(--r);
  transform: rotate(-8deg); box-shadow: 0 0 12px var(--glow);
}
.quota {
  font-size: 13px; color: var(--text-2); padding: 4px 10px;
  border: 1px solid var(--border-strong); border-radius: 999px;
}

.app {
  max-width: 520px; margin: 0 auto; padding: 0 16px calc(16px + var(--safe-bottom));
  display: flex; flex-direction: column; gap: 14px;
}

/* 3:4 frame */
.stage {
  position: relative; width: 100%; aspect-ratio: 3 / 4; overflow: hidden;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r);
  max-height: 64dvh; margin: 0 auto;
}
.stage.landscape { aspect-ratio: 4 / 3; }
.stage video, .stage img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.stage video.mirror { transform: scaleX(-1); }
.working {
  position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; gap: 12px;
  background: rgba(16, 16, 20, 0.55); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
}
.working p { margin: 0; font-weight: 600; }
.spinner {
  width: 44px; height: 44px; border-radius: 50%;
  border: 3px solid var(--lavender-soft); border-top-color: var(--accent);
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.nocam { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; padding: 24px; }
.nocam p { margin: 4px 0; font-weight: 600; }
.nocam .sub { font-weight: 400; color: var(--text-2); font-size: 14px; }
.hold {
  position: absolute; left: 50%; bottom: 12px; transform: translateX(-50%);
  min-height: 40px; padding: 8px 14px; border-radius: 999px; border: 1px solid var(--border-strong);
  background: rgba(16, 16, 20, 0.7); font-size: 13px; color: var(--text); cursor: pointer;
  user-select: none; -webkit-user-select: none; touch-action: none;
}

/* Filter chips: one scrolling row */
.filters {
  display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none;
  margin: 0 -16px; padding: 2px 16px; scroll-snap-type: x proximity;
}
.filters::-webkit-scrollbar { display: none; }
.chip {
  flex: none; scroll-snap-align: start; display: flex; align-items: center; gap: 6px;
  min-height: 44px; padding: 8px 14px; border-radius: var(--r);
  background: var(--surface); border: 1px solid var(--border); color: var(--text-2);
  font-size: 15px; cursor: pointer; transition: background 0.2s var(--ease), color 0.2s var(--ease);
}
.chip[aria-pressed="true"] { background: var(--lavender-soft); border-color: var(--accent); color: var(--text); }
.chip:disabled { opacity: 0.5; cursor: default; }

/* Controls */
.controls { display: flex; align-items: center; justify-content: space-between; padding: 4px 24px; }
.controls.result { justify-content: center; gap: 12px; padding: 4px 0; }
.round {
  width: 52px; height: 52px; display: grid; place-items: center; cursor: pointer;
  border-radius: 50%; background: var(--surface); border: 1px solid var(--border-strong);
}
.round svg { width: 24px; height: 24px; fill: none; stroke: var(--text); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.shutter {
  width: 76px; height: 76px; border-radius: 50%; padding: 5px; cursor: pointer;
  background: transparent; border: 3px solid var(--text);
}
.shutter span {
  display: block; width: 100%; height: 100%; border-radius: 50%; background: var(--text);
  transition: transform 0.15s var(--ease), background 0.2s;
}
.shutter:active span { transform: scale(0.88); background: var(--accent); }
.shutter:disabled { opacity: 0.4; cursor: default; }
.btn {
  min-height: 48px; padding: 10px 20px; border-radius: var(--r); cursor: pointer; font-weight: 600;
  background: var(--surface-2); border: 1px solid var(--border-strong);
}
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
button:focus-visible, label:focus-within { outline: 2px solid var(--accent); outline-offset: 2px; }

.toast {
  position: fixed; left: 50%; bottom: calc(24px + var(--safe-bottom)); transform: translateX(-50%);
  max-width: calc(100% - 32px); padding: 12px 16px; border-radius: var(--r);
  background: rgba(40, 40, 52, 0.95); border: 1px solid var(--border-strong);
  font-size: 14px; text-align: center; z-index: 10;
}
.toast.error { border-color: var(--danger); }

@media (prefers-reduced-motion: reduce) { * { animation-duration: 0.01ms !important; transition: none !important; } }
