:root {
  color-scheme: dark;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans JP", "Noto Sans KR", sans-serif;
  --chrome: rgba(20, 18, 16, .62);
  --line: rgba(255, 255, 255, .34);
  --cream: #fff7e8;
  --ink: #171310;
  --accent: #ed8d42;
  --safe-top: max(env(safe-area-inset-top), 14px);
  --safe-bottom: max(env(safe-area-inset-bottom), 18px);
}

* { box-sizing: border-box; }
html, body { margin: 0; width: 100%; height: 100%; overflow: hidden; background: #0d0d0d; }
button, a { font: inherit; -webkit-tap-highlight-color: transparent; }
button { color: inherit; }
[hidden] { display: none !important; }

.app, .camera-screen, .result-screen, .welcome, .error-screen {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  min-height: 100svh;
}

.welcome, .error-screen {
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: 18px;
  padding: calc(var(--safe-top) + 34px) 24px calc(var(--safe-bottom) + 24px);
  background:
    radial-gradient(circle at 70% 18%, rgba(237, 141, 66, .22), transparent 30%),
    linear-gradient(160deg, #221e1a, #0d0c0b 64%);
}

.welcome-copy { margin: auto 0; }
.eyebrow { margin: 0 0 10px; color: #e5a574; font-size: 11px; font-weight: 800; letter-spacing: .22em; }
.welcome h1 { margin: 0; font-size: clamp(52px, 18vw, 82px); line-height: .95; letter-spacing: .12em; }
.welcome-copy > p:last-child { margin: 18px 0 0; color: rgba(255,255,255,.72); font-size: 16px; letter-spacing: .06em; }
.privacy-note { margin: 0; color: rgba(255,255,255,.48); font-size: 11px; line-height: 1.5; text-align: center; }

.primary-button, .secondary-button, .text-button {
  min-height: 52px;
  border: 0;
  border-radius: 999px;
  font-weight: 750;
  letter-spacing: .02em;
}
.primary-button { color: var(--ink); background: var(--cream); }
.secondary-button { color: #fff; background: rgba(255,255,255,.16); border: 1px solid rgba(255,255,255,.22); }
.text-button { color: rgba(255,255,255,.75); background: transparent; }

.camera-screen { background: #000; }
.preview { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; background: #000; }
.capture-flash { position: absolute; inset: 0; pointer-events: none; background: #fff; opacity: 0; }
.capture-flash.active { animation: capture-flash .18s ease-out; }
@keyframes capture-flash { 0% { opacity: .38; } 100% { opacity: 0; } }

.top-controls, .bottom-controls { position: absolute; left: 0; right: 0; display: flex; align-items: center; z-index: 3; }
.top-controls { top: 0; justify-content: space-between; padding: calc(var(--safe-top) + 2px) 18px 12px; background: linear-gradient(rgba(0,0,0,.48), transparent); }
.bottom-controls { bottom: 0; justify-content: space-between; padding: 18px 20px calc(var(--safe-bottom) + 10px); background: linear-gradient(transparent, rgba(0,0,0,.62) 38%); }

.round-button {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border: 1px solid var(--line);
  border-radius: 50%;
  color: #fff;
  background: var(--chrome);
  backdrop-filter: blur(14px);
  text-decoration: none;
  font-size: 22px;
  font-weight: 650;
}
.home-button { font-size: 16px; letter-spacing: .02em; }

.film-button {
  width: 106px;
  min-height: 52px;
  padding: 9px 10px 8px;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: #fff;
  background: var(--chrome);
  backdrop-filter: blur(14px);
  text-align: left;
}
.film-button span { display: block; font-size: 13px; font-weight: 850; letter-spacing: .06em; white-space: nowrap; }
.film-button small { display: block; margin-top: 4px; color: rgba(255,255,255,.55); font-size: 7px; letter-spacing: .14em; }

.shutter {
  position: absolute;
  left: 50%;
  bottom: calc(var(--safe-bottom) + 2px);
  width: 88px;
  height: 88px;
  padding: 12px;
  border: 0;
  background: transparent;
  transform: translateX(-50%);
}
.shutter img { width: 64px; height: 64px; display: block; border-radius: 50%; box-shadow: 0 4px 20px rgba(0,0,0,.34); transition: transform 100ms ease, filter 160ms ease; }
.shutter:active img, .shutter.pressed img { transform: scale(.95); }
.shutter[disabled] img { filter: grayscale(.55) brightness(.72); }
.shutter-progress { position: absolute; inset: 7px; border: 2px solid transparent; border-top-color: rgba(255,255,255,.82); border-radius: 50%; opacity: 0; }
.shutter.processing .shutter-progress { opacity: 1; animation: spin .85s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.latest-button {
  width: 54px;
  height: 54px;
  padding: 2px;
  border: 1px solid rgba(255,255,255,.6);
  border-radius: 13px;
  overflow: hidden;
  color: rgba(255,255,255,.66);
  background: var(--chrome);
}
.latest-button img { width: 100%; height: 100%; object-fit: cover; border-radius: 10px; }
.latest-button span { display: grid; place-items: center; width: 100%; height: 100%; font-size: 25px; }
.latest-button:disabled { opacity: .62; }

.camera-message { position: absolute; left: 50%; bottom: calc(var(--safe-bottom) + 108px); z-index: 3; margin: 0; padding: 7px 12px; border-radius: 999px; background: rgba(0,0,0,.58); color: rgba(255,255,255,.86); font-size: 12px; transform: translateX(-50%); opacity: 0; transition: opacity .2s; white-space: nowrap; }
.camera-message.visible { opacity: 1; }

.sheet { position: fixed; inset: 0; z-index: 10; }
.sheet-backdrop { position: absolute; inset: 0; width: 100%; border: 0; background: rgba(0,0,0,.54); }
.sheet-panel { position: absolute; left: 0; right: 0; bottom: 0; padding: 10px 20px calc(var(--safe-bottom) + 20px); border-radius: 24px 24px 0 0; background: #191715; box-shadow: 0 -12px 40px rgba(0,0,0,.35); }
.sheet-handle { width: 38px; height: 4px; margin: 0 auto 22px; border-radius: 99px; background: rgba(255,255,255,.26); }
.sheet h2 { margin: 0 0 18px; font-size: 24px; }
.region-options { display: grid; gap: 8px; }
.region-options button { display: flex; align-items: center; justify-content: space-between; min-height: 54px; padding: 0 15px; border: 1px solid rgba(255,255,255,.12); border-radius: 12px; color: #fff; background: rgba(255,255,255,.045); text-align: left; }
.region-options strong { font-size: 14px; letter-spacing: .08em; }
.region-options span { color: rgba(255,255,255,.48); font-size: 11px; }
.region-options button.selected { border-color: #e6a06b; background: rgba(237,141,66,.13); }
.mode-options { display: grid; grid-template-columns: 1fr 1fr; gap: 5px; margin: 14px 0 18px; padding: 4px; border-radius: 12px; background: rgba(255,255,255,.07); }
.mode-options button { min-height: 42px; border: 0; border-radius: 9px; color: rgba(255,255,255,.56); background: transparent; font-size: 12px; font-weight: 800; letter-spacing: .1em; }
.mode-options button.selected { color: #1a1512; background: var(--cream); }
.sheet-panel > .primary-button { width: 100%; }

.result-screen { background: #090909; }
.result-screen > img { width: 100%; height: 100%; object-fit: contain; }
.result-header { position: absolute; left: 0; right: 0; top: 0; display: flex; align-items: center; justify-content: space-between; padding: calc(var(--safe-top) + 2px) 18px 38px; background: linear-gradient(rgba(0,0,0,.62), transparent); }
.result-header p { margin: 0; font-size: 12px; font-weight: 800; letter-spacing: .1em; }
.result-actions { position: absolute; left: 0; right: 0; bottom: 0; display: grid; grid-template-columns: 1.2fr .8fr; gap: 9px; padding: 42px 20px calc(var(--safe-bottom) + 14px); background: linear-gradient(transparent, rgba(0,0,0,.82) 30%); }
.result-actions .text-button, .result-actions .download-link, .install-hint { grid-column: 1 / -1; }
.download-link { color: rgba(255,255,255,.78); text-align: center; font-size: 13px; }
.install-hint { margin: 4px 0 0; color: rgba(255,255,255,.62); font-size: 11px; line-height: 1.45; text-align: center; }

.error-screen { justify-content: center; }
.error-screen h2 { margin: 0; }
.error-screen > p:not(.eyebrow) { color: rgba(255,255,255,.62); line-height: 1.7; }
.error-screen a { color: rgba(255,255,255,.66); text-align: center; }

@media (orientation: landscape) {
  .bottom-controls { padding-left: max(28px, env(safe-area-inset-left)); padding-right: max(28px, env(safe-area-inset-right)); }
  .top-controls { padding-left: max(28px, env(safe-area-inset-left)); padding-right: max(28px, env(safe-area-inset-right)); }
  .sheet-panel { left: 50%; width: min(480px, 100%); transform: translateX(-50%); border-radius: 24px 24px 0 0; }
  .result-actions { left: auto; width: min(410px, 48%); padding-right: max(20px, env(safe-area-inset-right)); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
