:root {
  color-scheme: light;
  --green: #15803d;
  --green-dark: #166534;
  --ink: #172033;
  --muted: #64748b;
  --line: #e2e8f0;
  --surface: #ffffff;
  --background: #f1f5f9;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; max-width: 100%; overflow-x: hidden; }
body {
  font-family: "Be Vietnam Pro", "Segoe UI", Arial, sans-serif;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  color: var(--ink);
  background: var(--background);
}
button, input, textarea, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
.hidden { display: none !important; }
.app-shell { width: min(100%, 760px); min-height: 100vh; margin: 0 auto; background: #f8fafc; }
.topbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 12px;
  padding: 14px 16px; color: white; background: linear-gradient(135deg, var(--green-dark), var(--green));
  box-shadow: 0 4px 16px rgba(15, 23, 42, .16);
}
.topbar h1 { margin: 0; font-size: 18px; line-height: 1.25; }
.document-topbar h1 { color: #fef3c7; font-weight: 800; letter-spacing: -.2px; }
.document-topbar small { color: #dcfce7; opacity: .92; }
.topbar small { display: block; margin-top: 3px; opacity: .8; }
.icon-button {
  width: 42px; height: 42px; flex: 0 0 42px; border: 0; border-radius: 50%; display: grid;
  place-items: center; color: inherit; background: rgba(255,255,255,.14); cursor: pointer; text-decoration: none;
}
.icon-button:hover { background: rgba(255,255,255,.24); }
.topbar-title { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.content { padding: 18px 14px 36px; }
.intro { margin: 0 2px 18px; color: var(--muted); font-size: 14px; line-height: 1.55; }
.meeting-list, .document-list { display: grid; width: 100%; min-width: 0; gap: 12px; }
.meeting-card, .document-card {
  width: 100%; max-width: 100%; min-width: 0; border: 1px solid var(--line); border-radius: 18px; padding: 16px;
  background: var(--surface); box-shadow: 0 5px 18px rgba(15, 23, 42, .06);
}
.pastel-0 { background: #eff6ff; border-color: #bfdbfe; }
.pastel-1 { background: #f0fdf4; border-color: #bbf7d0; }
.pastel-2 { background: #fff7ed; border-color: #fed7aa; }
.pastel-3 { background: #fdf2f8; border-color: #fbcfe8; }
.pastel-4 { background: #f5f3ff; border-color: #ddd6fe; }
.pastel-5 { background: #ecfeff; border-color: #a5f3fc; }
button.meeting-card { display: flex; align-items: center; gap: 14px; text-align: left; cursor: pointer; }
.meeting-card:hover { border-color: #86efac; transform: translateY(-1px); }
.card-icon {
  width: 48px; height: 48px; flex: 0 0 48px; border-radius: 15px; display: grid; place-items: center;
  color: white; background: linear-gradient(135deg, #22c55e, var(--green)); font-size: 21px;
}
.card-body { display: block; flex: 1; min-width: 0; max-width: 100%; }
.card-title { display: block; max-width: 100%; margin: 0; color: #0f172a; font-weight: 800; font-size: 16px; line-height: 1.4; overflow-wrap: anywhere; }
.card-meta { display: block; margin: 6px 0 0; color: #64748b; font-size: 12px; font-weight: 500; line-height: 1.45; }
.chevron { color: #94a3b8; }
.empty-state { padding: 54px 20px; text-align: center; color: var(--muted); }
.empty-state i { display: block; margin-bottom: 13px; color: #94a3b8; font-size: 42px; }
.status { padding: 30px 12px; text-align: center; color: var(--muted); }
.spinner { animation: spin .9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.modal {
  position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 18px;
  background: rgba(15,23,42,.72); backdrop-filter: blur(5px);
}
.modal-panel { width: min(100%, 430px); border-radius: 22px; padding: 22px; background: white; box-shadow: 0 24px 80px rgba(0,0,0,.28); }
.modal-panel h2 { margin: 0 0 8px; font-size: 20px; }
.modal-panel p { margin: 0 0 18px; color: var(--muted); font-size: 14px; line-height: 1.5; }
.field { display: grid; gap: 7px; margin-bottom: 14px; }
.field label { font-size: 13px; font-weight: 700; }
.field input, .field textarea, .field select {
  width: 100%; border: 1px solid #cbd5e1; border-radius: 12px; padding: 11px 12px; color: var(--ink); background: white;
}
#meeting-password { text-transform: uppercase; letter-spacing: .08em; }
.field input:focus, .field textarea:focus, .field select:focus { outline: 3px solid #bbf7d0; border-color: var(--green); }
.button-row { display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; }
.btn { border: 0; border-radius: 12px; padding: 11px 16px; font-weight: 750; cursor: pointer; }
.btn:disabled { opacity: .55; cursor: wait; }
.btn-primary { color: white; background: var(--green); }
.btn-primary:hover { background: var(--green-dark); }
.btn-secondary { color: #334155; background: #e2e8f0; }
.error-message { min-height: 18px; margin: 8px 0; color: #dc2626; font-size: 13px; }

.meeting-heading { margin-bottom: 16px; }
.meeting-heading h2 { margin: 0 0 6px; font-size: 22px; }
.meeting-heading p { margin: 0; color: var(--muted); line-height: 1.5; }
.document-card { display: grid; gap: 12px; }
.document-head { display: flex; align-items: center; gap: 12px; }
.document-head .card-icon { background: linear-gradient(135deg, #ef4444, #b91c1c); }
.document-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
.document-actions button { display: flex; align-items: center; justify-content: center; gap: 7px; }

.viewer { position: fixed; inset: 0; z-index: 200; display: flex; flex-direction: column; background: #111827; color: white; }
.viewer-bar { display: flex; align-items: center; gap: 10px; padding: 10px 12px; background: #0f172a; }
.viewer-title { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 750; }
.viewer-body { flex: 1; min-height: 0; display: grid; place-items: center; overflow: hidden; }
.pdf-frame { width: 100%; height: 100%; border: 0; background: white; }
.original-pdf-scroll { width: 100%; max-width: 100vw; height: 100%; min-width: 0; min-height: 0; overflow-x: hidden; overflow-y: auto; overscroll-behavior: contain; touch-action: pan-y; -webkit-overflow-scrolling: touch; background: #334155; }
.original-pdf-pages { display: flex; box-sizing: border-box; width: 100%; max-width: 100%; min-width: 0; flex-direction: column; align-items: center; gap: 12px; overflow-x: hidden; padding: 12px; }
.original-pdf-sheet { position: relative; width: 100%; max-width: 960px; min-width: 0; flex: 0 0 auto; overflow: hidden; contain: layout paint; background: white; box-shadow: 0 5px 18px rgba(0,0,0,.35); }
.original-pdf-sheet canvas { display: block; max-width: 100% !important; background: white; }
.original-pdf-page-mark { position: absolute; right: 7px; bottom: 7px; border-radius: 999px; padding: 3px 7px; color: #e2e8f0; background: rgba(15,23,42,.72); font-size: 10px; pointer-events: none; }
.flip-stage { position: relative; width: 100%; height: 100%; display: grid; place-items: center; overflow: auto; padding: 14px; }
.flip-book { box-shadow: 0 12px 45px rgba(0,0,0,.5); }
.flip-page { display: grid; place-items: center; overflow: hidden; background: white; }
.flip-page canvas { display: block; width: 100%; height: 100%; object-fit: contain; }
.flip-page img { display: block; width: 100%; height: 100%; object-fit: contain; }
.flip-page-placeholder { display: grid; place-items: center; gap: 8px; width: 100%; height: 100%; color: #64748b; background: #f8fafc; font-size: 13px; }
.flip-end-guard { position: absolute; z-index: 60; top: 0; right: 0; width: 50%; height: 100%; display: flex; align-items: flex-end; justify-content: center; padding: 20px; cursor: not-allowed; touch-action: none; background: transparent; }
.flip-end-guard span { display: inline-flex; align-items: center; gap: 7px; margin-bottom: 4px; padding: 8px 13px; border: 1px solid rgba(255,255,255,.35); border-radius: 999px; color: #fff; background: rgba(15,23,42,.88); box-shadow: 0 5px 20px rgba(0,0,0,.25); font-size: 12px; font-weight: 800; letter-spacing: .04em; pointer-events: none; }
.flip-end-guard.flip-end-pulse span { animation: flip-end-pulse .32s ease-out; }
@keyframes flip-end-pulse { 50% { transform: scale(1.08); background: #15803d; } }
.document-card { border-width: 2px; padding: 18px; box-shadow: 0 8px 24px rgba(15,23,42,.09); }
.document-card .card-title { font-size: 17px; }
.document-card.pastel-0 { background: #dbeafe; border-color: #93c5fd; }
.document-card.pastel-1 { background: #dcfce7; border-color: #86efac; }
.document-card.pastel-2 { background: #ffedd5; border-color: #fdba74; }
.document-card.pastel-3 { background: #fce7f3; border-color: #f9a8d4; }
.document-card.pastel-4 { background: #ede9fe; border-color: #c4b5fd; }
.document-card.pastel-5 { background: #cffafe; border-color: #67e8f9; }
.viewer-counter { min-width: 72px; text-align: center; font-size: 13px; color: #cbd5e1; }

@media (max-width: 480px) {
  .topbar { gap: 9px; padding: 11px 10px; }
  .topbar h1 { font-size: 16px; line-height: 1.35; }
  .topbar small { font-size: 11px; }
  .icon-button { width: 38px; height: 38px; flex-basis: 38px; }
  .content { padding: 14px 9px 28px; }
  .meeting-card, .document-card { gap: 10px; padding: 12px; border-radius: 15px; }
  .card-icon { width: 42px; height: 42px; flex-basis: 42px; border-radius: 13px; }
  .card-title { font-size: 14px; }
  .card-meta { margin-top: 4px; font-size: 11px; line-height: 1.5; }
  .document-actions { grid-template-columns: 1fr; }
  .modal { padding: 10px; }
  .modal-panel { max-height: calc(100dvh - 20px); overflow-y: auto; padding: 18px 15px; border-radius: 18px; }
  .original-pdf-pages { gap: 7px; padding: 5px; }
  .flip-stage { overflow: hidden; padding: 6px; touch-action: none; }
}
