:root {
  --bg-dark: #16211c;
  --bg-panel: #1d2b24;
  --bg-elevated: #26382f;
  --bg-input: #111a15;
  --border-subtle: #354c40;
  --border-strong: #537563;
  --text-main: #eef4f0;
  --text-muted: #a9bdb0;
  --accent: #3d8b63;
  --accent-hover: #4ba175;
  --focus-ring: #7fd4a8;
  --danger: #e06c58;
  --target-size: 24px;
}

@media (pointer: coarse) {
  :root {
    --target-size: 44px;
  }
}

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

html,
body {
  margin: 0;
  padding: 0;
  block-size: 100%;
  background-color: var(--bg-dark);
  color: var(--text-main);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans JP", sans-serif;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

h1,
h2,
h3 {
  margin: 0;
  text-wrap: balance;
}

:where(
  button,
  select,
  textarea,
  input:not([type="checkbox"], [type="radio"]),
  [role="button"],
  label:has(input[type="checkbox"], input[type="radio"]),
  input[type="radio"] + label
) {
  min-block-size: var(--target-size);
  min-inline-size: var(--target-size);
}

:where(button, input, textarea) {
  font: inherit;
}

:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
}

.visually-hidden {
  position: absolute;
  clip-path: inset(50%);
  overflow: hidden;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  border: 0;
  white-space: nowrap;
}

.app-shell {
  display: grid;
  grid-template-rows: auto 1fr;
  block-size: 100dvh;
  max-block-size: 100dvh;
  overflow: hidden;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.45rem 0.85rem;
  padding-block: max(0.45rem, env(safe-area-inset-top, 0px)) 0.45rem;
  padding-inline: max(0.75rem, env(safe-area-inset-left, 0px)) max(0.75rem, env(safe-area-inset-right, 0px));
  background-color: var(--bg-panel);
  border-block-end: 1px solid var(--border-subtle);
}

.brand-group {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.45rem;
  min-inline-size: 0;
}

.coop-link {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.875rem;
  font-weight: 600;
}

.coop-link:hover {
  color: var(--text-main);
  text-decoration: underline;
}

.sep {
  color: var(--border-strong);
}

.app-title {
  font-size: clamp(0.95rem, 0.85rem + 0.35vw, 1.15rem);
  font-weight: 700;
  letter-spacing: 0.01em;
}

.zone-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
  background-color: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  color: var(--text-muted);
  font-size: 0.8rem;
  font-weight: 500;
}

.toolbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.45rem;
}

:where(.toolbar > :not(button, input, select, textarea, a, [role="button"], label)) {
  min-inline-size: 0;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  font-size: 0.8rem;
  background-color: var(--bg-input);
  border: 1px solid var(--border-subtle);
  color: var(--text-muted);
}

.status-dot {
  inline-size: 0.5rem;
  block-size: 0.5rem;
  border-radius: 50%;
  background-color: #d4a017;
}

.status-connected .status-dot {
  background-color: #46c37b;
}

.status-disconnected .status-dot {
  background-color: var(--danger);
}

.view-switcher {
  display: inline-flex;
  align-items: center;
  margin: 0;
  padding: 0.14rem;
  border-radius: 0.5rem;
  border: 1px solid var(--border-strong);
  background-color: var(--bg-input);
  gap: 0.14rem;
}

.view-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.2rem 0.62rem;
  border-radius: 0.36rem;
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--text-muted);
  cursor: pointer;
  border: 1px solid transparent;
  transition: background-color 120ms ease, color 120ms ease, border-color 120ms ease;
}

.view-pill:hover {
  color: var(--text-main);
}

.view-switcher input[type="radio"]:checked + .view-pill {
  background-color: var(--accent);
  border-color: #63c792;
  color: #ffffff;
}

.view-switcher input[type="radio"]:focus-visible + .view-pill {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
}

.media-btn,
.profile-btn,
.secondary-btn,
.primary-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.38rem;
  padding: 0.32rem 0.68rem;
  border-radius: 0.45rem;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid var(--border-strong);
  background-color: var(--bg-elevated);
  color: var(--text-main);
  transition: background-color 120ms ease, border-color 120ms ease, box-shadow 150ms ease-out;
}

@media (prefers-reduced-motion: no-preference) {
  :where(.media-btn, .profile-btn, .secondary-btn, .primary-btn, .stage-expand-btn, .chat-delete-btn) {
    transition: background-color 120ms ease, border-color 120ms ease, box-shadow 150ms ease-out, scale 150ms ease-out, opacity 140ms ease;
  }

  :where(.media-btn, .profile-btn, .secondary-btn, .primary-btn, .stage-expand-btn, .chat-delete-btn):active {
    scale: 0.97;
  }
}

.media-btn:hover,
.profile-btn:hover,
.secondary-btn:hover {
  background-color: #31483d;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.28);
}

.media-led {
  inline-size: 0.5rem;
  block-size: 0.5rem;
  border-radius: 50%;
  background-color: #6b7f73;
  flex-shrink: 0;
}

.media-btn[aria-pressed="true"] {
  background-color: #244b38;
  border-color: #63c792;
  color: #ffffff;
}

.media-btn[aria-pressed="true"] .media-led {
  background-color: #46df8d;
  box-shadow: 0 0 6px rgba(70, 223, 141, 0.75);
}

.bike-btn[aria-pressed="true"] {
  background-color: #1d3c47;
  border-color: #1ac2e8;
}

.bike-btn[aria-pressed="true"] .media-led {
  background-color: #1ac2e8;
  box-shadow: 0 0 6px rgba(26, 194, 232, 0.8);
}

.screen-btn[aria-pressed="true"] {
  background-color: #4a3519;
  border-color: #f0b44c;
}

.screen-btn[aria-pressed="true"] .media-led {
  background-color: #f6c453;
  box-shadow: 0 0 6px rgba(246, 196, 83, 0.85);
}

.media-btn[hidden] {
  display: none;
}

.xr-btn[aria-pressed="true"] {
  background-color: #2f2852;
  border-color: #a992ff;
}

.xr-btn[aria-pressed="true"] .media-led {
  background-color: #b8a4ff;
  box-shadow: 0 0 6px rgba(184, 164, 255, 0.85);
}

.primary-btn {
  background-color: var(--accent);
  border-color: #52a97c;
  color: #ffffff;
}

.primary-btn:hover {
  background-color: var(--accent-hover);
}

.color-dot {
  inline-size: 0.7rem;
  block-size: 0.7rem;
  border-radius: 50%;
  background-color: #2d6a4f;
  border: 1px solid rgba(255, 255, 255, 0.65);
  flex-shrink: 0;
}

.edit-tag {
  font-size: 0.72rem;
  font-weight: 500;
  color: var(--text-muted);
  padding-inline-start: 0.15rem;
}

.workspace {
  display: grid;
  grid-template-columns: 1fr 22rem;
  min-block-size: 0;
  overflow: hidden;
}

@media (max-width: 820px) {
  .workspace {
    grid-template-columns: 1fr;
    grid-template-rows: 52% 48%;
  }
}

.map-stage {
  position: relative;
  min-inline-size: 0;
  min-block-size: 0;
  background-color: #243b29;
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
}

#village-canvas,
#village-canvas-3d {
  display: block;
  inline-size: 100%;
  block-size: 100%;
  touch-action: none;
}

#village-canvas {
  cursor: crosshair;
}

#village-canvas.is-hover-interactive {
  cursor: pointer;
}

#village-canvas-3d {
  cursor: grab;
}

#village-canvas-3d.is-hover-interactive {
  cursor: pointer;
}

#village-canvas-3d:active {
  cursor: grabbing;
}

#village-canvas[hidden],
#village-canvas-3d[hidden] {
  display: none;
}

.minimap-canvas {
  position: absolute;
  inset-block-start: 0.75rem;
  inset-inline-start: 0.75rem;
  inline-size: 168px;
  block-size: 112px;
  border-radius: 0.4rem;
  touch-action: none;
  cursor: pointer;
  z-index: 4;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.36);
}

@media (max-width: 520px) {
  .minimap-canvas {
    inline-size: 126px;
    block-size: 84px;
  }
}

/* Floating Stage Broadcast Viewer + Proximity Video Dock */
.floating-media-stack {
  position: absolute;
  inset-block-start: 0.75rem;
  inset-inline-end: 0.75rem;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.55rem;
  max-inline-size: min(44rem, calc(100% - 12rem));
  pointer-events: none;
  z-index: 5;
}

@media (max-width: 600px) {
  .floating-media-stack {
    max-inline-size: calc(100% - 1.5rem);
    inset-block-start: auto;
    inset-block-end: 2.6rem;
  }
}

.stage-viewer {
  inline-size: min(20rem, 100%);
  border-radius: 0.6rem;
  background-color: rgba(18, 28, 23, 0.95);
  border: 1.5px solid #d9a441;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.48);
  pointer-events: auto;
  overflow: hidden;
}

.stage-viewer[hidden] {
  display: none;
}

.stage-viewer.is-expanded {
  inline-size: min(42rem, calc(100vw - 2rem));
}

.stage-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.35rem 0.5rem;
  padding: 0.35rem 0.55rem;
  background-color: rgba(29, 43, 36, 0.96);
  border-block-end: 1px solid var(--border-subtle);
}

.stage-title-wrap {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.35rem;
  min-inline-size: 0;
}

.stage-live-dot {
  inline-size: 0.48rem;
  block-size: 0.48rem;
  border-radius: 50%;
  background-color: #f6c453;
  box-shadow: 0 0 6px rgba(246, 196, 83, 0.8);
  flex-shrink: 0;
}

.stage-speaker {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-main);
}

.stage-meta {
  font-size: 0.7rem;
  padding: 0.08rem 0.38rem;
  border-radius: 999px;
  background-color: var(--bg-input);
  border: 1px solid var(--border-subtle);
  color: var(--text-muted);
}

.stage-controls {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.stage-rate {
  font-size: 0.7rem;
  font-variant-numeric: tabular-nums;
  color: #8fd9b1;
}

.stage-expand-btn {
  padding: 0.14rem 0.48rem;
  border-radius: 0.35rem;
  border: 1px solid var(--border-strong);
  background-color: var(--bg-elevated);
  color: var(--text-main);
  font-size: 0.72rem;
  font-weight: 600;
  cursor: pointer;
}

.stage-expand-btn:hover {
  background-color: #31483d;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
}

.stage-canvas-wrap {
  position: relative;
  inline-size: 100%;
  aspect-ratio: 16 / 9;
  background-color: #0d1410;
}

.stage-viewer.is-audio-only .stage-canvas-wrap {
  aspect-ratio: auto;
  min-block-size: 4.5rem;
}

#stage-canvas {
  display: block;
  inline-size: 100%;
  block-size: 100%;
  object-fit: contain;
}

.stage-viewer.is-audio-only #stage-canvas {
  display: none;
}

.stage-audio-fallback {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  padding: 0.85rem 0.75rem;
  background: radial-gradient(circle at 50% 45%, #263a2f, #121c17);
}

.stage-audio-fallback[hidden] {
  display: none;
}

.stage-audio-caption {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.video-dock {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0.5rem;
  max-inline-size: 100%;
  pointer-events: none;
}

.video-card {
  position: relative;
  inline-size: 8.75rem;
  aspect-ratio: 4 / 3;
  border-radius: 0.55rem;
  overflow: hidden;
  background-color: #131d18;
  border: 1.5px solid rgba(169, 189, 176, 0.45);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.42);
  pointer-events: auto;
}

.video-card.is-self {
  border-color: #63c792;
}

.video-card.is-screen {
  inline-size: 11.25rem;
  aspect-ratio: 16 / 9;
  border-color: #38bdf8;
}

.video-card video {
  inline-size: 100%;
  block-size: 100%;
  object-fit: cover;
  display: block;
}

.video-card:not(.is-audio-only) video {
  cursor: pointer;
}

.video-card.is-self video {
  transform: scaleX(-1);
}

.video-card.is-screen video,
.video-card.is-self.is-screen video {
  object-fit: contain;
  background-color: #0b110e;
  transform: none;
}

.video-expand-btn {
  position: absolute;
  inset-block-start: 0.3rem;
  inset-inline-end: 0.3rem;
  z-index: 2;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-inline-size: 24px;
  min-block-size: 24px;
  padding: 0.14rem 0.45rem;
  border-radius: 0.34rem;
  border: 1px solid rgba(169, 189, 176, 0.6);
  background-color: rgba(12, 19, 15, 0.86);
  color: #f2f7f4;
  font-size: 0.68rem;
  font-weight: 700;
  line-height: 1.1;
  cursor: pointer;
  opacity: 0;
  transition: opacity 120ms ease, background-color 120ms ease, border-color 120ms ease;
}

.video-expand-btn[hidden] {
  display: none;
}

.video-card:hover .video-expand-btn,
.video-card:focus-within .video-expand-btn,
.video-card.is-screen .video-expand-btn {
  opacity: 1;
}

@media (hover: none) {
  .video-expand-btn {
    opacity: 1;
  }
}

@media (pointer: coarse) {
  .video-expand-btn::after {
    content: "";
    position: absolute;
    inset: -8px;
  }
}

.video-expand-btn:hover {
  background-color: rgba(24, 44, 36, 0.96);
  border-color: var(--focus-ring);
}

.video-expand-btn:focus-visible {
  opacity: 1;
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
}

.video-card.is-audio-only video {
  opacity: 0;
  position: absolute;
  pointer-events: none;
}

.voice-avatar-fallback {
  position: absolute;
  inset: 0;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.25rem;
  background: radial-gradient(circle at 50% 42%, #24382e, #121c17);
}

.video-card.is-audio-only .voice-avatar-fallback {
  display: flex;
}

.voice-circle {
  inline-size: 2.3rem;
  block-size: 2.3rem;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.95rem;
  color: #ffffff;
}

.video-card-label {
  position: absolute;
  inset-inline: 0.35rem;
  inset-block-end: 0.3rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.25rem;
  padding: 0.12rem 0.42rem;
  border-radius: 0.35rem;
  background-color: rgba(12, 19, 15, 0.78);
  color: #f2f7f4;
  font-size: 0.72rem;
  font-weight: 600;
}

.video-card-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rtc-state-dot {
  inline-size: 0.45rem;
  block-size: 0.45rem;
  border-radius: 50%;
  background-color: #d4a017;
  flex-shrink: 0;
}

.rtc-state-dot.is-live {
  background-color: #46df8d;
}

.unmute-banner {
  position: absolute;
  inset-block-start: 0.75rem;
  inset-inline-start: 50%;
  transform: translateX(-50%);
  padding: 0.4rem 0.85rem;
  border-radius: 999px;
  border: 1px solid #ffd166;
  background-color: rgba(20, 31, 25, 0.94);
  color: #ffd166;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  z-index: 6;
}

.walk-hint {
  position: absolute;
  inset-inline-start: 50%;
  inset-block-end: 0.75rem;
  transform: translateX(-50%);
  padding: 0.3rem 0.75rem;
  border-radius: 999px;
  background-color: rgba(17, 26, 21, 0.82);
  border: 1px solid rgba(169, 189, 176, 0.3);
  color: var(--text-main);
  font-size: 0.78rem;
  pointer-events: none;
  white-space: nowrap;
  max-inline-size: calc(100% - 1.5rem);
  overflow: hidden;
  text-overflow: ellipsis;
  transition: opacity 300ms ease;
}

.walk-hint.is-faded {
  opacity: 0;
}

.side-panel {
  container: sidepanel / inline-size;
  display: grid;
  grid-template-rows: auto 1fr auto;
  min-block-size: 0;
  min-inline-size: 0;
  background-color: var(--bg-panel);
  border-inline-start: 1px solid var(--border-subtle);
}

@media (max-width: 820px) {
  .side-panel {
    border-inline-start: 0;
    border-block-start: 1px solid var(--border-subtle);
  }
}

.roster-bar {
  padding: 0.55rem 0.75rem;
  border-block-end: 1px solid var(--border-subtle);
  background-color: rgba(17, 26, 21, 0.35);
}

.roster-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-block-end: 0.4rem;
}

.p2p-caption {
  font-size: 0.72rem;
  color: var(--text-muted);
}

.panel-heading {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.count-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-inline-size: 1.35rem;
  padding: 0.05rem 0.38rem;
  border-radius: 999px;
  background-color: var(--bg-elevated);
  color: var(--text-main);
  font-size: 0.75rem;
}

.roster-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  list-style: none;
  margin: 0;
  padding: 0;
  max-block-size: 4.4rem;
  overflow-y: auto;
}

.roster-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.32rem;
  padding: 0.16rem 0.5rem;
  border-radius: 999px;
  background-color: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  color: var(--text-main);
  font-size: 0.78rem;
  cursor: pointer;
}

.roster-chip:hover {
  border-color: var(--border-strong);
}

.roster-chip.is-self {
  border-color: #65b88b;
}

.chip-media-tag {
  font-size: 0.68rem;
  color: #6ce09f;
  font-weight: 700;
}

.chip-bike-tag {
  font-size: 0.68rem;
  color: #4fd5f3;
  font-weight: 700;
}

.chip-podium-tag {
  font-size: 0.68rem;
  color: #f6c453;
  font-weight: 700;
}

.chip-seat-tag {
  font-size: 0.68rem;
  color: #a9d5bc;
  font-weight: 700;
}

.chip-verified-tag {
  font-size: 0.7rem;
  color: #7fd4a8;
  font-weight: 700;
}

.podium-capture-video {
  position: fixed;
  inset-inline-start: 0;
  inset-block-start: 0;
  inline-size: 1px;
  block-size: 1px;
  opacity: 0.001;
  pointer-events: none;
  z-index: -1;
}

.chat-log {
  padding: 0.65rem 0.75rem;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  min-block-size: 0;
}

.chat-empty {
  color: var(--text-muted);
  font-size: 0.85rem;
  margin: auto 0;
  text-align: center;
  padding: 1rem 0.5rem;
}

.chat-item {
  font-size: 0.88rem;
  line-height: 1.4;
  padding: 0.35rem 0.5rem;
  border-radius: 0.4rem;
  background-color: rgba(17, 26, 21, 0.48);
}

.chat-item.is-system {
  background: transparent;
  padding: 0.1rem 0.25rem;
  color: var(--text-muted);
  font-size: 0.78rem;
}

.chat-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.4rem;
  margin-block-end: 0.12rem;
}

.chat-meta-end {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  flex-shrink: 0;
}

.chat-delete-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  inline-size: 24px;
  block-size: 24px;
  min-inline-size: 24px;
  min-block-size: 24px;
  margin-inline-end: 0.15rem;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 0.32rem;
  background-color: transparent;
  color: var(--text-muted);
  font-size: 0.74rem;
  line-height: 1;
  cursor: pointer;
  opacity: 0;
}

@media (pointer: coarse) {
  .chat-delete-btn::after {
    content: "";
    position: absolute;
    inset: -10px;
  }
}

.chat-item:hover .chat-delete-btn,
.chat-item:focus-within .chat-delete-btn {
  opacity: 1;
}

@media (hover: none) {
  .chat-delete-btn {
    opacity: 1;
  }
}

.chat-delete-btn:hover {
  background-color: rgba(224, 108, 88, 0.18);
  border-color: rgba(224, 108, 88, 0.55);
  color: #ff9c8b;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.24);
}

.chat-author {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-weight: 700;
  font-size: 0.82rem;
}

.chat-time {
  color: var(--text-muted);
  font-size: 0.72rem;
  flex-shrink: 0;
}

.chat-body {
  color: var(--text-main);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.chat-form {
  display: flex;
  align-items: flex-end;
  gap: 0.45rem;
  padding-block: 0.55rem max(0.55rem, env(safe-area-inset-bottom, 0px));
  padding-inline: 0.7rem max(0.7rem, env(safe-area-inset-right, 0px));
  border-block-start: 1px solid var(--border-subtle);
  background-color: var(--bg-panel);
}

#chat-input {
  flex: 1;
  inline-size: 100%;
  min-inline-size: 0;
  block-size: auto;
  field-sizing: content;
  min-block-size: 2.375rem;
  max-block-size: 10lh;
  overflow-y: auto;
  font-size: max(1rem, 1em);
  line-height: 1.35;
  padding: 0.5rem 0.65rem;
  border-radius: 0.45rem;
  border: 1px solid var(--border-strong);
  background-color: var(--bg-input);
  color: var(--text-main);
  resize: none;
}

#chat-input::placeholder {
  color: var(--text-muted);
}

dialog {
  padding: 0;
  border: 1px solid var(--border-strong);
  border-radius: 0.75rem;
  background-color: var(--bg-panel);
  color: var(--text-main);
  max-inline-size: min(26rem, calc(100vw - 1.5rem));
  inline-size: 100%;
  box-shadow: 0 18px 42px rgba(0, 0, 0, 0.55);
}

dialog:modal {
  overscroll-behavior: contain;
}

dialog::backdrop {
  overflow: hidden;
  overscroll-behavior: contain;
  background-color: rgba(10, 16, 13, 0.62);
  backdrop-filter: blur(2px);
}

.dialog-card {
  padding: 1.15rem 1.25rem;
}

.dialog-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-block-end: 1rem;
}

.dialog-header h2 {
  font-size: 1.1rem;
}

.icon-close-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border-subtle);
  border-radius: 0.4rem;
  background-color: var(--bg-elevated);
  color: var(--text-main);
  cursor: pointer;
  padding: 0.25rem 0.5rem;
}

.icon-close-btn::after {
  content: "";
  position: absolute;
  inset: -8px;
}

.field {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.28rem;
  margin-block-end: 1.15rem;
}

.field label {
  font-size: 0.9rem;
  font-weight: 600;
}

.field input {
  font-size: max(1rem, 1em);
  padding: 0.55rem 0.7rem;
  min-block-size: 48px;
  border-radius: 0.45rem;
  border: 1px solid var(--border-strong);
  background-color: var(--bg-input);
  color: var(--text-main);
}

.field input:user-invalid {
  border-color: var(--danger);
}

.field-hint {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.color-fieldset {
  margin: 0 0 1.2rem 0;
  padding: 0.7rem 0.8rem;
  border: 1px solid var(--border-subtle);
  border-radius: 0.5rem;
}

.color-fieldset legend {
  padding: 0 0.35rem;
  font-size: 0.88rem;
  font-weight: 600;
}

.radio-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.radio-option {
  display: inline-flex;
  align-items: center;
  gap: 0.38rem;
  padding: 0.3rem 0.6rem;
  border-radius: 0.4rem;
  background-color: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  font-size: 0.85rem;
  cursor: pointer;
}

.radio-option:has(input:checked) {
  border-color: var(--focus-ring);
  background-color: #2c4639;
}

.radio-option input[type="radio"] {
  accent-color: var(--accent);
  margin: 0;
}

.swatch {
  inline-size: 0.85rem;
  block-size: 0.85rem;
  border-radius: 50%;
  background-color: #2d6a4f;
  border: 1px solid rgba(255, 255, 255, 0.7);
}

.swatch-forest {
  background-color: #2d6a4f;
}

.swatch-terracotta {
  background-color: #c8553d;
}

.swatch-cobalt {
  background-color: #2b59c3;
}

.swatch-ochre {
  background-color: #b5830e;
}

.swatch-plum {
  background-color: #7b3f8c;
}

#profile-dialog {
  max-inline-size: min(31rem, calc(100vw - 1.5rem));
  max-block-size: calc(100dvh - 1.75rem);
  overflow-y: auto;
}

.identity-section {
  margin-block-start: 1.15rem;
  padding-block-start: 1rem;
  border-block-start: 1px solid var(--border-subtle);
}

.identity-heading {
  margin: 0 0 0.55rem 0;
  font-size: 0.94rem;
  font-weight: 700;
  color: var(--text-main);
}

.claim-status-msg {
  min-block-size: 1.25rem;
  margin-block-end: 0.45rem;
  font-size: 0.8rem;
  color: #7fd4a8;
}

.claim-status-msg.is-error {
  color: #ff9c8b;
}

.claim-field {
  margin-block-end: 0.7rem;
}

.passkey-zero-email-hint {
  margin: 0 0 0.5rem 0;
}

.claim-field p {
  margin: 0;
}

#claim-otp-input {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 1.2rem;
  letter-spacing: 0.34em;
  min-block-size: 48px;
}

.claim-btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-block-end: 0.75rem;
}

.claimed-summary {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.45rem;
  padding: 0.5rem 0.65rem;
  margin-block-end: 0.65rem;
  border-radius: 0.45rem;
  background-color: var(--bg-input);
  border: 1px solid var(--border-subtle);
}

.verified-pill {
  display: inline-flex;
  align-items: center;
  padding: 0.12rem 0.48rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  background-color: rgba(70, 223, 141, 0.16);
  color: #7fd4a8;
  border: 1px solid rgba(127, 212, 168, 0.55);
}

.claimed-email {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-main);
}

.passkey-count {
  font-size: 0.76rem;
  color: var(--text-muted);
}

.portable-assets-box {
  margin-block-start: 0.65rem;
  padding-block-start: 0.65rem;
  border-block-start: 1px dashed var(--border-subtle);
}

.portable-assets-caption {
  margin: 0 0 0.45rem 0;
  font-size: 0.78rem;
  color: var(--text-muted);
}

#notice-dialog {
  max-inline-size: min(36rem, calc(100vw - 1.5rem));
  max-block-size: calc(100dvh - 1.75rem);
  overflow-y: auto;
}

.notice-dl {
  margin: 0 0 1rem 0;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.notice-row {
  padding: 0.5rem 0.65rem;
  border-radius: 0.45rem;
  background-color: var(--bg-input);
  border: 1px solid var(--border-subtle);
}

.notice-row dt {
  font-size: 0.76rem;
  font-weight: 700;
  color: var(--text-muted);
  margin-block-end: 0.14rem;
}

.notice-row dd {
  margin: 0;
  font-size: 0.88rem;
  color: var(--text-main);
}

.notice-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-block-end: 1rem;
}

.notice-ext-link {
  display: inline-flex;
  align-items: center;
  padding: 0.3rem 0.62rem;
  border-radius: 0.4rem;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--focus-ring);
  background-color: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  text-decoration: none;
}

.notice-ext-link:hover {
  border-color: var(--focus-ring);
  text-decoration: underline;
}

.dialog-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0.55rem;
}

#notify-dialog {
  max-inline-size: min(34rem, calc(100vw - 1.5rem));
  max-block-size: calc(100dvh - 1.75rem);
  overflow-y: auto;
}

.notify-level-list {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.notify-level-card {
  display: flex;
  align-items: flex-start;
  gap: 0.55rem;
  padding: 0.5rem 0.65rem;
  border-radius: 0.45rem;
  background-color: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  cursor: pointer;
}

.notify-level-card:has(input:checked) {
  border-color: var(--focus-ring);
  background-color: #263d31;
}

.notify-level-card input[type="radio"] {
  margin-block-start: 0.2rem;
  flex-shrink: 0;
  accent-color: var(--accent);
}

.notify-level-copy {
  display: flex;
  flex-direction: column;
  gap: 0.14rem;
}

.notify-level-copy strong {
  font-size: 0.88rem;
  color: var(--text-main);
}

.notify-level-copy small {
  font-size: 0.78rem;
  color: var(--text-muted);
  line-height: 1.35;
}

.notify-email-panel {
  margin-block-start: 0.65rem;
  padding-block-start: 0.65rem;
  border-block-start: 1px dashed var(--border-subtle);
}

.notify-session-email-box {
  margin-block-end: 0.7rem;
  padding: 0.55rem 0.65rem;
  border-radius: 0.45rem;
  background-color: var(--bg-input);
  border: 1px solid var(--border-subtle);
}

.notify-session-email-box p {
  margin: 0 0 0.4rem 0;
}

.compact-btn {
  padding: 0.3rem 0.65rem;
  min-block-size: 2.15rem;
  font-size: 0.8rem;
}

#notify-email-otp-input {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 1.15rem;
  letter-spacing: 0.3em;
}

.notify-advanced-details {
  margin-block-end: 1rem;
  border: 1px solid var(--border-subtle);
  border-radius: 0.5rem;
  background-color: rgba(17, 26, 21, 0.32);
}

.notify-advanced-details > summary {
  padding: 0.6rem 0.8rem;
  font-size: 0.86rem;
  font-weight: 600;
  color: var(--text-main);
  cursor: pointer;
}

.notify-advanced-body {
  padding: 0.4rem 0.75rem 0.25rem;
}

.newsletter-dialog-section {
  margin-block-end: 1rem;
  padding-block-start: 0.9rem;
  border-block-start: 1px solid var(--border-subtle);
}

.nl-dialog-header-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-block-end: 0.5rem;
}

.nl-composer-box {
  padding: 0.75rem 0.85rem;
  margin-block-end: 0.85rem;
  border-radius: 0.5rem;
  background-color: var(--bg-input);
  border: 1px solid var(--border-subtle);
}

.nl-composer-hint {
  margin: 0 0 0.6rem 0;
}

.nl-textarea {
  font-family: inherit;
  font-size: max(1rem, 1em);
  line-height: 1.45;
  padding: 0.55rem 0.7rem;
  border-radius: 0.45rem;
  border: 1px solid var(--border-strong);
  background-color: var(--bg-panel);
  color: var(--text-main);
  resize: vertical;
}

.nl-bilingual-details {
  margin-block-end: 0.65rem;
  border: 1px dashed var(--border-subtle);
  border-radius: 0.45rem;
  padding: 0.45rem 0.65rem;
}

.nl-bilingual-details > summary {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
}

.nl-bilingual-inner {
  margin-block-start: 0.6rem;
}

.nl-send-email-row {
  margin-block-end: 0.6rem;
}

.nl-dialog-list {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.nl-issue-card {
  padding: 0.65rem 0.75rem;
  border-radius: 0.45rem;
  background-color: var(--bg-input);
  border: 1px solid var(--border-subtle);
}

.nl-issue-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.4rem;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-block-end: 0.25rem;
}

.nl-issue-title {
  margin: 0 0 0.35rem 0;
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--text-main);
}

.nl-issue-body {
  margin: 0;
  font-size: 0.84rem;
  line-height: 1.5;
  color: var(--text-main);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.nl-delete-btn {
  padding: 0.16rem 0.48rem;
  font-size: 0.74rem;
  border-radius: 0.35rem;
  border: 1px solid rgba(224, 108, 88, 0.55);
  background: transparent;
  color: #ff9c8b;
  cursor: pointer;
}

.notify-intro {
  margin: 0 0 0.65rem 0;
}

.notify-ios-box {
  padding: 0.6rem 0.75rem;
  margin-block-end: 0.75rem;
  border-radius: 0.45rem;
  background-color: #2f2a18;
  border: 1px solid #b5830e;
  color: #f6e7c1;
  font-size: 0.82rem;
}

.notify-ios-box[hidden],
.secondary-btn[hidden] {
  display: none;
}

.notify-check-list {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.notify-check-row {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  min-block-size: max(2rem, var(--target-size));
}

.notify-check-row input[type="checkbox"] {
  inline-size: 1.15rem;
  block-size: 1.15rem;
  margin: 0;
  flex-shrink: 0;
  accent-color: var(--accent);
  cursor: pointer;
}

.notify-check-row label {
  font-size: 0.88rem;
  color: var(--text-main);
  cursor: pointer;
  padding-block: 0.2rem;
}

.notify-time-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.65rem;
  margin-block-start: 0.55rem;
}

.notify-time-field {
  margin-block-end: 0;
}

.notify-privacy-wrap {
  margin-block-start: 0.65rem;
  padding-block-start: 0.55rem;
  border-block-start: 1px dashed var(--border-subtle);
}

.notify-actions {
  margin-block-start: 0.25rem;
}

#arcade-dialog {
  max-inline-size: min(96vw, 86rem);
  inline-size: min(96vw, 86rem);
  block-size: min(90dvh, 54rem);
  max-block-size: calc(100dvh - 1rem);
  overflow: hidden;
  background-color: #111822;
  border-color: #3b5578;
}

#arcade-dialog[open] {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
}

.arcade-dialog-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem 0.85rem;
  padding: 0.48rem 0.75rem;
  background-color: #182230;
  border-block-end: 1px solid #2d425c;
}

.arcade-dialog-title-group {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.55rem;
  min-inline-size: 0;
}

.arcade-dialog-title-group h2 {
  font-size: 0.96rem;
  font-weight: 700;
  color: var(--text-main);
}

.arcade-voice-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.12rem 0.5rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
  background-color: rgba(59, 130, 246, 0.16);
  border: 1px solid rgba(96, 165, 250, 0.45);
  color: #bfdbfe;
  white-space: nowrap;
}

.arcade-dialog-controls {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  flex-shrink: 0;
}

.arcade-tab-link {
  padding: 0.22rem 0.56rem;
  font-size: 0.76rem;
}

.arcade-iframe {
  display: block;
  inline-size: 100%;
  block-size: 100%;
  min-block-size: 0;
  border: 0;
  background-color: #0f141b;
}

.arcade-play-banner {
  position: absolute;
  inset-block-end: 2.85rem;
  inset-inline-start: 50%;
  transform: translateX(-50%);
  z-index: 6;
  min-block-size: 2.375rem;
  padding: 0.45rem 1.05rem;
  border-radius: 999px;
  border: 1.5px solid #38bdf8;
  background-color: rgba(15, 23, 42, 0.94);
  color: #e0f2fe;
  font-size: 0.86rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  cursor: pointer;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.45);
  white-space: nowrap;
  transition: background-color 120ms ease, border-color 120ms ease, transform 120ms ease;
}

.arcade-play-banner[hidden] {
  display: none;
}

.arcade-play-banner:hover {
  background-color: rgba(20, 42, 68, 0.98);
  border-color: #7dd3fc;
}

.arcade-play-banner:focus-visible {
  outline: 2px solid #7dd3fc;
  outline-offset: 2px;
}

#screen-viewer-dialog {
  max-inline-size: min(95vw, 84rem);
  inline-size: min(95vw, 84rem);
  block-size: min(88dvh, 52rem);
  max-block-size: calc(100dvh - 1.25rem);
  overflow: hidden;
  background-color: #0d1511;
  border-color: #3a6b56;
}

#screen-viewer-dialog[open] {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
}

.screen-viewer-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem 0.85rem;
  padding: 0.5rem 0.8rem;
  background-color: #14211b;
  border-block-end: 1px solid var(--border-subtle);
}

.screen-viewer-title-group {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  min-inline-size: 0;
}

.screen-viewer-title-group h2 {
  margin: 0;
  font-size: 0.96rem;
  font-weight: 700;
  color: var(--text-main);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.screen-viewer-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.12rem 0.5rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
  background-color: rgba(56, 189, 248, 0.16);
  border: 1px solid rgba(56, 189, 248, 0.48);
  color: #bae6fd;
  white-space: nowrap;
}

.screen-viewer-badge.is-idle {
  background-color: rgba(169, 189, 176, 0.14);
  border-color: rgba(169, 189, 176, 0.36);
  color: var(--text-muted);
}

.screen-viewer-controls {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  flex-shrink: 0;
}

.screen-viewer-action-btn {
  padding: 0.25rem 0.62rem;
  font-size: 0.78rem;
}

.screen-viewer-action-btn[hidden] {
  display: none;
}

.screen-viewer-stage {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  inline-size: 100%;
  block-size: 100%;
  min-block-size: 0;
  background-color: #080d0a;
  overflow: hidden;
}

.screen-viewer-video {
  display: block;
  inline-size: 100%;
  block-size: 100%;
  object-fit: contain;
  background-color: #080d0a;
}

.screen-viewer-video.is-self-cam {
  transform: scaleX(-1);
}

.screen-viewer-video[hidden],
.screen-viewer-empty[hidden] {
  display: none;
}

.screen-viewer-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.85rem;
  padding: 1.5rem;
  text-align: center;
}

.screen-viewer-empty-text {
  margin: 0;
  font-size: 0.92rem;
  color: var(--text-muted);
}

/* --- Non-Modal WebRTC & Web Audio Inspector (iPhone + Desktop) --- */
#audio-diag-dialog {
  position: fixed;
  inset-block-start: auto;
  inset-block-end: max(0.5rem, env(safe-area-inset-bottom, 0px));
  inset-inline-start: auto;
  inset-inline-end: max(0.5rem, env(safe-area-inset-right, 0px));
  margin: 0;
  z-index: 45;
  inline-size: min(56rem, calc(100vw - 1rem));
  max-inline-size: calc(100vw - 1rem);
  max-block-size: min(78dvh, 44rem);
  background-color: rgba(22, 33, 28, 0.97);
  border: 1px solid var(--border-strong);
  border-radius: 0.75rem;
  box-shadow: 0 14px 38px rgba(0, 0, 0, 0.62);
  overflow: hidden;
}

#audio-diag-dialog[open] {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
}

#audio-diag-dialog.is-minimized {
  inline-size: min(30rem, calc(100vw - 1rem));
  max-block-size: none;
}

#audio-diag-dialog.is-minimized .audio-diag-body {
  display: none;
}

.audio-diag-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.45rem 0.75rem;
  padding: 0.5rem 0.75rem;
  background-color: var(--bg-elevated);
  border-block-end: 1px solid var(--border-subtle);
}

.audio-diag-title-group {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.45rem 0.65rem;
  min-inline-size: 0;
}

.audio-diag-title-group h2 {
  font-size: 0.92rem;
  font-weight: 700;
}

.diag-pill-summary {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.74rem;
  padding: 0.12rem 0.48rem;
  border-radius: 999px;
  background-color: var(--bg-input);
  border: 1px solid var(--border-subtle);
  color: var(--text-muted);
  white-space: nowrap;
}

.audio-diag-header-actions {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.audio-diag-body {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  min-block-size: 0;
  padding: 0.65rem 0.75rem;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

.audio-diag-body > * {
  flex-shrink: 0;
}

.diag-kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(10.5rem, 1fr));
  gap: 0.38rem;
}

.diag-kpi-item {
  display: flex;
  flex-direction: column;
  gap: 0.12rem;
  padding: 0.38rem 0.52rem;
  border-radius: 0.45rem;
  background-color: var(--bg-input);
  border: 1px solid var(--border-subtle);
  min-inline-size: 0;
}

.diag-kpi-wide {
  grid-column: 1 / -1;
}

.diag-kpi-label {
  font-size: 0.69rem;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 0.02em;
}

.diag-kpi-val {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.75rem;
  color: var(--text-main);
  overflow-wrap: anywhere;
}

.is-warn-text {
  color: #f4a261;
  font-weight: 600;
}

.diag-controls-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.45rem 0.65rem;
  padding: 0.42rem 0.55rem;
  border-radius: 0.45rem;
  background-color: var(--bg-panel);
  border: 1px solid var(--border-subtle);
}

.diag-field-inline {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.38rem;
}

.diag-field-inline label {
  font-size: 0.76rem;
  font-weight: 600;
  color: var(--text-muted);
  white-space: nowrap;
}

.diag-select {
  padding: 0.25rem 0.45rem;
  border-radius: 0.38rem;
  border: 1px solid var(--border-strong);
  background-color: var(--bg-input);
  color: var(--text-main);
  font-size: 0.78rem;
  max-inline-size: min(21rem, 78vw);
}

.diag-mic-flags {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  margin: 0;
  padding: 0.18rem 0.5rem;
  border-radius: 0.38rem;
  border: 1px solid var(--border-subtle);
}

.diag-mini-legend {
  padding-inline: 0.22rem;
  font-size: 0.68rem;
  color: var(--text-muted);
}

.diag-flag-label {
  display: inline-flex;
  align-items: center;
  gap: 0.22rem;
  font-size: 0.75rem;
  white-space: nowrap;
  cursor: pointer;
}

.diag-table-wrap {
  flex: 0 0 auto;
  overflow: auto;
  max-inline-size: 100%;
  min-block-size: 6.5rem;
  max-block-size: 12rem;
  container-type: inline-size;
  border: 1px solid var(--border-subtle);
  border-radius: 0.45rem;
  background-color: var(--bg-input);
  -webkit-overflow-scrolling: touch;
}

.diag-event-wrap {
  max-block-size: 9.5rem;
}

.diag-table {
  inline-size: max-content;
  min-inline-size: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 0.75rem;
}

.diag-table-caption {
  caption-side: top;
  text-align: start;
  padding: 0.32rem 0.55rem;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-muted);
  background-color: var(--bg-panel);
  border-block-end: 1px solid var(--border-subtle);
}

.diag-table thead {
  position: sticky;
  inset-block-start: 0;
  z-index: 3;
}

.diag-table th,
.diag-table td {
  padding: 0.32rem 0.5rem;
  border-block-end: 1px solid rgba(83, 117, 99, 0.28);
  border-inline-end: 1px solid rgba(83, 117, 99, 0.22);
  white-space: nowrap;
  vertical-align: middle;
}

.diag-table thead th {
  position: relative;
  background-color: var(--bg-elevated);
  color: var(--text-main);
  font-weight: 600;
  text-align: start;
}

.diag-table thead th:has(> button.th-sort-btn) {
  padding: 0;
}

.th-sort-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.3rem;
  inline-size: 100%;
  min-block-size: max(28px, var(--target-size));
  padding: 0.3rem 0.75rem 0.3rem 0.5rem;
  border: 0;
  background: transparent;
  color: inherit;
  font-size: 0.74rem;
  font-weight: 600;
  text-align: start;
  white-space: nowrap;
  cursor: pointer;
}

.th-sort-btn:hover {
  background-color: rgba(127, 212, 168, 0.1);
}

.th-sort-icon {
  font-size: 0.68rem;
  line-height: 1;
}

.diag-table thead th .th-sort-icon::before {
  content: "⇅";
  opacity: 0.55;
}

.diag-table thead th[aria-sort="ascending"] .th-sort-icon::before {
  content: "▲";
  opacity: 1;
  color: var(--focus-ring);
}

.diag-table thead th[aria-sort="descending"] .th-sort-icon::before {
  content: "▼";
  opacity: 1;
  color: var(--focus-ring);
}

.col-resizer {
  position: absolute;
  inset-block: 0;
  inset-inline-end: 0;
  inline-size: 9px;
  cursor: col-resize;
  touch-action: none;
  z-index: 2;
}

.col-resizer:hover,
.col-resizer.is-dragging {
  background-color: rgba(127, 212, 168, 0.45);
}

.diag-table tbody th {
  position: sticky;
  inset-inline-start: 0;
  z-index: 1;
  background-color: #15201b;
  font-weight: 600;
  text-align: start;
}

.col-w-peer {
  min-inline-size: 10rem;
}

.col-w-detail,
.col-detail-cell {
  min-inline-size: 14rem;
}

.col-w-badge {
  min-inline-size: 5.2rem;
}

.col-w-code,
.col-code-cell {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.col-w-num,
.col-num-cell {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  text-align: end;
}

.is-warn-cell {
  color: #f4a261;
  background-color: rgba(224, 108, 88, 0.14);
  font-weight: 600;
}

.diag-empty-cell {
  text-align: center;
  color: var(--text-muted);
  padding: 0.65rem;
}

.diag-export-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.45rem 0.6rem;
}

.diag-copy-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.diag-copy-tip {
  font-size: 0.74rem;
  font-weight: 600;
  color: var(--focus-ring);
  opacity: 0;
  transition: opacity 0.15s ease;
  pointer-events: none;
  white-space: nowrap;
}

.diag-copy-tip:not(:empty) {
  opacity: 1;
}

.diag-upload-status {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.75rem;
  color: var(--focus-ring);
}

.diag-raw-details summary {
  font-size: 0.75rem;
  color: var(--text-muted);
  cursor: pointer;
}

.diag-json-textarea {
  margin-block-start: 0.35rem;
  inline-size: 100%;
  padding: 0.45rem;
  border-radius: 0.4rem;
  border: 1px solid var(--border-subtle);
  background-color: var(--bg-input);
  color: var(--text-main);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.72rem;
  resize: vertical;
}

@media (prefers-reduced-motion: reduce) {
  .diag-copy-tip {
    transition: none;
  }
}

.chat-action-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-inline-size: 24px;
  min-block-size: 24px;
  padding: 0.1rem 0.38rem;
  border: 1px solid var(--border-subtle);
  border-radius: 0.32rem;
  background-color: var(--bg-elevated);
  color: var(--text-muted);
  font-size: 0.7rem;
  font-weight: 600;
  line-height: 1.1;
  cursor: pointer;
  opacity: 0;
  transition: opacity 120ms ease, border-color 120ms ease, color 120ms ease;
}

.chat-item:hover .chat-action-btn,
.chat-item:focus-within .chat-action-btn,
.chat-item.is-long-note .chat-action-btn {
  opacity: 1;
}

@media (hover: none) {
  .chat-action-btn {
    opacity: 1;
  }
}

@media (pointer: coarse) {
  .chat-action-btn::after {
    content: "";
    position: absolute;
    inset: -6px;
  }
}

.chat-action-btn:hover {
  border-color: var(--focus-ring);
  color: var(--text-main);
}

.chat-action-btn:focus-visible {
  opacity: 1;
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
}

#text-viewer-dialog {
  max-inline-size: min(94vw, 56rem);
  inline-size: min(94vw, 56rem);
  block-size: min(86dvh, 48rem);
  max-block-size: calc(100dvh - 1.25rem);
  overflow: hidden;
  background-color: var(--bg-panel);
  border-color: var(--border-strong);
}

#text-viewer-dialog[open] {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
}

.text-viewer-body {
  margin: 0;
  padding: 1rem 1.25rem;
  overflow-y: auto;
  overscroll-behavior: contain;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Noto Sans Mono CJK JP", monospace;
  font-size: 0.88rem;
  line-height: 1.52;
  color: var(--text-main);
  background-color: #0e1612;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}





