:root {
  --bg: #0e0b14;
  --bg-elevated: #171320;
  --card: #1c1726;
  --card-hover: #241e34;
  --text: #f3eefc;
  --text-dim: #a89fc0;
  --accent: #ff6fb0;
  --accent-2: #8a6bff;
  --accent-grad: linear-gradient(135deg, #ff6fb0, #8a6bff);
  --line: rgba(255, 255, 255, 0.08);
  --radius: 18px;
  --shadow: 0 12px 30px rgba(0, 0, 0, 0.35);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

body {
  min-height: 100vh;
  padding-bottom: 48px;
}

a {
  color: inherit;
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(14, 11, 20, 0.85);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
  padding: 14px 20px;
}

.app-header__row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  max-width: 1080px;
  margin: 0 auto;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 1.15rem;
  letter-spacing: 0.2px;
}

.brand__mark {
  width: 32px;
  height: 32px;
  border-radius: 10px;
  background: var(--accent-grad);
  display: grid;
  place-items: center;
  font-size: 16px;
}

.search-wrap {
  flex: 1;
  max-width: 360px;
  position: relative;
}

.search-wrap input {
  width: 100%;
  padding: 10px 14px 10px 36px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--bg-elevated);
  color: var(--text);
  font-size: 0.92rem;
  outline: none;
}

.search-wrap input:focus {
  border-color: var(--accent-2);
}

.search-wrap::before {
  content: "🔍";
  position: absolute;
  left: 13px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 13px;
  opacity: 0.7;
}

.fav-toggle {
  background: var(--bg-elevated);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 999px;
  padding: 10px 14px;
  font-size: 0.85rem;
  cursor: pointer;
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 6px;
}

.fav-toggle.active {
  background: var(--accent-grad);
  border-color: transparent;
}

.chips {
  max-width: 1080px;
  margin: 14px auto 0;
  padding: 0 20px;
  display: flex;
  gap: 8px;
  overflow-x: auto;
  scrollbar-width: none;
}

.chips::-webkit-scrollbar {
  display: none;
}

.chip {
  flex: none;
  border: 1px solid var(--line);
  background: var(--bg-elevated);
  color: var(--text-dim);
  border-radius: 999px;
  padding: 8px 16px;
  font-size: 0.85rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.chip.active {
  background: var(--accent-grad);
  color: #fff;
  border-color: transparent;
}

main {
  max-width: 1080px;
  margin: 0 auto;
  padding: 20px;
}

.section-title {
  font-size: 0.95rem;
  color: var(--text-dim);
  margin: 26px 2px 12px;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 14px;
}

.pose-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px;
  cursor: pointer;
  position: relative;
  transition: transform 0.15s, background 0.15s, box-shadow 0.15s;
}

.pose-card:hover {
  background: var(--card-hover);
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}

.pose-card__thumb {
  background: radial-gradient(circle at 50% 20%, rgba(138, 107, 255, 0.18), transparent 70%);
  border-radius: 12px;
  aspect-ratio: 3/4;
  display: grid;
  place-items: center;
  overflow: hidden;
}

.pose-svg {
  width: 85%;
  height: 85%;
}

.pose-figure .pose-head {
  fill: none;
  stroke: var(--text);
  stroke-width: 3.2;
}

.pose-limb {
  fill: none;
  stroke: var(--text);
  stroke-width: 3.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.pose-connector {
  stroke: var(--accent);
  stroke-width: 2.6;
  opacity: 0.85;
}

.pose-prop {
  stroke: rgba(255, 255, 255, 0.25);
  stroke-width: 2.2;
  stroke-dasharray: 4 4;
  fill: none;
}

.pose-card__name {
  font-size: 0.84rem;
  font-weight: 600;
  margin-top: 8px;
  line-height: 1.25;
}

.pose-card__meta {
  font-size: 0.72rem;
  color: var(--text-dim);
  margin-top: 2px;
}

.pose-card__fav {
  position: absolute;
  top: 10px;
  right: 10px;
  background: rgba(0, 0, 0, 0.4);
  border: none;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: #fff;
  font-size: 13px;
  cursor: pointer;
}

.pose-card__fav.active {
  background: var(--accent-grad);
}

.empty-state {
  text-align: center;
  color: var(--text-dim);
  padding: 60px 20px;
}

/* ---------- Modal (pose detail) ---------- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(5, 4, 8, 0.75);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 50;
}

@media (min-width: 640px) {
  .modal-backdrop {
    align-items: center;
  }
}

.modal {
  background: var(--bg-elevated);
  border-radius: 24px 24px 0 0;
  width: 100%;
  max-width: 420px;
  max-height: 88vh;
  overflow-y: auto;
  padding: 20px;
  border: 1px solid var(--line);
}

@media (min-width: 640px) {
  .modal {
    border-radius: 24px;
  }
}

.modal__close {
  float: right;
  background: var(--card);
  border: none;
  color: var(--text);
  width: 32px;
  height: 32px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 15px;
}

.modal__hero {
  background: radial-gradient(circle at 50% 20%, rgba(255, 111, 176, 0.18), transparent 70%);
  border-radius: 16px;
  aspect-ratio: 4/5;
  display: grid;
  place-items: center;
  margin: 10px 0 16px;
}

.modal__hero .pose-svg {
  width: 72%;
  height: 72%;
}

.modal__title {
  font-size: 1.2rem;
  font-weight: 700;
  margin: 0 0 4px;
}

.modal__tags {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}

.tag {
  font-size: 0.72rem;
  color: var(--text-dim);
  border: 1px solid var(--line);
  padding: 3px 9px;
  border-radius: 999px;
}

.modal__tip {
  font-size: 0.9rem;
  color: var(--text-dim);
  line-height: 1.5;
  margin-bottom: 18px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 13px 18px;
  border-radius: 14px;
  border: none;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
}

.btn-primary {
  background: var(--accent-grad);
  color: #fff;
}

.btn-secondary {
  background: var(--card);
  color: var(--text);
  border: 1px solid var(--line);
  margin-top: 8px;
}

/* ---------- Camera overlay ---------- */
.camera-view {
  position: fixed;
  inset: 0;
  background: #000;
  z-index: 60;
  display: flex;
  flex-direction: column;
}

.camera-view video,
.camera-view canvas.capture-preview {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.camera-view .pose-overlay {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.camera-view .pose-overlay .pose-limb,
.camera-view .pose-overlay .pose-head {
  stroke: #fff;
}

.camera-view .pose-overlay .pose-connector {
  stroke: var(--accent);
}

.camera-top,
.camera-bottom {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px;
  gap: 10px;
}

.camera-top {
  background: linear-gradient(to bottom, rgba(0, 0, 0, 0.55), transparent);
}

.camera-bottom {
  margin-top: auto;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.6), transparent);
  flex-direction: column;
  gap: 14px;
}

.icon-btn {
  background: rgba(255, 255, 255, 0.12);
  border: none;
  color: #fff;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 16px;
  cursor: pointer;
}

.opacity-row {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  color: #fff;
  font-size: 0.8rem;
}

.opacity-row input[type="range"] {
  flex: 1;
}

.shutter-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 28px;
}

.shutter-btn {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  border: 4px solid #fff;
  background: rgba(255, 255, 255, 0.15);
  cursor: pointer;
}

.shutter-btn:active {
  background: #fff;
}

.camera-hint {
  color: #fff;
  text-align: center;
  font-size: 0.8rem;
  opacity: 0.85;
  padding: 0 24px;
}

.camera-error {
  color: #fff;
  text-align: center;
  padding: 40px 24px;
  margin: auto;
}

.preview-actions {
  display: flex;
  gap: 12px;
  width: 100%;
}

.preview-actions .btn {
  width: auto;
  flex: 1;
}
