@import url('https://fonts.googleapis.com/css2?family=Barlow+Condensed:wght@600;700;800&family=Inter:wght@400;500;600;700&family=IBM+Plex+Mono:wght@500;600&display=swap');

:root {
  --charcoal: #0F172A;
  --panel: #16213A;
  --orange-500: #F97316;
  --orange-600: #EA580C;
  --green-500: #10B981;
  --green-600: #059669;
  --white: #FFFFFF;
  --slate-50: #F8FAFC;
  --slate-300: #CBD5E1;
  --slate-400: #94A3B8;
  --slate-500: #64748B;
  --border: rgba(255,255,255,0.1);
  --kiosk-max: 1080px; /* real kiosk displays are commonly ~1080px wide in portrait; this is a ceiling, not a fixed size */
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; height: 100%; background: var(--charcoal); overscroll-behavior: none; }
body {
  font-family: 'Inter', sans-serif;
  color: var(--white);
  touch-action: pan-y;
  user-select: none;
  -webkit-user-select: none;
}
::-webkit-scrollbar { width: 0; height: 0; }
.font-display { font-family: 'Barlow Condensed', 'Arial Narrow', sans-serif; }
.font-mono { font-family: 'IBM Plex Mono', monospace; }
button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input, textarea, select { font-family: 'Inter', sans-serif; color: var(--white); }
a { color: inherit; }

.app {
  width: 100%;
  max-width: var(--kiosk-max);
  height: 100vh;
  height: 100dvh;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  background: var(--charcoal);
  overflow: hidden;
  position: relative;
}

/* ---------- touch target + active-press helper ---------- */
.tap { transition: transform .12s ease; }
.tap:active { transform: scale(0.95); }
.btn-min { min-height: 60px; }

/* ---------- header ---------- */
.header { flex-shrink: 0; padding: 20px 16px 12px; border-bottom: 1px solid var(--border); }
.header-top { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; }
.logo-mark {
  height: 44px;
  width: auto;
  flex-shrink: 0;
  object-fit: contain;
}
.brand-title { font-size: 20px; font-weight: 800; line-height: 1; letter-spacing: -0.02em; }
.brand-sub { font-family: 'IBM Plex Mono', monospace; color: var(--green-500); font-size: 10px; letter-spacing: .12em; text-transform: uppercase; margin: 4px 0 0; }

.pulse-rule { width: 100%; height: 16px; margin-bottom: 14px; opacity: .8; }

.quiz-btn {
  width: 100%; min-height: 60px; border-radius: 16px; margin-bottom: 14px;
  background: linear-gradient(90deg, var(--orange-500), var(--orange-600));
  color: #fff; font-weight: 700; font-size: 16px;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  box-shadow: 0 10px 25px -8px rgba(249,115,22,.4);
}

.search-wrap { position: relative; }
.search-wrap svg { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--slate-400); }
.search-input {
  width: 100%; min-height: 52px; padding: 0 16px 0 44px; border-radius: 16px;
  background: var(--panel); border: 1px solid var(--border); font-size: 15px; color: #fff;
}
.search-input::placeholder { color: var(--slate-500); }
.search-input:focus { outline: none; border-color: var(--orange-500); }

.chip-row { display: flex; gap: 8px; overflow-x: auto; margin-top: 12px; padding-bottom: 4px; }
.chip {
  flex-shrink: 0; padding: 8px 16px; min-height: 40px; border-radius: 999px;
  font-family: 'IBM Plex Mono', monospace; font-size: 12.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .03em;
  background: var(--panel); color: var(--slate-300); border: 1px solid var(--border); white-space: nowrap;
}
.chip.active-all { background: #fff; color: var(--charcoal); border-color: transparent; }

/* ---------- main grid ---------- */
.main { flex: 1; min-height: 0; overflow-y: auto; padding: 20px 16px; }
.result-count { font-family: 'IBM Plex Mono', monospace; color: var(--slate-500); font-size: 11px; text-transform: uppercase; letter-spacing: .08em; margin: 0 0 12px; }
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; padding-bottom: 110px; }
.empty-state { text-align: center; padding: 64px 0; color: var(--slate-400); }

.card {
  text-align: left; background: var(--panel); border: 1px solid var(--border); border-radius: 16px;
  padding: 16px; display: flex; flex-direction: column; gap: 12px; min-height: 240px;
}
.card-thumb {
  width: 100%; aspect-ratio: 16 / 9; border-radius: 12px; overflow: hidden;
  display: flex; align-items: center; justify-content: center; position: relative; flex-shrink: 0;
}
.card-thumb img { width: 100%; height: 100%; object-fit: cover; }
.card-thumb-placeholder { display: flex; flex-direction: column; align-items: center; gap: 6px; opacity: .7; }
.card-thumb-placeholder span { font-family: 'IBM Plex Mono', monospace; font-size: 11px; text-transform: uppercase; letter-spacing: .05em; }
.card-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.hex {
  width: 44px; height: 47px; flex-shrink: 0; display: flex; align-items: center; justify-content: center;
  clip-path: polygon(50% 0%, 100% 25%, 100% 75%, 50% 100%, 0% 75%, 0% 25%);
}
.card-tag { font-family: 'IBM Plex Mono', monospace; font-size: 11px; letter-spacing: .03em; padding: 4px 8px; border-radius: 999px; text-transform: uppercase; }
.card-tags { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; }
.card-title { font-size: 22px; font-weight: 700; line-height: 1.1; letter-spacing: -0.01em; margin: 0; }
.card-summary { color: var(--slate-300); font-size: 14px; line-height: 1.4; flex: 1; margin: 0; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.card-footer { display: flex; align-items: center; justify-content: space-between; padding-top: 8px; border-top: 1px solid var(--border); }
.card-meta { font-family: 'IBM Plex Mono', monospace; font-size: 11px; color: var(--slate-400); }
.card-read { color: var(--orange-500); font-size: 13px; font-weight: 600; display: flex; align-items: center; gap: 2px; }

/* ---------- FAB + staff dot ---------- */
.fab {
  position: fixed; bottom: 24px; right: 24px; width: 64px; height: 64px; border-radius: 999px; z-index: 30;
  background: linear-gradient(135deg, var(--orange-500), var(--green-500));
  display: flex; align-items: center; justify-content: center; box-shadow: 0 10px 30px rgba(0,0,0,.4);
  animation: pulseGlow 2.4s ease-in-out infinite;
}
.staff-dot { position: fixed; bottom: 24px; left: 24px; width: 32px; height: 32px; border-radius: 999px; z-index: 30; background: rgba(255,255,255,.05); }
@keyframes pulseGlow { 0%,100% { box-shadow: 0 0 0 0 rgba(16,185,129,.55) } 50% { box-shadow: 0 0 0 14px rgba(16,185,129,0) } }

/* ---------- modal (research + quiz) ---------- */
.overlay { position: fixed; inset: 0; background: var(--charcoal); z-index: 40; display: flex; flex-direction: column; animation: fadeIn .2s ease; }
.overlay.quiz { z-index: 50; }
@keyframes fadeIn { from { opacity: 0 } to { opacity: 1 } }
.overlay-header { flex-shrink: 0; display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.icon-btn { width: 60px; height: 60px; border-radius: 999px; background: rgba(255,255,255,.05); border: 1px solid var(--border); display: flex; align-items: center; justify-content: center; }
.overlay-body { flex: 1; min-height: 0; overflow-y: auto; padding: 20px; }

.modal-title { font-size: 30px; font-weight: 800; line-height: 1.05; margin: 0; }
.modal-meta { font-family: 'IBM Plex Mono', monospace; color: var(--slate-400); font-size: 12px; margin: 8px 0 0; }
.section-label { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; margin: 24px 0 10px; }
.section-label.green { color: var(--green-500); }
.section-label.orange { color: var(--orange-500); }
.finding-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.finding-item { display: flex; gap: 12px; color: var(--slate-100, #f1f5f9); font-size: 15px; line-height: 1.4; }
.finding-num { font-family: 'IBM Plex Mono', monospace; color: var(--orange-500); flex-shrink: 0; }
.summary-gallery { display: flex; flex-direction: column; gap: 12px; margin-top: 10px; }
.summary-gallery img { width: 100%; border-radius: 12px; border: 1px solid var(--border); display: block; }
.qr-card { background: var(--panel); border: 1px solid var(--border); border-radius: 16px; padding: 20px; display: flex; align-items: center; gap: 20px; margin-top: 24px; }
.qr-card img { background: var(--slate-50); border-radius: 8px; padding: 8px; }
.qr-title { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 15px; margin: 0; }
.qr-sub { color: var(--slate-400); font-size: 13px; margin: 6px 0 0; line-height: 1.4; }

/* ---------- quiz ---------- */
.quiz-body { flex: 1; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; justify-content: center; padding: 32px 24px; }
.quiz-dots { display: flex; gap: 8px; justify-content: center; margin-bottom: 32px; }
.quiz-dot { height: 6px; width: 40px; border-radius: 999px; background: rgba(255,255,255,.15); }
.quiz-dot.done { background: var(--orange-500); }
.quiz-progress { font-family: 'IBM Plex Mono', monospace; color: var(--green-500); font-size: 13px; text-align: center; margin: 0 0 12px; }
.quiz-question { font-size: 28px; font-weight: 700; text-align: center; line-height: 1.2; margin: 0 0 32px; }
.quiz-option {
  width: 100%; min-height: 64px; padding: 0 20px; border-radius: 12px; border: 1px solid var(--border);
  background: var(--panel); color: #f1f5f9; font-size: 16px; font-weight: 500; text-align: left;
  display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px;
}
.quiz-option.correct { background: rgba(16,185,129,.2); border-color: var(--green-500); color: #6ee7b7; }
.quiz-option.wrong { background: rgba(249,115,22,.2); border-color: var(--orange-500); color: #fdba74; }
.quiz-result { text-align: center; display: flex; flex-direction: column; align-items: center; gap: 16px; }
.quiz-result h2 { font-size: 32px; font-weight: 800; margin: 0; }
.quiz-result p { color: var(--slate-300); font-size: 15px; max-width: 320px; margin: 0; }
.quiz-btn-secondary { min-height: 60px; padding: 0 24px; border-radius: 12px; background: var(--panel); border: 1px solid var(--border); color: #fff; font-weight: 600; display: flex; align-items: center; gap: 8px; }
.quiz-btn-primary { min-height: 60px; padding: 0 32px; border-radius: 12px; background: var(--orange-500); color: #fff; font-weight: 700; }

/* ---------- AI drawer ---------- */
.drawer-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.6); z-index: 50; display: flex; align-items: flex-end; justify-content: center; }
.drawer {
  width: 100%; max-width: var(--kiosk-max); height: 78vh; height: 78dvh; background: var(--charcoal); border-top: 1px solid var(--border);
  border-radius: 24px 24px 0 0; display: flex; flex-direction: column; min-height: 0;
  animation: slideUp .25s ease; box-shadow: 0 -10px 40px rgba(0,0,0,.5);
}
@keyframes slideUp { from { transform: translateY(24px); opacity: 0 } to { transform: translateY(0); opacity: 1 } }
.drawer-header { flex-shrink: 0; display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--border); border-radius: 24px 24px 0 0; background: var(--charcoal); }
.drawer-avatar { position: relative; width: 40px; height: 40px; border-radius: 999px; background: linear-gradient(135deg, var(--orange-500), var(--green-500)); display: flex; align-items: center; justify-content: center; }
.drawer-avatar .ping { position: absolute; inset: 0; border-radius: 999px; background: rgba(16,185,129,.3); animation: ping 1.6s cubic-bezier(0,0,.2,1) infinite; }
@keyframes ping { 75%, 100% { transform: scale(2); opacity: 0; } }
.drawer-name { font-weight: 700; font-size: 15px; margin: 0; }
.drawer-sub { font-family: 'IBM Plex Mono', monospace; color: var(--green-500); font-size: 11px; margin: 4px 0 0; }
.drawer-messages { flex: 1; min-height: 0; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 12px; scrollbar-width: thin; }
.msg-row { display: flex; flex-direction: column; }
.msg-row.user { align-items: flex-end; }
.msg-row.ai { align-items: flex-start; }
.bubble { max-width: 85%; padding: 12px 16px; border-radius: 16px; font-size: 16px; line-height: 1.5; white-space: pre-wrap; }
.bubble.user { background: var(--orange-500); color: #fff; border-bottom-right-radius: 4px; }
.bubble.ai { background: var(--panel); color: #f1f5f9; border: 1px solid var(--border); border-bottom-left-radius: 4px; }
.match-list { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; max-width: 85%; width: 100%; }
.match-card { display: flex; align-items: center; gap: 12px; padding: 10px 12px; min-height: 52px; border-radius: 12px; background: var(--panel); border: 1px solid var(--border); text-align: left; }
.match-title { font-size: 13px; font-weight: 600; line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.match-cta { font-family: 'IBM Plex Mono', monospace; color: var(--green-500); font-size: 11px; margin-top: 2px; }
.chip-scroll { display: flex; gap: 8px; overflow-x: auto; padding: 0 16px 10px; flex-shrink: 0; }
.prompt-chip { flex-shrink: 0; padding: 10px 16px; min-height: 44px; border-radius: 999px; background: var(--panel); border: 1px solid var(--border); font-size: 13px; font-weight: 500; white-space: nowrap; }
.drawer-input-row { flex-shrink: 0; display: flex; gap: 8px; padding: 16px; border-top: 1px solid var(--border); }
.drawer-input { flex: 1; min-height: 60px; padding: 0 16px; border-radius: 12px; background: var(--panel); border: 1px solid var(--border); font-size: 15px; }
.drawer-input::placeholder { color: var(--slate-500); }
.drawer-input:focus { outline: none; border-color: var(--orange-500); }
.drawer-send { min-height: 60px; min-width: 60px; border-radius: 12px; background: var(--orange-500); display: flex; align-items: center; justify-content: center; }
.drawer-send:disabled { opacity: .4; }

/* ---------- admin ---------- */
.admin-body { background: var(--charcoal); min-height: 100vh; min-height: 100dvh; font-family: 'Inter', sans-serif; user-select: text; }
.admin-header { border-bottom: 1px solid var(--border); padding: 18px 24px; display: flex; align-items: center; justify-content: space-between; position: sticky; top: 0; background: var(--charcoal); z-index: 10; flex-wrap: wrap; gap: 12px; }
.admin-title { font-size: 22px; font-weight: 800; margin: 0; line-height: 1; }
.admin-sub { font-family: 'IBM Plex Mono', monospace; color: var(--green-500); font-size: 11px; margin: 6px 0 0; }
.admin-actions { display: flex; gap: 10px; }
.btn-ghost { min-height: 44px; padding: 0 16px; border-radius: 12px; background: var(--panel); border: 1px solid var(--border); color: var(--slate-300); font-weight: 600; font-size: 13px; }
.admin-grid { display: grid; grid-template-columns: 1fr; gap: 24px; padding: 24px; align-items: start; }
@media (min-width: 1024px) { .admin-grid { grid-template-columns: 1fr 420px; } }
.paper-row { display: flex; align-items: center; gap: 14px; background: var(--panel); border: 1px solid var(--border); border-radius: 14px; padding: 14px; margin-bottom: 10px; }
.paper-row-title { font-weight: 600; font-size: 15px; margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.paper-row-meta { font-family: 'IBM Plex Mono', monospace; color: var(--slate-400); font-size: 12px; margin: 2px 0 0; }
.form-panel { background: var(--panel); border: 1px solid var(--border); border-radius: 16px; padding: 20px; position: sticky; top: 96px; }
.form-label { display: block; font-family: 'IBM Plex Mono', monospace; color: var(--slate-400); font-size: 11px; text-transform: uppercase; margin-bottom: 6px; }
.form-input, .form-textarea, .form-select {
  width: 100%; min-height: 48px; padding: 0 12px; border-radius: 10px; background: var(--charcoal); border: 1px solid var(--border); font-size: 14px;
}
.form-textarea { min-height: auto; padding: 10px 12px; resize: vertical; }
.field { margin-bottom: 16px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.submit-btn { width: 100%; min-height: 52px; border-radius: 12px; background: linear-gradient(90deg, var(--orange-500), var(--orange-600)); color: #fff; font-weight: 700; font-size: 15px; }
.saved-flash { color: var(--green-500); font-size: 12px; text-align: center; font-family: 'IBM Plex Mono', monospace; margin-top: 8px; }

.image-upload-row { display: flex; align-items: center; gap: 14px; }
.image-preview {
  width: 84px; height: 84px; border-radius: 12px; overflow: hidden; flex-shrink: 0;
  background: var(--charcoal); border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
}
.image-preview img { width: 100%; height: 100%; object-fit: cover; }
.image-preview svg { opacity: .5; }

.chip.selected { border-color: transparent; }

.summary-images-wrap { display: flex; flex-wrap: wrap; gap: 10px; }
.summary-image-tile { position: relative; width: 84px; height: 84px; border-radius: 12px; overflow: hidden; border: 1px solid var(--border); }
.summary-image-tile img { width: 100%; height: 100%; object-fit: cover; display: block; }
.summary-image-remove {
  position: absolute; top: 4px; right: 4px; width: 24px; height: 24px; border-radius: 999px;
  background: rgba(15,23,42,.85); display: flex; align-items: center; justify-content: center;
}

.login-wrap { min-height: 100vh; min-height: 100dvh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.login-card { width: 100%; max-width: 360px; background: var(--panel); border: 1px solid var(--border); border-radius: 20px; padding: 28px; }
.login-error { color: var(--orange-500); font-size: 13px; margin-top: 10px; text-align: center; }

.hidden { display: none !important; }

/* ---------- kiosk-scale responsiveness ----------
   The base styles above target a narrow (phone-preview width) screen. Real kiosk
   touch displays are commonly 700-1080px wide in portrait — these breakpoints let
   the grid and key type scale up instead of staying a stretched 2-column phone
   layout with wasted space. */
@media (min-width: 640px) {
  .header { padding: 28px 24px 16px; }
  .logo-mark { height: 56px; }
  .brand-title { font-size: 26px; }
  .brand-sub { font-size: 12px; }
  .quiz-btn { font-size: 18px; }
  .search-input { font-size: 16px; }
  .main { padding: 24px 24px 0; }
  .grid { grid-template-columns: 1fr 1fr 1fr; gap: 16px; }
  .card-title { font-size: 24px; }
  .card-summary { font-size: 15px; }
  .modal-title { font-size: 36px; }
  .quiz-question { font-size: 32px; }
  .bubble { font-size: 17px; }
  .fab { width: 72px; height: 72px; }
}

@media (min-width: 900px) {
  .grid { grid-template-columns: 1fr 1fr 1fr 1fr; gap: 18px; }
  .modal-title { font-size: 40px; }
}
