/* scan.chonrieng.com — same look as the Chốn Riêng homepage: a desk lamp in a dark room,
   one accent (lamp yellow), League Spartan for display, Be Vietnam Pro for text. */
:root {
  --ink: #0f0e0c;
  --ink-2: #171512;
  --ink-3: #211e1a;
  --paper: #f2ede3;
  --muted: #a59d8f;
  --line: rgba(242, 237, 227, 0.12);
  --lamp: #f2c14e;
  --lamp-ink: #1b1508;
  --bad: #ff7a6b;
  --r: 14px;
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
  --display: "League Spartan", "Be Vietnam Pro", system-ui, sans-serif;
  --body: "Be Vietnam Pro", system-ui, sans-serif;
  --safe-b: env(safe-area-inset-bottom, 0px);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100dvh;
  background:
    radial-gradient(120% 60% at 30% -10%, rgba(242, 193, 78, 0.1), transparent 60%),
    var(--ink);
  color: var(--paper);
  font-family: var(--body);
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
body.is-editing, body.is-sheet, body.is-viewing, body.is-camera { overflow: hidden; }
button { font: inherit; color: inherit; cursor: pointer; }
a { color: inherit; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--lamp); outline-offset: 3px; border-radius: 8px; }
/* the full-screen layers take the focus themselves when they open: no ring around the whole screen */
.viewer:focus-visible, .camera:focus-visible, .editor:focus-visible, .sheet-panel:focus-visible { outline: none; }
.sr-only {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; border: 0;
  overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap;
}

.ico { width: 1.2em; height: 1.2em; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }

/* ---------- top ---------- */
.top {
  display: flex; align-items: center; gap: 10px;
  max-width: 640px; margin: 0 auto;
  padding: calc(14px + env(safe-area-inset-top, 0px)) 20px 6px;
}
.brand {
  font-family: var(--display); font-weight: 700; font-size: 1.32rem;
  letter-spacing: -0.03em; text-decoration: none;
}
.brand-tag {
  font-size: 0.72rem; letter-spacing: 0.18em; text-transform: uppercase;
  color: var(--lamp-ink); background: var(--lamp);
  padding: 3px 9px 2px; border-radius: 999px; font-weight: 600;
}

.wrap { max-width: 640px; margin: 0 auto; padding: 0 20px 140px; }

/* ---------- home ---------- */
.hero { padding-top: 8px; }
.cat-scene { display: block; width: min(100%, 360px); margin: 6px auto 4px; overflow: visible; }
.cat-scene .eye, .cat-scene .pupil, .cat-scene .glint { transform-box: fill-box; transform-origin: center; animation: blink 5.5s infinite; }
.cat-scene .scan-line { opacity: 0; }
@keyframes blink { 0%, 93%, 100% { transform: scaleY(1); } 95.5% { transform: scaleY(0.08); } }

.title {
  font-family: var(--display); font-weight: 700;
  font-size: clamp(2.6rem, 11vw, 3.6rem); line-height: 0.96; letter-spacing: -0.03em;
  margin: 8px 0 14px;
}
.lamp-word { color: var(--lamp); }
.lead { color: #d8d1c4; margin: 0 0 22px; max-width: 34em; }

.cta { display: grid; gap: 10px; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.55em;
  min-height: 52px; padding: 0.85em 1.4em;
  border: 1px solid transparent; border-radius: 999px;
  font-weight: 600; white-space: nowrap;
  transition: background 0.3s var(--ease), border-color 0.3s var(--ease), transform 0.15s var(--ease);
}
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.45; cursor: default; }
.btn--lamp { background: var(--lamp); color: var(--lamp-ink); box-shadow: 0 8px 30px -10px rgba(242, 193, 78, 0.55); }
.btn--lamp:hover { background: #ffd56e; }
.btn--ghost { background: var(--ink-2); border-color: var(--line); }
.btn--ghost:hover { border-color: rgba(242, 237, 227, 0.3); }
.btn--wide { width: 100%; }
.btn--sm { min-height: 44px; padding: 0.55em 1.05em; font-size: 0.94rem; }

.tips { list-style: none; margin: 28px 0 0; padding: 0; display: grid; gap: 10px; }
.tips li {
  position: relative; padding: 12px 14px 12px 40px;
  background: var(--ink-2); border: 1px solid var(--line); border-radius: var(--r);
  color: #cfc8ba; font-size: 0.94rem;
}
.tips li::before {
  content: ""; position: absolute; left: 15px; top: 19px; width: 10px; height: 10px; border-radius: 50%;
  background: var(--lamp); box-shadow: 0 0 12px 3px rgba(242, 193, 78, 0.45);
}
.tips b { color: var(--paper); font-weight: 600; }

.privacy {
  display: flex; gap: 10px; align-items: flex-start;
  margin: 26px 0 0; color: var(--muted); font-size: 0.86rem;
}
.privacy .ico { margin-top: 2px; color: var(--lamp); }

/* ---------- pages ---------- */
.pages { padding-top: 10px; }
.pages-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.pages-title { font-family: var(--display); font-size: 2rem; letter-spacing: -0.02em; margin: 6px 0 12px; }
.link-btn { background: none; border: 0; padding: 8px 0; color: var(--muted); text-decoration: underline; text-underline-offset: 3px; }
.link-btn[data-armed] { color: var(--bad); }

.chips { display: flex; flex-wrap: wrap; gap: 6px; padding: 2px 0 10px; }
.chips button {
  flex: 1 1 auto; min-height: 40px; padding: 0 10px; border-radius: 999px; white-space: nowrap;
  background: var(--ink-2); border: 1px solid var(--line); color: #d8d1c4; font-size: 0.86rem;
}
.chips button[aria-checked="true"] { background: var(--paper); color: var(--ink); border-color: var(--paper); font-weight: 600; }

.page-grid { list-style: none; margin: 6px 0 0; padding: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
@media (min-width: 560px) { .page-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.page-card {
  position: relative; background: var(--ink-2); border: 1px solid var(--line); border-radius: var(--r); padding: 8px;
  transition: transform 0.24s var(--ease), box-shadow 0.2s var(--ease), border-color 0.2s var(--ease);
  -webkit-touch-callout: none; user-select: none; -webkit-user-select: none;
}
.page-card.is-dragging {
  z-index: 5; transition: none; transform-origin: 0 0;
  border-color: var(--lamp); box-shadow: 0 22px 44px -10px rgba(0, 0, 0, 0.75);
}
.page-grid.is-reordering .page-card:not(.is-dragging) { opacity: 0.8; }
.page-thumb {
  position: relative; display: grid; place-items: center; width: 100%; aspect-ratio: 3 / 4;
  padding: 0; border: 0; border-radius: 8px; background: var(--ink-3); overflow: hidden;
}
.page-thumb img { display: block; max-width: 100%; max-height: 100%; object-fit: contain; box-shadow: 0 4px 16px rgba(0, 0, 0, 0.45); -webkit-user-drag: none; }
.page-thumb img:not([src]) { display: none; }
.page-card.is-loading .page-thumb::after {
  content: ""; position: absolute; left: 0; right: 0; top: 0; height: 3px; border-radius: 3px;
  background: var(--lamp); box-shadow: 0 0 14px 2px rgba(242, 193, 78, 0.6);
  animation: sweep 1.2s ease-in-out infinite alternate;
}
@keyframes sweep { to { top: calc(100% - 3px); } }
.page-no {
  position: absolute; top: 14px; left: 14px; min-width: 26px; height: 26px; padding: 0 7px;
  display: grid; place-items: center; border-radius: 999px; pointer-events: none;
  background: var(--lamp); color: var(--lamp-ink); font-weight: 700; font-size: 0.82rem;
}
.page-flag {
  position: absolute; left: 14px; bottom: 14px; padding: 3px 9px; border-radius: 999px; pointer-events: none;
  background: rgba(15, 14, 12, 0.85); color: var(--lamp); font-size: 0.74rem; font-weight: 600;
}

.add-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 16px; }
.hint-small { color: var(--muted); font-size: 0.86rem; margin: 12px 0 0; }

/* ---------- dock ---------- */
.dock {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  padding: 14px 20px calc(14px + var(--safe-b));
  background: linear-gradient(to top, var(--ink) 55%, rgba(15, 14, 12, 0));
}
.dock .btn { max-width: 600px; margin: 0 auto; display: flex; }

.foot { max-width: 640px; margin: 0 auto; padding: 0 20px calc(110px + var(--safe-b)); color: var(--muted); font-size: 0.84rem; }
.foot a { color: var(--paper); }

/* ---------- shared round icon button ---------- */
.icon-btn {
  width: 44px; height: 44px; flex: none; display: grid; place-items: center;
  border: 0; border-radius: 999px; background: none; color: var(--paper);
}
.icon-btn svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.icon-btn--glass { background: rgba(15, 14, 12, 0.55); -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px); }
.icon-btn[aria-pressed="true"] { background: var(--lamp); color: var(--lamp-ink); }

/* ---------- full-screen page view ---------- */
.viewer {
  position: fixed; inset: 0; z-index: 25; display: flex; flex-direction: column;
  background: #070706; padding: env(safe-area-inset-top, 0px) 0 var(--safe-b);
}
.viewer-top { display: flex; align-items: center; gap: 8px; padding: 6px 12px; }
.viewer-count { flex: 1; text-align: center; font-weight: 600; font-variant-numeric: tabular-nums; }
.viewer-stage { position: relative; flex: 1; min-height: 0; overflow: hidden; touch-action: none; user-select: none; -webkit-user-select: none; }
.viewer-track { display: flex; height: 100%; will-change: transform; }
.viewer-slide {
  position: relative; flex: 0 0 100%; height: 100%; overflow: hidden;
  display: flex; align-items: center; justify-content: center; padding: 8px 14px;
}
.viewer-slide img {
  flex: none; display: block; max-width: 100%; max-height: 100%;
  background: #fff; box-shadow: 0 12px 40px rgba(0, 0, 0, 0.6); -webkit-user-drag: none;
}
.viewer-slide img:not([src]) { display: none; }
.viewer-slide.is-updating::after {
  content: ""; position: absolute; left: 50%; top: 4px; width: 72px; margin-left: -36px; height: 3px; border-radius: 3px;
  background: var(--lamp); box-shadow: 0 0 12px 2px rgba(242, 193, 78, 0.6);
  animation: glow 0.8s ease-in-out infinite alternate;
}
@keyframes glow { from { opacity: 0.25; } }
.viewer-nav {
  position: absolute; top: 50%; margin-top: -24px; width: 48px; height: 48px; display: grid; place-items: center;
  border: 1px solid var(--line); border-radius: 999px; background: rgba(15, 14, 12, 0.75); color: var(--paper);
}
.viewer-nav svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.viewer-nav--prev { left: 12px; }
.viewer-nav--next { right: 12px; }
.viewer-nav:disabled { opacity: 0; pointer-events: none; }
.viewer-stage.is-zoomed .viewer-nav { display: none; }
@media (hover: none) { .viewer-nav { display: none; } }
.viewer-note {
  margin: 4px 14px 2px; padding: 8px 12px; border-radius: 12px; text-align: center;
  background: rgba(242, 193, 78, 0.12); color: var(--lamp); font-size: 0.86rem;
}
.viewer-filters { display: grid; gap: 4px; justify-items: center; padding: 8px 12px 0; }
.viewer-filter-row { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; width: 100%; max-width: 520px; }
.viewer-filter-row button {
  display: grid; gap: 4px; justify-items: center; padding: 6px 4px 5px;
  border: 1px solid var(--line); border-radius: 12px; background: var(--ink-2); color: #d8d1c4; font-size: 0.76rem;
}
.viewer-filter-row button[aria-checked="true"] { border-color: var(--lamp); color: var(--lamp); font-weight: 600; }
.viewer-filter-row img { display: block; width: 100%; height: 62px; object-fit: contain; border-radius: 6px; background: var(--ink-3); }
.viewer-bar { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 2px; padding: 6px 6px 8px; }
.viewer-bar button {
  display: grid; justify-items: center; align-content: center; gap: 3px; min-height: 58px; padding: 6px 2px;
  border: 0; border-radius: 12px; background: none; color: #d8d1c4; font-size: 0.76rem; white-space: nowrap;
}
.viewer-bar button:active { background: var(--ink-3); }
.viewer-bar button[aria-expanded="true"] { color: var(--lamp); }
.viewer-bar svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- camera ---------- */
.camera {
  position: fixed; inset: 0; z-index: 35; display: flex; flex-direction: column;
  background: #000; color: #fff; padding: env(safe-area-inset-top, 0px) 0 var(--safe-b);
}
.camera-top { display: flex; align-items: center; gap: 8px; padding: 6px 12px; }
.camera-gap { flex: 1; }
.cam-pill {
  min-height: 40px; padding: 0 14px; border-radius: 999px; font-size: 0.86rem; font-weight: 600;
  border: 1px solid rgba(255, 255, 255, 0.25); background: rgba(15, 14, 12, 0.55); color: #fff;
}
.cam-pill[aria-pressed="true"] { background: var(--lamp); border-color: var(--lamp); color: var(--lamp-ink); }
.camera-stage { position: relative; flex: 1; min-height: 0; }
.camera-video, .camera-overlay { position: absolute; inset: 0; width: 100%; height: 100%; }
.camera-video { object-fit: contain; background: #000; }
.camera-overlay { pointer-events: none; }
.camera-hint {
  position: absolute; left: 50%; top: 12px; transform: translateX(-50%); margin: 0;
  max-width: calc(100% - 24px); padding: 8px 14px; border-radius: 999px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  background: rgba(15, 14, 12, 0.72); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); font-size: 0.9rem;
}
.camera-hint:empty { display: none; }
.camera-debug {
  position: absolute; left: 8px; bottom: 8px; margin: 0; padding: 4px 8px; border-radius: 6px;
  background: rgba(0, 0, 0, 0.65); color: #9fe39f; font-size: 11px; white-space: pre-wrap;
}
.camera-bottom { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; padding: 14px 22px 4px; }
.cam-thumb {
  justify-self: start; position: relative; width: 52px; height: 52px; padding: 0;
  border: 2px solid #fff; border-radius: 10px; background: #222;
}
.cam-thumb img { display: block; width: 100%; height: 100%; object-fit: cover; border-radius: 8px; }
.cam-thumb.is-pop { animation: pop 0.38s var(--ease); }
@keyframes pop { 0% { transform: scale(0.55); } 60% { transform: scale(1.12); } 100% { transform: scale(1); } }
.cam-count {
  position: absolute; top: -9px; right: -9px; min-width: 22px; height: 22px; padding: 0 6px;
  display: grid; place-items: center; border-radius: 999px;
  background: var(--lamp); color: var(--lamp-ink); font-size: 0.76rem; font-weight: 700;
}
.shutter {
  --p: 0;
  width: 78px; height: 78px; padding: 0; border: 0; border-radius: 50%; display: grid; place-items: center;
  background: conic-gradient(var(--lamp) calc(var(--p) * 360deg), rgba(255, 255, 255, 0.9) 0);
}
.shutter span { width: 62px; height: 62px; border-radius: 50%; background: #fff; border: 3px solid #000; transition: transform 0.12s var(--ease); }
.shutter:active span { transform: scale(0.9); }
.cam-done {
  justify-self: end; min-height: 44px; padding: 0 18px; border: 0; border-radius: 999px;
  background: rgba(255, 255, 255, 0.16); color: #fff; font-weight: 600;
}
.cam-native {
  align-self: center; margin: 2px 0 6px; padding: 8px 12px; border: 0; background: none;
  color: rgba(255, 255, 255, 0.66); font-size: 0.82rem; text-decoration: underline; text-underline-offset: 3px;
}
.camera-flash { position: absolute; inset: 0; background: #fff; opacity: 0; pointer-events: none; }
.camera-flash.is-on { animation: flash 0.32s ease-out; }
@keyframes flash { from { opacity: 0.85; } to { opacity: 0; } }

/* ---------- editor ---------- */
.editor {
  position: fixed; inset: 0; z-index: 30; display: flex; flex-direction: column;
  background: #070706;
  padding: env(safe-area-inset-top, 0px) 0 var(--safe-b);
}
.editor-hint { margin: 0; padding: 14px 20px 10px; text-align: center; color: #d8d1c4; font-size: 0.94rem; }
.editor-stage { position: relative; flex: 1; margin: 0 14px; touch-action: none; user-select: none; -webkit-user-select: none; }
.editor-img { position: absolute; display: block; pointer-events: none; -webkit-user-drag: none; }
.editor-svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.editor-shade { fill: rgba(7, 7, 6, 0.55); }
.editor-quad { fill: rgba(242, 193, 78, 0.08); stroke: var(--lamp); stroke-width: 2; stroke-linejoin: round; }
.editor-quad.is-bad { stroke: var(--bad); fill: rgba(255, 122, 107, 0.1); }
.editor-handle-hit { fill: transparent; }
.editor-handle-dot { fill: var(--lamp); stroke: #070706; stroke-width: 2.5; transition: r 0.15s var(--ease); }
.editor-handle.is-active .editor-handle-dot { r: 13; }
.editor-loupe {
  position: absolute; width: 140px; height: 140px; border-radius: 50%;
  border: 2px solid var(--lamp); box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6); pointer-events: none;
}
.editor-bar { display: flex; gap: 8px; align-items: center; padding: 12px 14px; }
.editor-gap { flex: 1; }

/* ---------- sheet ---------- */
.sheet { position: fixed; inset: 0; z-index: 40; display: flex; align-items: flex-end; justify-content: center; }
.sheet-backdrop { position: absolute; inset: 0; background: rgba(0, 0, 0, 0.6); }
.sheet-panel {
  position: relative; width: 100%; max-width: 560px;
  background: var(--ink-2); border: 1px solid var(--line); border-bottom: 0;
  border-radius: 22px 22px 0 0;
  padding: 22px 20px calc(18px + var(--safe-b));
  display: grid; gap: 12px;
  animation: rise 0.35s var(--ease);
}
.sheet-panel > div { display: grid; gap: 12px; }
@keyframes rise { from { transform: translateY(30px); opacity: 0; } }
.sheet-title { font-family: var(--display); font-size: 1.7rem; letter-spacing: -0.02em; margin: 0 0 4px; }
.field { display: grid; gap: 6px; border: 0; padding: 0; margin: 0; }
.field-label { color: var(--muted); font-size: 0.86rem; }
.field-row { display: flex; align-items: center; background: var(--ink); border: 1px solid var(--line); border-radius: 12px; padding: 0 14px; }
.field-row:focus-within { border-color: var(--lamp); }
.field-input { flex: 1; min-width: 0; min-height: 48px; background: none; border: 0; outline: 0; color: var(--paper); font: inherit; font-size: 16px; }
.field-suffix { color: var(--muted); }
.seg { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; background: var(--ink); border: 1px solid var(--line); border-radius: 14px; padding: 4px; }
.seg button { min-height: 42px; border: 0; border-radius: 10px; background: none; color: #d8d1c4; font-size: 0.94rem; }
.seg button[aria-checked="true"] { background: var(--paper); color: var(--ink); font-weight: 600; }
.sheet-later { justify-self: center; }
.sheet-result { margin: 0 0 6px; color: #d8d1c4; word-break: break-all; }
.sheet-working { justify-items: center; padding: 26px 0 30px; }
.sheet-progress { margin: 0; color: #d8d1c4; }

/* small "cat scanning" loader used while busy */
.mini-cat { position: relative; width: 64px; height: 48px; }
.mini-cat::before {
  content: ""; position: absolute; left: 8px; right: 8px; top: 10px; bottom: 0; border-radius: 4px; background: var(--paper);
}
.mini-cat::after {
  content: ""; position: absolute; left: 4px; right: 4px; top: 10px; height: 3px; border-radius: 3px;
  background: var(--lamp); box-shadow: 0 0 12px 2px rgba(242, 193, 78, 0.7);
  animation: mini-scan 1s ease-in-out infinite alternate;
}
.mini-cat span {
  position: absolute; left: 50%; top: 0; width: 26px; height: 16px; margin-left: -13px;
  background: #1d1a17; border-radius: 13px 13px 4px 4px;
}
@keyframes mini-scan { to { transform: translateY(34px); } }

.busy {
  position: fixed; inset: 0; z-index: 50; display: grid; place-content: center; justify-items: center; gap: 14px;
  background: rgba(7, 7, 6, 0.78); color: #d8d1c4;
}
.busy p { margin: 0; }

.toast {
  position: fixed; left: 50%; bottom: calc(90px + var(--safe-b)); z-index: 60;
  transform: translateX(-50%); width: min(92vw, 520px);
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px; border-radius: 14px;
  background: var(--paper); color: var(--ink); font-size: 0.92rem;
  box-shadow: 0 12px 34px rgba(0, 0, 0, 0.5);
}
.toast-action { margin-left: auto; background: none; border: 0; color: var(--ink); font-weight: 700; text-decoration: underline; padding: 6px 0; }

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

/* ---------- actions added by a host page (Bàn học: "Lưu vào Tủ", "Gửi cho bạn"); the box stays
   empty and hidden on scan.chonrieng.com. Same classes in Bàn học's account.css. ---------- */
.host-actions { display: grid; min-width: 0; gap: 10px; }
.host-actions .btn { white-space: normal; }
.host-actions:empty { display: none; }
.host-ask:empty { display: none; }
.host-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.host-row .btn { padding-left: 0.8em; padding-right: 0.8em; }
.host-note { margin: 0; color: var(--muted); font-size: 0.88rem; }
.host-note:empty { display: none; }
.host-link { justify-self: start; }
.host-card { display: grid; gap: 10px; padding: 14px; border: 1px solid var(--line); border-radius: 14px; background: var(--ink); }
.host-card p { margin: 0; color: #d8d1c4; font-size: 0.94rem; }
.host-card .host-card-title { color: var(--paper); font-weight: 600; font-size: 1rem; }
.host-card:focus { outline: none; }
.host-error { margin: 0; color: #ffb4a8; font-size: 0.9rem; }
