:root {
  --accent: #0d4250;
  --accent-strong: #0a3540;
  --accent-tint: #e7f0f2;
  --ink: #0f1a1e;
  --muted: #6b7a7d;
  --line: #ebeff0;
  --bg: #f7f8f8;
  --card: #ffffff;
  --radius: 18px;
  --shadow-sm: 0 2px 10px rgba(13, 66, 80, 0.06);
  --shadow: 0 6px 22px rgba(13, 66, 80, 0.08);
  --shadow-lg: 0 18px 50px rgba(13, 66, 80, 0.16);
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  overscroll-behavior-y: none;
}

body { min-height: 100dvh; }

.app {
  max-width: 560px;
  margin: 0 auto;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding: max(env(safe-area-inset-top), 14px) 18px max(env(safe-area-inset-bottom), 18px);
}

/* ---------- TOPBAR ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 4px 4px 0;
}
.brand { display: flex; align-items: center; gap: 8px; }
.brand__mark {
  color: #fff;
  display: grid; place-items: center;
  width: 26px; height: 26px;
  background: var(--accent);
  border-radius: 8px;
}
.brand__name {
  font-size: 14px; font-weight: 600; color: var(--ink);
  letter-spacing: -0.01em;
}
.topbar__dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--accent); opacity: .35;
}

/* ---------- MAIN ---------- */
.main {
  flex: 1;
  display: flex; flex-direction: column;
  justify-content: center;
  padding: 12px 0;
}

/* ---------- CAPTURE ---------- */
.capture {
  flex: 1;
  display: flex; flex-direction: column; align-items: center;
  gap: 18px;
}

.viewfinder {
  appearance: none; border: none; padding: 0; cursor: pointer;
  position: relative;
  width: 100%; max-width: 420px;
  flex: 1;
  min-height: 260px;
  background:
    radial-gradient(120% 80% at 50% 40%, #ffffff 0%, #eef2f3 100%);
  border-radius: 26px;
  overflow: hidden;
  display: grid; place-items: center;
  transition: transform .12s ease;
}
.viewfinder:active { transform: scale(.985); }

.viewfinder__bracket {
  position: absolute; width: 26px; height: 26px;
  border-color: var(--accent); border-style: solid; border-width: 0;
}
.viewfinder__bracket--tl { top: 14px; left: 14px; border-top-width: 2px; border-left-width: 2px; border-top-left-radius: 8px; }
.viewfinder__bracket--tr { top: 14px; right: 14px; border-top-width: 2px; border-right-width: 2px; border-top-right-radius: 8px; }
.viewfinder__bracket--bl { bottom: 14px; left: 14px; border-bottom-width: 2px; border-left-width: 2px; border-bottom-left-radius: 8px; }
.viewfinder__bracket--br { bottom: 14px; right: 14px; border-bottom-width: 2px; border-right-width: 2px; border-bottom-right-radius: 8px; }

.viewfinder__hint {
  font-size: 13px; color: var(--muted);
  letter-spacing: .02em;
  padding: 6px 12px; border-radius: 999px;
  background: rgba(255,255,255,.75);
  backdrop-filter: blur(4px);
}

/* ---------- DOCK ---------- */
.dock {
  display: grid; grid-template-columns: 1fr auto 1fr;
  align-items: center; justify-items: center;
  width: 100%; max-width: 420px;
  gap: 24px;
  padding: 6px 0 4px;
}
.dock__side {
  appearance: none; border: none; cursor: pointer;
  width: 46px; height: 46px; border-radius: 50%;
  background: var(--card);
  color: var(--accent);
  display: grid; place-items: center;
  box-shadow: var(--shadow-sm);
  transition: transform .1s ease, background .15s ease;
}
.dock__side:hover { background: var(--accent-tint); }
.dock__side:active { transform: scale(.94); }
.dock__side--ghost {
  background: transparent; box-shadow: none; pointer-events: none;
}

.dock__shutter {
  appearance: none; border: none; cursor: pointer;
  width: 76px; height: 76px; border-radius: 50%;
  background: var(--card);
  display: grid; place-items: center;
  padding: 5px;
  box-shadow: 0 0 0 3px var(--accent), var(--shadow);
  transition: transform .1s ease;
}
.dock__shutter:active { transform: scale(.94); }
.dock__shutter-core {
  width: 100%; height: 100%; border-radius: 50%;
  background: var(--accent);
  display: block;
}

.capture__foot {
  font-size: 12.5px; color: var(--muted);
  text-align: center; max-width: 300px;
  margin: 2px 0 0; line-height: 1.5;
}

/* ---------- LOADING ---------- */
.loading {
  flex: 1;
  display: flex; flex-direction: column; align-items: center; text-align: center;
  gap: 6px; padding-top: 12px;
}
.loading__scan {
  position: relative;
  width: min(70%, 260px);
  border-radius: 22px;
  overflow: hidden;
  box-shadow: var(--shadow-lg);
  background: #f3f5f6;
}
.loading__scan img { display: block; width: 100%; height: auto; opacity: .92; }
.loading__beam {
  position: absolute; left: 0; right: 0; top: 0; height: 26%;
  background: linear-gradient(180deg, rgba(13,66,80,0) 0%, rgba(20,120,140,0.32) 60%, rgba(13,66,80,0) 100%);
  border-bottom: 2px solid rgba(20,150,175,0.9);
  animation: scan 1.7s ease-in-out infinite;
}
@keyframes scan {
  0% { transform: translateY(-10%); }
  50% { transform: translateY(330%); }
  100% { transform: translateY(-10%); }
}
.loading__text { font-size: 18px; font-weight: 600; margin: 22px 0 0; letter-spacing: -0.01em; }
.loading__sub { color: var(--muted); font-size: 13.5px; margin: 4px 0 0; }

/* ---------- RESULTS ---------- */
.results { display: flex; flex-direction: column; gap: 14px; }
.results__bar {
  display: grid; grid-template-columns: auto 1fr auto;
  align-items: center; padding: 0 2px 2px;
}
.results__count {
  text-align: center;
  font-size: 12px; font-weight: 600;
  color: var(--muted); letter-spacing: .06em; text-transform: uppercase;
}
.iconbtn {
  appearance: none; border: none; cursor: pointer;
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--card); color: var(--accent);
  display: grid; place-items: center;
  box-shadow: var(--shadow-sm);
  transition: transform .1s ease, background .15s ease;
}
.iconbtn:hover { background: var(--accent-tint); }
.iconbtn:active { transform: scale(.94); }
.iconbtn--ghost {
  background: transparent; box-shadow: none; cursor: default;
}

.cards { display: flex; flex-direction: column; gap: 10px; }
.card {
  appearance: none; border: 1px solid var(--line); background: var(--card);
  border-radius: 18px; padding: 12px 14px;
  display: flex; align-items: center; gap: 12px;
  cursor: pointer; text-align: left;
  font: inherit; color: var(--ink);
  box-shadow: var(--shadow-sm);
  transition: transform .1s ease, border-color .15s ease;
}
.card:active { transform: scale(.985); }
.card:hover { border-color: var(--accent); }
.card__icon {
  flex-shrink: 0;
  width: 44px; height: 44px; border-radius: 14px;
  background: var(--accent-tint);
  display: grid; place-items: center;
  font-size: 22px; line-height: 1;
}
.card--accent .card__icon {
  background: var(--accent);
  color: #fff;
}
.card__body {
  flex: 1; min-width: 0;
  display: flex; flex-direction: column; gap: 3px;
}
.card__title {
  display: block;
  font-size: 15px; font-weight: 600; letter-spacing: -0.01em;
  line-height: 1.25; color: var(--ink);
  word-break: break-word;
}
.card__meta {
  display: block;
  font-size: 12px; color: var(--muted);
  letter-spacing: .01em;
}
.card__arrow {
  color: var(--muted); font-size: 20px; margin-left: 2px; line-height: 1;
}

/* ---------- ERROR ---------- */
.error {
  flex: 1;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; gap: 14px;
}
.error__icon { color: var(--accent); }
.error__text { font-size: 17px; font-weight: 600; max-width: 300px; margin: 0; }

/* ---------- BUTTONS ---------- */
.btn {
  appearance: none; border: none; cursor: pointer;
  font: inherit; font-weight: 600;
  border-radius: 999px;
  padding: 14px 22px;
  width: 100%; max-width: 320px;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  transition: transform .08s ease, background .15s ease;
}
.btn:active { transform: scale(.97); }
.btn--primary {
  background: var(--accent); color: #fff;
  box-shadow: var(--shadow);
  font-size: 16px;
}
.btn--primary:hover { background: var(--accent-strong); }

/* ---------- FOOTER ---------- */
.foot {
  text-align: center; color: var(--muted); font-size: 11px;
  padding: 10px 0 2px; letter-spacing: .04em;
}

/* ---------- SHEET ---------- */
.sheet { position: fixed; inset: 0; z-index: 50; display: flex; align-items: flex-end; justify-content: center; }
.sheet__backdrop {
  position: absolute; inset: 0;
  background: rgba(11,40,48,.45);
  backdrop-filter: blur(2px);
  animation: fade .2s ease;
}
.sheet__card {
  position: relative; width: 100%; max-width: 560px;
  background: var(--card); border-radius: 26px 26px 0 0;
  padding: 26px 22px max(env(safe-area-inset-bottom), 26px);
  box-shadow: var(--shadow-lg);
  max-height: 86dvh; overflow-y: auto;
  animation: slideup .26s cubic-bezier(.2,.8,.2,1);
}
@media (min-width: 560px) {
  .sheet { align-items: center; }
  .sheet__card { border-radius: 24px; margin: 20px; }
}
.sheet__close {
  position: absolute; top: 14px; right: 14px;
  width: 36px; height: 36px; border-radius: 50%;
  border: none; background: var(--accent-tint); color: var(--accent);
  cursor: pointer; display: grid; place-items: center;
}
.sheet__tag {
  display: inline-block; font-size: 11px; font-weight: 700; letter-spacing: .06em;
  text-transform: uppercase; color: var(--accent); background: var(--accent-tint);
  padding: 5px 11px; border-radius: 999px;
}
.sheet__title {
  font-size: 24px; letter-spacing: -0.02em;
  margin: 12px 0 8px; line-height: 1.15; font-weight: 700;
}
.sheet__desc {
  font-size: 13.5px; color: var(--muted);
  margin: 0 0 18px; line-height: 1.5;
  font-style: italic;
}
.sheet__h {
  font-size: 11px; text-transform: uppercase; letter-spacing: .08em;
  color: var(--muted); font-weight: 700; margin: 20px 0 10px;
}
.sheet__ing { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.sheet__ing li {
  background: var(--accent-tint); color: var(--accent-strong);
  padding: 7px 12px; border-radius: 10px; font-size: 13.5px; font-weight: 500;
}
.sheet__steps { padding-left: 4px; margin: 0; list-style: none; counter-reset: step; }
.sheet__steps li {
  position: relative; padding: 0 0 16px 40px; counter-increment: step;
  font-size: 15.5px; line-height: 1.45;
}
.sheet__steps li::before {
  content: counter(step);
  position: absolute; left: 0; top: -1px;
  width: 27px; height: 27px; border-radius: 50%;
  background: var(--accent); color: #fff;
  display: grid; place-items: center; font-size: 13px; font-weight: 700;
}
.sheet__steps li:last-child { padding-bottom: 0; }

@keyframes slideup { from { transform: translateY(100%); } to { transform: translateY(0); } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

@media (prefers-reduced-motion: reduce) {
  .loading__beam, .sheet__card, .sheet__backdrop { animation: none; }
}
