:root {
  --ink: #0f172a;
  --ink-soft: #475569;
  --bg: #f3f5fa;
  --card: #ffffff;
  --line: #e2e8f0;
  --blue: #2457e6;
  --blue-deep: #1a3fb8;
  --blue-tint: #e8eefd;
  --wa: #1fa855;
  --mail: #d93025;
  --frame: #22d16b;
  --radius: 20px;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06), 0 2px 8px rgba(15, 23, 42, 0.06);
  --shadow-md: 0 4px 12px rgba(15, 23, 42, 0.08), 0 12px 32px rgba(15, 23, 42, 0.08);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: 'Heebo', 'Assistant', Arial, sans-serif;
  font-size: 22px;
  font-weight: 500;
  overscroll-behavior: none;
  -webkit-user-select: none;
  user-select: none;
}

button { font: inherit; color: inherit; cursor: pointer; }
svg { width: 1em; height: 1em; flex: none; }
.sprite { position: absolute; width: 0; height: 0; }

.screen { display: none; flex-direction: column; height: 100dvh; min-height: 100dvh; }
.screen.active { display: flex; animation: enter 0.22s ease-out; }
@keyframes enter { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ---------- buttons ---------- */
.btn {
  display: flex; align-items: center; justify-content: center; gap: 12px;
  width: 100%; min-height: 64px; padding: 12px 18px;
  border: none; border-radius: 18px;
  font-size: 23px; font-weight: 700;
  transition: transform 0.08s ease, filter 0.15s ease;
}
.btn svg { font-size: 30px; }
.btn:active { transform: scale(0.97); filter: brightness(0.95); }
.btn-primary { min-height: 74px; font-size: 26px; color: #fff; background: linear-gradient(180deg, #2f63f0, var(--blue-deep)); box-shadow: 0 6px 16px rgba(36, 87, 230, 0.35); }
.btn-soft { background: var(--card); color: var(--ink); box-shadow: inset 0 0 0 2px var(--line); }
.btn-wa { min-height: 74px; color: #fff; background: linear-gradient(180deg, #25c062, #17914a); box-shadow: 0 6px 16px rgba(31, 168, 85, 0.32); }
.btn-mail { min-height: 74px; color: #fff; background: linear-gradient(180deg, #ea4335, #c5221f); box-shadow: 0 6px 16px rgba(217, 48, 37, 0.3); }

.back-btn {
  display: flex; align-items: center; gap: 4px; flex: none;
  min-height: 56px; padding: 0 16px 0 18px;
  border: none; border-radius: 16px; background: var(--card); box-shadow: var(--shadow-sm);
  font-size: 21px; font-weight: 700;
}
.back-btn svg { font-size: 24px; }
.icon-btn {
  display: grid; place-items: center; width: 56px; height: 56px; flex: none;
  border: none; border-radius: 16px; background: var(--card); box-shadow: var(--shadow-sm);
  font-size: 28px;
}

/* ---------- top bars ---------- */
.bar { display: flex; align-items: center; gap: 14px; padding: 18px 16px 12px; padding-top: max(18px, env(safe-area-inset-top)); }
.bar h1 { margin: 0; font-size: 27px; font-weight: 800; line-height: 1.2; }
.bar-titles { min-width: 0; }
.bar-sub { margin: 2px 0 0; font-size: 19px; color: var(--ink-soft); }

/* ---------- home ---------- */
.brand { display: flex; align-items: center; gap: 12px; padding: 20px 16px 0; padding-top: max(20px, env(safe-area-inset-top)); }
.brand-logo { width: 44px; height: 44px; border-radius: 12px; box-shadow: var(--shadow-sm); }
.brand-name { font-size: 21px; font-weight: 700; color: var(--ink-soft); }
.home-main { flex: 1; display: flex; flex-direction: column; gap: 20px; padding: 16px; }
.greeting h1 { margin: 12px 0 4px; font-size: 40px; font-weight: 800; }
.greeting p { margin: 0; font-size: 23px; color: var(--ink-soft); line-height: 1.4; }

.hero {
  position: relative; overflow: hidden;
  flex: 1; max-height: 420px; min-height: 280px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px;
  border: none; border-radius: 28px; color: #fff;
  background:
    radial-gradient(circle at 85% 10%, rgba(255, 255, 255, 0.22), transparent 45%),
    linear-gradient(160deg, #3a6ff5 0%, #1a3fb8 100%);
  box-shadow: 0 14px 34px rgba(36, 87, 230, 0.38);
  transition: transform 0.1s ease;
}
.hero:active { transform: scale(0.98); }
.hero-icon { display: grid; place-items: center; width: 116px; height: 116px; border-radius: 50%; background: rgba(255, 255, 255, 0.18); box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.35); }
.hero-icon svg { font-size: 60px; }
.hero-title { font-size: 34px; font-weight: 800; }
.hero-sub { font-size: 21px; opacity: 0.85; }

.tip { display: flex; gap: 12px; align-items: flex-start; padding: 16px; border-radius: var(--radius); background: var(--card); box-shadow: var(--shadow-sm); }
.tip-icon { font-size: 30px; color: #d99a00; margin-top: 2px; }
.tip p { margin: 0; font-size: 20px; line-height: 1.45; color: var(--ink-soft); }
.tip strong { color: var(--ink); }
.note { text-align: center; color: var(--ink-soft); margin: 0; font-size: 19px; }

/* ---------- bottom sheet ---------- */
.sheet {
  display: flex; flex-direction: column; gap: 14px;
  padding: 18px 16px; padding-bottom: max(18px, env(safe-area-inset-bottom));
  background: var(--card); border-radius: 26px 26px 0 0;
  box-shadow: 0 -6px 24px rgba(15, 23, 42, 0.08);
}
.sheet .row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.sheet .row .btn { font-size: 21px; }
.sheet-label { margin: 0; font-size: 19px; font-weight: 700; color: var(--ink-soft); }

/* ---------- approve / corners ---------- */
.stage { flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; padding: 8px 20px 20px; }
.paper { max-width: 100%; max-height: 100%; border-radius: 6px; background: #fff; box-shadow: var(--shadow-md); }
.corners-main canvas { touch-action: none; max-width: 100%; max-height: 100%; border-radius: 10px; box-shadow: var(--shadow-md); }

/* ---------- document ---------- */
.doc-main { flex: 1; overflow-y: auto; padding: 4px 16px 20px; }
.pages { list-style: none; margin: 0 0 16px; padding: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.pages li { position: relative; padding: 8px; border-radius: 16px; background: var(--card); box-shadow: var(--shadow-sm); }
.pages img { display: block; width: 100%; aspect-ratio: 1 / 1.414; object-fit: contain; border-radius: 8px; background: #f1f3f7; }
.pages .label {
  position: absolute; bottom: 16px; inset-inline-start: 16px;
  min-width: 40px; height: 40px; padding: 0 10px; border-radius: 20px;
  box-shadow: 0 2px 6px rgba(15, 23, 42, 0.25);
  display: grid; place-items: center;
  background: var(--ink); color: #fff; font-size: 21px; font-weight: 800;
}
.add-page {
  display: flex; align-items: center; justify-content: center; gap: 14px;
  width: 100%; min-height: 80px; border-radius: 18px;
  border: 2.5px dashed #b8c4dc; background: transparent; color: var(--blue-deep);
  font-size: 23px; font-weight: 700;
}
.add-page:active { background: var(--blue-tint); }
.add-page-icon { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 50%; background: var(--blue-tint); font-size: 28px; }

/* ---------- camera ---------- */
.camera { position: relative; background: #000; }
.camera video, .camera canvas { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.camera-hint {
  position: absolute; top: max(18px, env(safe-area-inset-top)); left: 50%; transform: translateX(-50%);
  max-width: calc(100% - 32px); width: max-content;
  padding: 14px 22px; border-radius: 999px;
  background: rgba(15, 23, 42, 0.62); -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
  color: #fff; font-size: 23px; font-weight: 700; text-align: center;
}
.camera-bar {
  position: absolute; bottom: 0; inset-inline: 0;
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center;
  padding: 22px 16px; padding-bottom: max(28px, env(safe-area-inset-bottom));
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.7));
}
.cam-side { display: flex; flex-direction: column; align-items: center; gap: 6px; border: none; background: none; color: #fff; font-size: 19px; font-weight: 700; justify-self: center; }
.cam-side-icon { display: grid; place-items: center; width: 60px; height: 60px; border-radius: 50%; background: rgba(255, 255, 255, 0.18); -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px); font-size: 28px; }
.cam-side.on .cam-side-icon { background: #ffd400; color: #111; }
.cam-side[hidden] { display: flex; visibility: hidden; }
.shutter { display: grid; place-items: center; width: 92px; height: 92px; border-radius: 50%; border: 5px solid #fff; background: transparent; padding: 0; }
.shutter span { width: 72px; height: 72px; border-radius: 50%; background: #fff; transition: transform 0.08s ease; }
.shutter:active span { transform: scale(0.88); }

/* ---------- modals ---------- */
.modal { position: fixed; inset: 0; z-index: 10; display: flex; align-items: flex-end; background: rgba(15, 23, 42, 0.5); }
.modal[hidden] { display: none; }
.modal-box {
  width: 100%; display: flex; flex-direction: column; gap: 22px;
  padding: 28px 20px; padding-bottom: max(24px, env(safe-area-inset-bottom));
  background: var(--card); border-radius: 26px 26px 0 0; animation: sheet-up 0.22s ease-out;
}
@keyframes sheet-up { from { transform: translateY(30px); opacity: 0; } to { transform: none; opacity: 1; } }
.modal-box p { margin: 0; font-size: 24px; line-height: 1.45; text-align: center; }
.modal-center { align-items: center; justify-content: center; }
.busy-box { display: flex; flex-direction: column; align-items: center; gap: 18px; padding: 28px 32px; border-radius: 22px; background: var(--card); box-shadow: var(--shadow-md); }
.busy-box p { margin: 0; font-size: 22px; font-weight: 700; text-align: center; }
.spinner { width: 48px; height: 48px; border-radius: 50%; border: 5px solid var(--blue-tint); border-top-color: var(--blue); animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
