/* ── Ensure hidden attribute works ── */
[hidden] { display: none !important; }

/* ── Reset & Base ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { height: 100%; }

body {
  background: var(--black);
  color: var(--light-gray);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.7;
  min-height: 100%;
  -webkit-text-size-adjust: 100%;
}

a { color: var(--gold); text-decoration: none; transition: color var(--transition); }
a:hover { color: var(--gold-light); }

/* ── Top Bar ── */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1.5rem;
  background: var(--dark);
  border-bottom: 1px solid var(--dark-light);
  /* Safe area for notch/Dynamic Island */
  padding-top: max(0.75rem, env(safe-area-inset-top));
  padding-left: max(1.5rem, env(safe-area-inset-left));
  padding-right: max(1.5rem, env(safe-area-inset-right));
}

.topbar-brand {
  font-size: 1.1rem;
  font-weight: 300;
  color: var(--white);
  letter-spacing: 0.05em;
}

.topbar-brand strong {
  font-weight: 700;
  color: var(--gold);
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.topbar-name {
  font-size: 0.85rem;
  color: var(--light-gray);
}

.role-badge {
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 0.15rem 0.5rem;
  border-radius: 3px;
  background: var(--gold-dark);
  color: var(--white);
}

#logout-btn {
  padding: 0.35rem 0.75rem;
  background: transparent;
  border: 1px solid var(--gray-dark);
  border-radius: var(--radius);
  color: var(--gray);
  font-family: var(--font-sans);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
  transition: all var(--transition);
  min-height: 44px; /* touch-friendly */
}

#logout-btn:hover {
  border-color: var(--gray);
  color: var(--light-gray);
}

/* ── Dashboard Layout ── */
.dashboard {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 1.25rem;
  padding: 1.25rem;
  max-width: 1200px;
  margin: 0 auto;
  /* Safe area for sides */
  padding-left: max(1.25rem, env(safe-area-inset-left));
  padding-right: max(1.25rem, env(safe-area-inset-right));
}

@media (max-width: 800px) {
  .topbar {
    padding: 0.6rem 1rem;
    padding-top: max(0.6rem, env(safe-area-inset-top));
  }
  .topbar-name { display: none; }

  .dashboard {
    grid-template-columns: 1fr;
    gap: 1rem;
    padding: 1rem;
    padding-left: max(1rem, env(safe-area-inset-left));
    padding-right: max(1rem, env(safe-area-inset-right));
  }

  /* On mobile, show sidebar (audio/rolodex) first, sessions below */
  .sidebar { order: -1; }
}

/* ── Panels ── */
.panel {
  background: var(--dark);
  border: 1px solid var(--dark-light);
  border-radius: var(--radius);
  padding: 1.25rem;
}

.panel h2 {
  font-size: 0.85rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--gray);
  margin-bottom: 1rem;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}

.panel-header h2 {
  margin-bottom: 0;
}

.panel-actions {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.sub-heading {
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--gray);
  margin: 1rem 0 0.5rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--dark-light);
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

/* ── Item List ── */
.item-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-height: 480px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.item-list::-webkit-scrollbar { width: 4px; }
.item-list::-webkit-scrollbar-track { background: transparent; }
.item-list::-webkit-scrollbar-thumb { background: var(--gray-dark); border-radius: 2px; }
.item-list::-webkit-scrollbar-thumb:hover { background: var(--gray); }

/* Sessions panel gets more height since it's the main content */
.sessions-panel .item-list {
  max-height: 600px;
}

.empty-state {
  font-size: 0.85rem;
  color: var(--gray-dark);
  text-align: center;
  padding: 1.5rem 0;
}

/* ── Session Card ── */
.session-card {
  background: var(--dark-mid);
  border: 1px solid var(--dark-light);
  border-radius: var(--radius);
  padding: 0.85rem 1rem;
  transition: border-color var(--transition);
}

.session-card:hover {
  border-color: var(--gray-dark);
}

.session-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.35rem;
}

.session-title {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--white);
}

.session-meta {
  font-size: 0.8rem;
  color: var(--gray);
}

.session-notes {
  font-size: 0.8rem;
  color: var(--gray);
  margin-top: 0.35rem;
  font-style: italic;
}

.session-actions {
  display: flex;
  gap: 0.4rem;
  margin-top: 0.6rem;
  flex-wrap: wrap;
}

/* ── Status Badge ── */
.status-badge {
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 0.15rem 0.45rem;
  border-radius: 3px;
}

.status-requested { background: rgba(201, 168, 76, 0.2); color: var(--gold); }
.status-confirmed { background: rgba(46, 204, 113, 0.2); color: var(--success); }
.status-live { background: rgba(231, 76, 60, 0.2); color: var(--error); }
.status-completed { background: rgba(136, 136, 136, 0.2); color: var(--gray); }
.status-cancelled { background: rgba(136, 136, 136, 0.1); color: var(--gray-dark); }

.type-badge {
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 0.15rem 0.45rem;
  border-radius: 3px;
  background: var(--dark-light);
  color: var(--light-gray);
  margin-left: 0.35rem;
}

/* ── Network Item ── */
.network-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.6rem 0;
  border-bottom: 1px solid var(--dark-light);
}

.network-item:last-child { border-bottom: none; }
.network-name { font-size: 0.9rem; color: var(--white); }
.network-role {
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--gray);
}
.network-actions { display: flex; gap: 0.3rem; }

/* ── Rolodex ── */
.rolodex-search { margin-bottom: 0.75rem; }

.form-input-sm {
  padding: 0.55rem 0.75rem;
  font-size: 0.85rem;
  width: 100%;
  background: var(--dark);
  border: 1px solid var(--dark-light);
  border-radius: var(--radius);
  color: var(--white);
  font-family: var(--font-sans);
  min-height: 40px; /* touch-friendly */
}
.form-input-sm:focus { outline: none; border-color: var(--gold); }
.form-input-sm::placeholder { color: var(--gray-dark); }

.form-select-sm {
  padding: 0.45rem 0.6rem;
  font-size: 0.8rem;
  width: 100%;
  background: var(--dark);
  border: 1px solid var(--dark-light);
  border-radius: var(--radius);
  color: var(--white);
  font-family: var(--font-sans);
  min-height: 44px; /* touch-friendly */
}

.add-contact-inline {
  padding: 0.75rem;
  margin-bottom: 0.75rem;
  background: var(--dark-mid);
  border: 1px solid var(--dark-light);
  border-radius: var(--radius);
}
.add-contact-form { display: flex; flex-direction: column; gap: 0.5rem; }
.add-contact-actions { display: flex; gap: 0.4rem; }

.rolodex-section-label {
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--gray);
  padding: 0.5rem 0 0.35rem;
}

.rolodex-list {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  max-height: 420px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.rolodex-list::-webkit-scrollbar { width: 4px; }
.rolodex-list::-webkit-scrollbar-track { background: transparent; }
.rolodex-list::-webkit-scrollbar-thumb { background: var(--gray-dark); border-radius: 2px; }

.contact-card {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.65rem 0.75rem;
  background: var(--dark-mid);
  border: 1px solid var(--dark-light);
  border-radius: var(--radius);
  transition: border-color var(--transition);
  min-height: 52px; /* touch-friendly */
}
.contact-card:hover { border-color: var(--gray-dark); }
.contact-card.contact-offline { opacity: 0.55; }
.contact-card.contact-invited { opacity: 0.6; }
.contact-card.contact-invited .contact-name { color: var(--gray); }

.contact-avatar {
  position: relative;
  width: 36px;
  height: 36px;
  min-width: 36px;
  border-radius: 50%;
  background: var(--dark-light);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--gold);
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.contact-online-dot {
  position: absolute;
  bottom: 0;
  right: 0;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--success);
  border: 2px solid var(--dark-mid);
}

.contact-info { flex: 1; min-width: 0; }
.contact-name {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--white);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.contact-role-badge {
  display: inline-block;
  font-size: 0.6rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 0.1rem 0.35rem;
  border-radius: 3px;
  background: var(--dark-light);
  color: var(--gray);
  margin-top: 0.1rem;
}

.contact-actions { display: flex; gap: 0.3rem; flex-shrink: 0; }

.btn-start-session {
  padding: 0.3rem 0.6rem;
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  background: rgba(46, 204, 113, 0.15);
  color: var(--success);
  border: 1px solid rgba(46, 204, 113, 0.25);
  border-radius: var(--radius);
  cursor: pointer;
  transition: all var(--transition);
  min-height: 44px; /* touch-friendly */
}
.btn-start-session:hover { background: rgba(46, 204, 113, 0.25); }

.pending-invite-card {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.65rem 0.75rem;
  background: rgba(201, 168, 76, 0.08);
  border: 1px solid var(--gold-dark);
  border-radius: var(--radius);
  min-height: 52px;
}
.pending-invite-card .contact-avatar { background: rgba(201, 168, 76, 0.2); color: var(--gold-light); }
.pending-invite-card .contact-name { color: var(--gold-light); }

/* Live session contact */
.contact-card.contact-live {
  border-color: var(--success);
  background: rgba(46, 204, 113, 0.08);
  opacity: 1;
}
.contact-card.contact-live .contact-role-badge {
  background: rgba(46, 204, 113, 0.2);
  color: var(--success);
}

.contact-rtt {
  font-size: 0.7rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.03em;
  color: var(--gray);
}
.contact-rtt.rtt-good { color: var(--success); }
.contact-rtt.rtt-ok { color: var(--gold); }
.contact-rtt.rtt-bad { color: var(--error); }

/* ── Account Details ── */
.account-details { margin-top: 0.5rem; }

.info-row {
  display: flex;
  justify-content: space-between;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--dark-light);
  font-size: 0.85rem;
}
.info-row:last-child { border-bottom: none; }

.info-label {
  color: var(--gray);
  text-transform: uppercase;
  font-size: 0.7rem;
  letter-spacing: 0.1em;
}

/* ── Buttons ── */
.btn {
  padding: 0.45rem 0.85rem;
  font-family: var(--font-sans);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  transition: all var(--transition);
  min-height: 44px; /* touch-friendly */
  touch-action: manipulation; /* prevent double-tap zoom */
}

.btn-gold { background: var(--gold); color: var(--black); }
.btn-gold:hover { background: var(--gold-light); }

.btn-outline {
  background: transparent;
  border: 1px solid var(--gray-dark);
  color: var(--light-gray);
}
.btn-outline:hover {
  border-color: var(--gold);
  color: var(--gold);
}

.btn-sm {
  padding: 0.3rem 0.6rem;
  font-size: 0.65rem;
  min-height: 44px;
}

.btn-success { background: rgba(46, 204, 113, 0.2); color: var(--success); border: 1px solid rgba(46, 204, 113, 0.3); }
.btn-success:hover { background: rgba(46, 204, 113, 0.3); }

.btn-danger { background: rgba(231, 76, 60, 0.15); color: var(--error); border: 1px solid rgba(231, 76, 60, 0.2); }
.btn-danger:hover { background: rgba(231, 76, 60, 0.25); }

.btn-full { width: 100%; padding: 0.75rem; margin-top: 0.5rem; min-height: 44px; }

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

/* ── Filter Select ── */
.filter-select,
.form-select {
  padding: 0.45rem 0.7rem;
  background: var(--dark-mid);
  border: 1px solid var(--gray-dark);
  border-radius: var(--radius);
  color: var(--light-gray);
  font-family: var(--font-sans);
  font-size: 0.8rem;
  cursor: pointer;
  min-height: 44px; /* touch-friendly */
}

.filter-select:focus,
.form-select:focus {
  outline: none;
  border-color: var(--gold);
}

/* ── Form Inputs (modal) ── */
.form-input,
.form-textarea {
  width: 100%;
  padding: 0.65rem 0.85rem;
  background: var(--dark-mid);
  border: 1px solid var(--gray-dark);
  border-radius: var(--radius);
  color: var(--white);
  font-family: var(--font-sans);
  font-size: 16px; /* prevent iOS zoom on focus */
  transition: border-color var(--transition);
  min-height: 44px;
}

.form-input:focus,
.form-textarea:focus {
  outline: none;
  border-color: var(--gold);
}

.form-textarea { resize: vertical; }

.form-group { margin-bottom: 1rem; }

.form-group label {
  display: block;
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--gray);
  margin-bottom: 0.3rem;
}

.form-group label.checkbox-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  text-transform: none;
  font-size: 0.8rem;
}

.form-group label.checkbox-label input[type="checkbox"] {
  accent-color: var(--accent);
  width: 1rem;
  height: 1rem;
}

/* ── Modal ── */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 1rem;
  padding-top: max(1rem, env(safe-area-inset-top));
  padding-bottom: max(1rem, env(safe-area-inset-bottom));
}

.modal-content {
  background: var(--dark);
  border: 1px solid var(--dark-light);
  border-radius: 12px;
  box-shadow: var(--shadow);
  width: 100%;
  max-width: 440px;
  max-height: 90vh;
  overflow-y: auto;
  padding: 1.75rem 1.5rem;
  -webkit-overflow-scrolling: touch;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
}

.modal-header h2 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--white);
  letter-spacing: 0.05em;
}

.modal-close {
  background: none;
  border: none;
  color: var(--gray);
  font-size: 1.5rem;
  cursor: pointer;
  line-height: 1;
  transition: color var(--transition);
  min-width: 44px;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.modal-close:hover { color: var(--white); }

/* ── Message ── */
.message {
  text-align: center;
  font-size: 0.85rem;
  padding: 0.65rem;
  border-radius: var(--radius);
  margin-top: 0.75rem;
}

.message.error { background: rgba(231, 76, 60, 0.15); color: var(--error); }
.message.success { background: rgba(46, 204, 113, 0.15); color: var(--success); }

/* ── Invite Notification ── */
.invite-notification {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.85rem 1.25rem;
  background: rgba(201, 168, 76, 0.1);
  border: 1px solid var(--gold-dark);
  border-radius: var(--radius);
  font-size: 0.9rem;
  color: var(--gold-light);
  gap: 0.75rem;
}

.invite-notification-actions {
  display: flex;
  gap: 0.4rem;
  flex-shrink: 0;
}

@media (max-width: 500px) {
  .invite-notification {
    flex-direction: column;
    text-align: center;
    gap: 0.5rem;
  }
}

/* ── Agent Panel ── */
.form-row {
  display: flex;
  gap: 0.5rem;
}

.form-half { flex: 1; }

.live-status {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.6rem 0;
}

.live-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--error);
  animation: pulse 1.5s infinite;
  flex-shrink: 0;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

.rtt-value {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--white);
}

.rtt-good { color: var(--success); }
.rtt-ok { color: var(--gold); }
.rtt-bad { color: var(--error); }

.network-info {
  margin-bottom: 0.75rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--dark-light);
}

.network-info .info-row {
  padding: 0.3rem 0;
  border-bottom: none;
}

.net-ip {
  font-size: 0.75rem;
  font-family: 'SF Mono', 'Menlo', monospace;
  color: var(--light-gray);
  word-break: break-all;
}

.net-ip.available { color: var(--success); }
.net-ip.unavailable { color: var(--gray-dark); }

.net-method { font-size: 0.8rem; font-weight: 600; }
.net-direct-v6 { color: var(--success); }
.net-direct-v4 { color: var(--gold); }
.net-turn { color: var(--error); }
.net-unknown { color: var(--gray); }

/* Connection quality badges */
.conn-badge-pill {
  font-size: 0.6rem; font-weight: 700; padding: 1px 5px;
  border-radius: 3px; text-transform: uppercase; margin-left: 0.4rem;
  letter-spacing: 0.03em; vertical-align: middle;
}
.turn-badge { background: rgba(255, 149, 0, 0.15); color: var(--gold); }
.fec-badge { background: rgba(0, 122, 255, 0.15); color: var(--accent); }

.quality-dot {
  width: 8px; height: 8px; border-radius: 50%;
  display: inline-block; vertical-align: middle; margin-right: 0.3rem;
}
.quality-green { background: var(--success); }
.quality-yellow { background: var(--gold); }
.quality-red { background: var(--error); }

/* ── Pro Audio Level Meters (TotalMix-style) ── */
/* ── Pro Meters — horizontal TotalMix-style ── */
.pro-meters { margin: 0.5rem 0 0.25rem; }
.pm-scale-row {
  display: flex; align-items: flex-end; height: 16px;
  margin-bottom: 1px;
}
.pm-scale-pad { width: 56px; flex-shrink: 0; }
.pm-scale-pad-r { width: 48px; flex-shrink: 0; }
.pm-scale-canvas {
  flex: 1; display: block; height: 16px;
  /* Canvas has an intrinsic `width` attribute set by meters.js; without
     min-width:0 the flex item inherits that as its minimum, which blows
     out the parent grid track on narrow viewports. */
  min-width: 0; max-width: 100%;
}
.pm-group { }
.pm-group-divider {
  height: 1px; background: var(--dark-light); margin: 4px 0 3px;
}
.pm-row {
  display: flex; align-items: center; gap: 0; height: 20px;
  margin-bottom: 1px;
}
.pm-label {
  width: 26px; flex-shrink: 0; text-align: right; padding-right: 5px;
  font-size: 0.55rem; font-weight: 700; letter-spacing: 0.06em;
  text-transform: uppercase; color: var(--gray);
  font-family: "SF Mono", Menlo, Consolas, monospace;
}
.pm-label-peer { color: var(--gold-dark); }
.pm-ovr {
  width: 26px; flex-shrink: 0; text-align: center;
  font-size: 0.5rem; font-weight: 800; letter-spacing: 0.04em;
  color: var(--gray-dark); background: var(--dark-mid); border-radius: 2px;
  line-height: 16px; height: 16px; cursor: pointer;
  -webkit-tap-highlight-color: transparent; touch-action: manipulation;
  transition: background 0.1s, color 0.1s;
  margin-right: 4px;
  font-family: "SF Mono", Menlo, Consolas, monospace;
}
.pm-ovr.lit { color: var(--white); background: var(--error); }
.pm-bar-canvas {
  flex: 1; display: block; height: 18px;
  image-rendering: pixelated;
  /* Same reason as .pm-scale-canvas — prevent intrinsic canvas width from
     establishing the flex-item minimum and blowing out the grid track. */
  min-width: 0; max-width: 100%;
}
.pm-db {
  width: 44px; flex-shrink: 0; text-align: right; padding-left: 5px;
  font-size: 0.6rem; font-weight: 600; font-variant-numeric: tabular-nums;
  color: var(--gray); white-space: nowrap;
  font-family: "SF Mono", Menlo, Consolas, monospace;
}
.pm-ref-row {
  display: flex; justify-content: flex-end; gap: 0;
  height: 12px; margin-bottom: 2px;
}
.pm-ref-pad { flex: 1; }
.pm-ref {
  width: 44px; flex-shrink: 0; text-align: right; padding-left: 5px;
  font-size: 0.45rem; font-variant-numeric: tabular-nums;
  color: var(--gray-dark); white-space: nowrap;
  font-family: "SF Mono", Menlo, Consolas, monospace;
}
.pm-toolbar {
  display: flex; align-items: center; gap: 6px;
  margin-top: 4px;
}
.pm-btn {
  padding: 2px 8px; min-height: 32px;
  font-family: "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.55rem; font-weight: 700; letter-spacing: 0.04em;
  background: var(--dark-mid); border: 1px solid var(--gray-dark); border-radius: 3px;
  color: var(--gray); cursor: pointer;
  -webkit-tap-highlight-color: transparent; touch-action: manipulation;
  transition: all 0.12s;
}
.pm-btn.active { color: var(--gold); border-color: #5a4a20; background: rgba(201,168,76,0.1); }
.pm-sel {
  padding: 2px 6px; min-height: 32px;
  font-family: "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.55rem; font-weight: 600;
  background: var(--dark-mid); border: 1px solid var(--gray-dark); border-radius: 3px;
  color: var(--gray); cursor: pointer;
}

/* ── Profile ── */
.profile-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.password-section { margin-top: 0.5rem; }

.form-static {
  font-size: 0.85rem;
  color: var(--gray);
  padding: 0.4rem 0;
}

/* ── Focus Styles ── */
.btn:focus-visible,
.btn-start-session:focus-visible,
.modal-close:focus-visible,
.filter-select:focus-visible,
.form-select:focus-visible,
.device-toggle:focus-visible,
#logout-btn:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}

.form-input:focus-visible,
.form-textarea:focus-visible,
.form-input-sm:focus-visible,
.form-select-sm:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: -1px;
}

/* ── Safe area bottom padding ── */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
  body { padding-bottom: env(safe-area-inset-bottom); }
}

/* ══════════════════════════════════════════════════════════════════════════
   ROLE-BASED ADAPTIVE UI
   Body gets class "role-{role}" and optionally "platform-ios"
   ══════════════════════════════════════════════════════════════════════════ */

/* ── Artist View ──
   Simplified focus: accept invites, see live status, audio running.
   Device routing available via collapsible disclosure toggle. */

.role-artist #new-session-btn { display: none; }
.role-artist #edit-profile-btn { display: none; }
.role-artist .password-section { display: none; }
.role-artist #agent-not-found a[href*="downloads"] { display: none; }

/* Device section: collapsed by default for artist */
.role-artist #agent-devices {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.35s ease, opacity 0.25s ease, margin 0.35s ease;
  opacity: 0;
  margin-top: 0;
}

.role-artist #agent-devices.expanded {
  max-height: 500px;
  opacity: 1;
  margin-top: 0.75rem;
}

/* The toggle button — styled as a subtle disclosure link */
.device-toggle {
  display: none; /* only shown for artists */
}

.role-artist .device-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.5rem 0;
  margin-top: 0.5rem;
  border: none;
  background: none;
  color: var(--gray);
  font-family: var(--font-sans);
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  cursor: pointer;
  transition: color var(--transition);
  width: 100%;
  min-height: 44px;
  touch-action: manipulation;
}

.role-artist .device-toggle:hover {
  color: var(--gold);
}

.device-toggle-arrow {
  display: inline-block;
  transition: transform 0.3s ease;
  font-size: 0.6rem;
}

.device-toggle.open .device-toggle-arrow {
  transform: rotate(180deg);
}

/* On mobile, artist gets a cleaner single-panel feel */
@media (max-width: 800px) {
  .role-artist .sessions-panel { display: none; }
  .role-artist .account-panel { display: none; }

  .role-artist .agent-panel {
    border-color: var(--gold-dark);
    border-width: 1px;
  }
}

/* ── Producer View ──
   Session management + booking focus. No device routing (producers monitor, not record). */

.role-producer #agent-devices { display: none; }
.role-producer #agent-network { display: none; }

/* ── Studio View ──
   Full control surface — this is the default, everything visible. */

/* Studio gets a subtle highlight on the audio panel to emphasize it */
.role-studio .agent-panel {
  border-color: var(--dark-light);
}

/* ══════════════════════════════════════════════════════════════════════════
   AUv3 EFFECTS CHAIN — touch-friendly plugin list
   ══════════════════════════════════════════════════════════════════════════ */

.au-plugin-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--dark-light);
  min-height: 48px;
  gap: 0.5rem;
}
.au-plugin-row:last-child { border-bottom: none; }

.au-plugin-info {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex: 1;
  min-width: 0;
}

.au-plugin-chain {
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  color: var(--dark);
  background: var(--gold-dark);
  padding: 0.15rem 0.35rem;
  border-radius: 3px;
  flex-shrink: 0;
}

.au-plugin-name {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--gold);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.au-plugin-bypassed .au-plugin-name {
  color: var(--text-muted);
  text-decoration: line-through;
}
.au-plugin-bypassed .au-plugin-chain {
  opacity: 0.4;
}

.au-plugin-actions {
  display: flex;
  gap: 0.35rem;
  flex-shrink: 0;
}

.au-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  min-height: 44px;
  padding: 0.4rem;
  border: 1px solid var(--dark-light);
  border-radius: 6px;
  background: var(--dark);
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.75rem;
  font-weight: 600;
  transition: all 0.15s ease;
  -webkit-tap-highlight-color: transparent;
}
.au-btn:active {
  transform: scale(0.92);
  background: var(--dark-light);
}

.au-btn-bypass {
  min-width: 48px;
  font-weight: 700;
  letter-spacing: 0.03em;
}
.au-btn-on {
  color: var(--success);
  border-color: var(--success);
  background: rgba(46, 204, 113, 0.08);
}
.au-btn-off {
  color: var(--error);
  border-color: var(--error);
  background: rgba(231, 76, 60, 0.08);
}

.au-btn-params {
  color: var(--gold);
  border-color: var(--gold-dark);
}
.au-btn-params:active {
  background: rgba(201, 168, 76, 0.15);
}

.au-btn-remove {
  color: var(--error);
  border-color: transparent;
  background: none;
}
.au-btn-remove:active {
  background: rgba(231, 76, 60, 0.15);
}

/* ── Platform: iOS ──
   Hide desktop-only elements, adjust for native bridge. */

.platform-ios #agent-not-found { display: none !important; }  /* no download prompt */
.platform-ios #agent-log-toggle { display: none; }  /* logs via native, not web */

/* ── iPad Landscape ──
   Wider sidebar, more breathing room, optimized for two-column layout.
   iPad landscape is ≥1024px wide — gets the desktop two-column grid. */

@media (min-width: 1024px) and (min-height: 600px) {
  .dashboard {
    grid-template-columns: 1fr 380px;
    gap: 1.5rem;
    padding: 1.5rem 2rem;
  }

  .panel { padding: 1.5rem; }
  .sessions-panel .item-list { max-height: 70vh; }
  .rolodex-list { max-height: 50vh; }
}

/* iPad portrait (768-1023px) — single column but wider panels */
@media (min-width: 768px) and (max-width: 1023px) {
  .dashboard {
    grid-template-columns: 1fr;
    max-width: 680px;
    gap: 1.25rem;
  }
  /* Show sidebar first (audio panel) */
  .sidebar { order: -1; }
}

/* Pointer devices (Magic Keyboard, trackpad) — hover states */
@media (pointer: fine) {
  .contact-card:hover { border-color: var(--gold-dark); }
  .session-card:hover { border-color: var(--gold-dark); }
  .btn:hover { transform: translateY(-1px); }
}

/* ── Share Invite ── */
.share-invite {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.75rem;
  padding: 0.6rem 0.75rem;
  background: var(--dark-mid);
  border: 1px solid var(--dark-light);
  border-radius: var(--radius);
}

.share-invite-label {
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--gray);
  white-space: nowrap;
}

.share-invite-btn {
  padding: 0.35rem 0.7rem;
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  border-radius: var(--radius);
  cursor: pointer;
  min-height: 44px;
  touch-action: manipulation;
  white-space: nowrap;
  transition: all var(--transition);
}

.share-invite-btn-accent {
  background: var(--gold);
  color: var(--black);
  border: none;
}
.share-invite-btn-accent:hover { background: var(--gold-light); }

.share-invite-btn-outline {
  background: transparent;
  border: 1px solid var(--gray-dark);
  color: var(--light-gray);
}
.share-invite-btn-outline:hover {
  border-color: var(--gold);
  color: var(--gold);
}

.share-invite-copied {
  color: var(--success) !important;
  border-color: var(--success) !important;
}

@media (prefers-reduced-motion: reduce) {
  .live-dot { animation: none; opacity: 1; }
}
