.app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
  background: var(--surface);
}

/* ── Header ── */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  background: var(--surface-container);
  border-bottom: 1px solid var(--outline-variant);
  flex-shrink: 0;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 14px;
}

.app-logo {
  display: block;
  border-radius: 6px;
  flex-shrink: 0;
}

.app-header h1 {
  font-family: var(--brand);
  font-size: 16px;
  font-weight: 600;
  margin: 0;
  color: var(--on-surface);
  letter-spacing: 0.2px;
}

.header-status {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px 3px 8px;
  background: var(--surface-container-high);
  border-radius: 20px;
}

.header-status-text {
  font-size: 11px;
  font-weight: 500;
  color: var(--on-surface-variant);
}

/* ── Tabs ── */
.tabs {
  display: flex;
  gap: 2px;
}

.tabs button {
  background: none;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 5px 12px;
  font-size: 13px;
  color: var(--on-surface-variant);
  cursor: pointer;
  transition: all 0.15s;
  font-family: var(--sans);
}

.tabs button:hover {
  background: var(--surface-container-high);
}

.tabs button.active {
  background: var(--primary-container);
  color: var(--on-primary-container);
  border-color: transparent;
  font-weight: 500;
}

/* ── Content ── */
.app-content {
  flex: 1;
  min-height: 0;
  overflow: hidden;
  padding: 24px;
  display: flex;
  flex-direction: column;
}

/* The single active panel fills the content area. */
.app-content > * {
  flex: 1;
  min-height: 0;
}

/* ── Shared ── */
.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
  display: inline-block;
}

.muted {
  color: var(--on-surface-variant);
  font-size: 13px;
}

.error-text {
  font-size: 13px;
  color: var(--error);
  margin: 0;
  padding: 10px 12px;
  background: color-mix(in srgb, var(--error) 8%, transparent);
  border-radius: 8px;
  line-height: 1.4;
}

/* ── Dashboard ── */
.dashboard {
  display: flex;
  flex-direction: column;
  gap: 14px;
  height: 100%;
  min-height: 0;
}

.dashboard > .status-bar,
.dashboard > .start-section,
.dashboard > .stats-grid,
.dashboard > .error-text {
  flex-shrink: 0;
}

/* Compact status bar, accented by state. Replaces the old oversized hero. */
.status-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-radius: 12px;
  border: 1px solid var(--outline-variant);
  background: var(--surface-container);
}

.status-bar.running {
  border-color: color-mix(in srgb, var(--green) 35%, transparent);
  background: color-mix(in srgb, var(--success-container) 25%, var(--surface-container));
}

.status-bar.starting {
  border-color: color-mix(in srgb, var(--orange) 35%, transparent);
}

.status-led {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
  background: var(--gray);
}

.status-led.running {
  background: var(--green);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--green) 16%, transparent);
  animation: breathe 2.4s ease-in-out infinite;
}

.status-led.starting {
  background: var(--orange);
  animation: breathe 1.2s ease-in-out infinite;
}

@keyframes breathe {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.45; }
}

.status-bar-text {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.status-bar-text strong {
  font-size: 14px;
  color: var(--on-surface);
}

.status-bar-sub {
  font-size: 12px;
  color: var(--on-surface-variant);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.status-action {
  padding: 6px 16px;
  font-size: 12px;
  flex-shrink: 0;
}

/* Activity log lives at the bottom of the dashboard and fills the leftover
   space, scrolling inside itself. */
.dash-logs {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.dash-logs-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.dash-logs-title {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--on-surface-variant);
}

.start-section {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.start-btn {
  align-self: flex-start;
}

.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.ws-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--brand);
  font-size: 14px;
  font-weight: 500;
  color: var(--on-surface);
  line-height: 1;
}

.ws-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}

.ws-dot.pulsing {
  animation: breathe 2s ease-in-out infinite;
}

.stat-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 20px 16px;
  border-radius: 12px;
  border: 1px solid var(--outline-variant);
  background: var(--surface-container);
  transition: border-color 0.2s;
}

.stat-card:hover {
  border-color: color-mix(in srgb, var(--primary) 30%, var(--outline-variant));
}

.stat-value {
  font-size: 28px;
  font-weight: 600;
  color: var(--on-surface);
  font-family: var(--brand);
  line-height: 1;
}

.stat-label {
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--on-surface-variant);
}

/* ── Connection Panel ── */
.connection-panel {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* Incoming + outgoing side by side to keep the panel short (no scroll). */
.settings-row {
  display: flex;
  gap: 12px;
}

.settings-row > .settings-card {
  flex: 1;
  min-width: 0;
}

.panel-subtitle {
  font-size: 13px;
  color: var(--on-surface-variant);
  margin: 0;
}

.settings-card {
  border: 1px solid var(--outline-variant);
  border-radius: 14px;
  background: var(--surface-container);
  overflow: hidden;
}

.settings-section {
  padding: 16px 20px;
}

.settings-section h3 {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--on-surface-variant);
  margin: 0 0 10px;
}

.settings-divider {
  height: 1px;
  background: var(--outline-variant);
}

.settings-grid {
  display: grid;
  grid-template-columns: 72px 1fr;
  gap: 6px 12px;
  align-items: center;
}

.setting-key {
  font-size: 12px;
  color: var(--on-surface-variant);
}

.setting-val {
  font-size: 14px;
  font-family: var(--mono);
  color: var(--on-surface);
  background: none;
  padding: 0;
}

.setting-val.copyable {
  cursor: pointer;
  border-radius: 4px;
  transition: background 0.15s;
}

.setting-val.copyable:hover {
  background: var(--surface-container-high);
}

.password-field-inline {
  display: flex;
  align-items: center;
  gap: 8px;
}

.password-mono {
  font-size: 13px;
  letter-spacing: 0.3px;
}

.inline-btn {
  padding: 2px 8px;
  font-size: 11px;
  font-weight: 500;
  border: 1px solid var(--outline-variant);
  border-radius: 6px;
  background: var(--surface-container-high);
  color: var(--on-surface-variant);
  cursor: pointer;
  font-family: var(--sans);
  transition: all 0.15s;
  flex-shrink: 0;
}

.inline-btn:hover {
  background: var(--surface-container-highest);
  color: var(--on-surface);
}

.regen-btn {
  align-self: flex-start;
}

.settings-note {
  font-size: 12px;
  color: var(--on-surface-variant);
  padding: 10px 14px;
  background: color-mix(in srgb, var(--orange) 8%, transparent);
  border-radius: 8px;
  line-height: 1.5;
}

.settings-note strong {
  color: var(--on-surface);
}

/* ── Config Panel ── */
.panel {
}

.panel h2 {
  font-size: 14px;
  font-weight: 600;
  margin: 0 0 16px;
  color: var(--on-surface);
}

/* ── Forms ── */
.form-group {
  margin-bottom: 12px;
}

.form-group label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  color: var(--on-surface-variant);
  margin-bottom: 4px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.form-group input {
  width: 100%;
  padding: 9px 12px;
  font-size: 14px;
  border: 1px solid var(--outline-variant);
  border-radius: 8px;
  background: var(--surface);
  color: var(--on-surface);
  box-sizing: border-box;
  font-family: var(--sans);
  transition: border-color 0.15s, box-shadow 0.15s;
}

.form-group input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--primary) 15%, transparent);
}

.form-group input:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.form-group input::placeholder {
  color: var(--outline);
}

.form-row {
  display: flex;
  gap: 12px;
}

.form-row .form-group {
  flex: 1;
}

.form-group label.checkbox-field {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 6px;
  cursor: pointer;
  text-transform: none;
  letter-spacing: 0;
  font-weight: 400;
}

.form-group label.checkbox-field input[type="checkbox"] {
  width: 18px;
  height: 18px;
  margin: 0;
  flex: none;
  accent-color: var(--primary);
  cursor: pointer;
}

.form-group label.checkbox-field span {
  font-size: 13px;
  font-weight: 400;
  color: var(--on-surface);
  line-height: 1;
}

.field-hint {
  display: block;
  font-size: 11px;
  color: var(--on-surface-variant);
  margin-top: 6px;
}

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

/* ── Config panel: sub-tabbed, scrollable body, pinned actions ── */
.config-panel {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
}

.config-subtabs {
  display: flex;
  gap: 2px;
  margin-bottom: 16px;
  flex-shrink: 0;
}

.config-subtabs button {
  padding: 5px 12px;
  font-size: 13px;
  font-weight: 400;
  border: 1px solid transparent;
  border-radius: 8px;
  background: none;
  color: var(--on-surface-variant);
  cursor: pointer;
  transition: all 0.15s;
}

.config-subtabs button:hover {
  background: var(--surface-container-high);
}

.config-subtabs button.active {
  background: var(--primary-container);
  color: var(--on-primary-container);
  font-weight: 500;
}

.config-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding-right: 4px;
}

.config-panel .form-actions {
  flex-shrink: 0;
  align-items: center;
  border-top: 1px solid var(--outline-variant);
  padding-top: 12px;
}

.config-restart-hint {
  margin: 0 auto 0 0;
}

.form-group select {
  width: 100%;
  padding: 9px 12px;
  font-size: 14px;
  border: 1px solid var(--outline-variant);
  border-radius: 8px;
  background: var(--surface);
  color: var(--on-surface);
  box-sizing: border-box;
  font-family: var(--sans);
}

/* A control sitting right under explanatory text needs breathing room. */
.field-hint + select,
.field-hint + input,
.field-hint + .checkbox-field {
  margin-top: 10px;
}

.config-body button {
  margin-top: 8px;
}

/* ── Buttons ── */
button {
  padding: 9px 18px;
  font-size: 13px;
  font-weight: 500;
  border: 1px solid var(--outline-variant);
  border-radius: 8px;
  background: var(--surface-container-high);
  color: var(--on-surface);
  cursor: pointer;
  font-family: var(--sans);
  transition: all 0.15s;
}

button:hover:not(:disabled) {
  background: var(--surface-container-highest);
}

button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

button.primary {
  background: var(--primary);
  color: var(--on-primary);
  border-color: var(--primary);
}

button.primary:hover:not(:disabled) {
  opacity: 0.92;
}

button.small {
  padding: 4px 10px;
  font-size: 12px;
}

/* ── Logs ── */
.logs-panel {
  max-width: none;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.logs-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.logs-header h2 {
  margin: 0;
}

.logs-container {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  background: var(--surface-container);
  border: 1px solid var(--outline-variant);
  border-radius: 10px;
  padding: 12px;
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.7;
}

.logs-empty {
  color: var(--outline);
  font-style: italic;
}

.log-line {
  color: var(--on-surface);
  word-break: break-all;
}
