:root {
  color-scheme: dark;
  --bg: #0b0f17;
  --panel: #121826;
  --panel-2: #192132;
  --text: #f5f7fb;
  --muted: #9aa6b7;
  --line: rgba(255,255,255,.10);
  --accent: #e8edf5;
  --danger: #ff7b7b;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body { min-height: 100dvh; }

button { font: inherit; }

.app-shell {
  width: min(760px, 100%);
  margin: 0 auto;
  padding: max(14px, env(safe-area-inset-top)) 14px calc(24px + env(safe-area-inset-bottom));
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin: 4px 2px 14px;
}

.brand {
  font-size: 1.08rem;
  font-weight: 850;
  letter-spacing: .08em;
}

.brand span { font-weight: 450; }
.subtitle { color: var(--muted); font-size: .82rem; margin-top: 2px; }

.camera-card,
.queue-card,
.note-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 20px;
  overflow: hidden;
}

.camera-stage {
  position: relative;
  width: 100%;
  aspect-ratio: 3 / 4;
  background: #05070a;
  overflow: hidden;
}

video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.guide {
  position: absolute;
  inset: 8% 10%;
  border: 2px solid rgba(255,255,255,.78);
  border-radius: 15px;
  box-shadow: 0 0 0 999px rgba(0,0,0,.13);
  pointer-events: none;
}

.guide::before,
.guide::after {
  content: "";
  position: absolute;
  width: 34px;
  height: 34px;
  border-color: #fff;
}

.guide::before {
  top: -3px; left: -3px;
  border-top: 4px solid;
  border-left: 4px solid;
  border-radius: 12px 0 0 0;
}

.guide::after {
  right: -3px; bottom: -3px;
  border-right: 4px solid;
  border-bottom: 4px solid;
  border-radius: 0 0 12px 0;
}

.guide-label {
  position: absolute;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  white-space: nowrap;
  background: rgba(0,0,0,.58);
  padding: 6px 9px;
  border-radius: 999px;
  font-size: .72rem;
}

.camera-message {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  text-align: center;
  gap: 7px;
  padding: 30px;
  background: linear-gradient(rgba(5,7,10,.72), rgba(5,7,10,.86));
}

.camera-message span { color: var(--muted); font-size: .9rem; }

.controls {
  display: grid;
  grid-template-columns: 1fr 88px 1fr;
  align-items: center;
  gap: 10px;
  padding: 14px;
}

.secondary, .ghost, .text-btn {
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--text);
  border-radius: 12px;
  padding: 11px 12px;
  cursor: pointer;
}

.secondary:disabled { opacity: .4; cursor: default; }

.ghost { padding: 8px 11px; }

.capture {
  width: 74px;
  height: 74px;
  justify-self: center;
  border: 0;
  background: transparent;
  padding: 0;
  cursor: pointer;
}

.capture:disabled { opacity: .35; cursor: default; }

.capture-ring {
  width: 74px;
  height: 74px;
  display: grid;
  place-items: center;
  border: 4px solid #fff;
  border-radius: 50%;
}

.capture-dot {
  width: 58px;
  height: 58px;
  display: block;
  background: #fff;
  border-radius: 50%;
  transition: transform .08s ease;
}

.capture:active .capture-dot { transform: scale(.88); }

.stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin: 10px 0;
}

.stats article {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 15px;
  padding: 12px 8px;
  text-align: center;
}

.stats span {
  display: block;
  font-size: 1.45rem;
  font-weight: 780;
}

.stats small { color: var(--muted); }

.queue-card { padding: 15px; }

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.section-head h2 { margin: 0; font-size: 1.05rem; }
.section-head p { margin: 3px 0 0; color: var(--muted); font-size: .82rem; }

.text-btn {
  background: transparent;
  color: var(--muted);
  padding: 8px 9px;
}

.empty-state {
  border: 1px dashed var(--line);
  border-radius: 14px;
  color: var(--muted);
  text-align: center;
  padding: 24px 15px;
}

.thumb-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.thumb {
  position: relative;
  aspect-ratio: 3 / 4;
  overflow: hidden;
  border-radius: 12px;
  background: #0a0d12;
  border: 1px solid var(--line);
}

.thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.badge {
  position: absolute;
  left: 6px;
  bottom: 6px;
  border-radius: 999px;
  padding: 4px 7px;
  font-size: .65rem;
  background: rgba(0,0,0,.70);
}

.note-card {
  margin-top: 10px;
  padding: 14px 15px;
}

.note-card p { color: var(--muted); margin: 5px 0 0; line-height: 1.45; }

.hidden { display: none !important; }
.hidden-canvas { display: none; }

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(20px + env(safe-area-inset-bottom));
  transform: translateX(-50%) translateY(120px);
  background: #fff;
  color: #10141d;
  padding: 10px 14px;
  border-radius: 999px;
  font-weight: 650;
  opacity: 0;
  transition: .2s ease;
  pointer-events: none;
  z-index: 20;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

@media (min-width: 650px) {
  .camera-stage { aspect-ratio: 4 / 3; }
  .guide { inset: 8% 20%; }
  .thumb-grid { grid-template-columns: repeat(5, 1fr); }
}
