:root {
  color-scheme: dark;
  --bg: #0b0d11;
  --ink: #f4f5f6;
  --muted: #9aa3ad;
  --line: rgba(255, 255, 255, 0.1);
  --panel: #15181e;
  --panel-strong: #181c23;
  --surface: #101318;
  --accent: #d8c9a6;
  --accent-strong: #f0dfb6;
  --accent-ink: #16130d;
  --danger: #ff8b84;
  --shadow: 0 18px 44px rgba(0, 0, 0, 0.32);
  --shadow-sm: 0 8px 20px rgba(0, 0, 0, 0.22);
  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 18px;
  --ease: cubic-bezier(0.22, 0.8, 0.24, 1);
  --dur-fast: 140ms;
  --dur: 240ms;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  min-height: 100%;
  scrollbar-color: rgba(240, 223, 182, 0.3) transparent;
  scrollbar-width: thin;
}

::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

::-webkit-scrollbar-thumb {
  background: rgba(240, 223, 182, 0.3);
  border-radius: 8px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background: radial-gradient(1100px 620px at 12% -8%, rgba(240, 223, 182, 0.08), transparent 55%),
    linear-gradient(180deg, #12151b 0%, var(--bg) 46%, #08090c 100%);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 15.5px;
  line-height: 1.45;
  overflow-x: hidden;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

* {
  scrollbar-color: rgba(216, 201, 166, 0.62) rgba(255, 255, 255, 0.06);
  scrollbar-width: thin;
}

*::-webkit-scrollbar {
  height: 10px;
  width: 10px;
}

*::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.06);
  border-radius: 999px;
}

*::-webkit-scrollbar-thumb {
  background: rgba(216, 201, 166, 0.62);
  border: 2px solid #101318;
  border-radius: 999px;
}

*::-webkit-scrollbar-thumb:hover {
  background: rgba(240, 223, 182, 0.78);
}

button,
input,
textarea,
select {
  font: inherit;
}

input,
textarea,
select {
  font-size: max(16px, 1rem);
}

button {
  border: 1px solid rgba(240, 223, 182, 0.45);
  border-radius: var(--radius-sm);
  background: linear-gradient(180deg, var(--accent-strong), var(--accent));
  color: var(--accent-ink);
  cursor: pointer;
  font-weight: 700;
  min-height: 42px;
  padding: 0 16px;
  transition: transform var(--dur-fast) var(--ease), filter var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease);
}

button:hover {
  filter: brightness(1.06);
}

button:active {
  transform: scale(0.96);
}

button:disabled {
  cursor: not-allowed;
  filter: none;
  opacity: 0.52;
  transform: none;
}

button:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible,
a:focus-visible {
  outline: 2px solid rgba(240, 223, 182, 0.75);
  outline-offset: 2px;
}

a {
  color: var(--accent-strong);
  font-weight: 700;
  overflow-wrap: anywhere;
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

.shell {
  width: min(1180px, calc(100% - 28px));
  margin: 0 auto;
  min-height: 100vh;
  padding: max(18px, var(--safe-top)) 0 18px;
  padding-left: var(--safe-left);
  padding-right: var(--safe-right);
}

.topbar {
  align-items: center;
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.brand {
  align-items: center;
  display: flex;
  gap: 12px;
  min-width: 0;
}

.brand-mark {
  align-items: center;
  background: linear-gradient(150deg, var(--accent-strong), var(--accent));
  border-radius: 12px;
  box-shadow: var(--shadow-sm);
  color: var(--accent-ink);
  display: flex;
  flex-shrink: 0;
  height: 42px;
  justify-content: center;
  width: 42px;
}

.brand-mark svg {
  height: 22px;
  width: 22px;
}

.eyebrow,
.label {
  color: var(--accent);
  font-size: 0.76rem;
  font-weight: 700;
  margin: 0 0 5px;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  background: linear-gradient(120deg, #ffffff, #cfd3d8 70%);
  background-clip: text;
  -webkit-background-clip: text;
  color: transparent;
  font-size: clamp(1.7rem, 4.4vw, 2.7rem);
  font-weight: 780;
  line-height: 1.04;
  margin-bottom: 0;
  overflow-wrap: anywhere;
}

h2 {
  color: #ffffff;
  font-size: 1.3rem;
  font-weight: 740;
  line-height: 1.18;
  margin-bottom: 0;
}

h3 {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
  margin: 14px 0 8px;
  text-transform: uppercase;
}

.panel {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.025), rgba(255, 255, 255, 0)), var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}

.network-card,
.metric-row,
.usage-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.network-card {
  display: grid;
  gap: 2px;
  min-width: 190px;
  padding: 9px 12px;
}

.network-card span,
.metric-row span,
.room-head span {
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
}

.network-card strong,
.metric-row strong {
  color: #ffffff;
  font-weight: 720;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.connect-panel {
  align-items: stretch;
  display: grid;
  gap: 14px;
  grid-template-columns: minmax(270px, 0.95fr) minmax(340px, 1.18fr) minmax(300px, 0.9fr);
  padding: 16px;
}

.connect-card {
  align-items: center;
  display: grid;
  gap: 16px;
  grid-template-columns: 120px minmax(0, 1fr);
}

.qr-wrap {
  align-items: center;
  aspect-ratio: 1;
  background: #ffffff;
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  display: flex;
  justify-content: center;
  overflow: hidden;
  padding: 8px;
  width: 120px;
}

.qr-wrap img {
  display: block;
  height: 100%;
  object-fit: contain;
  width: 100%;
}

.address-list {
  color: var(--muted);
  display: grid;
  font-size: 0.88rem;
  gap: 4px;
  margin-top: 6px;
}

#primaryUrl {
  display: inline-block;
  font-size: 1.08rem;
  margin-top: 2px;
}

.usage-card {
  display: grid;
  gap: 10px;
  padding: 14px;
}

.usage-card h2 {
  font-size: 1rem;
}

.usage-card ol {
  color: var(--muted);
  display: grid;
  gap: 8px;
  margin: 0;
  padding-left: 20px;
}

.usage-card li::marker {
  color: var(--accent);
  font-weight: 800;
}

.metric-grid {
  display: grid;
  gap: 8px;
  grid-template-columns: 1fr;
}

.metric-row {
  display: grid;
  gap: 3px;
  min-width: 0;
  padding: 10px;
  transition: border-color var(--dur) var(--ease), background var(--dur) var(--ease);
}

.metric-row:hover {
  background: rgba(255, 255, 255, 0.045);
  border-color: rgba(255, 255, 255, 0.18);
}

.room-panel {
  margin-top: 18px;
  padding: 18px;
}

.section-heading {
  align-items: center;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.pin-lookup {
  display: grid;
  gap: 8px;
}

.pin-lookup label {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 700;
  text-transform: uppercase;
}

.pin-row {
  display: grid;
  gap: 10px;
  grid-template-columns: minmax(0, 1fr) auto;
}

.pin-row input {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #0d1015;
  color: var(--ink);
  font-size: 1.35rem;
  font-weight: 760;
  letter-spacing: 0.08em;
  min-height: 50px;
  padding: 0 14px;
  transition: border-color var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease);
  width: 100%;
}

.pin-row input:focus {
  border-color: rgba(240, 223, 182, 0.7);
  box-shadow: 0 0 0 4px rgba(240, 223, 182, 0.14);
  outline: 0;
}

.composer-row {
  transition: border-color var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease);
}

.composer-row:focus-within {
  border-color: rgba(240, 223, 182, 0.7);
  box-shadow: 0 0 0 4px rgba(240, 223, 182, 0.12);
}

.message {
  color: var(--danger);
  min-height: 20px;
  margin: 0;
}

.join-view {
  animation: panelIn var(--dur) var(--ease) both;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  display: grid;
  gap: 14px;
  margin: 0 auto;
  max-width: 380px;
  padding: 24px;
}

.join-view .section-heading {
  justify-content: center;
  margin-bottom: 4px;
  text-align: center;
}

.join-divider {
  align-items: center;
  color: var(--muted);
  display: flex;
  font-size: 0.8rem;
  gap: 10px;
  text-transform: uppercase;
}

.join-divider::before,
.join-divider::after {
  background: var(--line);
  content: "";
  flex: 1;
  height: 1px;
}

.room-view {
  animation: panelIn var(--dur) var(--ease) both;
  display: grid;
  gap: 12px;
}

.room-head {
  align-items: center;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0.015)), var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  display: grid;
  gap: 14px;
  grid-template-columns: minmax(150px, auto) minmax(220px, 1fr) auto;
  padding: 14px 16px;
}

.room-head strong {
  color: var(--accent-strong);
  display: block;
  font-size: 2rem;
  font-weight: 820;
  letter-spacing: 0.03em;
  line-height: 1;
}

.room-head-meta {
  display: grid;
  gap: 6px;
  justify-items: start;
  min-width: 0;
}

.room-head-meta small {
  color: var(--muted);
}

.device-name-control {
  display: grid;
  gap: 5px;
  max-width: 100%;
}

.device-name-control label,
.machine-filter span {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.device-name-row {
  align-items: center;
  display: flex;
  gap: 8px;
  min-width: 0;
}

.device-name-control input,
.machine-filter select {
  background: rgba(13, 16, 21, 0.88);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  color: var(--ink);
  min-height: 36px;
  outline: 0;
  padding: 0 10px;
  transition: border-color var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease);
}

.device-name-control input {
  max-width: 180px;
  width: 100%;
}

.device-save-button {
  min-height: 36px;
  padding: 0 12px;
  white-space: nowrap;
}

.device-save-button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.device-name-control input:focus,
.machine-filter select:focus {
  border-color: rgba(240, 223, 182, 0.72);
  box-shadow: 0 0 0 3px rgba(240, 223, 182, 0.12);
}

.room-head-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.sync-indicator {
  align-items: center;
  color: var(--muted, #9aa0a6);
  display: flex;
  font-size: 0.78rem;
  gap: 6px;
}

.sync-dot {
  background: var(--accent-strong, #d4af37);
  border-radius: 50%;
  display: inline-block;
  height: 7px;
  transition: background var(--dur) var(--ease);
  width: 7px;
}

.sync-indicator.is-syncing .sync-dot {
  animation: sync-pulse 0.6s ease-out;
}

.sync-indicator.is-reconnecting {
  color: var(--danger);
}

.sync-indicator.is-reconnecting .sync-dot {
  animation: sync-blink 1s ease-in-out infinite;
  background: var(--danger);
}

@keyframes sync-pulse {
  0% {
    box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent-strong, #d4af37) 60%, transparent);
    transform: scale(1);
  }
  60% {
    box-shadow: 0 0 0 6px transparent;
    transform: scale(1.4);
  }
  100% {
    box-shadow: 0 0 0 0 transparent;
    transform: scale(1);
  }
}

@keyframes sync-blink {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.25;
  }
}

@keyframes panelIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes popIn {
  from {
    opacity: 0;
    transform: scale(0.96) translateY(4px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

@keyframes feedRowIn {
  from {
    opacity: 0;
    transform: translateY(8px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.feed-list {
  align-content: start;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  display: grid;
  gap: 10px;
  min-height: 300px;
  overflow: visible;
  padding: 14px;
  transition: border-color var(--dur) var(--ease), background var(--dur) var(--ease);
}

.feed-list.is-over {
  background: #171c22;
  border-color: rgba(240, 223, 182, 0.8);
  box-shadow: 0 0 0 3px rgba(240, 223, 182, 0.14) inset;
}

.feed-list > .own {
  justify-self: end;
}

.feed-list > .other {
  justify-self: start;
}

.feed-list > .is-new {
  animation: feedRowIn 360ms var(--ease) both;
  animation-delay: calc(var(--i, 0) * 30ms);
}

.composer {
  display: grid;
  gap: 8px;
  position: sticky;
  bottom: max(10px, var(--safe-bottom));
  z-index: 5;
}

.composer-row {
  align-items: end;
  background: rgba(24, 28, 35, 0.96);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 16px 32px rgba(0, 0, 0, 0.28);
  display: flex;
  gap: 8px;
  padding: 8px;
}

.composer-row textarea {
  background: transparent;
  border: 0;
  color: var(--ink);
  flex: 1;
  max-height: 160px;
  min-height: 38px;
  outline: none;
  padding: 8px 4px;
  resize: none;
}

.ghost-button,
.copy-button {
  background: rgba(255, 255, 255, 0.07);
  border-color: var(--line);
  color: var(--ink);
}

.danger-button {
  background: rgba(255, 139, 132, 0.1);
  border-color: rgba(255, 139, 132, 0.45);
  color: var(--danger);
}

.danger-button:hover {
  background: rgba(255, 139, 132, 0.2);
}

.danger-button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.is-copied {
  background: rgba(216, 201, 166, 0.18);
  border-color: rgba(240, 223, 182, 0.75);
  color: var(--accent-strong);
}

.confirm-box {
  animation: popIn var(--dur-fast) var(--ease) both;
  background: rgba(255, 139, 132, 0.08);
  border: 1px solid rgba(255, 139, 132, 0.28);
  border-radius: var(--radius);
  display: grid;
  gap: 10px;
  padding: 12px;
}

.confirm-box p {
  color: #ffffff;
  margin-bottom: 0;
}

.confirm-box div {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

.preview-modal {
  align-items: center;
  display: flex;
  inset: 0;
  justify-content: center;
  padding: 16px;
  padding: max(16px, var(--safe-top)) max(16px, var(--safe-right)) max(16px, var(--safe-bottom)) max(16px, var(--safe-left));
  position: fixed;
  z-index: 50;
}

.preview-backdrop {
  background: rgba(0, 0, 0, 0.78);
  inset: 0;
  position: absolute;
}

.preview-dialog {
  animation: popIn var(--dur) var(--ease) both;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  display: grid;
  grid-template-rows: auto 1fr;
  height: min(96vh, 96dvh);
  max-width: min(1400px, 96vw);
  position: relative;
  width: 100%;
}

.preview-head {
  align-items: center;
  border-bottom: 1px solid var(--line);
  display: flex;
  gap: 12px;
  justify-content: space-between;
  padding: 10px 14px;
}

.preview-head strong {
  color: #ffffff;
  overflow: hidden;
  overflow-wrap: anywhere;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.preview-body {
  align-items: center;
  display: grid;
  justify-items: center;
  min-height: 0;
  overflow: auto;
  overscroll-behavior: contain;
  padding: 10px;
}

.preview-body img,
.preview-body video {
  border-radius: 8px;
  max-height: 100%;
  max-width: 100%;
}

.preview-body.is-image-preview img {
  cursor: zoom-in;
  transition: max-width var(--dur) var(--ease), max-height var(--dur) var(--ease);
}

.preview-body.is-image-preview.is-zoomed {
  align-items: start;
  cursor: zoom-out;
  justify-items: start;
}

.preview-body.is-image-preview.is-zoomed img {
  cursor: zoom-out;
  max-height: none;
  max-width: none;
}

.preview-body iframe {
  background: #ffffff;
  border: 0;
  border-radius: 8px;
  height: 100%;
  width: 100%;
}

.preview-body audio {
  width: 100%;
}

.preview-body pre {
  color: var(--ink);
  font-size: 0.86rem;
  height: 100%;
  margin: 0;
  overflow: auto;
  overscroll-behavior: contain;
  white-space: pre-wrap;
  width: 100%;
  word-break: break-word;
}

.preview-unsupported {
  color: var(--muted);
  display: grid;
  gap: 12px;
  justify-items: center;
  padding: 24px 12px;
  text-align: center;
}

.selection-bar {
  align-items: center;
  animation: popIn var(--dur-fast) var(--ease) both;
  background: rgba(216, 201, 166, 0.1);
  border: 1px solid rgba(240, 223, 182, 0.24);
  border-radius: var(--radius);
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: space-between;
  padding: 10px 12px;
  position: sticky;
  top: 8px;
  z-index: 4;
}

.selection-bar span {
  color: var(--muted);
  font-size: 0.86rem;
}

.selection-bar-info {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.selection-bar-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.attachments-toolbar {
  align-items: end;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: space-between;
}

.machine-filter {
  display: grid;
  gap: 5px;
  min-width: min(240px, 100%);
}

.machine-filter select:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.attachments-toolbar button {
  align-items: center;
  display: inline-flex;
  gap: 8px;
}

.attachments-toolbar button svg {
  height: 15px;
  width: 15px;
}

.row-select {
  align-items: center;
  display: none;
  flex-shrink: 0;
  gap: 8px;
}

.room-view.is-selecting .row-select {
  display: flex;
}

.row-select input {
  appearance: none;
  background: #0d1015;
  border: 1.5px solid rgba(255, 255, 255, 0.2);
  border-radius: 6px;
  cursor: pointer;
  flex: 0 0 auto;
  height: 22px;
  margin: 0;
  position: relative;
  transition: background 120ms ease, border-color 120ms ease, box-shadow 120ms ease, transform 120ms ease;
  width: 22px;
}

.row-select input:hover {
  border-color: rgba(240, 223, 182, 0.6);
}

.row-select input:active {
  transform: scale(0.9);
}

.row-select input:focus-visible {
  box-shadow: 0 0 0 3px rgba(240, 223, 182, 0.14);
  outline: 0;
}

.row-select input:checked,
.row-select input:indeterminate {
  background: var(--accent-strong);
  border-color: var(--accent-strong);
}

.row-select input::after {
  content: "";
  left: 50%;
  opacity: 0;
  position: absolute;
  top: 50%;
  transform: translate(-50%, -55%) rotate(45deg);
  transition: opacity 120ms ease;
}

.row-select input:checked::after {
  border-bottom: 2px solid var(--accent-ink);
  border-right: 2px solid var(--accent-ink);
  height: 10px;
  opacity: 1;
  width: 6px;
}

.row-select input:indeterminate::after {
  background: var(--accent-ink);
  border-radius: 2px;
  height: 2px;
  opacity: 1;
  transform: translate(-50%, -50%);
  width: 10px;
}

.select-all-control {
  cursor: pointer;
  gap: 8px;
}

.select-all-control span {
  color: var(--ink);
  font-size: 0.86rem;
  font-weight: 700;
}

.text-row,
.file-row {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  transition: background var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease), transform var(--dur-fast) var(--ease);
}

.text-row:hover,
.file-row:hover {
  background: rgba(255, 255, 255, 0.045);
  border-color: rgba(255, 255, 255, 0.16);
}

.text-row.own,
.file-row.own {
  background: rgba(216, 201, 166, 0.08);
  border-color: rgba(240, 223, 182, 0.28);
}

.text-row.own:hover,
.file-row.own:hover {
  background: rgba(216, 201, 166, 0.13);
}

.text-row,
.file-row {
  max-width: min(640px, 92%);
}

.text-row {
  display: grid;
  gap: 12px;
  min-height: 0;
  padding: 14px;
}

.text-content {
  color: #ffffff;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.text-meta {
  align-items: center;
  color: var(--muted);
  display: flex;
  flex-wrap: wrap;
  font-size: 0.86rem;
  gap: 10px;
  justify-content: flex-start;
}

.text-meta-actions {
  align-items: center;
  display: flex;
  gap: 8px;
  margin-left: auto;
}

.row-confirm {
  align-items: center;
  animation: popIn var(--dur-fast) var(--ease) both;
  background: rgba(255, 139, 132, 0.08);
  border: 1px solid rgba(255, 139, 132, 0.28);
  border-radius: var(--radius);
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: space-between;
  margin-top: 10px;
  padding: 8px 10px;
}

.row-confirm span {
  color: #ffffff;
  font-size: 0.86rem;
}

.row-confirm-actions {
  display: flex;
  gap: 8px;
}

.icon-button,
.copy-button,
.remove-button,
.preview-button,
.download-link {
  align-items: center;
  display: inline-flex;
  height: 36px;
  justify-content: center;
  min-height: 0;
  padding: 0;
  width: 36px;
}

.icon-button svg,
.copy-button svg,
.remove-button svg,
.preview-button svg,
.download-link svg {
  height: 16px;
  pointer-events: none;
  width: 16px;
}

.preview-button,
.download-link {
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  color: var(--ink);
}

.preview-button:hover,
.download-link:hover {
  filter: brightness(1.1);
}

#joinButton {
  height: 50px;
  min-height: 0;
  width: 50px;
}

.file-row {
  align-items: center;
  display: grid;
  gap: 12px;
  grid-template-columns: auto minmax(0, 1fr) auto;
  min-height: 58px;
  padding: 12px 14px;
}

.file-row-actions {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.file-name {
  color: #ffffff;
  font-weight: 720;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-meta {
  align-items: center;
  color: var(--muted);
  display: flex;
  flex-wrap: wrap;
  font-size: 0.86rem;
  gap: 8px;
}

.sender-pill {
  --sender-hue: 42;
  align-items: center;
  background: hsla(var(--sender-hue), 62%, 62%, 0.16);
  border: 1px solid hsla(var(--sender-hue), 62%, 68%, 0.32);
  border-radius: 999px;
  color: hsl(var(--sender-hue), 70%, 78%);
  display: inline-flex;
  font-size: 0.76rem;
  font-weight: 800;
  line-height: 1;
  max-width: min(220px, 100%);
  min-height: 24px;
  overflow: hidden;
  padding: 0 9px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Image attachments render as photo bubbles: the picture is the focus, filename stays tiny. */
.file-row.photo-card {
  background: transparent;
  border: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-width: min(320px, 84%);
  padding: 0;
  width: fit-content;
}

.file-row.photo-card:hover {
  background: transparent;
  transform: none;
}

.photo-frame {
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  position: relative;
}

.photo-frame .file-thumb {
  aspect-ratio: 4 / 3;
  background: var(--surface);
  border: 0;
  border-radius: 0;
  display: block;
  height: auto;
  min-height: 140px;
  padding: 0;
  width: 100%;
}

.photo-frame .file-thumb img {
  display: block;
  height: 100%;
  object-fit: cover;
  transition: transform 260ms var(--ease);
  width: 100%;
}

.photo-frame .file-thumb:hover img {
  transform: scale(1.035);
}

.photo-select {
  display: none;
  left: 8px;
  position: absolute;
  top: 8px;
}

.room-view.is-selecting .photo-select {
  display: flex;
}

.photo-actions {
  display: flex;
  gap: 6px;
  position: absolute;
  right: 8px;
  top: 8px;
}

.photo-actions .download-link,
.photo-actions .remove-button {
  background: rgba(10, 12, 16, 0.55);
  border: 1px solid rgba(255, 255, 255, 0.16);
  color: #ffffff;
  height: 32px;
  width: 32px;
}

.photo-actions .remove-button {
  border-color: rgba(255, 139, 132, 0.4);
  color: var(--danger);
}

.photo-actions .download-link:hover,
.photo-actions .remove-button:hover {
  filter: brightness(1.25);
}

.photo-caption {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 0 2px;
}

.photo-caption .file-name {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 500;
  max-width: 150px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.photo-caption .sender-pill {
  font-size: 0.68rem;
  min-height: 20px;
  padding: 0 7px;
}

.photo-caption .meta-text {
  color: var(--muted);
  font-size: 0.68rem;
}

.folder-row {
  display: block;
  min-height: 0;
  padding: 0;
}

.folder-summary {
  align-items: center;
  display: flex;
  gap: 12px;
  padding: 12px 14px;
}

.folder-icon {
  align-items: center;
  color: var(--accent);
  display: flex;
  flex-shrink: 0;
}

.folder-icon svg {
  height: 20px;
  width: 20px;
}

.folder-summary > div {
  flex: 1;
  min-width: 0;
}

.folder-toggle {
  flex-shrink: 0;
  min-height: 34px;
  padding: 0 12px;
}

.folder-files {
  border-top: 1px solid var(--line);
  display: grid;
  gap: 10px;
  padding: 12px 14px;
}

.attachment-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  max-height: 160px;
  overflow-y: auto;
}

.attachment-chip {
  align-items: center;
  animation: popIn var(--dur-fast) var(--ease) both;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--line);
  border-radius: 999px;
  display: inline-flex;
  gap: 8px;
  max-width: 220px;
  padding: 4px 6px 4px 4px;
}

.attachment-thumb {
  align-items: center;
  background: var(--surface);
  border-radius: 999px;
  color: var(--accent);
  display: flex;
  flex-shrink: 0;
  height: 30px;
  justify-content: center;
  overflow: hidden;
  width: 30px;
}

.attachment-thumb svg {
  height: 14px;
  width: 14px;
}

.attachment-thumb img {
  display: block;
  height: 100%;
  object-fit: cover;
  width: 100%;
}

.attachment-name {
  color: var(--ink);
  flex: 1;
  font-size: 0.82rem;
  font-weight: 600;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.attachment-remove {
  align-items: center;
  background: transparent;
  border: 0;
  color: var(--muted);
  display: inline-flex;
  flex-shrink: 0;
  height: 24px;
  justify-content: center;
  min-height: 0;
  padding: 0;
  transition: color var(--dur-fast) var(--ease), transform var(--dur-fast) var(--ease);
  width: 24px;
}

.attachment-remove svg {
  height: 12px;
  pointer-events: none;
  width: 12px;
}

.attachment-remove:hover {
  color: var(--danger);
  transform: scale(1.1);
}

.progress-list {
  display: grid;
  gap: 10px;
  max-height: 124px;
  overflow: auto;
}

.progress-item {
  animation: popIn var(--dur-fast) var(--ease) both;
  display: grid;
  gap: 6px;
}

.progress-item header {
  display: flex;
  font-size: 0.86rem;
  justify-content: space-between;
  gap: 8px;
}

.progress-item strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bar {
  background: rgba(232, 236, 239, 0.12);
  border-radius: 999px;
  height: 7px;
  overflow: hidden;
}

.bar span {
  background: linear-gradient(90deg, var(--accent), var(--accent-strong));
  display: block;
  height: 100%;
  transition: width var(--dur) var(--ease);
  width: 0;
}

.empty {
  color: var(--muted);
  padding: 8px 0;
}

@media (max-width: 1000px) {
  .connect-panel {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 940px) {
  .metric-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  .shell {
    width: min(100% - 14px, 1180px);
    padding: max(8px, var(--safe-top)) 0 14px;
  }

  .topbar,
  .connect-card,
  .metric-grid {
    align-items: stretch;
    display: grid;
    grid-template-columns: 1fr;
  }

  .topbar {
    gap: 10px;
    margin-bottom: 10px;
  }

  .brand {
    gap: 10px;
  }

  .brand-mark {
    height: 36px;
    width: 36px;
  }

  .brand-mark svg {
    height: 19px;
    width: 19px;
  }

  .eyebrow {
    font-size: 0.7rem;
    margin-bottom: 4px;
  }

  .connect-panel,
  .room-panel {
    padding: 12px;
  }

  .connect-card {
    justify-items: center;
    text-align: center;
  }

  .qr-wrap {
    border-radius: var(--radius);
    height: 132px;
    padding: 9px;
    width: 132px;
  }

  .qr-wrap img {
    border-radius: 6px;
    height: 100%;
    object-fit: contain;
    width: 100%;
  }

  #primaryUrl {
    display: block;
    font-size: 1rem;
    text-align: center;
  }

  h1 {
    font-size: clamp(1.4rem, 7vw, 1.7rem);
    line-height: 1.05;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  h2 {
    font-size: 1.12rem;
  }

  .pin-row,
  .text-meta,
  .confirm-box div,
  .room-head,
  .selection-bar {
    align-items: stretch;
    display: grid;
    grid-template-columns: 1fr;
  }

  .room-head-actions {
    justify-content: stretch;
  }

  .device-name-control,
  .device-name-row,
  .attachments-toolbar,
  .machine-filter {
    align-items: stretch;
    width: 100%;
  }

  .device-name-control {
    display: grid;
  }

  .device-name-row {
    display: grid;
    grid-template-columns: 1fr;
  }

  .device-name-control input {
    max-width: none;
  }

  .room-head-actions button,
  .selection-bar-actions button,
  .attachments-toolbar button {
    flex: 1;
  }

  .file-row {
    grid-template-columns: 1fr;
  }

  .text-row,
  .file-row {
    max-width: 96%;
  }

  .feed-list > .own,
  .feed-list > .other {
    justify-self: stretch;
  }

  .file-row.photo-card {
    max-width: 100%;
    width: 100%;
  }

  button {
    min-height: 44px;
  }

  .icon-button,
  .copy-button,
  .remove-button,
  .preview-button,
  .download-link {
    height: 40px;
    width: 40px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: 0.001ms !important;
  }
}
