/* Chat app styles. Tokens and shared components live in /theme.css. */

html, body { height: 100%; }

/* ---------- Layout ---------- */
.app {
  display: flex;
  height: 100dvh;
  overflow: hidden;
}

.sidebar {
  width: 300px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 28px;
  padding: 24px 20px;
  padding-top: max(24px, env(safe-area-inset-top));
  background: var(--bg-subtle);
  border-right: 1px solid var(--border);
  overflow-y: auto;
}

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

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

/* Brand (shared styles in theme.css) */
.brand-mobile { display: none; }

/* ---------- Sidebar contents ---------- */
.section-label {
  margin: 0 0 10px;
  font-size: 12px; font-weight: 600; letter-spacing: 0.06em;
  text-transform: uppercase; color: var(--text-muted);
}
.status-empty {
  font-size: 14px; color: var(--text-muted);
  padding: 14px; border: 1px dashed var(--border); border-radius: var(--radius);
}
.status-card {
  display: flex; flex-direction: column; gap: 12px;
  padding: 16px; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow);
}
.status-row { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.live-dot {
  width: 8px; height: 8px; border-radius: 50%; background: var(--live);
  box-shadow: 0 0 0 0 var(--live); animation: pulse 2s infinite;
}
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--live) 60%, transparent); }
  70% { box-shadow: 0 0 0 6px transparent; }
  100% { box-shadow: 0 0 0 0 transparent; }
}
.status-live { font-weight: 600; color: var(--live); }
.role-badge {
  margin-left: auto; font-size: 11px; font-weight: 600;
  padding: 2px 8px; border-radius: 99px;
  background: var(--accent-soft); color: var(--accent);
}
.code-display {
  font-family: var(--mono); font-size: 17px; font-weight: 600; letter-spacing: 0.04em;
  text-align: left; padding: 10px 12px; border-radius: 10px;
  background: var(--bg-subtle); border: 1px solid var(--border);
}
.code-display:hover { border-color: var(--accent); }

/* Copy buttons: code text followed by a copy icon that flips to a check once copied */
.copy-btn { display: inline-flex; align-items: center; gap: 8px; }
.copy-btn .code-text { flex: 1; min-width: 0; }
.copy-btn .icon { flex-shrink: 0; color: var(--text-muted); transition: color 0.15s; }
.copy-btn:hover .icon-copy { color: var(--accent); }
.copy-btn .icon-check { display: none; color: var(--live); }
.copy-btn.copied .icon-copy { display: none; }
.copy-btn.copied .icon-check { display: inline; }

.share-app .icon, .welcome .btn .icon { flex-shrink: 0; }
.status-meta { font-size: 14px; }
.sidebar-foot { margin-top: auto; display: flex; flex-direction: column; gap: 18px; }
.principles {
  margin: 0; padding: 0; list-style: none;
  display: flex; flex-direction: column; gap: 8px;
  font-size: 13px; color: var(--text-muted);
}
.principles li::before { content: "·"; margin-right: 8px; color: var(--accent); font-weight: 700; }

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 38px; height: 38px; border-radius: 10px;
  background: transparent; border: none;
}
.icon-btn:hover { background: var(--bg-subtle); }

/* ---------- Home ---------- */
.home { overflow-y: auto; }
.home-header { padding: 20px 24px 0; padding-top: max(20px, env(safe-area-inset-top)); }
.home-body {
  width: 100%; max-width: 440px; margin: 0 auto;
  padding: 48px 24px calc(32px + env(safe-area-inset-bottom));
  display: flex; flex-direction: column; gap: 18px;
}
.home-title { margin: 0; font-size: 30px; line-height: 1.15; letter-spacing: -0.02em; }
.home-sub { margin: -4px 0 8px; color: var(--text-muted); }

.field { display: flex; flex-direction: column; gap: 6px; }
.field-label { font-size: 14px; font-weight: 600; }
.field input {
  min-height: 48px; padding: 0 14px;
  border-radius: 12px; border: 1px solid var(--border);
  background: var(--surface); outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.field input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

.card {
  display: flex; flex-direction: column; gap: 12px;
  padding: 18px; margin: 0;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
}
.card-title { margin: 0; font-size: 16px; }
.card-text { margin: -6px 0 2px; font-size: 14px; color: var(--text-muted); }

.code-input {
  font-family: var(--mono); font-size: 18px !important; letter-spacing: 0.08em;
  text-align: center; text-transform: uppercase;
}

.divider { display: flex; align-items: center; gap: 12px; color: var(--text-muted); font-size: 13px; }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--border); }

.error { min-height: 1.2em; margin: 0; color: var(--danger); font-size: 14px; text-align: center; }
.conn-note { margin: 0; font-size: 12px; color: var(--text-muted); text-align: center; }
.conn-note:empty { display: none; }

.share-cta {
  display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 10px;
  padding-top: 16px; border-top: 1px solid var(--border);
  font-size: 14px;
}

/* ---------- Room ---------- */
.room-header {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 16px;
  padding-top: max(12px, env(safe-area-inset-top));
  border-bottom: 1px solid var(--border);
  background: var(--bg);
}
.room-title { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.room-code {
  align-self: flex-start;
  margin: -4px -8px; padding: 4px 8px; border-radius: 8px;
  border: none; background: none;
  font-family: var(--mono); font-weight: 600; font-size: 16px; letter-spacing: 0.04em;
}
.room-sub { font-size: 12px; color: var(--text-muted); }
.member-pill {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 5px 10px; border-radius: 99px;
  background: var(--accent-soft); color: var(--accent);
  font-size: 13px; font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.banner {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 16px;
  background: var(--warn-soft); color: var(--warn);
  border-bottom: 1px solid var(--warn-border);
  font-size: 13px; font-weight: 500;
}
.banner-text { flex: 1; min-width: 0; }
.banner-timer {
  font-variant-numeric: tabular-nums; font-weight: 700;
  padding: 2px 8px; border-radius: 99px; border: 1px solid var(--warn-border);
}
.banner-spinner {
  flex-shrink: 0; width: 14px; height: 14px; border-radius: 50%;
  border: 2px solid var(--warn-border); border-top-color: var(--warn);
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.status-card.offline .live-dot { background: var(--warn); animation: none; }
.status-card.offline .status-live { color: var(--warn); }

.messages {
  flex: 1; min-height: 0; overflow-y: auto;
  padding: 16px;
  display: flex; flex-direction: column; gap: 4px;
  overscroll-behavior: contain;
}
.messages > :first-child { margin-top: auto; }

.msg { display: flex; flex-direction: column; max-width: min(78%, 560px); }
.msg.mine { align-self: flex-end; align-items: flex-end; }
.msg.other { align-self: flex-start; align-items: flex-start; }
.msg + .msg { margin-top: 2px; }
.msg.new-group { margin-top: 10px; }
.msg-name { font-size: 12px; color: var(--text-muted); margin: 0 10px 3px; }
.bubble {
  padding: 9px 13px; border-radius: 18px;
  white-space: pre-wrap; word-wrap: break-word; overflow-wrap: anywhere;
}
.mine .bubble { background: var(--bubble-mine); color: var(--bubble-mine-text); border-bottom-right-radius: 6px; }
.other .bubble { background: var(--bubble-other); color: var(--bubble-other-text); border-bottom-left-radius: 6px; }
.msg-time { font-size: 11px; color: var(--text-muted); margin: 3px 10px 0; }

.system {
  align-self: center; margin: 10px 0;
  font-size: 12px; color: var(--text-muted);
  padding: 4px 12px; border-radius: 99px; background: var(--bg-subtle);
  text-align: center;
}
.welcome {
  align-self: center; text-align: center; max-width: 320px;
  margin: 12px auto; font-size: 14px; color: var(--text-muted);
}
.welcome strong { color: var(--text); display: block; font-size: 16px; margin-bottom: 4px; }
.room-code:hover { background: var(--bg-subtle); }
.welcome { display: flex; flex-direction: column; align-items: center; }
.welcome .code-display { margin: 14px 0 10px; color: var(--text); }
.welcome .btn { color: var(--text); }

.composer {
  display: flex; align-items: flex-end; gap: 8px;
  padding: 10px 12px;
  padding-bottom: max(10px, env(safe-area-inset-bottom));
  border-top: 1px solid var(--border);
  background: var(--bg);
}
.composer textarea {
  flex: 1; resize: none; max-height: 140px; min-height: 44px;
  padding: 11px 16px; border-radius: 22px;
  border: 1px solid var(--border); background: var(--bg-subtle);
  outline: none; line-height: 1.35;
}
.composer textarea:focus { border-color: var(--accent); }
.send-btn {
  flex-shrink: 0; width: 44px; height: 44px; border-radius: 50%; border: none;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--accent); color: var(--accent-contrast);
  transition: opacity 0.15s, transform 0.05s;
}
.send-btn:active { transform: scale(0.94); }
.send-btn:disabled { opacity: 0.35; cursor: not-allowed; }

/* ---------- Dialog ---------- */
.dialog {
  width: min(360px, calc(100vw - 32px));
  padding: 22px; border: 1px solid var(--border); border-radius: 18px;
  background: var(--surface); color: var(--text); box-shadow: var(--shadow);
}
.dialog::backdrop { background: rgba(0, 0, 0, 0.4); }
.dialog h2 { margin: 0 0 8px; font-size: 18px; }
.dialog p { margin: 0 0 20px; color: var(--text-muted); font-size: 14px; }
.dialog-actions { display: flex; gap: 10px; justify-content: flex-end; }


.mobile-only { display: none; }

/* ---------- Mobile ---------- */
@media (max-width: 820px) {
  .sidebar {
    position: fixed; inset: 0 auto 0 0; z-index: 30;
    width: min(300px, 85vw);
    transform: translateX(-100%);
    transition: transform 0.25s ease;
  }
  .sidebar.open { transform: translateX(0); box-shadow: var(--shadow); }
  .scrim { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.35); z-index: 20; }
  .brand-mobile { display: flex; }
  .mobile-only { display: inline-flex; }
  .home-body { padding-top: 32px; }
  .home-title { font-size: 26px; }
  .room-header { padding-left: 8px; padding-right: 12px; }
}

@media (min-width: 821px) {
  .home-header { display: none; }
  .home-body { padding-top: 12vh; }
}
