:root {
  color-scheme: light;
  --ink: #151917;
  --muted: #747d79;
  --quiet: #a2aaa6;
  --paper: #f5f6f2;
  --surface: #ffffff;
  --line: #dfe5e1;
  --stage: #111514;
  --accent: #ff5f57;
  --accent-deep: #df4e47;
  --signal: #2f9c69;
  --shadow: 0 20px 55px rgba(20, 30, 25, 0.13);
  font-family: Inter, "Noto Sans JP", "Yu Gothic", YuGothic, system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  min-height: 100%;
  background: var(--paper);
}

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  background: var(--paper);
  color: var(--ink);
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

button,
a.primary-button {
  font: inherit;
}

button:focus-visible,
a:focus-visible {
  outline: 3px solid rgba(255, 95, 87, 0.34);
  outline-offset: 4px;
}

[hidden] {
  display: none !important;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.app-shell {
  width: min(100%, 760px);
  min-height: 100vh;
  margin: 0 auto;
  padding: max(20px, env(safe-area-inset-top)) clamp(18px, 4vw, 34px) 28px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 40px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  color: var(--ink);
  font-size: 0.88rem;
  font-weight: 800;
  letter-spacing: -0.04em;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  width: 30px;
  height: 30px;
  place-items: center;
  border-radius: 9px;
  background: var(--ink);
}

.brand-mark svg {
  width: 19px;
  height: 19px;
  fill: none;
  stroke: #fff;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.7;
}

.privacy-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 28px;
  padding: 5px 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.45);
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 750;
}

.privacy-dot,
.live-dot,
.recording-indicator {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--signal);
}

.launch-panel,
.camera-panel,
.result-panel {
  width: min(100%, 620px);
  margin: 0 auto;
}

.launch-panel {
  padding: clamp(78px, 17vh, 158px) 0 70px;
}

.hero-copy {
  margin-bottom: 34px;
}

.eyebrow {
  margin: 0 0 14px;
  color: var(--quiet);
  font-size: 0.63rem;
  font-weight: 850;
  letter-spacing: 0.2em;
}

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

.hero-copy h1,
.camera-heading h1,
.result-heading h1 {
  margin-bottom: 17px;
  color: var(--ink);
  font-size: clamp(3.2rem, 13vw, 6.4rem);
  font-weight: 850;
  letter-spacing: -0.09em;
  line-height: 0.91;
}

.hero-copy h1 em {
  color: var(--accent);
  font-style: normal;
}

.hero-description {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 0.95rem;
  letter-spacing: -0.02em;
  line-height: 1.7;
}

.primary-button,
.secondary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 52px;
  border-radius: 15px;
  cursor: pointer;
  font-size: 0.88rem;
  font-weight: 800;
  text-decoration: none;
  transition: transform 160ms ease, background 160ms ease, border-color 160ms ease, opacity 160ms ease;
}

.primary-button {
  gap: 12px;
  width: min(100%, 268px);
  padding: 13px 16px;
  border: 0;
  background: var(--ink);
  color: #fff;
}

.primary-button:hover:not(:disabled),
.secondary-button:hover:not(:disabled),
.record-button:hover:not(:disabled) {
  transform: translateY(-2px);
}

.primary-button:hover:not(:disabled) {
  background: #2a302d;
}

.primary-button:active:not(:disabled),
.secondary-button:active:not(:disabled),
.record-button:active:not(:disabled) {
  transform: translateY(0);
}

.primary-button:disabled,
.secondary-button:disabled,
.record-button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.button-camera-icon {
  display: grid;
  width: 24px;
  height: 24px;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.38);
  border-radius: 7px;
}

.button-camera-icon svg {
  width: 15px;
  height: 15px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.5;
}

.button-arrow {
  margin-left: auto;
  font-size: 1.1rem;
  font-weight: 400;
}

.launch-note {
  margin: 13px 0 0 2px;
  color: var(--quiet);
  font-size: 0.68rem;
}

.launch-note span {
  color: var(--signal);
  font-size: 0.56rem;
  vertical-align: 1px;
}

.inline-error {
  width: min(100%, 510px);
  margin: 17px 0 0;
  padding: 11px 13px;
  border: 1px solid rgba(190, 65, 60, 0.2);
  border-radius: 12px;
  background: #fff0ee;
  color: #a83b35;
  font-size: 0.76rem;
  line-height: 1.55;
}

.camera-panel,
.result-panel {
  padding: 30px 0 58px;
}

.camera-heading,
.result-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 13px;
}

.camera-context {
  color: var(--quiet);
  font-size: 0.62rem;
  font-weight: 850;
  letter-spacing: 0.19em;
}

.model-status {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 28px;
  padding: 6px 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.58);
  color: var(--muted);
  font-size: 0.65rem;
  font-weight: 750;
  white-space: nowrap;
}

.model-status.is-ready {
  border-color: rgba(47, 156, 105, 0.23);
  background: #edf8f1;
  color: #267a53;
}

.model-status.is-error {
  max-width: 250px;
  border-color: rgba(190, 65, 60, 0.2);
  background: #fff0ee;
  color: #a83b35;
  white-space: normal;
}

.status-spinner {
  width: 10px;
  height: 10px;
  border: 1.5px solid rgba(116, 125, 121, 0.26);
  border-top-color: currentColor;
  border-radius: 50%;
  animation: spin 800ms linear infinite;
}

.is-ready .status-spinner {
  display: none;
}

.stage-wrap {
  width: min(100%, 430px);
  margin: 0 auto;
}

.stage {
  position: relative;
  overflow: hidden;
  width: 100%;
  aspect-ratio: 9 / 16;
  border-radius: 24px;
  background: var(--stage);
  box-shadow: var(--shadow);
  isolation: isolate;
}

#previewCanvas {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: var(--stage);
}

.stage-topline {
  position: absolute;
  top: 14px;
  right: 14px;
  left: 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  pointer-events: none;
}

.live-badge,
.face-count {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 28px;
  padding: 6px 9px;
  border-radius: 999px;
  background: rgba(17, 21, 20, 0.62);
  color: #fff;
  font-size: 0.62rem;
  font-weight: 800;
  letter-spacing: 0.12em;
}

.live-dot {
  width: 6px;
  height: 6px;
  background: var(--accent);
  box-shadow: 0 0 0 4px rgba(255, 95, 87, 0.16);
}

.face-count {
  max-width: 160px;
  overflow: hidden;
  font-weight: 650;
  letter-spacing: 0;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.stage-message {
  position: absolute;
  right: 16px;
  bottom: 16px;
  left: 16px;
  padding: 9px 11px;
  border-radius: 10px;
  background: rgba(17, 21, 20, 0.58);
  color: rgba(255, 255, 255, 0.8);
  font-size: 0.7rem;
  line-height: 1.4;
  text-align: center;
  transition: opacity 180ms ease;
}

.stage-message.is-hidden {
  opacity: 0;
  pointer-events: none;
}

.privacy-overlay {
  position: absolute;
  z-index: 2;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 13px;
  padding: 24px;
  background: var(--stage);
  color: #fff;
  text-align: center;
}

.privacy-record-badge {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding: 9px 12px;
  border: 1px solid rgba(255, 255, 255, 0.17);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.07);
  color: rgba(255, 255, 255, 0.9);
  font-size: 0.72rem;
  font-weight: 850;
  letter-spacing: 0.07em;
}

.privacy-record-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 5px rgba(255, 95, 87, 0.16);
  animation: pulse 1.2s ease-in-out infinite;
}

.privacy-timer {
  margin-left: 2px;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.08em;
}

.privacy-overlay-label {
  color: rgba(255, 255, 255, 0.58);
  font-size: 0.7rem;
}

.recording-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: min(100%, 430px);
  min-height: 31px;
  margin: 12px auto 9px;
}

.recording-info {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 750;
}

.recording-indicator {
  width: 7px;
  height: 7px;
  background: #aeb8b3;
}

.recording-indicator.is-recording {
  background: var(--accent);
  box-shadow: 0 0 0 5px rgba(255, 95, 87, 0.14);
  animation: pulse 1.2s ease-in-out infinite;
}

.recording-timer {
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.05em;
}

.camera-message {
  max-width: 62%;
  color: var(--muted);
  font-size: 0.68rem;
  line-height: 1.4;
  text-align: right;
}

.camera-message:empty {
  display: none;
}

.camera-controls {
  display: grid;
  grid-template-columns: 54px minmax(0, 1fr) 54px;
  align-items: center;
  gap: 18px;
  width: min(100%, 430px);
  margin: 0 auto;
}

.secondary-button {
  gap: 7px;
  padding: 11px 15px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.7);
  color: var(--ink);
}

.secondary-button:hover:not(:disabled) {
  border-color: #c9d1cc;
  background: var(--surface);
}

.control-button {
  width: 54px;
  height: 54px;
  padding: 0;
  border-radius: 50%;
}

.control-icon,
.privacy-button-icon {
  display: grid;
  width: 19px;
  height: 19px;
  place-items: center;
}

.control-icon svg,
.privacy-button-icon svg {
  width: 100%;
  height: 100%;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.65;
}

.record-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  min-height: 58px;
  padding: 13px 15px;
  border: 0;
  border-radius: 999px;
  background: var(--accent);
  box-shadow: 0 12px 25px rgba(255, 95, 87, 0.2);
  color: #fff;
  cursor: pointer;
  font: inherit;
  font-size: 0.86rem;
  font-weight: 850;
  transition: transform 160ms ease, background 160ms ease, box-shadow 160ms ease, opacity 160ms ease;
}

.record-button:hover:not(:disabled) {
  background: var(--accent-deep);
  box-shadow: 0 15px 29px rgba(255, 95, 87, 0.25);
}

.record-button.is-recording {
  background: var(--ink);
  box-shadow: 0 12px 25px rgba(20, 30, 25, 0.18);
}

.record-button.is-recording:hover:not(:disabled) {
  background: #2a302d;
}

.record-button-dot {
  width: 13px;
  height: 13px;
  border: 2px solid currentColor;
  border-radius: 50%;
}

.is-recording .record-button-dot {
  border-radius: 4px;
  background: currentColor;
}

.privacy-control-row {
  display: flex;
  justify-content: center;
  width: min(100%, 430px);
  margin: 13px auto 0;
}

.privacy-button {
  min-height: 43px;
  padding: 9px 15px;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font-size: 0.72rem;
}

.privacy-button.is-active {
  border-color: var(--ink);
  background: var(--ink);
  color: #fff;
}

.privacy-button.is-active:hover:not(:disabled) {
  border-color: #2a302d;
  background: #2a302d;
}

.result-panel {
  padding-top: clamp(54px, 10vh, 96px);
}

.result-heading h1 {
  margin-bottom: 0;
  font-size: clamp(2.5rem, 8vw, 4.2rem);
}

.result-check {
  display: grid;
  width: 40px;
  height: 40px;
  place-items: center;
  border-radius: 50%;
  background: #e4f5eb;
  color: #267a53;
  font-size: 1.2rem;
  font-weight: 900;
}

.recorded-video-wrap {
  overflow: hidden;
  width: min(100%, 430px);
  margin: 0 auto;
  border-radius: 22px;
  background: var(--stage);
  box-shadow: var(--shadow);
}

#recordedVideo {
  display: block;
  width: 100%;
  max-height: 72vh;
  background: var(--stage);
}

.result-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-top: 18px;
}

.download-button {
  width: auto;
  min-width: 170px;
}

.result-actions .secondary-button {
  min-width: 105px;
}

.source-video {
  position: fixed;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes pulse {
  50% {
    opacity: 0.42;
  }
}

@media (max-width: 620px) {
  .app-shell {
    padding-right: 15px;
    padding-left: 15px;
  }

  .launch-panel {
    padding-top: clamp(70px, 14vh, 112px);
  }

  .hero-copy h1 {
    font-size: clamp(3.25rem, 18vw, 5rem);
  }

  .camera-panel,
  .result-panel {
    padding-top: 28px;
  }

  .camera-heading {
    margin-bottom: 11px;
  }

  .stage {
    border-radius: 21px;
  }

  .recording-row {
    align-items: center;
  }

  .camera-message {
    max-width: 58%;
  }

  .camera-controls {
    gap: 11px;
  }

  .control-button {
    width: 50px;
    height: 50px;
  }

  .result-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .download-button,
  .result-actions .secondary-button {
    width: 100%;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}
