:root {
  color-scheme: light;
  --ink: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;
  --bg: #f1f5f9;
  --card: #ffffff;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --accent-soft: #dbeafe;
  --danger: #dc2626;
  --radius: 20px;
  font-family: "DM Sans", "Segoe UI", system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
}

body {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}

button {
  font: inherit;
}

.guest-screen {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: max(24px, env(safe-area-inset-top)) 20px max(24px, env(safe-area-inset-bottom));
  background:
    radial-gradient(ellipse 90% 50% at 50% -20%, #bfdbfe 0%, transparent 60%),
    radial-gradient(circle at 100% 100%, #e0e7ff 0%, transparent 40%),
    var(--bg);
}

.guest-screen[hidden] {
  display: none !important;
}

.guest-card {
  width: min(100%, 380px);
  padding: 36px 28px 32px;
  text-align: center;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow:
    0 1px 2px rgba(15, 23, 42, 0.04),
    0 20px 50px rgba(15, 23, 42, 0.1);
}

.guest-kicker {
  margin: 0 0 12px;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
}

.guest-title {
  margin: 0 0 12px;
  font-size: 1.875rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.guest-lead {
  margin: 0 0 28px;
  font-size: 1rem;
  line-height: 1.55;
  color: var(--muted);
}

.btn-primary {
  width: 100%;
  padding: 15px 24px;
  border: 0;
  border-radius: 999px;
  background: linear-gradient(180deg, #3b82f6 0%, var(--accent) 100%);
  color: white;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 10px 24px rgba(37, 99, 235, 0.35);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.btn-primary:hover {
  box-shadow: 0 12px 28px rgba(37, 99, 235, 0.45);
}

.btn-primary:active {
  transform: scale(0.98);
}

.app-shell {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg);
}

.app-shell[hidden] {
  display: none !important;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: calc(12px + env(safe-area-inset-top)) 16px 12px;
  background: linear-gradient(180deg, #1e293b 0%, var(--ink) 100%);
  color: white;
  box-shadow: 0 4px 20px rgba(15, 23, 42, 0.15);
}

.brand {
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: 0.01em;
}

.top-actions {
  display: flex;
  gap: 8px;
}

.auth-btn,
.tab-btn {
  border: 0;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.1s ease;
}

.auth-btn {
  padding: 9px 16px;
  background: white;
  color: var(--ink);
  font-size: 0.875rem;
  font-weight: 600;
}

.auth-btn:active,
.tab-btn:active {
  transform: scale(0.97);
}

.auth-btn--ghost {
  background: rgba(255, 255, 255, 0.1);
  color: white;
  border: 1px solid rgba(255, 255, 255, 0.22);
}

.auth-btn--ghost:hover {
  background: rgba(255, 255, 255, 0.16);
}

#log-count {
  display: inline-block;
  min-width: 1.25rem;
  padding: 0 6px;
  margin-left: 4px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 0.75rem;
  font-weight: 700;
}

main {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.tab {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.tab[hidden] {
  display: none !important;
}

.tab-hello {
  align-items: center;
  justify-content: center;
  padding: 32px 24px;
}

.hello-title {
  margin: 0;
  max-width: 22ch;
  padding: 28px 32px;
  font-size: clamp(1.35rem, 4.5vw, 2rem);
  font-weight: 700;
  line-height: 1.35;
  text-align: center;
  word-break: break-word;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 8px 30px rgba(15, 23, 42, 0.06);
}

#tab-iframe {
  position: relative;
  padding: 0;
  background: white;
}

.refresh-frame {
  position: absolute;
  z-index: 2;
  top: 12px;
  right: 12px;
  padding: 10px 16px;
  border: 0;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.85);
  color: white;
  font-size: 0.8125rem;
  font-weight: 600;
  cursor: pointer;
  backdrop-filter: blur(8px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

iframe {
  flex: 1;
  width: 100%;
  min-height: 0;
  border: 0;
  background: white;
}

.log-drawer {
  position: fixed;
  z-index: 5;
  left: 12px;
  right: 12px;
  bottom: calc(76px + env(safe-area-inset-bottom));
  background: #0f172a;
  color: #e2e8f0;
  border-radius: var(--radius);
  box-shadow: 0 16px 40px rgba(15, 23, 42, 0.4);
  border: 1px solid #334155;
}

.log-drawer[hidden] {
  display: none !important;
}

.log-list {
  list-style: none;
  margin: 0;
  padding: 12px;
  max-height: 36dvh;
  overflow: auto;
}

.log-list li {
  margin: 0 0 8px;
  padding: 10px 12px;
  border-radius: 12px;
  background: #1e293b;
  font-size: 12px;
  line-height: 1.45;
  word-break: break-word;
}

.log-list time {
  display: block;
  margin-bottom: 4px;
  color: #94a3b8;
  font-size: 11px;
}

.log-list .error {
  color: #fecaca;
}

.log-list details {
  margin-top: 6px;
}

.log-list pre {
  margin: 6px 0 0;
  white-space: pre-wrap;
  word-break: break-all;
  color: #cbd5e1;
  font-size: 11px;
}

.tabs {
  display: flex;
  gap: 6px;
  padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
  background: var(--card);
  border-top: 1px solid var(--line);
  box-shadow: 0 -4px 20px rgba(15, 23, 42, 0.04);
}

.tab-btn {
  flex: 1;
  padding: 13px 12px;
  background: var(--bg);
  color: var(--muted);
  font-size: 0.9375rem;
  font-weight: 600;
  border-radius: 14px;
}

.tab-btn.is-active {
  background: var(--accent);
  color: white;
  box-shadow: 0 4px 14px rgba(37, 99, 235, 0.35);
}
