@import url('/css/core/_variables.css');
@import url('/css/core/_gradients.css');
@import url('/css/core/_animations.css');
@import url('/css/core/_utilities.css');
@import url('/css/components/_navigation.css');

:root {
  --nav-shell-height: clamp(4.9rem, calc(4rem + 2.4vh), 5.75rem);
  --port-page-top-gap: clamp(0.75rem, 1.2vw, 1.15rem);
  --port-page-top-clearance: calc(var(--nav-shell-height) + var(--port-page-top-gap) + env(safe-area-inset-top, 0px));
}

/* ============================================================================
   Port Page — Local Crew Captain dashboard
   ============================================================================ */

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

html,
body {
  margin: 0;
  min-height: 100%;
  overflow-x: hidden;
}

[hidden] {
  display: none !important;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg-dark);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

/* Space background wash */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse at 20% 15%, oklch(75% 0.18 195 / 0.05), transparent 50%),
    radial-gradient(ellipse at 80% 80%, oklch(65% 0.25 295 / 0.04), transparent 55%);
  pointer-events: none;
  z-index: -1;
}

html[data-theme='light'] body::before {
  background:
    radial-gradient(ellipse at 20% 15%, oklch(75% 0.18 195 / 0.08), transparent 50%),
    radial-gradient(ellipse at 80% 80%, oklch(65% 0.25 295 / 0.06), transparent 55%);
}

/* ============================================================================
   Nav overrides — Port is current page
   ============================================================================ */

.nav-links a[aria-current='page'] {
  font-weight: 600;
  color: transparent;
  -webkit-text-fill-color: transparent;
  background-position: 0 50%;
}

.nav-links a[aria-current='page']::after {
  opacity: 1;
  transform: scaleX(1);
}

.port-status-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.35rem 0.8rem;
  min-height: 2.5rem;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  border-radius: 999px;
  background: oklch(55% 0.18 75 / 0.12);
  color: oklch(78% 0.18 75);
  border: 1px solid oklch(55% 0.18 75 / 0.28);
  white-space: nowrap;
  flex-shrink: 0;
}

.signout-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2.75rem;
  height: 2.75rem;
  padding: 0;
  background: rgba(15, 23, 42, 0.38);
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text-muted);
  cursor: pointer;
  transition: border-color 0.15s ease, color 0.15s ease, background 0.15s ease;
  flex-shrink: 0;
}

.signout-btn:hover {
  border-color: oklch(68% 0.22 25 / 0.5);
  color: oklch(68% 0.22 25);
  background: oklch(68% 0.22 25 / 0.08);
}

.signout-btn svg {
  width: 16px;
  height: 16px;
}

html[data-theme='light'] .signout-btn {
  background: rgba(255, 255, 255, 0.72);
}

/* ============================================================================
   Main layout
   ============================================================================ */

.port-main {
  flex: 1;
  padding-top: var(--port-page-top-clearance);
  padding-bottom: clamp(2rem, 4vw, 4rem);
}

.port-section {
  width: 100%;
}

/* ============================================================================
   Loading state
   ============================================================================ */

.port-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  min-height: calc(100dvh - var(--port-page-top-clearance) - clamp(2rem, 4vw, 4rem));
  color: var(--text-muted);
}

.port-loading p {
  margin: 0;
  font-size: 0.9rem;
}

.loading-spinner {
  width: 36px;
  height: 36px;
}

.spinner-ring {
  width: 36px;
  height: 36px;
  border: 2px solid var(--border);
  border-top-color: var(--accent-cyan);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ============================================================================
   Onboarding panel
   ============================================================================ */

.onboarding-panel {
  max-width: 480px;
  margin: 0 auto;
  padding: clamp(3rem, 6vw, 5rem) var(--container-padding) clamp(2rem, 4vw, 3rem);
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.port-section-title {
  font-size: clamp(1.6rem, 4vw, 2.25rem);
  font-weight: 700;
  margin: 0;
  background: var(--prism-gradient-118);
  background-clip: text;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  text-shadow: none;
  line-height: 1.2;
}

.port-section-subtitle {
  margin: 0;
  color: var(--text-secondary);
  font-size: 1rem;
}

.username-form {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.username-field {
  display: flex;
  align-items: center;
  background: rgba(26, 31, 38, 0.6);
  border: 1px solid var(--border);
  border-radius: 0.6rem;
  overflow: hidden;
  transition: border-color 0.15s ease;
}

.username-field:focus-within {
  border-color: oklch(75% 0.18 195 / 0.6);
}

html[data-theme='light'] .username-field {
  background: rgba(255, 255, 255, 0.9);
  border-color: rgba(15, 23, 42, 0.15);
}

.username-at {
  padding: 0.75rem 0 0.75rem 0.9rem;
  color: var(--accent-cyan);
  font-weight: 700;
  font-size: 1rem;
  user-select: none;
}

.username-input {
  flex: 1;
  padding: 0.75rem 0.5rem;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 1rem;
  font-weight: 500;
}

.username-input::placeholder { color: var(--text-muted); }

.username-indicator {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-right: 0.5rem;
}

.username-indicator::after {
  content: '';
  display: block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.username-indicator[data-state='available']::after { background: oklch(72% 0.18 145); }
.username-indicator[data-state='taken']::after     { background: oklch(68% 0.22 25); }
.username-indicator[data-state='invalid']::after   { background: oklch(78% 0.18 85); }
.username-indicator[data-state='checking']::after  {
  background: var(--accent-cyan);
  animation: pulse 1s ease-in-out infinite;
}

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

.username-availability {
  margin: 0;
  font-size: 0.85rem;
  min-height: 1.3em;
}

.username-availability[data-tone='success'] { color: oklch(72% 0.18 145); }
.username-availability[data-tone='error']   { color: oklch(68% 0.22 25); }
.username-availability[data-tone='warning'] { color: oklch(78% 0.18 85); }
.username-availability[data-tone='info']    { color: var(--text-muted); }

/* Buttons */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.75rem 1.5rem;
  border-radius: 0.6rem;
  border: none;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  text-decoration: none;
  transition: opacity 0.15s ease, transform 0.12s ease, box-shadow 0.15s ease;
  white-space: nowrap;
}

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
}

.btn-primary {
  background: var(--primary);
  color: #0a0f1a;
  box-shadow: 0 2px 12px oklch(70% 0.22 145 / 0.3);
}

.btn-primary:not(:disabled):hover {
  opacity: 0.9;
  transform: translateY(-1px);
  box-shadow: 0 4px 18px oklch(70% 0.22 145 / 0.45);
}

.btn-primary:not(:disabled):active { transform: translateY(0); }

.btn-claim {
  width: 100%;
  background: var(--prism-gradient-118);
  background-size: var(--prism-size, 200% 100%);
  color: #0a0f1a;
  font-weight: 700;
}

html[data-theme='light'] .btn-claim { color: #0f172a; }

.btn-claim svg {
  width: 18px;
  height: 18px;
}

.btn-secondary {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  background: var(--light-subtle);
  border-color: oklch(75% 0.18 195 / 0.3);
  color: var(--text-primary);
}

.btn-sm {
  padding: 0.45rem 0.9rem;
  font-size: 0.85rem;
}

.onboarding-status {
  margin: 0;
  font-size: 0.88rem;
  text-align: center;
  min-height: 1.4em;
}

.onboarding-status[data-state='idle']    { display: none; }
.onboarding-status[data-tone='success']  { color: oklch(72% 0.18 145); }
.onboarding-status[data-tone='error']    { color: oklch(68% 0.22 25); }
.onboarding-status[data-tone='warning']  { color: oklch(78% 0.18 85); }
.onboarding-status[data-tone='info']     { color: var(--text-muted); }

.onboarding-signout {
  margin: 1.5rem 0 0;
  font-size: 0.82rem;
  color: var(--text-muted);
  text-align: center;
}

.btn-link {
  background: none;
  border: none;
  padding: 0;
  color: var(--text-muted);
  font-size: inherit;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.btn-link:hover {
  color: var(--text-primary);
}

/* ============================================================================
   Dashboard layout
   ============================================================================ */

.port-header {
  padding: clamp(0.45rem, 1vw, 0.8rem) 0 clamp(1rem, 2vw, 1.5rem);
  border-bottom: 1px solid var(--border);
  margin-bottom: clamp(1rem, 2vw, 1.5rem);
}

.port-header-shell {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.port-header-copy {
  display: grid;
  gap: 0.45rem;
  max-width: 46rem;
}

.port-header-actions {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.75rem;
  margin-left: auto;
}

.port-header-kicker {
  margin: 0;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent-cyan);
}

.port-header-summary {
  margin: 0;
  max-width: 46rem;
  font-size: 0.96rem;
  color: var(--text-secondary);
}

.port-title {
  font-size: clamp(1.75rem, 4vw, 2.5rem);
  font-weight: 700;
  margin: 0;
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.port-title-label {
  background: var(--prism-gradient-118);
  background-clip: text;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  text-shadow: none;
}

.captain-handle {
  color: var(--text-muted);
  font-weight: 500;
  font-size: 0.7em;
}

.dashboard-grid {
  display: grid;
  gap: 1rem;
  margin-bottom: 1rem;
}

@media (min-width: 900px) {
  .dashboard-grid {
    grid-template-columns: minmax(0, 0.92fr) minmax(0, 1.08fr);
  }
}

.dashboard-secondary {
  display: grid;
  gap: 1rem;
  align-items: start;
}

@media (min-width: 1080px) {
  .dashboard-secondary {
    grid-template-columns: minmax(0, 1.15fr) minmax(0, 0.85fr);
  }
}

/* ============================================================================
   Section labels
   ============================================================================ */

.section-label {
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin: 0 0 1rem;
}

/* ============================================================================
   Surface tone system
   ============================================================================ */

:is(.captain-card, .crew-section, .crew-hud, .crew-task-form-section, .crew-recent-tasks-section, .community-card) {
  position: relative;
  overflow: hidden;
  isolation: isolate;
}

:is(.captain-card, .crew-section, .crew-hud, .crew-task-form-section, .crew-recent-tasks-section, .community-card) > * {
  position: relative;
  z-index: 1;
}

:is(.captain-card, .crew-section, .crew-hud, .crew-task-form-section, .crew-recent-tasks-section, .community-card)::before {
  content: '';
  position: absolute;
  inset: 0 0 auto 0;
  height: 3px;
  background: var(--surface-accent, var(--prism-gradient-118));
  opacity: 0.92;
  z-index: 0;
}

:is(.captain-card, .crew-section, .crew-hud, .crew-task-form-section, .crew-recent-tasks-section, .community-card)::after {
  content: '';
  position: absolute;
  right: -4rem;
  bottom: -4rem;
  width: 12rem;
  height: 12rem;
  background: var(--surface-glow, radial-gradient(circle, oklch(75% 0.18 195 / 0.16) 0%, transparent 72%));
  filter: blur(12px);
  opacity: 0.45;
  pointer-events: none;
  z-index: 0;
}

.captain-card {
  --surface-accent: linear-gradient(90deg, oklch(80% 0.16 195), oklch(68% 0.22 245));
  --surface-glow: radial-gradient(circle, oklch(75% 0.18 195 / 0.18) 0%, transparent 72%);
}

.crew-section {
  --surface-accent: linear-gradient(90deg, oklch(82% 0.16 85), oklch(76% 0.18 195));
  --surface-glow: radial-gradient(circle, oklch(80% 0.18 85 / 0.18) 0%, transparent 72%);
}

.crew-hud {
  --surface-accent: linear-gradient(90deg, oklch(78% 0.18 195), oklch(72% 0.19 145));
  --surface-glow: radial-gradient(circle, oklch(72% 0.19 145 / 0.18) 0%, transparent 72%);
}

.crew-task-form-section {
  --surface-accent: linear-gradient(90deg, oklch(74% 0.19 25), oklch(74% 0.18 195));
  --surface-glow: radial-gradient(circle, oklch(74% 0.19 25 / 0.14) 0%, transparent 72%);
}

.crew-recent-tasks-section {
  --surface-accent: linear-gradient(90deg, oklch(72% 0.19 145), oklch(78% 0.18 195));
  --surface-glow: radial-gradient(circle, oklch(72% 0.19 145 / 0.16) 0%, transparent 72%);
}

.token-bank-card {
  --surface-accent: linear-gradient(90deg, oklch(83% 0.15 85), oklch(78% 0.17 145));
  --surface-glow: radial-gradient(circle, oklch(82% 0.16 85 / 0.16) 0%, transparent 72%);
}

.community-policy-card {
  --surface-accent: linear-gradient(90deg, oklch(80% 0.16 195), oklch(70% 0.2 235));
  --surface-glow: radial-gradient(circle, oklch(76% 0.18 195 / 0.16) 0%, transparent 72%);
}

.premium-admin-card {
  --surface-accent: linear-gradient(90deg, oklch(78% 0.18 85), oklch(72% 0.2 25));
  --surface-glow: radial-gradient(circle, oklch(78% 0.18 85 / 0.16) 0%, transparent 72%);
}

.log-composer-card {
  --surface-accent: linear-gradient(90deg, oklch(79% 0.16 165), oklch(78% 0.18 195));
  --surface-glow: radial-gradient(circle, oklch(76% 0.18 195 / 0.14) 0%, transparent 72%);
}

.log-feed-card {
  --surface-accent: linear-gradient(90deg, oklch(72% 0.19 145), oklch(78% 0.18 195));
  --surface-glow: radial-gradient(circle, oklch(72% 0.19 145 / 0.14) 0%, transparent 72%);
}

/* ============================================================================
   Captain card
   ============================================================================ */

.captain-card {
  background: rgba(26, 31, 38, 0.55);
  border: 1px solid var(--border);
  border-radius: 1rem;
  padding: 1.35rem;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  box-shadow: 0 16px 38px rgba(4, 10, 20, 0.14);
}

html[data-theme='light'] .captain-card {
  background: rgba(255, 255, 255, 0.88);
  border-color: rgba(15, 23, 42, 0.1);
}

.captain-profile {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.captain-avatar-wrap {
  position: relative;
  flex-shrink: 0;
}

.captain-avatar {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--gray-800);
  display: block;
}

.avatar-ring {
  position: absolute;
  inset: -3px;
  border-radius: 50%;
  background: var(--prism-gradient-118);
  background-size: var(--prism-size, 200% 100%);
  mask: radial-gradient(circle, transparent 31px, black 32px);
  -webkit-mask: radial-gradient(circle, transparent 31px, black 32px);
}

.captain-info {
  min-width: 0;
}

.captain-name {
  margin: 0 0 0.15rem;
  font-weight: 600;
  font-size: 1rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.captain-username {
  margin: 0 0 0.15rem;
  color: var(--accent-cyan);
  font-size: 0.9rem;
  font-weight: 500;
}

.captain-since {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.8rem;
}

/* ============================================================================
   Crew section
   ============================================================================ */

.crew-section {
  background: rgba(26, 31, 38, 0.55);
  border: 1px solid var(--border);
  border-radius: 1rem;
  padding: 1.35rem;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  box-shadow: 0 16px 38px rgba(4, 10, 20, 0.14);
}

html[data-theme='light'] .crew-section {
  background: rgba(255, 255, 255, 0.88);
  border-color: rgba(15, 23, 42, 0.1);
}

.crew-offline {
  display: flex;
  align-items: flex-start;
  gap: 1.25rem;
  flex-wrap: wrap;
}

.radar-wrap {
  flex-shrink: 0;
}

.radar-svg {
  width: 72px;
  height: 72px;
  opacity: 0.75;
}

@media (prefers-reduced-motion: reduce) {
  .radar-svg animateTransform {
    display: none;
  }
}

.crew-status-text {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.crew-offline-label {
  margin: 0;
  font-weight: 600;
  font-size: 0.95rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.offline-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent-cyan);
  animation: pulse 2.5s ease-in-out infinite;
}

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

.crew-offline-hint {
  margin: 0;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.crew-offline-install {
  margin: 0.5rem 0 0;
  font-size: 0.78rem;
  color: var(--text-muted);
}

.crew-offline-install a {
  color: var(--accent-cyan);
  text-decoration: none;
}

.crew-offline-install a:hover {
  text-decoration: underline;
}

/* ============================================================================
   Device Token Dialog
   ============================================================================ */

.crew-token-dialog {
  max-width: 28rem;
  margin: 0 auto;
  padding: 1.25rem;
  text-align: center;
  border-radius: 0.9rem;
  background: rgba(9, 14, 24, 0.45);
  border: 1px solid rgba(75, 180, 220, 0.16);
}

.token-dialog-title {
  margin: 0 0 0.5rem;
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-primary);
}

.token-dialog-desc {
  margin: 0 0 1.25rem;
  font-size: 0.85rem;
  color: var(--text-muted);
  line-height: 1.5;
}

.token-dialog-desc code {
  background: rgba(75, 180, 220, 0.12);
  color: var(--accent-cyan);
  padding: 0.15em 0.4em;
  border-radius: 0.25rem;
  font-size: 0.85em;
}

.token-display {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.device-token-value {
  font-family: 'JetBrains Mono', 'SF Mono', 'Fira Code', monospace;
  font-size: 1.6rem;
  font-weight: 700;
  letter-spacing: 0.15em;
  color: var(--accent-cyan);
  padding: 0.5rem 1rem;
  background: rgba(75, 180, 220, 0.08);
  border: 1px solid rgba(75, 180, 220, 0.25);
  border-radius: 0.5rem;
  user-select: all;
}

.token-expiry {
  margin: 0 0 0.5rem;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.token-status {
  margin: 0 0 0.75rem;
  font-size: 0.85rem;
  min-height: 1.2em;
}

.token-status[data-tone='info'] { color: var(--accent-cyan); }
.token-status[data-tone='success'] { color: oklch(72% 0.19 145); }
.token-status[data-tone='error'] { color: oklch(68% 0.22 25); }
.token-status[data-tone='idle'] { color: transparent; }

/* ============================================================================
   Orchestrator List (Connected Crew)
   ============================================================================ */

.crew-connected {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.orchestrator-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0.5rem;
}

.orch-card {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.6rem 1rem;
  background: rgba(26, 31, 38, 0.4);
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
  font-family: inherit;
  font-size: 0.9rem;
  color: var(--text-primary);
}

.orch-card:hover {
  border-color: var(--accent-cyan);
  background: rgba(75, 180, 220, 0.06);
}

.orch-card.selected {
  border-color: var(--accent-cyan);
  background: rgba(75, 180, 220, 0.1);
}

html[data-theme='light'] .orch-card {
  background: rgba(255, 255, 255, 0.7);
}

html[data-theme='light'] .orch-card:hover,
html[data-theme='light'] .orch-card.selected {
  background: rgba(75, 180, 220, 0.08);
}

.orch-status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.status-online { background: oklch(72% 0.19 145); }
.status-busy { background: oklch(80% 0.18 85); }
.status-idle { background: oklch(72% 0.19 145); opacity: 0.6; }
.status-offline { background: var(--text-muted); opacity: 0.4; }

.orch-name {
  font-weight: 600;
}

.orch-mode {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* ============================================================================
   Live HUD
   ============================================================================ */

.crew-hud {
  margin-top: 1rem;
  background: rgba(26, 31, 38, 0.55);
  border: 1px solid var(--border);
  border-radius: 1rem;
  padding: 1.35rem;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  box-shadow: 0 16px 38px rgba(4, 10, 20, 0.14);
}

html[data-theme='light'] .crew-hud {
  background: rgba(255, 255, 255, 0.88);
  border-color: rgba(15, 23, 42, 0.1);
}

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

.hud-identity {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.hud-orch-name {
  font-weight: 700;
  font-size: 1.1rem;
}

.hud-mode-badge {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 0.15em 0.5em;
  border-radius: 0.25rem;
  background: var(--text-muted);
  color: var(--bg-dark);
}

.hud-mode-badge[data-mode='command'] { background: oklch(60% 0 0 / 0.5); color: var(--text-primary); }
.hud-mode-badge[data-mode='chat'] { background: oklch(75% 0.18 195); color: var(--bg-dark); }
.hud-mode-badge[data-mode='group'] { background: oklch(65% 0.25 295); color: white; }
.hud-mode-badge[data-mode='auto'] { background: oklch(80% 0.18 85); color: var(--bg-dark); }
.hud-mode-badge[data-mode='agent'] { background: oklch(65% 0.22 245); color: white; }

.hud-busy-indicator {
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  padding: 0.1em 0.4em;
  border-radius: 0.2rem;
}

.hud-busy-indicator[data-state='busy'] {
  background: oklch(80% 0.18 85 / 0.2);
  color: oklch(80% 0.18 85);
}

.hud-busy-indicator[data-state='idle'] {
  background: oklch(72% 0.19 145 / 0.2);
  color: oklch(72% 0.19 145);
}

.hud-heartbeat {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.heartbeat-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.heartbeat-dot[data-state='fresh'] { background: oklch(72% 0.19 145); }
.heartbeat-dot[data-state='aging'] { background: oklch(80% 0.18 85); }
.heartbeat-dot[data-state='stale'] { background: oklch(68% 0.22 25); }
.heartbeat-dot[data-state='unknown'] { background: var(--text-muted); opacity: 0.4; }

.heartbeat-label {
  font-size: 0.8rem;
}

/* HUD Grid */
.hud-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(115px, 1fr));
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.hud-tile {
  background: rgba(26, 31, 38, 0.4);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 0.5rem;
  padding: 0.75rem;
  text-align: center;
}

html[data-theme='light'] .hud-tile {
  background: rgba(255, 255, 255, 0.6);
  border-color: rgba(15, 23, 42, 0.06);
}

.hud-tile-label {
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 0.35rem;
}

.hud-tile-value {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--text-primary);
}

.hud-tile-values {
  display: flex;
  gap: 0.75rem;
  justify-content: center;
}

.hud-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.stat-num {
  font-size: 1.2rem;
  font-weight: 700;
}

.stat-label {
  font-size: 0.65rem;
  color: var(--text-muted);
  text-transform: uppercase;
}

.stat-unit {
  font-size: 0.7rem;
  color: var(--text-muted);
  font-weight: 400;
}

.hud-stat[data-stat='pending'] .stat-num { color: oklch(80% 0.18 85); }
.hud-stat[data-stat='completed'] .stat-num { color: oklch(72% 0.19 145); }
.hud-stat[data-stat='failed'] .stat-num { color: oklch(68% 0.22 25); }

/* HUD Tasks Row */
.hud-tasks-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.hud-task-card {
  background: rgba(26, 31, 38, 0.4);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 0.5rem;
  padding: 0.75rem;
}

html[data-theme='light'] .hud-task-card {
  background: rgba(255, 255, 255, 0.6);
  border-color: rgba(15, 23, 42, 0.06);
}

.hud-task-label {
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 0.35rem;
}

.hud-task-content {
  font-size: 0.85rem;
  color: var(--text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* HUD Resources */
.hud-resources {
  margin-bottom: 1rem;
}

.hud-resources-title {
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin: 0 0 0.5rem;
}

.hud-resource-list {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  max-height: 13rem;
  overflow-y: auto;
}

.hud-resource-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.35rem 0.5rem;
  background: rgba(26, 31, 38, 0.3);
  border-radius: 0.35rem;
  font-size: 0.8rem;
}

html[data-theme='light'] .hud-resource-item {
  background: rgba(255, 255, 255, 0.5);
}

.resource-tier-badge {
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 0.1em 0.35em;
  border-radius: 0.2rem;
  background: var(--text-muted);
  color: var(--bg-dark);
}

.resource-tier-badge[data-tier='top'] { background: oklch(80% 0.18 85); }
.resource-tier-badge[data-tier='mid'] { background: oklch(75% 0.18 195); color: var(--bg-dark); }
.resource-tier-badge[data-tier='low'] { background: oklch(60% 0 0 / 0.5); color: var(--text-primary); }

.resource-alias {
  font-weight: 600;
  color: var(--text-primary);
}

.resource-model {
  color: var(--text-muted);
  font-size: 0.75rem;
}

.hud-empty {
  margin: 0;
  font-size: 0.85rem;
  color: var(--text-muted);
  font-style: italic;
}

/* HUD Daily Session */
.hud-daily-session {
  margin-bottom: 1rem;
  padding: 0.6rem 0.75rem;
  background: rgba(26, 31, 38, 0.3);
  border-radius: 0.5rem;
}

.hud-daily-stats {
  display: flex;
  gap: 1rem;
  font-size: 0.85rem;
  color: var(--text-secondary);
}

/* HUD Actions */
.hud-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  padding-top: 0.75rem;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

html[data-theme='light'] .hud-actions {
  border-top-color: rgba(15, 23, 42, 0.06);
}

.btn-danger {
  background: oklch(68% 0.22 25 / 0.12);
  border: 1px solid oklch(68% 0.22 25 / 0.3);
  color: oklch(68% 0.22 25);
  font-size: 0.8rem;
  padding: 0.4rem 0.8rem;
  border-radius: 0.35rem;
  cursor: pointer;
  font-family: inherit;
  font-weight: 500;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.btn-danger:hover {
  background: oklch(68% 0.22 25 / 0.2);
  border-color: oklch(68% 0.22 25 / 0.5);
}

/* ============================================================================
   Remote Task Form
   ============================================================================ */

.crew-task-form-section {
  background: rgba(26, 31, 38, 0.55);
  border: 1px solid var(--border);
  border-radius: 1rem;
  padding: 1.35rem;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  box-shadow: 0 16px 38px rgba(4, 10, 20, 0.14);
}

html[data-theme='light'] .crew-task-form-section {
  background: rgba(255, 255, 255, 0.88);
  border-color: rgba(15, 23, 42, 0.1);
}

.remote-task-form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  height: 100%;
}

.task-field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.task-label {
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.task-textarea {
  width: 100%;
  padding: 0.65rem 0.8rem;
  background: rgba(26, 31, 38, 0.5);
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.9rem;
  line-height: 1.5;
  resize: vertical;
  min-height: 104px;
  transition: border-color 0.15s ease;
}

html[data-theme='light'] .task-textarea {
  background: rgba(255, 255, 255, 0.8);
}

.task-textarea:focus {
  outline: none;
  border-color: var(--accent-cyan);
}

.task-char-count {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-align: right;
}

.task-priority-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.priority-buttons {
  display: flex;
  gap: 0;
  border-radius: 0.35rem;
  overflow: hidden;
  border: 1px solid var(--border);
}

.priority-btn {
  padding: 0.35rem 0.75rem;
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.priority-btn + .priority-btn {
  border-left: 1px solid var(--border);
}

.priority-btn:hover {
  background: rgba(75, 180, 220, 0.06);
  color: var(--text-primary);
}

.priority-btn.active {
  background: var(--accent-cyan);
  color: var(--bg-dark);
  font-weight: 600;
}

.priority-btn[data-priority='high'].active { background: oklch(68% 0.22 25); color: white; }
.priority-btn[data-priority='medium'].active { background: oklch(80% 0.18 85); color: var(--bg-dark); }
.priority-btn[data-priority='low'].active { background: oklch(72% 0.19 145); color: var(--bg-dark); }

.task-submit-status {
  font-size: 0.85rem;
  min-height: 1.2em;
  margin: 0;
}

/* ============================================================================
   Recent Tasks List
   ============================================================================ */

.crew-recent-tasks-section {
  background: rgba(26, 31, 38, 0.55);
  border: 1px solid var(--border);
  border-radius: 1rem;
  padding: 1.35rem;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  flex-direction: column;
  box-shadow: 0 16px 38px rgba(4, 10, 20, 0.14);
}

html[data-theme='light'] .crew-recent-tasks-section {
  background: rgba(255, 255, 255, 0.88);
  border-color: rgba(15, 23, 42, 0.1);
}

.recent-tasks-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  flex: 1;
  min-height: 0;
  max-height: 21rem;
  overflow-y: auto;
}

.task-item {
  padding: 0.75rem;
  background: rgba(26, 31, 38, 0.3);
  border-radius: 0.5rem;
  border-left: 3px solid var(--border);
}

.task-item[data-status='submitted'] { border-left-color: oklch(80% 0.18 85); }
.task-item[data-status='acknowledged'] { border-left-color: oklch(75% 0.18 195); }
.task-item[data-status='completed'] { border-left-color: oklch(72% 0.19 145); }
.task-item[data-status='failed'] { border-left-color: oklch(68% 0.22 25); }

html[data-theme='light'] .task-item {
  background: rgba(255, 255, 255, 0.5);
}

.task-item-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.35rem;
  flex-wrap: wrap;
}

.task-status-badge {
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 0.1em 0.35em;
  border-radius: 0.2rem;
}

.task-submitted { background: oklch(80% 0.18 85 / 0.2); color: oklch(80% 0.18 85); }
.task-acknowledged { background: oklch(75% 0.18 195 / 0.2); color: oklch(75% 0.18 195); }
.task-completed { background: oklch(72% 0.19 145 / 0.2); color: oklch(72% 0.19 145); }
.task-failed { background: oklch(68% 0.22 25 / 0.2); color: oklch(68% 0.22 25); }

.task-priority-badge {
  font-size: 0.6rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 0.1em 0.3em;
  border-radius: 0.2rem;
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-muted);
}

.task-priority-badge[data-priority='high'] { color: oklch(68% 0.22 25); }
.task-priority-badge[data-priority='medium'] { color: oklch(80% 0.18 85); }
.task-priority-badge[data-priority='low'] { color: oklch(72% 0.19 145); }

.task-date {
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-left: auto;
}

.task-item-content {
  font-size: 0.85rem;
  color: var(--text-secondary);
  line-height: 1.4;
}

.task-item-summary {
  margin-top: 0.35rem;
  padding-top: 0.35rem;
  border-top: 1px solid rgba(255, 255, 255, 0.04);
  font-size: 0.8rem;
  color: var(--text-muted);
  font-style: italic;
}

html[data-theme='light'] .task-item-summary {
  border-top-color: rgba(15, 23, 42, 0.06);
}

/* ============================================================================
   Button extensions
   ============================================================================ */

.btn-xs {
  font-size: 0.75rem;
  padding: 0.25rem 0.5rem;
}

/* ============================================================================
   Responsive — HUD grid
   ============================================================================ */

@media (max-width: 1079px) {
  .community-layout {
    grid-template-columns: 1fr;
  }

  .community-sidebar {
    order: 2;
  }

  .community-main {
    order: 1;
  }

  .log-feed-header {
    flex-direction: column;
    align-items: stretch;
  }

  .feed-tabs {
    width: 100%;
    justify-content: stretch;
  }

  .feed-tab {
    flex: 1 1 0;
    justify-content: center;
  }

  .section-filter-row {
    overflow-x: auto;
    padding-bottom: 0.2rem;
  }

  .port-log-head-actions {
    width: 100%;
    justify-content: flex-start;
  }
}

@media (max-width: 640px) {
  .port-main {
    padding-bottom: 1.5rem;
  }

  .port-header-shell {
    flex-direction: column;
  }

  .port-header-actions {
    width: 100%;
    justify-content: space-between;
    margin-left: 0;
  }

  .port-header-summary {
    font-size: 0.9rem;
  }

  .hud-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .hud-tasks-row {
    grid-template-columns: 1fr;
  }

  .hud-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .orchestrator-list {
    grid-template-columns: 1fr;
  }

  .token-display {
    flex-direction: column;
    gap: 0.5rem;
  }

  .device-token-value {
    font-size: 1.2rem;
  }

  .token-metric-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .log-composer-toolbar,
  .log-feed-header,
  .port-log-head,
  .port-log-actions,
  .reply-form-actions,
  .membership-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .port-log-action-group {
    width: 100%;
    border-radius: 0.9rem;
  }

}

@media (min-width: 1024px) {
  .hud-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

/* ============================================================================
   Port community and Logs
   ============================================================================ */

.port-community-section {
  margin-top: 1.4rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.community-section-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}

.community-title {
  margin: 0;
  font-size: clamp(1.45rem, 3vw, 2rem);
  line-height: 1.15;
  letter-spacing: -0.02em;
}

.community-summary {
  margin: 0.6rem 0 0;
  max-width: 60rem;
  color: var(--text-secondary);
  font-size: 0.95rem;
}

.community-layout {
  display: grid;
  gap: 1rem;
  align-items: start;
}

@media (min-width: 1080px) {
  .community-layout {
    grid-template-columns: minmax(19rem, 0.8fr) minmax(0, 1.2fr);
  }
}

.community-sidebar,
.community-main {
  display: grid;
  gap: 1rem;
}

.community-card {
  background: linear-gradient(180deg, rgba(26, 31, 38, 0.7) 0%, rgba(18, 24, 36, 0.62) 100%);
  border: 1px solid var(--border);
  border-radius: 1rem;
  padding: 1.25rem;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow: 0 16px 44px rgba(4, 10, 20, 0.18);
}

html[data-theme='light'] .community-card {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.96) 0%, rgba(245, 249, 255, 0.9) 100%);
  border-color: rgba(15, 23, 42, 0.1);
  box-shadow: 0 18px 42px rgba(15, 23, 42, 0.08);
}

.community-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.8rem;
}

.community-kicker {
  margin: 0 0 0.3rem;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: oklch(76% 0.18 195);
}

.community-card-title {
  margin: 0;
  font-size: 1.02rem;
  line-height: 1.35;
}

.community-card-copy {
  margin: 0;
  color: var(--text-secondary);
  font-size: 0.9rem;
  max-width: 34rem;
}

.membership-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2.1rem;
  padding: 0.35rem 0.8rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  border: 1px solid transparent;
}

.membership-pill[data-tier='free'] {
  background: rgba(75, 180, 220, 0.12);
  color: oklch(78% 0.18 195);
  border-color: rgba(75, 180, 220, 0.24);
}

.membership-pill[data-tier='premium'] {
  background: linear-gradient(135deg, oklch(78% 0.18 85 / 0.22), oklch(72% 0.19 145 / 0.18));
  color: oklch(88% 0.17 92);
  border-color: oklch(80% 0.18 85 / 0.36);
}

.token-metric-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem;
  margin-top: 1rem;
}

.token-metric-card {
  display: grid;
  gap: 0.25rem;
  padding: 0.85rem 0.9rem;
  border-radius: 0.8rem;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.06);
}

html[data-theme='light'] .token-metric-card {
  background: rgba(15, 23, 42, 0.03);
  border-color: rgba(15, 23, 42, 0.06);
}

.token-metric-label {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.token-metric-value {
  font-size: 1.45rem;
  line-height: 1;
  font-weight: 700;
}

.token-policy-list {
  display: grid;
  gap: 0.45rem;
  margin-top: 1rem;
}

.token-policy-line {
  margin: 0;
  color: var(--text-secondary);
  font-size: 0.86rem;
}

.membership-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-top: 1rem;
}

.community-form {
  display: grid;
  gap: 0.75rem;
}

.toggle-row {
  display: flex;
  align-items: flex-start;
  gap: 0.65rem;
  font-size: 0.92rem;
  color: var(--text-secondary);
  cursor: pointer;
}

.toggle-row input {
  margin-top: 0.2rem;
}

.field-label {
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.community-input,
.community-select,
.log-composer-input,
.reply-input,
.flag-reason-select {
  width: 100%;
  padding: 0.7rem 0.8rem;
  background: rgba(14, 20, 30, 0.72);
  border: 1px solid var(--border);
  border-radius: 0.7rem;
  color: var(--text-primary);
  font: inherit;
  transition: border-color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
}

html[data-theme='light'] :is(.community-input, .community-select, .log-composer-input, .reply-input, .flag-reason-select) {
  background: rgba(255, 255, 255, 0.92);
}

:is(.community-input, .community-select, .log-composer-input, .reply-input, .flag-reason-select):focus {
  outline: none;
  border-color: oklch(75% 0.18 195 / 0.75);
  box-shadow: 0 0 0 3px oklch(75% 0.18 195 / 0.14);
}

.log-composer-input,
.reply-input {
  resize: vertical;
  line-height: 1.5;
}

.log-composer-input {
  min-height: 8.5rem;
}

.terms-box {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  display: grid;
  gap: 0.55rem;
}

html[data-theme='light'] .terms-box {
  border-top-color: rgba(15, 23, 42, 0.08);
}

.terms-title {
  margin: 0;
  font-size: 0.96rem;
}

.terms-copy {
  margin: 0;
  font-size: 0.88rem;
  color: var(--text-secondary);
}

.community-status {
  margin: 0;
  min-height: 1.3em;
  font-size: 0.84rem;
}

.task-submit-status,
.community-status {
  display: block;
  width: fit-content;
  max-width: 100%;
  line-height: 1.45;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 999px;
  background: transparent;
  transition: border-color 0.15s ease, background 0.15s ease, color 0.15s ease;
}

:is(.task-submit-status, .community-status)[data-tone='info'] {
  color: oklch(78% 0.18 195);
  background: rgba(75, 180, 220, 0.1);
  border-color: rgba(75, 180, 220, 0.18);
  padding: 0.28rem 0.7rem;
}

:is(.task-submit-status, .community-status)[data-tone='success'] {
  color: oklch(72% 0.19 145);
  background: rgba(130, 205, 120, 0.12);
  border-color: rgba(130, 205, 120, 0.2);
  padding: 0.28rem 0.7rem;
}

:is(.task-submit-status, .community-status)[data-tone='error'] {
  color: oklch(68% 0.22 25);
  background: rgba(235, 92, 92, 0.12);
  border-color: rgba(235, 92, 92, 0.18);
  padding: 0.28rem 0.7rem;
}

:is(.task-submit-status, .community-status)[data-tone='idle'] {
  color: transparent;
  border-color: transparent;
  background: transparent;
  padding: 0;
}

.community-context-note {
  margin: 0;
  max-width: 42rem;
  padding: 0.8rem 0.9rem;
  border-radius: 0.9rem;
  border: 1px solid rgba(75, 180, 220, 0.12);
  background: linear-gradient(135deg, rgba(75, 180, 220, 0.1), rgba(255, 255, 255, 0.02));
  color: var(--text-secondary);
  font-size: 0.84rem;
  line-height: 1.55;
}

html[data-theme='light'] .community-context-note {
  background: linear-gradient(135deg, rgba(75, 180, 220, 0.08), rgba(255, 255, 255, 0.94));
  border-color: rgba(75, 180, 220, 0.14);
}

.log-composer-hint {
  border-color: rgba(75, 180, 220, 0.16);
}

.log-feed-context {
  margin-top: 0.55rem;
  border-color: rgba(130, 205, 120, 0.16);
  background: linear-gradient(135deg, rgba(130, 205, 120, 0.1), rgba(255, 255, 255, 0.02));
}

html[data-theme='light'] .log-feed-context {
  background: linear-gradient(135deg, rgba(130, 205, 120, 0.08), rgba(255, 255, 255, 0.94));
  border-color: rgba(130, 205, 120, 0.16);
}

.log-composer-toolbar {
  display: flex;
  align-items: flex-end;
  gap: 0.8rem;
  flex-wrap: wrap;
}

.log-composer-field-group {
  display: grid;
  gap: 0.35rem;
  min-width: 10rem;
  flex: 1 1 11rem;
}

.log-composer-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.log-composer-actions .community-status {
  flex: 1 1 14rem;
}

.log-feed-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}

.feed-tabs {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.25rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.06);
}

html[data-theme='light'] .feed-tabs {
  background: rgba(15, 23, 42, 0.03);
  border-color: rgba(15, 23, 42, 0.06);
}

.feed-tab,
.section-filter,
.mini-action-btn,
.rating-btn {
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-secondary);
  font: inherit;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease, transform 0.12s ease;
}

.feed-tab {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  min-height: 2.25rem;
  padding: 0.35rem 0.8rem;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 700;
}

.feed-tab:hover,
.section-filter:hover,
.mini-action-btn:hover,
.rating-btn:hover {
  background: rgba(75, 180, 220, 0.08);
  color: var(--text-primary);
}

.feed-tab.active,
.section-filter.active {
  background: rgba(75, 180, 220, 0.16);
  border-color: rgba(75, 180, 220, 0.2);
  color: oklch(82% 0.16 195);
}

.section-filter-row {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}

.section-filter {
  min-height: 2rem;
  padding: 0.35rem 0.75rem;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
  border-color: rgba(255, 255, 255, 0.08);
}

html[data-theme='light'] .section-filter {
  border-color: rgba(15, 23, 42, 0.08);
}

.port-logs-list {
  display: grid;
  gap: 0.9rem;
}

.port-log-card,
.port-reply-card {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 1rem;
}

html[data-theme='light'] :is(.port-log-card, .port-reply-card) {
  background: rgba(15, 23, 42, 0.03);
  border-color: rgba(15, 23, 42, 0.07);
}

.port-log-card {
  position: relative;
  overflow: hidden;
  padding: 1rem;
  box-shadow: 0 14px 34px rgba(4, 10, 20, 0.12);
}

html[data-theme='light'] .port-log-card {
  box-shadow: 0 14px 30px rgba(15, 23, 42, 0.06);
}

.port-log-card::before {
  content: '';
  position: absolute;
  inset: 0 auto 0 0;
  width: 0.28rem;
  background: linear-gradient(180deg, rgba(75, 180, 220, 0.9), rgba(75, 180, 220, 0.12));
}

.port-log-card[data-audience='public'] {
  border-color: rgba(130, 205, 120, 0.16);
}

.port-log-card[data-audience='public']::before {
  background: linear-gradient(180deg, rgba(130, 205, 120, 0.94), rgba(130, 205, 120, 0.12));
}

.port-log-card[data-audience='mates'] {
  border-color: rgba(75, 180, 220, 0.16);
}

.port-log-card[data-audience='profile'] {
  border-color: rgba(235, 195, 80, 0.18);
}

.port-log-card[data-audience='profile']::before {
  background: linear-gradient(180deg, rgba(235, 195, 80, 0.94), rgba(235, 195, 80, 0.12));
}

.port-log-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.8rem;
}

.port-log-head-main {
  display: flex;
  align-items: flex-start;
  gap: 0.8rem;
  min-width: 0;
}

.port-log-author-block {
  display: grid;
  gap: 0.25rem;
  min-width: 0;
}

.port-log-head-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.port-log-pills,
.port-reply-meta {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.log-pill {
  display: inline-flex;
  align-items: center;
  min-height: 1.65rem;
  padding: 0.18rem 0.45rem;
  border-radius: 999px;
  background: rgba(75, 180, 220, 0.1);
  color: oklch(80% 0.16 195);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.log-pill[data-section='daily-log'] {
  background: rgba(235, 195, 80, 0.12);
  color: oklch(84% 0.16 85);
}

.log-pill[data-audience='public'] {
  background: rgba(130, 205, 120, 0.12);
  color: oklch(82% 0.16 145);
}

.log-pill[data-author-type='captain'] {
  background: linear-gradient(135deg, oklch(80% 0.18 85 / 0.18), oklch(70% 0.18 35 / 0.2));
  color: oklch(88% 0.15 92);
}

.log-pill-premium {
  background: linear-gradient(135deg, oklch(80% 0.18 85 / 0.2), oklch(70% 0.18 35 / 0.22));
  color: oklch(89% 0.14 92);
}

.port-log-avatar {
  display: grid;
  place-items: center;
  flex-shrink: 0;
  width: 2.75rem;
  height: 2.75rem;
  border-radius: 0.85rem;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: linear-gradient(135deg, oklch(76% 0.18 195), oklch(66% 0.14 245));
  color: white;
  font-size: 0.8rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  box-shadow: 0 12px 22px rgba(4, 10, 20, 0.18);
}

.port-log-avatar[data-author-type='captain'] {
  background: linear-gradient(135deg, oklch(80% 0.18 85), oklch(71% 0.17 35));
}

.port-log-avatar[data-author-type='orchestrator'] {
  background: linear-gradient(135deg, oklch(76% 0.16 145), oklch(66% 0.14 195));
}

html[data-theme='light'] .port-log-avatar {
  border-color: rgba(15, 23, 42, 0.08);
  box-shadow: 0 10px 22px rgba(15, 23, 42, 0.08);
}

.port-log-avatar-small {
  width: 2.2rem;
  height: 2.2rem;
  border-radius: 0.75rem;
  font-size: 0.72rem;
}

.port-log-author {
  margin: 0.45rem 0 0;
  font-size: 1rem;
}

.port-log-meta,
.port-reply-meta {
  margin: 0.2rem 0 0;
  color: var(--text-muted);
  font-size: 0.8rem;
  line-height: 1.5;
}

.port-log-content,
.port-reply-content {
  margin: 0.85rem 0 0;
  color: var(--text-secondary);
  font-size: 0.95rem;
  line-height: 1.65;
  white-space: pre-wrap;
  word-break: break-word;
}

.port-empty-state {
  display: grid;
  gap: 0.45rem;
  padding: 1.1rem 1.15rem;
  border-radius: 0.95rem;
  border: 1px dashed rgba(75, 180, 220, 0.18);
  background: linear-gradient(135deg, rgba(75, 180, 220, 0.08), rgba(255, 255, 255, 0.02));
}

html[data-theme='light'] .port-empty-state {
  background: linear-gradient(135deg, rgba(75, 180, 220, 0.06), rgba(255, 255, 255, 0.94));
  border-color: rgba(75, 180, 220, 0.16);
}

.port-empty-title,
.port-empty-copy {
  margin: 0;
}

.port-empty-title {
  font-size: 0.98rem;
  font-weight: 700;
}

.port-empty-copy {
  max-width: 34rem;
  color: var(--text-secondary);
  font-size: 0.88rem;
  line-height: 1.6;
}

.port-log-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-top: 0.95rem;
}

.port-log-action-group {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  flex-wrap: wrap;
  min-height: 2.35rem;
  padding: 0.35rem 0.45rem;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.07);
  background: rgba(255, 255, 255, 0.03);
}

html[data-theme='light'] .port-log-action-group {
  border-color: rgba(15, 23, 42, 0.07);
  background: rgba(15, 23, 42, 0.03);
}

.port-log-action-group-rating {
  background: rgba(75, 180, 220, 0.08);
}

.port-log-action-group-thread {
  background: rgba(130, 205, 120, 0.08);
}

.port-log-action-group-moderation {
  background: rgba(235, 195, 80, 0.08);
}

.rating-btn,
.mini-action-btn {
  min-height: 2rem;
  padding: 0.35rem 0.65rem;
  border-radius: 999px;
  border-color: rgba(255, 255, 255, 0.08);
  font-size: 0.78rem;
  font-weight: 600;
}

html[data-theme='light'] :is(.rating-btn, .mini-action-btn) {
  border-color: rgba(15, 23, 42, 0.08);
}

.rating-btn.active {
  border-color: rgba(75, 180, 220, 0.28);
  background: rgba(75, 180, 220, 0.14);
  color: oklch(82% 0.16 195);
}

:is(.rating-btn, .mini-action-btn, .flag-reason-select):disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.port-log-score {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-right: 0.15rem;
}

.flag-inline-label {
  flex: 1 1 10rem;
  min-width: min(10rem, 100%);
}

.flag-reason-select {
  min-height: 2rem;
  padding-block: 0.35rem;
  font-size: 0.78rem;
  border-radius: 999px;
}

.reply-form {
  display: grid;
  gap: 0.6rem;
  margin-top: 0.95rem;
  padding-top: 0.95rem;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

html[data-theme='light'] .reply-form {
  border-top-color: rgba(15, 23, 42, 0.06);
}

.reply-form-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.port-log-replies {
  display: grid;
  gap: 0.65rem;
  margin-top: 0.95rem;
  padding-left: clamp(0.65rem, 2vw, 1rem);
  border-left: 2px solid rgba(75, 180, 220, 0.18);
}

.port-reply-card {
  padding: 0.85rem 0.9rem;
}

.port-reply-head {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
}

.port-reply-copy {
  display: grid;
  gap: 0.35rem;
  min-width: 0;
}

.port-reply-meta {
  margin: 0;
}

.port-reply-content {
  margin: 0;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ============================================================================
   Footer
   ============================================================================ */

.site-footer {
  border-top: 1px solid var(--border);
  padding: 1.25rem 0 0.75rem;
  margin-top: auto;
}

.footer-content {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  max-width: var(--container-max-width);
  margin: 0 auto;
  padding: 0 var(--container-padding);
}

.footer-links {
  display: flex;
  gap: 1.25rem;
  flex-wrap: wrap;
}

.footer-links a {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.88rem;
  transition: color 0.15s ease;
}

.footer-links a:hover { color: var(--text-secondary); }

.footer-utility-controls {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.65rem;
  min-height: 2.75rem;
}

.footer-meta {
  text-align: center;
  max-width: var(--container-max-width);
  margin: 0.5rem auto 0;
  padding: 0 var(--container-padding) 0.5rem;
}

.footer-tagline,
.footer-copy {
  margin: 0;
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* ============================================================================
   Theme toggle
   ============================================================================ */

.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.75rem;
  height: 2.75rem;
  padding: 0;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.8rem;
  font-family: inherit;
  transition: border-color 0.15s ease, color 0.15s ease;
}

.theme-toggle:hover {
  border-color: var(--accent-cyan);
  color: var(--text-secondary);
}

.footer-utility-controls :is(.theme-toggle, .footer-share-button) {
  flex: 0 0 auto;
  width: 2.75rem;
  height: 2.75rem;
  padding: 0;
  border-radius: 999px;
}

.theme-toggle-label {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
}

.theme-toggle-icon {
  width: 16px;
  height: 16px;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

.theme-toggle-icon svg { width: 16px; height: 16px; }

.icon-sun { display: none; }

html[data-theme='light'] .icon-moon { display: none; }
html[data-theme='light'] .icon-sun  { display: block; }

/* ============================================================================
   Firebase emulator banner override
   ============================================================================ */

#firebase-emulator-warning,
.firebase-emulator-warning {
  display: none !important;
  visibility: hidden !important;
  opacity: 0 !important;
  pointer-events: none !important;
}

/* ============================================================================
   Tab navigation (Phase 1)
   ============================================================================ */

.port-tabs {
  position: sticky;
  top: var(--nav-shell-height);
  z-index: 10;
  margin: 0 calc(-1 * var(--container-padding, 1.5rem));
  padding: 0 var(--container-padding, 1.5rem);
  background: oklch(10% 0.01 240 / 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

html[data-theme='light'] .port-tabs {
  background: oklch(98% 0.005 240 / 0.9);
}

.port-tabs-strip {
  display: flex;
  gap: 0.2rem;
  padding: 0.5rem 0;
  overflow-x: auto;
  scrollbar-width: none;
}

.port-tabs-strip::-webkit-scrollbar {
  display: none;
}

.port-tab {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.4rem 1.1rem;
  min-height: 2.4rem;
  border-radius: 999px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
  flex-shrink: 0;
}

.port-tab:hover {
  background: rgba(75, 180, 220, 0.08);
  color: var(--text-secondary);
}

.port-tab.active,
.port-tab[aria-selected='true'] {
  background: rgba(75, 180, 220, 0.14);
  border-color: rgba(75, 180, 220, 0.22);
  color: oklch(82% 0.16 195);
}

/* Tab panels */
.port-tab-panel {
  padding-top: clamp(1rem, 2vw, 1.5rem);
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

/* ============================================================================
   Crew status pill (Phase 1)
   ============================================================================ */

.crew-status-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.3rem 0.75rem;
  min-height: 2.1rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  border: 1px solid transparent;
  white-space: nowrap;
  flex-shrink: 0;
  transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

.crew-status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}

.crew-status-pill[data-state='offline'] {
  background: rgba(75, 180, 220, 0.08);
  border-color: rgba(75, 180, 220, 0.16);
  color: var(--text-muted);
}

.crew-status-pill[data-state='offline'] .crew-status-dot {
  background: oklch(75% 0.18 195 / 0.45);
}

.crew-status-pill[data-state='connected'] {
  background: oklch(72% 0.19 145 / 0.12);
  border-color: oklch(72% 0.19 145 / 0.28);
  color: oklch(72% 0.19 145);
}

.crew-status-pill[data-state='connected'] .crew-status-dot {
  background: oklch(72% 0.19 145);
  animation: pulse 2s ease-in-out infinite;
}

.crew-status-pill[data-state='busy'] {
  background: oklch(80% 0.18 85 / 0.12);
  border-color: oklch(80% 0.18 85 / 0.28);
  color: oklch(80% 0.18 85);
}

.crew-status-pill[data-state='busy'] .crew-status-dot {
  background: oklch(80% 0.18 85);
  animation: pulse 1s ease-in-out infinite;
}

@media (prefers-reduced-motion: reduce) {
  .crew-status-pill .crew-status-dot {
    animation: none;
  }
}

/* ============================================================================
   Feed tab layout (Phase 2)
   ============================================================================ */

.feed-composer-section {
  background: linear-gradient(180deg, rgba(26, 31, 38, 0.7) 0%, rgba(18, 24, 36, 0.62) 100%);
  border: 1px solid var(--border);
  border-radius: 1rem;
  padding: 1.25rem;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow: 0 16px 44px rgba(4, 10, 20, 0.18);
}

html[data-theme='light'] .feed-composer-section {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.96) 0%, rgba(245, 249, 255, 0.9) 100%);
  border-color: rgba(15, 23, 42, 0.1);
}

.log-feed-card {
  background: linear-gradient(180deg, rgba(26, 31, 38, 0.7) 0%, rgba(18, 24, 36, 0.62) 100%);
  border: 1px solid var(--border);
  border-radius: 1rem;
  padding: 1.25rem;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow: 0 16px 44px rgba(4, 10, 20, 0.18);
}

html[data-theme='light'] .log-feed-card {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.96) 0%, rgba(245, 249, 255, 0.9) 100%);
  border-color: rgba(15, 23, 42, 0.1);
}

/* ============================================================================
   Community tab — details/summary (Phase 4)
   ============================================================================ */

.token-policy-details,
.captain-controls-details {
  margin-top: 1rem;
}

.details-summary {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.6rem 0.75rem;
  border-radius: 0.6rem;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.07);
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
  cursor: pointer;
  list-style: none;
  user-select: none;
  transition: background 0.15s ease, color 0.15s ease;
}

.details-summary::-webkit-details-marker { display: none; }

.details-summary::after {
  content: '›';
  margin-left: auto;
  font-size: 1rem;
  font-weight: 400;
  transition: transform 0.2s ease;
  display: inline-block;
}

details[open] > .details-summary::after {
  transform: rotate(90deg);
}

.details-summary:hover {
  background: rgba(75, 180, 220, 0.08);
  color: var(--text-secondary);
}

html[data-theme='light'] .details-summary {
  background: rgba(15, 23, 42, 0.04);
  border-color: rgba(15, 23, 42, 0.08);
}

.token-policy-details .token-policy-list {
  margin-top: 0.75rem;
  padding: 0 0.75rem;
}

.captain-controls-details > .community-card {
  margin-top: 0.75rem;
}

/* ============================================================================
   Profile tab (Phase 6)
   ============================================================================ */

#tab-profile .captain-card {
  max-width: 32rem;
}

/* ============================================================================
   Toast notifications (Phase 5)
   ============================================================================ */

.port-toast {
  position: fixed;
  bottom: clamp(1.25rem, 3vw, 2rem);
  left: 50%;
  transform: translateX(-50%) translateY(0.5rem);
  z-index: 100;
  min-width: 16rem;
  max-width: min(90vw, 28rem);
  padding: 0.85rem 1.25rem;
  border-radius: 999px;
  background: rgba(18, 26, 42, 0.92);
  border: 1px solid rgba(75, 180, 220, 0.22);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  box-shadow: 0 12px 36px rgba(4, 10, 20, 0.4);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  font-size: 0.88rem;
  color: var(--text-primary);
  animation: toastSlideUp 0.25s ease forwards;
}

html[data-theme='light'] .port-toast {
  background: rgba(255, 255, 255, 0.96);
  border-color: rgba(75, 180, 220, 0.2);
}

@keyframes toastSlideUp {
  from { opacity: 0; transform: translateX(-50%) translateY(0.75rem); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}

.port-toast[hidden] {
  display: none !important;
}

.toast-message {
  flex: 1;
}

.toast-action {
  background: rgba(75, 180, 220, 0.14);
  border: 1px solid rgba(75, 180, 220, 0.22);
  color: oklch(82% 0.16 195);
  border-radius: 999px;
  padding: 0.25rem 0.75rem;
  font-family: inherit;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  transition: background 0.15s ease;
}

.toast-action:hover {
  background: rgba(75, 180, 220, 0.24);
}

/* ============================================================================
   Crew tab single-column layout (Phase 3)
   ============================================================================ */

#tab-crew .crew-hud {
  margin-top: 0;
}

/* ============================================================================
   Compact header (Phase 6)
   ============================================================================ */

.port-header {
  padding: clamp(0.4rem, 0.8vw, 0.65rem) 0 0;
  border-bottom: none;
  margin-bottom: 0;
}

.port-header-shell {
  align-items: center;
}

@media (max-width: 640px) {
  .port-tabs-strip {
    gap: 0.1rem;
  }

  .port-tab {
    padding: 0.4rem 0.75rem;
    font-size: 0.78rem;
  }
}
