*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* TAN - MON CHERI display font (uses installed font or file in /fonts) */
@font-face {
  font-family: "TAN Mon Cheri";
  src: local("TAN - MON CHERI"), local("TAN Mon Cheri"), local("TAN-MONCHERI"),
    url("fonts/TAN-MON-CHERI.woff2") format("woff2"),
    url("fonts/TAN-MON-CHERI.woff") format("woff"),
    url("fonts/TAN-MON-CHERI.otf") format("opentype"),
    url("fonts/TAN-MON-CHERI.ttf") format("truetype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

:root {
  --lime: #b8ff00;
  --lime-hover: #a7e800;
  --bg: #f5f5f3;
  --muted: #727a61;
  --border: #e2e3e1;
}

html,
body {
  height: 100%;
}

body {
  background: #e5e5e5;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text",
    "Inter", "Helvetica Neue", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  color: #000;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  min-height: 100dvh;
}

/* Mobile: full screen */
.app {
  width: 100%;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  user-select: none;
}

/* Desktop/tablet: phone-like frame */
@media (min-width: 480px) {
  body {
    padding: 16px;
  }
  .app {
    width: 390px;
    height: 844px;
    min-height: 0;
    max-height: calc(100vh - 32px);
    border-radius: 48px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    overflow: hidden;
  }
}

.content {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 68px 24px 28px;
  padding-bottom: max(28px, env(safe-area-inset-bottom));
}

.title {
  font-family: "TAN Mon Cheri", "Optima", "Avenir Next", "Playfair Display", Georgia, sans-serif;
  font-size: clamp(35px, 11.5vw, 48px);
  line-height: 1.08;
  font-weight: 400;
  letter-spacing: -0.01em;
  overflow-wrap: break-word;
}

.date {
  margin-top: 8px;
  font-size: 14px;
  color: var(--muted);
}

.spacer {
  flex: 1;
}

/* Search */
.search {
  width: 100%;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 9999px;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
  cursor: text;
  transition: border-color 0.2s;
}

.search:focus-within {
  border-color: #c9cbc6;
}

.search-icon {
  width: 16px;
  height: 16px;
  color: var(--muted);
  flex-shrink: 0;
}

.search input {
  width: 100%;
  background: transparent;
  border: 0;
  outline: none;
  font: inherit;
  font-size: 14px;
  color: #000;
}

.search input::placeholder {
  color: #000;
  opacity: 0.85;
}

/* CTA */
.cta {
  width: 100%;
  background: var(--lime);
  border: 0;
  border-radius: 36px;
  padding: 20px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  font: inherit;
  color: #000;
  text-align: left;
  transition: transform 0.15s, background-color 0.2s;
}

.cta:hover {
  background: var(--lime-hover);
}

.cta:active {
  transform: scale(0.99);
}

.cta-text {
  display: flex;
  flex-direction: column;
}

.cta-title {
  font-size: 24px;
  line-height: 1.25;
}

.cta-sub {
  font-size: 14px;
  color: rgba(0, 0, 0, 0.75);
  margin-top: 2px;
}

.cta-arrow {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: #000;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.cta-arrow svg {
  width: 16px;
  height: 16px;
}

/* =========================================================
   Features: header links, search results, OK, scanner, toast
   ========================================================= */
[hidden] {
  display: none !important;
}

.app {
  position: relative;
}

.header-top {
  position: absolute;
  top: 24px;
  left: 24px;
  right: 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.link-admin {
  margin-left: auto;
  font-size: 13px;
  color: var(--muted);
  text-decoration: none;
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: #fff;
}
.link-admin:hover {
  color: #000;
}

.mode-badge {
  font-size: 11px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 4px 10px;
  border-radius: 999px;
  background: #000;
  color: var(--lime);
}

/* --- Search + OK --- */
.actions {
  position: relative;
}

.search {
  padding: 8px 8px 8px 16px;
  min-height: 52px;
}

.ok-btn {
  flex-shrink: 0;
  height: 36px;
  min-width: 56px;
  padding: 0 16px;
  border: 0;
  border-radius: 999px;
  background: #000;
  color: #fff;
  font: inherit;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: opacity 0.2s, background-color 0.2s;
}
.ok-btn:disabled {
  background: #e9eae7;
  color: #a3a79a;
  cursor: not-allowed;
}

.results {
  position: absolute;
  left: 0;
  right: 0;
  bottom: calc(100% - 4px);
  margin-bottom: 12px;
  max-height: 340px;
  overflow-y: auto;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 6px;
  box-shadow: 0 12px 32px -12px rgba(0, 0, 0, 0.18);
  z-index: 5;
}

.result-item {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 12px;
  border: 0;
  background: transparent;
  border-radius: 16px;
  text-align: left;
  font: inherit;
  color: #000;
  cursor: pointer;
}
.result-item:hover,
.result-item.is-selected {
  background: #f1f2ee;
}
.ri-name {
  display: block;
  font-size: 15px;
}
.ri-meta {
  display: block;
  font-size: 12px;
  color: var(--muted);
  margin-top: 2px;
}
.badge {
  flex-shrink: 0;
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--lime);
}
.results-empty {
  padding: 14px;
  font-size: 14px;
  color: var(--muted);
  text-align: center;
}

/* --- Result card (shared) --- */
.rc {
  border-radius: 28px;
  padding: 18px 20px;
  color: #000;
}
.rc-success {
  background: var(--lime);
}
.rc-warn {
  background: #ffd84d;
}
.rc-error {
  background: #ff6b5b;
}
.rc-label {
  font-size: 13px;
  font-weight: 500;
}
.rc-name {
  font-size: 26px;
  line-height: 1.15;
  margin-top: 6px;
  letter-spacing: -0.01em;
}
.rc-sub {
  font-size: 14px;
  margin-top: 6px;
}
.rc-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 20px;
  margin-top: 10px;
}
.rc-meta dt {
  font-size: 11px;
  opacity: 0.6;
}
.rc-meta dd {
  font-size: 14px;
}

/* --- Toast (home, above search bar) --- */
.toast {
  position: absolute;
  left: 0;
  right: 0;
  bottom: calc(100% + 12px);
  z-index: 10;
  box-shadow: 0 12px 32px -12px rgba(0, 0, 0, 0.25);
  border-radius: 28px;
  animation: slideUp 0.25s ease;
  cursor: pointer;
}

/* --- Scanner overlay --- */
.scanner {
  position: absolute;
  inset: 0;
  z-index: 20;
  background: #0b0f12;
  color: #fff;
  display: flex;
  flex-direction: column;
  padding: 24px 20px;
  padding-bottom: max(20px, env(safe-area-inset-bottom));
  animation: fadeIn 0.2s ease;
}
.scanner-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
}
.scanner-title {
  font-size: 24px;
}
.scanner-count {
  font-size: 13px;
  color: rgba(255, 255, 255, 0.6);
  margin-top: 2px;
}
.scanner-count span {
  color: var(--lime);
}
.icon-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 0;
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.icon-btn svg {
  width: 18px;
  height: 18px;
}

.scanner-view {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 14px;
  min-height: 0;
}
#reader {
  width: 100%;
  aspect-ratio: 1 / 1;
  max-height: 60vh;
  border-radius: 28px;
  overflow: hidden;
  background: #151a1f;
  border: 0 !important;
}
#reader video {
  width: 100% !important;
  height: 100% !important;
  object-fit: cover;
}
.scan-hint {
  text-align: center;
  font-size: 14px;
  color: rgba(255, 255, 255, 0.7);
}

.scan-result {
  position: absolute;
  left: 16px;
  right: 16px;
  bottom: max(24px, calc(env(safe-area-inset-bottom) + 16px));
  animation: slideUp 0.25s ease;
  cursor: pointer;
  box-shadow: 0 16px 40px -8px rgba(0, 0, 0, 0.5);
  border-radius: 28px;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes slideUp {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: none; }
}
@keyframes slideDown {
  from { opacity: 0; transform: translateY(-16px); }
  to { opacity: 1; transform: none; }
}
