:root {
  --db-bg: #0a0a0a;
  --db-surface: #161616;
  --db-surface-2: #1f1f1f;
  --db-border: rgba(255, 255, 255, 0.08);
  --db-border-gold: rgba(201, 169, 98, 0.35);
  --db-gold: #c9a962;
  --db-gold-light: #e8d5a3;
  --db-gold-dim: rgba(201, 169, 98, 0.15);
  --db-text: #f2f2f2;
  --db-text-muted: #9a9a9a;
  --db-danger: #e53935;
  --db-radius: 12px;
  --db-font-display: Georgia, "Times New Roman", serif;
  --db-font-ui: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

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

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--db-bg);
  color: var(--db-text);
  font-family: var(--db-font-ui);
}

body {
  background-image: radial-gradient(ellipse 90% 55% at 50% -15%, rgba(201, 169, 98, 0.08), transparent 60%);
}

.hidden {
  display: none !important;
}

.help-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.help-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--db-border-gold);
  background: rgba(10, 10, 10, 0.85);
  backdrop-filter: blur(8px);
}

.help-brand {
  font-family: var(--db-font-display);
  font-size: 1.15rem;
  color: var(--db-gold-light);
  text-decoration: none;
}

.help-brand span {
  display: block;
  font-size: 0.68rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--db-gold);
  margin-top: 0.15rem;
  font-family: var(--db-font-ui);
}

.help-top a.portal {
  color: var(--db-text-muted);
  text-decoration: none;
  font-size: 0.9rem;
}

.help-top a.portal:hover {
  color: var(--db-gold-light);
}

.help-main {
  flex: 1;
  display: flex;
  flex-direction: column;
}

/* Landing */
.help-landing {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem 1rem;
}

.help-card {
  width: min(520px, 100%);
  background: var(--db-surface);
  border: 1px solid var(--db-border-gold);
  border-radius: var(--db-radius);
  padding: 1.75rem 1.5rem;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.45);
}

.help-card h1 {
  margin: 0 0 0.5rem;
  font-family: var(--db-font-display);
  font-weight: 400;
  font-size: 1.75rem;
  color: var(--db-gold-light);
}

.help-card .lead {
  margin: 0 0 1.5rem;
  color: var(--db-text-muted);
  line-height: 1.5;
  font-size: 0.95rem;
}

.help-actions {
  display: grid;
  gap: 0.75rem;
}

.btn {
  appearance: none;
  border: 1px solid var(--db-border-gold);
  background: var(--db-gold-dim);
  color: var(--db-gold-light);
  border-radius: 8px;
  padding: 0.85rem 1rem;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
}

.btn:hover {
  background: rgba(201, 169, 98, 0.28);
  color: var(--db-text);
}

.btn--ghost {
  background: transparent;
  border-color: var(--db-border);
  color: var(--db-text-muted);
}

.btn--ghost:hover {
  border-color: var(--db-gold);
  color: var(--db-gold-light);
}

.btn--danger {
  border-color: rgba(229, 57, 53, 0.5);
  background: rgba(229, 57, 53, 0.12);
  color: #ff8a80;
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.help-form {
  display: grid;
  gap: 0.75rem;
  margin-top: 0.5rem;
}

.help-form label {
  display: grid;
  gap: 0.35rem;
  font-size: 0.85rem;
  color: var(--db-gold);
}

.help-form input {
  background: var(--db-surface-2);
  border: 1px solid var(--db-border-gold);
  border-radius: 8px;
  color: var(--db-text);
  padding: 0.7rem 0.8rem;
  font-size: 1rem;
}

.help-form input:focus {
  outline: none;
  box-shadow: 0 0 0 2px rgba(201, 169, 98, 0.25);
}

.help-error {
  color: #ff8a80;
  font-size: 0.88rem;
  margin: 0;
}

.help-hint {
  margin: 1rem 0 0;
  font-size: 0.8rem;
  color: var(--db-text-muted);
  line-height: 1.45;
}

/* Session layout */
.help-session {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(280px, 340px) 1fr;
  min-height: 0;
}

.help-chat {
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--db-border);
  background: var(--db-surface);
  min-height: 0;
}

.help-chat__head {
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--db-border);
}

.help-chat__head h2 {
  margin: 0;
  font-size: 0.95rem;
  color: var(--db-gold-light);
  font-weight: 600;
}

.help-chat__meta {
  margin: 0.35rem 0 0;
  font-size: 0.78rem;
  color: var(--db-text-muted);
}

.help-presence {
  margin: 0.4rem 0 0.55rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--db-gold-light);
}

.help-presence.is-waiting {
  color: #e0b84a;
}

.help-presence.is-ready {
  color: #8fd694;
}

.help-code-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
  margin-top: 0.35rem;
}

.help-code-display {
  font-family: ui-monospace, monospace;
  letter-spacing: 0.12em;
  color: var(--db-gold);
  font-size: 1.1rem;
}

.btn--sm {
  padding: 0.35rem 0.65rem !important;
  font-size: 0.8rem !important;
}

.help-stage__video-wrap:fullscreen,
.help-stage__video-wrap:-webkit-full-screen {
  background: #000;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.help-stage__video-wrap:fullscreen #remote-screen,
.help-stage__video-wrap:-webkit-full-screen #remote-screen {
  max-height: 100vh;
  border: none;
  border-radius: 0;
}

.help-messages {
  flex: 1;
  overflow: auto;
  padding: 0.85rem;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.help-msg {
  background: var(--db-surface-2);
  border: 1px solid var(--db-border);
  border-radius: 8px;
  padding: 0.55rem 0.65rem;
}

.help-msg__who {
  font-size: 0.72rem;
  color: var(--db-gold);
  margin-bottom: 0.2rem;
}

.help-msg__body {
  font-size: 0.9rem;
  line-height: 1.4;
  white-space: pre-wrap;
  word-break: break-word;
}

.help-msg__file a {
  color: var(--db-gold-light);
  font-size: 0.85rem;
}

.help-chat__compose {
  border-top: 1px solid var(--db-border);
  padding: 0.75rem;
  display: grid;
  gap: 0.5rem;
}

.help-chat__compose textarea {
  width: 100%;
  min-height: 4rem;
  resize: vertical;
  background: var(--db-surface-2);
  border: 1px solid var(--db-border-gold);
  border-radius: 8px;
  color: var(--db-text);
  padding: 0.55rem 0.65rem;
  font: inherit;
}

.help-chat__row {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.help-stage {
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: #0d0d0d;
}

.help-stage__toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  padding: 0.65rem 0.85rem;
  border-bottom: 1px solid var(--db-border);
  background: var(--db-surface);
}

.help-stage__status {
  margin-left: auto;
  font-size: 0.8rem;
  color: var(--db-text-muted);
}

.help-stage__video-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 280px;
  padding: 0.75rem;
  position: relative;
}

#remote-screen {
  max-width: 100%;
  max-height: calc(100vh - 9rem);
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #000;
  border-radius: 8px;
  border: 1px solid var(--db-border);
}

.help-stage__placeholder.hidden {
  display: none !important;
}

.help-stage__placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 2rem;
  color: var(--db-text-muted);
  pointer-events: none;
  line-height: 1.5;
}

.help-stage__placeholder strong {
  display: block;
  margin-bottom: 0.5rem;
  font-size: 1.15rem;
  color: var(--db-gold-light);
  font-weight: 600;
}

.help-stage__placeholder span {
  font-size: 0.9rem;
  max-width: 28rem;
}

#remote-screen.hidden {
  display: none !important;
}

@media (max-width: 860px) {
  .help-session {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(240px, 42vh) 1fr;
  }

  .help-chat {
    border-right: none;
    border-bottom: 1px solid var(--db-border);
    order: 2;
  }

  .help-stage {
    order: 1;
  }
}
