.relay-app-header {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.65rem 1.25rem;
}

.relay-app-header .relay-app-views {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-inline-end: auto;
}

.relay-app-header .relay-app-views a {
  display: inline-flex;
  align-items: center;
  min-height: 2.75rem;
  padding: 0.45rem 0.85rem;
  border: 1px solid transparent;
  border-radius: 0.6rem;
  text-decoration: none;
}

.relay-app-header .relay-app-views a:hover,
.relay-app-header .relay-app-views a[aria-current="page"] {
  border-color: var(--line);
  background: var(--panel);
  color: var(--gold);
}

.relay-app-header .relay-app-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
}

/* Shared communication controls for full pages and the compact Relay. */
:root {
  --relay-surface: #111c2c;
  --relay-raised: #18283d;
  --relay-field: #0c1727;
  --relay-text: #f4f1e8;
  --relay-muted: #adc0d5;
  --relay-edge: #49617d;
  --relay-accent: #f0cc81;
  --relay-highlight: #82d9f6;
  --relay-glow: #61c9ed36;
  --relay-selected: #344332;
}
html[data-theta-appearance="day"] {
  --relay-surface: #fffdf7;
  --relay-raised: #edf3f5;
  --relay-field: #ffffff;
  --relay-text: #21374a;
  --relay-muted: #4a6071;
  --relay-edge: #99abb8;
  --relay-accent: #76530e;
  --relay-highlight: #196a91;
  --relay-glow: #287fa82b;
  --relay-selected: #f1e5bf;
}
body[data-theta-surface] {
  color: var(--relay-text);
}
body[data-theta-surface] button:not(.theta-appearance-toggle) {
  min-height: 44px;
  min-width: 44px;
  width: auto;
  max-width: 100%;
  padding: .55rem .85rem;
  border: 1px solid var(--relay-edge);
  border-radius: .7rem;
  background: linear-gradient(135deg, var(--relay-raised), var(--relay-surface));
  color: var(--relay-text);
  font: 600 .8125rem/1.3 system-ui, sans-serif;
  letter-spacing: normal;
  box-shadow: inset 0 1px 0 #ffffff12, 0 2px 8px #00000012;
  transition: border-color .15s, box-shadow .15s, transform .15s;
  touch-action: manipulation;
  white-space: normal;
}
body[data-theta-surface] button:not(:disabled):not(.theta-appearance-toggle):hover {
  border-color: var(--relay-highlight);
  box-shadow: 0 0 0 1px var(--relay-glow), 0 0 16px var(--relay-glow);
  transform: translateY(-1px);
}
body[data-theta-surface] button:not(:disabled):not(.theta-appearance-toggle):active {
  transform: translateY(0);
}
body[data-theta-surface] :is(button, a, input, select, textarea):focus-visible {
  outline: 2px solid var(--relay-highlight);
  outline-offset: 3px;
}
body[data-theta-surface] :is(button[aria-pressed="true"], button[aria-current="true"]) {
  border-color: var(--relay-accent);
  background: var(--relay-selected);
  color: var(--relay-accent);
}
body[data-theta-surface] :is(button.gold, button.gold-button, button.send) {
  background: linear-gradient(125deg, #f0d492, #cda345) !important;
  color: #172333 !important;
  border-color: #b8954a !important;
  margin-top: 0;
}
body[data-theta-surface] :is(button.danger, button.end-call) {
  background: #5c2833;
  color: #fff1f1;
  border-color: #bd6575;
}
body[data-theta-surface] .icon-button:not(#new-relay) {
  width: 44px;
  height: 44px;
  padding: .55rem;
  flex-shrink: 0;
}
body[data-theta-surface] #new-relay {
  flex-shrink: 0;
  white-space: nowrap;
}
body[data-theta-surface] :is(.inbox-heading, .conversation-header, .header-actions, .controls, .call-controls, .director-bar) {
  flex-wrap: wrap;
  gap: .5rem;
}
body[data-theta-surface] .inbox-heading {
  align-items: center;
  padding: 1rem;
}
body[data-theta-surface] .relay-inbox-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: .5rem;
  margin: 0 1rem .5rem;
}
body[data-theta-surface] .relay-inbox-actions button {
  width: 100%;
}
body[data-theta-surface] :is(.thread-card, .meeting-card, .detail-action) {
  width: 100% !important;
  text-align: left;
}
body[data-theta-surface] .thread-card {
  padding: .75rem;
}
body[data-theta-surface] .detail-action {
  margin-bottom: .4rem;
}
body[data-theta-surface] .tabs {
  gap: .35rem;
  padding: 0 1rem .75rem;
}
body[data-theta-surface] .tabs button {
  flex-shrink: 0;
  padding: .45rem .65rem;
}
body[data-theta-surface] .relay-citizen-actions {
  grid-template-columns: repeat(auto-fit, minmax(7rem, 1fr));
  margin: .75rem 0 0;
}
body[data-theta-surface] .relay-app-header {
  height: auto;
  min-height: 70px;
}
body[data-theta-surface] dialog {
  padding: 1.25rem;
  border-color: var(--relay-edge);
  background: var(--relay-surface);
  color: var(--relay-text);
}
body[data-theta-surface] dialog .dialog-close {
  float: right;
}
body[data-theta-surface] #relay-ringtone-dialog {
  text-align: left;
}
body[data-theta-surface] #relay-ringtone-dialog label {
  margin-top: .75rem;
}
body[data-theta-surface] :is(input, select, textarea) {
  background-color: var(--relay-field);
  color: var(--relay-text);
  border-color: var(--relay-edge);
}
body[data-theta-surface] :is(.search input, .composer textarea) {
  background: transparent;
}
.relay-music-link {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  margin-left: .65rem;
  color: var(--relay-highlight);
  text-decoration: underline;
}
html[data-theta-appearance="day"] body[data-theta-surface] :is(.inbox, .conversation, .conversation-header, .details, .composer, .composer-foot, .register, .stage-panel, .council, .meeting-entry, .file-shelf, .agenda, .director-bar, .stage-top, #meeting-entry) {
  background: var(--relay-surface) !important;
  color: var(--relay-text) !important;
  border-color: var(--relay-edge) !important;
}
html[data-theta-appearance="day"] body[data-theta-surface] :is(.bubble, .search, .preview-bar, .trade-context, .reply-preview, .quoted, .member, .message, .task, .meeting-file) {
  background: var(--relay-raised) !important;
  color: var(--relay-text) !important;
  border-color: var(--relay-edge) !important;
}
html[data-theta-appearance="day"] body[data-theta-surface] .mine .bubble {
  background: #e6ecdf !important;
}
html[data-theta-appearance="day"] body[data-theta-surface] :is(.thread-intro, .composer-status, .message-meta, .list-label, .detail-note, .muted, .fine, .composer-foot, .inbox-footer, .thread-copy p, .identity p) {
  color: var(--relay-muted) !important;
}
html[data-theta-appearance="day"] body[data-theta-surface] :is(button.danger, button.end-call) {
  background: #fbe8e9 !important;
  color: #802334 !important;
  border-color: #bb6675 !important;
}
@media (max-width: 600px) {
  body[data-theta-surface] .header-actions { width: auto; }
  body[data-theta-surface] .conversation-header { padding: .75rem; }
  body[data-theta-surface] .conversation-header .identity { min-width: 7rem; }
  body[data-theta-surface] .relay-app-header { padding: .75rem; }
  body[data-theta-surface] .controls { gap: .5rem; }
}
@media (prefers-reduced-motion: reduce) {
  body[data-theta-surface] button:not(.theta-appearance-toggle) {
    transition: none;
    transform: none !important;
  }
}

/* Supporting navigation and recovery notices must follow the same appearance. */
html[data-theta-appearance="day"] body[data-theta-surface] > nav,
html[data-theta-appearance="day"] body[data-theta-surface] #relay-access-recovery {
  background: var(--relay-raised) !important;
  color: var(--relay-text) !important;
  border-color: var(--relay-edge) !important;
}
html[data-theta-appearance="day"] body[data-theta-surface] #relay-access-recovery p {
  color: var(--relay-muted) !important;
}
html[data-theta-appearance="day"] body[data-theta-surface] > nav a,
html[data-theta-appearance="day"] body[data-theta-surface] > p > a {
  color: var(--relay-highlight) !important;
}
