:root {
  --bg: #f6f8f5;
  --card: #ffffff;
  --line: #dfe6dd;
  --ink: #1f2823;
  --muted: #5e6d64;
  --primary: #0f9270;
  --primary-strong: #0b7a5d;
  --secondary: #fff2c7;
  --secondary-line: #f1d487;
  --danger: #b9384a;
  --ok: #0f8459;
}

* {
  box-sizing: border-box;
}

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

body.user-page {
  font-family: "Manrope", "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--ink);
}

.user-shell {
  width: min(760px, calc(100vw - 1rem));
  margin: 0 auto;
  padding: 0.7rem 0.5rem 1.2rem;
  display: grid;
  gap: 0.7rem;
}

.card,
.hero-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 0.8rem;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.04);
}

.hero-card {
  display: grid;
  grid-template-columns: 52px 1fr;
  gap: 0.65rem;
  align-items: center;
}

.brand-logo {
  width: 52px;
  height: 52px;
  border-radius: 12px;
  object-fit: cover;
  border: 1px solid #e6eadf;
  background: #fff;
}

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

h1 {
  font-size: 1.1rem;
  line-height: 1.15;
}

.hero-copy {
  margin-top: 0.35rem;
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.4;
}

h2 {
  font-size: 0.98rem;
  line-height: 1.2;
}

h3 {
  font-size: 0.9rem;
}

.muted {
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.35;
}

.row-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  margin-bottom: 0.55rem;
}

.input,
.btn {
  width: 100%;
  border-radius: 12px;
  border: 1px solid var(--line);
  font: inherit;
}

.input {
  padding: 0.78rem 0.82rem;
  margin-bottom: 0.55rem;
  background: #fff;
}

.btn {
  padding: 0.8rem 0.9rem;
  font-weight: 800;
  cursor: pointer;
}

.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.btn-primary {
  border-color: transparent;
  color: #fff;
  background: linear-gradient(135deg, var(--primary), #11ab84);
}

.btn-secondary {
  background: var(--secondary);
  border-color: var(--secondary-line);
  color: #654500;
}

.badge {
  padding: 0.25rem 0.5rem;
  border-radius: 999px;
  border: 1px solid #dde4db;
  background: #f4f7f2;
  color: #516158;
  font-size: 0.74rem;
  font-weight: 800;
}

.status-line {
  min-height: 1.1rem;
  margin-top: 0.5rem;
  font-size: 0.86rem;
  font-weight: 700;
  color: var(--primary-strong);
}

.status-headline {
  display: block;
  font-size: 1.25rem;
  font-weight: 800;
  line-height: 1.25;
  letter-spacing: -0.01em;
}

.capture-tips {
  margin-top: 0.55rem;
  margin-bottom: 0.7rem;
  padding: 0.8rem 0.9rem;
  border: 1px solid #d8e6dd;
  border-radius: 14px;
  background: linear-gradient(180deg, #f6fbf8, #eef7f2);
}

.capture-tips-title {
  font-size: 0.9rem;
  font-weight: 800;
}

.capture-tips-list {
  margin: 0.45rem 0 0;
  padding-left: 1.1rem;
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.45;
}

.capture-tips-list li + li {
  margin-top: 0.28rem;
}

.side-grid {
  display: grid;
  gap: 0.65rem;
}

.side-card {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 0.65rem;
  background: #fbfcfb;
}

.side-card h3 {
  margin-bottom: 0.45rem;
}

.capture-box {
  position: relative;
  display: grid;
  place-items: center;
  width: 100%;
  padding: 0;
  min-height: 180px;
  border-radius: 12px;
  border: 1px dashed #cfd8cf;
  background: #ffffff;
  cursor: pointer;
  overflow: hidden;
  appearance: none;
}

.capture-box:focus-visible {
  outline: 3px solid rgba(15, 146, 112, 0.28);
  outline-offset: 2px;
}

.capture-guide {
  position: absolute;
  inset: 0;
  pointer-events: none;
  display: grid;
  place-items: center;
}

.capture-guide::before {
  content: "";
  width: min(82%, 320px);
  aspect-ratio: 1.58 / 1;
  border-radius: 12px;
  border: 2px dashed rgba(15, 146, 112, 0.55);
  background: linear-gradient(180deg, rgba(15, 146, 112, 0.04), rgba(15, 146, 112, 0));
  box-shadow: inset 0 0 0 999px rgba(255, 255, 255, 0.12);
}

.capture-guide .corner {
  position: absolute;
  width: 20px;
  height: 20px;
  border-color: rgba(15, 146, 112, 0.9);
  border-style: solid;
  border-width: 0;
}

.capture-guide .corner.tl {
  top: 22%;
  left: calc(50% - min(41%, 160px));
  border-top-width: 3px;
  border-left-width: 3px;
  border-top-left-radius: 6px;
}

.capture-guide .corner.tr {
  top: 22%;
  right: calc(50% - min(41%, 160px));
  border-top-width: 3px;
  border-right-width: 3px;
  border-top-right-radius: 6px;
}

.capture-guide .corner.bl {
  bottom: 22%;
  left: calc(50% - min(41%, 160px));
  border-bottom-width: 3px;
  border-left-width: 3px;
  border-bottom-left-radius: 6px;
}

.capture-guide .corner.br {
  bottom: 22%;
  right: calc(50% - min(41%, 160px));
  border-bottom-width: 3px;
  border-right-width: 3px;
  border-bottom-right-radius: 6px;
}

.file-input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
  width: 0;
  height: 0;
}

.placeholder {
  color: var(--muted);
  font-weight: 700;
  text-align: center;
  padding: 0 1rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
}

.camera-icon {
  width: 48px;
  height: 48px;
  opacity: 0.45;
}

.camera-auto-status {
  position: absolute;
  bottom: 8px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 10;
  padding: 0.3rem 0.7rem;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.65);
  color: #fff;
  font-size: 0.78rem;
  font-weight: 700;
  white-space: nowrap;
  transition: background 200ms;
}

.camera-auto-status.ready {
  background: rgba(15, 132, 89, 0.85);
}

.capture-box.has-preview {
  min-height: 0;
  background: #f1f6f1;
}

.preview {
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: clamp(180px, 56vw, 320px);
  object-fit: contain;
  display: block;
  margin: 0 auto;
  position: relative;
  z-index: 1;
  background: #f1f6f1;
}

.side-status {
  min-height: 1.05rem;
  margin-top: 0.45rem;
  font-size: 0.84rem;
  line-height: 1.3;
}

.side-status.ok {
  color: var(--ok);
  font-weight: 700;
}

.side-status.bad {
  color: var(--danger);
  font-weight: 700;
}

.side-status.wait {
  color: var(--muted);
}

.result-box {
  margin-top: 0.55rem;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: #fbfcff;
  padding: 0.65rem;
  font-size: 0.88rem;
  line-height: 1.35;
}

.result-box.ok {
  border-color: #c6ead8;
  background: #f2fff8;
  color: var(--ok);
}

.result-box.bad {
  border-color: #efc7ce;
  background: #fff5f7;
  color: var(--danger);
}

.action-grid {
  display: grid;
  gap: 0.75rem;
  margin-top: 0.65rem;
}

.action-grid .btn.btn-primary,
.action-grid .btn.btn-secondary {
  padding: 1.15rem 1rem;
  font-size: 1.1rem;
  font-weight: 800;
  border-radius: 14px;
  letter-spacing: 0.01em;
  min-height: 3.4rem;
}

.success-card {
  text-align: center;
}

.success-card h2 {
  margin-bottom: 0.3rem;
}

.success-card .btn {
  margin-top: 0.6rem;
}

/* ─── Locked (success) side card ─── */
.side-card.locked .capture-box {
  pointer-events: none;
  opacity: 0.45;
  cursor: default;
}

.side-card.locked {
  border-color: var(--ok);
  background: #f2fff8;
}

/* ─── Success Overlay ─── */
.success-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(15, 132, 89, 0.16);
  display: grid;
  place-items: center;
  animation: overlayFadeIn 100ms ease both;
}

.success-overlay.fading-out {
  animation: overlayFadeOut 200ms ease both;
}

.success-emoji {
  font-size: min(40vw, 180px);
  animation: emojiPop 300ms cubic-bezier(0.34, 1.56, 0.64, 1) both;
  filter: drop-shadow(0 8px 24px rgba(15, 132, 89, 0.25));
}

@keyframes overlayFadeIn {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

@keyframes overlayFadeOut {
  from {
    opacity: 1;
  }

  to {
    opacity: 0;
  }
}

@keyframes emojiPop {
  from {
    opacity: 0;
    transform: scale(0.3);
  }

  to {
    opacity: 1;
    transform: scale(1);
  }
}

.hidden {
  display: none !important;
}

.capture-box.has-preview .capture-guide {
  opacity: 0.15;
}

.camera-modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(11, 16, 14, 0.78);
  display: grid;
  align-items: end;
  padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom);
}

.camera-sheet {
  width: 100%;
  background: #f7faf6;
  border-top-left-radius: 18px;
  border-top-right-radius: 18px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  padding: 0.65rem;
  box-shadow: 0 -12px 40px rgba(0, 0, 0, 0.18);
  max-height: calc(100dvh - env(safe-area-inset-top) - env(safe-area-inset-bottom));
  overflow: auto;
}

.camera-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.45rem;
}

.camera-side-label {
  font-weight: 800;
  font-size: 0.92rem;
  color: var(--ink);
}

.camera-close {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #fff;
  color: #33423a;
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
}

.camera-stage {
  position: relative;
  width: 100%;
  border-radius: 14px;
  overflow: hidden;
  background: #131816;
  aspect-ratio: 3 / 4;
  cursor: pointer;
}

.camera-stage:focus-visible {
  outline: 3px solid rgba(38, 223, 173, 0.35);
  outline-offset: 2px;
}

.camera-video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transform: none;
}

.live-guide {
  z-index: 2;
}

.live-guide::before {
  position: absolute;
  left: var(--guide-left, calc(50% - min(41%, 210px)));
  top: var(--guide-top, calc(50% - min(25.95%, 133px)));
  width: var(--guide-width, min(82%, 420px));
  height: var(--guide-height, calc(min(82%, 420px) / 1.58));
  border-style: solid;
  border-width: 2px;
  border-color: rgba(255, 255, 255, 0.9);
  background: linear-gradient(180deg, rgba(15, 146, 112, 0.08), rgba(15, 146, 112, 0));
  box-shadow: inset 0 0 0 999px rgba(0, 0, 0, 0.13);
}

.live-guide .corner {
  display: none;
}

.camera-status {
  min-height: 1rem;
  margin: 0.5rem 0 0;
  font-size: 0.84rem;
  color: #d33d58;
  font-weight: 700;
}

.camera-actions {
  margin-top: 0.45rem;
}

@media (min-width: 720px) {
  .side-grid {
    grid-template-columns: 1fr 1fr;
  }

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

  .camera-modal {
    align-items: center;
    padding: 1rem;
  }

  .camera-sheet {
    max-width: 520px;
    margin: 0 auto;
    border-radius: 18px;
  }
}

@media (orientation: landscape) and (hover: none) and (pointer: coarse) {
  .camera-modal {
    align-items: stretch;
    padding: 0;
    background: rgba(11, 16, 14, 0.92);
  }

  .camera-sheet {
    width: 100vw;
    max-width: none;
    height: 100dvh;
    max-height: none;
    margin: 0;
    border-radius: 0;
    border: none;
    padding:
      calc(env(safe-area-inset-top) + 0.25rem) calc(env(safe-area-inset-right) + 0.35rem) calc(env(safe-area-inset-bottom) + 0.25rem) calc(env(safe-area-inset-left) + 0.35rem);
    background: #101614;
    box-shadow: none;
    display: grid;
    grid-template-rows: auto minmax(0, 1fr) auto;
    gap: 0.3rem;
    overflow: hidden;
  }

  .camera-topbar {
    margin: 0;
    min-height: 2.5rem;
    padding: 0 0.15rem;
  }

  .camera-side-label {
    color: #f4f7f2;
    font-size: 0.86rem;
  }

  .camera-close {
    width: 34px;
    height: 34px;
    border-radius: 999px;
    border-color: rgba(255, 255, 255, 0.16);
    background: rgba(255, 255, 255, 0.08);
    color: #f4f7f2;
  }

  .camera-stage {
    width: 100%;
    height: 100%;
    min-height: 0;
    aspect-ratio: auto;
    border-radius: 16px;
  }

  .camera-status {
    min-height: 0.9rem;
    margin: 0;
    font-size: 0.77rem;
    text-align: center;
    color: rgba(255, 255, 255, 0.9);
  }
}
