:root {
  color-scheme: dark;
  --bg: #111318;
  --panel: #1b1f28;
  --panel-2: #232936;
  --line: #343b4a;
  --text: #f7f5ee;
  --muted: #b9bfcc;
  --accent: #20d5b4;
  --accent-2: #ffcf4a;
  --danger: #ff6a7a;
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.34);
  --webcam-aspect: 5 / 3;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  background:
    radial-gradient(circle at top left, rgba(32, 213, 180, 0.12), transparent 34rem),
    linear-gradient(135deg, #111318 0%, #151923 52%, #201923 100%);
  color: var(--text);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.035), transparent 220px);
}

button,
input {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

.app-shell {
  width: min(1340px, calc(100vw - 28px));
  min-height: 100vh;
  margin: 0 auto;
  padding: 18px 0 34px;
  display: grid;
  grid-template-columns: 1fr;
  grid-template-areas:
    "camera"
    "shot"
    "search";
  gap: 14px;
  align-items: start;
}

.camera-stage,
.shot-panel,
.search-content {
  background: rgba(27, 31, 40, 0.88);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.camera-stage {
  grid-area: camera;
  min-width: 0;
  width: 100%;
  max-width: 1240px;
  justify-self: center;
  padding: 14px;
  display: grid;
  grid-template-rows: auto auto;
  gap: 12px;
}

.stage-top,
.shot-header,
.actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.site-brand {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.site-logo {
  width: clamp(58px, 6.8vw, 84px);
  height: clamp(58px, 6.8vw, 84px);
  object-fit: contain;
  flex: 0 0 auto;
  filter: drop-shadow(0 10px 24px rgba(32, 213, 180, 0.18));
}

.site-brand-copy {
  min-width: 0;
}

.brand-name {
  margin: 0 0 4px;
  font-family: "Arial Rounded MT Bold", "Nunito", "Trebuchet MS", Inter, system-ui, sans-serif;
  font-size: clamp(1.35rem, 2.2vw, 2.35rem);
  font-weight: 900;
  line-height: 1;
  letter-spacing: 0;
  text-wrap: balance;
}

.brand-funny {
  color: var(--accent);
}

.brand-webcam {
  color: #ff4fa3;
}

.brand-domain {
  color: var(--accent-2);
  font-size: 0.78em;
}

.eyebrow {
  margin: 0 0 5px;
  color: var(--accent);
  font-size: 0.8rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0;
}

.tracking-status {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 0.86rem;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(1.55rem, 2.1vw, 2.5rem);
  line-height: 1.05;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 0;
  font-size: 1.05rem;
}

h3 {
  margin-bottom: 10px;
  font-size: 0.95rem;
}

.icon-button {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--line);
  font-size: 1.35rem;
}

.studio-links {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.studio-links a {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 12px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--text);
  font-size: 0.86rem;
  font-weight: 700;
  text-decoration: none;
}

.viewer {
  position: relative;
  overflow: hidden;
  width: 100%;
  max-width: min(100%, calc((100dvh - 180px) * 5 / 3));
  min-width: 280px;
  height: auto;
  aspect-ratio: var(--webcam-aspect);
  margin: 0 auto;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #07080a;
}

video,
canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

video {
  opacity: 0;
  pointer-events: none;
}

.permission-card {
  position: absolute;
  inset: 0;
  z-index: 3;
  display: grid;
  place-content: center;
  justify-items: center;
  padding: 24px;
  text-align: center;
  background:
    linear-gradient(rgba(10, 12, 16, 0.35), rgba(10, 12, 16, 0.7)),
    repeating-linear-gradient(135deg, #191e29 0 16px, #11151e 16px 32px);
}

.permission-card p {
  max-width: 430px;
  color: var(--muted);
}

.permission-card.is-hidden {
  display: none;
}

.controls {
  display: grid;
  gap: 10px;
}

.effect-navigator-row {
  display: flex;
  gap: 8px;
  align-items: stretch;
  margin-bottom: -4px;
}

.effect-navigator {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--panel-2);
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid var(--line);
}

.category-select {
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 12px;
  font-weight: 800;
  font-size: 0.95rem;
  outline: none;
  cursor: pointer;
  transition: border-color 0.2s;
}

.category-select:focus,
.category-select:hover {
  border-color: var(--accent);
}

.snapshot.has-image {
  background: transparent;
  border: 1px solid var(--line);
}

/* Camera Capture Animations */
.camera-flash {
  position: absolute;
  inset: 0;
  background: white;
  z-index: 100;
  opacity: 1;
  pointer-events: none;
  transition: opacity 0.5s ease-out;
}

.flying-snapshot {
  position: fixed;
  z-index: 1000;
  object-fit: cover;
  border-radius: 8px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.7);
  pointer-events: none;
  transition: all 0.7s cubic-bezier(0.25, 1, 0.3, 1);
}

.nav-btn {
  background: transparent;
  color: var(--text);
  border: none;
  font-size: 1.2rem;
  padding: 4px 16px;
  cursor: pointer;
  border-radius: 4px;
  transition: background 0.2s;
}

.nav-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--accent);
}

#currentEffectDisplay {
  font-weight: 800;
  color: var(--accent);
  font-size: 1rem;
  text-align: center;
  flex: 1;
}

.effect-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(108px, 1fr));
  gap: 8px;
  max-height: 138px;
  overflow: auto;
  padding-right: 4px;
  scrollbar-color: var(--accent) rgba(255, 255, 255, 0.08);
}

.effect-button {
  min-height: 40px;
  padding: 8px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--text);
  font-weight: 800;
  font-size: 0.84rem;
  line-height: 1.1;
}

.effect-button[aria-pressed="true"] {
  color: #07120f;
  background: var(--accent);
  border-color: transparent;
}

@keyframes btn-shine-idle {
  0% { transform: translateX(-150%) skewX(-25deg); }
  2% { transform: translateX(150%) skewX(-25deg); }
  100% { transform: translateX(150%) skewX(-25deg); }
}

@keyframes pulse-glow-idle {
  0% { box-shadow: 0 0 0 rgba(32, 213, 180, 0); }
  0.5% { box-shadow: 0 0 20px rgba(32, 213, 180, 0.8); }
  1% { box-shadow: 0 0 0 rgba(32, 213, 180, 0); }
  1.5% { box-shadow: 0 0 20px rgba(32, 213, 180, 0.8); }
  2% { box-shadow: 0 0 0 rgba(32, 213, 180, 0); }
  100% { box-shadow: 0 0 0 rgba(32, 213, 180, 0); }
}

@keyframes btn-shine-hover {
  0% { transform: translateX(-150%) skewX(-25deg); }
  100% { transform: translateX(150%) skewX(-25deg); }
}

@keyframes pulse-glow-hover {
  0% { box-shadow: 0 0 10px rgba(32, 213, 180, 0.4); }
  50% { box-shadow: 0 0 25px rgba(46, 224, 255, 0.8); }
  100% { box-shadow: 0 0 10px rgba(32, 213, 180, 0.4); }
}

.capture-btn-small {
  background: linear-gradient(135deg, var(--accent), #2ee0ff);
  color: #07120f;
  border: none;
  border-radius: 8px;
  padding: 0 20px;
  font-weight: 900;
  font-size: 0.95rem;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.2s, background 0.2s;
  animation: pulse-glow-idle 120s infinite;
}

.capture-btn-small::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(255, 255, 255, 0.4);
  transform: translateX(-150%) skewX(-25deg);
  animation: btn-shine-idle 120s infinite;
}

.capture-btn-small > i,
.capture-btn-small > span {
  display: inline-block;
  transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
  position: relative;
  z-index: 1;
}

.capture-btn-small:hover:not(:disabled) {
  transform: scale(1.05);
  animation: pulse-glow-hover 1.5s infinite;
}

.capture-btn-small:hover:not(:disabled)::before {
  animation: btn-shine-hover 1.5s infinite;
}

.capture-btn-small:hover:not(:disabled) > i {
  transform: scale(1.2) rotate(-10deg);
}

.capture-btn-small:hover:not(:disabled) > span {
  transform: scale(1.05);
}

.capture-btn-small:disabled {
  background: var(--panel-2);
  color: var(--muted);
  animation: none;
  box-shadow: none;
}

.capture-btn-small:disabled::before {
  display: none;
}

.header-actions {
  display: flex;
  gap: 8px;
}

.action-btn {
  min-height: 44px;
  padding: 0 18px;
  border-radius: 8px;
  background: var(--accent-2);
  color: #07120f;
  font-weight: 900;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: none;
  cursor: pointer;
  transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.2s;
}

.action-btn > i,
.action-btn > span {
  display: inline-block;
  transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.action-btn:hover:not(:disabled) {
  opacity: 0.9;
  transform: scale(1.05);
}

.action-btn:hover:not(:disabled) > i {
  transform: scale(1.2) rotate(-10deg);
}

.action-btn:hover:not(:disabled) > span {
  transform: scale(1.05);
}

@keyframes pulse-glow-warm {
  0% { box-shadow: 0 0 10px rgba(255, 78, 80, 0.4); }
  50% { box-shadow: 0 0 25px rgba(249, 212, 35, 0.8); }
  100% { box-shadow: 0 0 10px rgba(255, 78, 80, 0.4); }
}

.start-btn-flashy {
  background: linear-gradient(135deg, #ff4e50, #f9d423);
  color: #07120f;
  border: none;
  border-radius: 8px;
  padding: 0 24px;
  min-height: 52px;
  font-weight: 900;
  font-size: 1.15rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.2s;
  animation: pulse-glow-warm 1.5s infinite;
}

.start-btn-flashy::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(255, 255, 255, 0.4);
  transform: translateX(-150%) skewX(-25deg);
  animation: btn-shine-hover 1.5s infinite;
}

.start-btn-flashy > i,
.start-btn-flashy > span {
  display: inline-block;
  transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
  position: relative;
  z-index: 1;
}

.start-btn-flashy:hover {
  transform: scale(1.05);
}

.start-btn-flashy:hover > i {
  transform: scale(1.2) rotate(-10deg);
}

.start-btn-flashy:hover > span {
  transform: scale(1.05);
}

#download {
  min-height: 44px;
  padding: 0 18px;
  border-radius: 8px;
  background: var(--accent);
  color: #07120f;
  font-weight: 900;
}

#download {
  background: var(--accent-2);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.shot-panel {
  grid-area: shot;
  width: 100%;
  max-width: 1240px;
  justify-self: center;
  padding: 16px;
  display: grid;
  grid-template-columns: minmax(260px, 420px) 1fr;
  grid-template-rows: auto auto;
  grid-template-areas:
    "header keywords"
    "snapshot keywords";
  gap: 14px;
  max-height: none;
}

.shot-panel .shot-header {
  grid-area: header;
}

.shot-panel .snapshot-frame {
  grid-area: snapshot;
}

.shot-panel .seo-list {
  grid-area: keywords;
}

.snapshot-frame {
  position: relative;
  overflow: hidden;
  display: grid;
  place-items: center;
  min-height: 240px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.22);
}

.carousel-btn {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(0, 0, 0, 0.6);
  color: white;
  border: none;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  font-size: 1.2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 10;
  transition: background 0.2s;
}

.carousel-btn:hover {
  background: rgba(0, 0, 0, 0.8);
}

.carousel-btn.left {
  left: 10px;
}

.carousel-btn.right {
  right: 10px;
}

.shot-counter {
  position: absolute;
  bottom: 10px;
  background: rgba(0, 0, 0, 0.6);
  color: white;
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 0.8rem;
  font-weight: bold;
}

#snapshot {
  display: none;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

#snapshot.has-image {
  display: block;
}

#snapshotEmpty {
  padding: 18px;
  color: var(--muted);
  text-align: center;
}

.seo-list {
  border-top: 1px solid var(--line);
  padding-top: 14px;
}

#keywordLinks {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

#keywordLinks a {
  color: var(--text);
  text-decoration: underline;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.04);
  font-size: 0.82rem;
}

.search-content {
  grid-area: search;
  max-width: 1240px;
  justify-self: center;
  padding: 18px;
  color: var(--muted);
}

.search-content h2 {
  margin-bottom: 8px;
  color: var(--text);
  font-size: clamp(1.15rem, 1.6vw, 1.45rem);
}

.search-content > p {
  max-width: 940px;
  margin-bottom: 16px;
  line-height: 1.6;
}

.search-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.search-grid article {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.035);
}

.search-grid p {
  margin-bottom: 0;
  font-size: 0.92rem;
  line-height: 1.5;
}

/* Category Colors */
.effect-button[data-category="funny"] { border-color: rgba(255, 107, 107, 0.4); background: rgba(255, 107, 107, 0.08); }
.effect-button[data-category="funny"][aria-pressed="true"] { background: #ff8787; border-color: #ff8787; color: #111; }

.effect-button[data-category="classic"] { border-color: rgba(132, 94, 247, 0.4); background: rgba(132, 94, 247, 0.08); }
.effect-button[data-category="classic"][aria-pressed="true"] { background: #b197fc; border-color: #b197fc; color: #111; }

.effect-button[data-category="fun"] { border-color: rgba(252, 196, 25, 0.4); background: rgba(252, 196, 25, 0.08); }
.effect-button[data-category="fun"][aria-pressed="true"] { background: #fcc419; border-color: #fcc419; color: #111; }

.effect-button[data-category="color"] { border-color: rgba(59, 201, 219, 0.4); background: rgba(59, 201, 219, 0.08); }
.effect-button[data-category="color"][aria-pressed="true"] { background: #66d9e8; border-color: #66d9e8; color: #111; }

.effect-button[data-category="glow"] { border-color: rgba(81, 207, 102, 0.4); background: rgba(81, 207, 102, 0.08); }
.effect-button[data-category="glow"][aria-pressed="true"] { background: #69db7c; border-color: #69db7c; color: #111; }

.effect-button[data-category="warp"] { border-color: rgba(255, 146, 43, 0.4); background: rgba(255, 146, 43, 0.08); }
.effect-button[data-category="warp"][aria-pressed="true"] { background: #ffa94d; border-color: #ffa94d; color: #111; }

.effect-button[data-category="art"] { border-color: rgba(240, 101, 149, 0.4); background: rgba(240, 101, 149, 0.08); }
.effect-button[data-category="art"][aria-pressed="true"] { background: #fcc2d7; border-color: #fcc2d7; color: #111; }

@media (max-width: 900px) {
  .app-shell {
    grid-template-columns: 1fr;
    grid-template-areas:
      "camera"
      "shot"
      "search";
    width: min(100vw - 18px, 820px);
    padding: 9px 0 22px;
  }

  .viewer {
    height: auto;
    aspect-ratio: var(--webcam-aspect);
    min-height: 0;
  }

  .shot-panel {
    position: static;
    grid-template-columns: 1fr;
    grid-template-areas:
      "header"
      "snapshot"
      "keywords";
  }

  .effect-strip {
    max-height: 174px;
  }

  .search-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 520px) {
  .app-shell {
    width: 100%;
    padding: 0 0 18px;
    gap: 10px;
  }

  .camera-stage,
  .shot-panel,
  .search-content {
    border-left: 0;
    border-right: 0;
    border-radius: 0;
    padding: 10px;
  }

  .stage-top {
    align-items: flex-start;
    flex-direction: column;
  }

  .site-brand {
    gap: 10px;
  }

  .site-logo {
    width: 56px;
    height: 56px;
  }

  .studio-links {
    justify-content: flex-start;
  }

  .viewer {
    height: auto;
    aspect-ratio: var(--webcam-aspect);
    min-height: 0;
  }

  .effect-navigator-row {
    flex-direction: column;
  }

  .actions {
    gap: 8px;
  }

  .timer-btn {
    min-width: 58px;
    padding: 0 10px;
  }

  .capture-btn-large {
    min-height: 50px !important;
  }

  .effect-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    max-height: 176px;
  }
}

/* Editor Panel Styles */
.editor-sidebar {
  display: none;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  flex-direction: column;
  overflow: hidden;
}

.editor-sidebar.open {
  display: flex;
}

.panels {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
}

.panel { display: none; }
.panel.active { display: block; }

.control-group {
  margin-bottom: 16px;
  background: var(--panel-2);
  padding: 12px;
  border-radius: 8px;
}
.control-group label {
  display: flex;
  justify-content: space-between;
  margin-bottom: 8px;
  font-size: 0.85rem;
  color: var(--muted);
}
input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
}
.val-input {
  background: var(--bg);
  color: var(--accent);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 2px 4px;
  width: 50px;
  text-align: right;
  font-family: inherit;
  font-size: 0.85rem;
}
.checkbox-group {
  display: flex;
  gap: 15px;
  margin-top: 10px;
}
.checkbox-group label {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 0.85rem;
  cursor: pointer;
}
.editor-select {
  width: 100%;
  padding: 8px;
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 4px;
  margin-top: 5px;
  font-family: inherit;
}
.save-btn {
  background: var(--accent);
  color: #07120f;
  border: none;
  padding: 8px 16px;
  border-radius: 6px;
  cursor: pointer;
  font-weight: bold;
}
.save-btn:hover { background: #16a38a; }
