:root {
  color-scheme: light;
  --bg: #f3efe6;
  --card: #fffdf8;
  --ink: #1d1a16;
  --muted: #5e584f;
  --line: #ddd6c8;
  --accent: #1f4b99;
  --warn: #8a3d12;
}

* { box-sizing: border-box; }

html, body { margin: 0; }

body {
  font-family: "Segoe UI", "Helvetica Neue", Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.4;
}

button, input, textarea { font: inherit; }

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

a { color: var(--accent); }

h1, h2 { line-height: 1.2; }

h1 { margin: 0; font-size: 1.6rem; }

h2, h3 { margin: 0; font-size: 1rem; }

.lede, .muted { color: var(--muted); }

.toolbar {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  padding: 10px 16px;
  background: transparent;
  border-bottom: 0;
}

.toolbar label { font-weight: 600; }

.toolbar select {
  flex: 0 1 auto;
  width: calc(28ch + 16px);
  min-width: 0;
  max-width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  background: white;
  color: var(--ink);
}

body.directory {
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

body.directory .toolbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  color: #f3efe6;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.9);
}

.stage {
  flex: 1 1 auto;
  min-height: 0;
  position: relative;
  overflow: hidden;
  background: #111;
}

body.directory .stage {
  position: absolute;
  inset: 0;
}

.stage img {
  position: absolute;
  width: auto;
  height: auto;
  max-width: none;
  max-height: none;
}

.stage img:not([src]) { display: none; }

#backgrounds {
  object-fit: fill;
  z-index: 0;
}

#spirals {
  object-fit: fill;
  z-index: 1;
  pointer-events: none;
}

@font-face {
  font-family: 'Roboto Condensed';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("/static/fonts/RobotoCondensed-Bold.woff2") format("woff2");
}

.words {
  position: absolute;
  z-index: 3;
  left: 50%;
  margin: 0;
  max-width: min(90vw, 40rem);
  padding: 0 16px;
  text-align: center;
  color: pink;
  font-family: 'Roboto Condensed', sans-serif;
  font-weight: 700;
  line-height: 1.2;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.85);
  pointer-events: none;
  overflow-wrap: anywhere;
  opacity: 0;
  animation: word-colors 3000ms linear infinite;
}

.words-center {
  top: 50%;
  transform: translate(-50%, -50%);
  font-size: 40px;
}

.words-bottom {
  bottom: 1.5rem;
  transform: translateX(-50%);
  font-size: 40px;
}

@keyframes word-colors {
  0%, 100% { color: pink; }
  50% { color: red; }
}

.words:empty { display: none; }

@media (width < 400px) {
  .words { display: none; }
}

.not-found {
  position: absolute;
  inset: 0;
  z-index: 0;
  margin: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  color: #f3efe6;
  font-size: clamp(2rem, 8vw, 5rem);
  font-weight: 700;
  line-height: 1.1;
  text-align: center;
}

.toast-stack {
  position: fixed;
  z-index: 4;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  display: grid;
  gap: 8px;
  width: min(32rem, calc(100% - 32px));
  pointer-events: none;
}

.toast {
  margin: 0;
  padding: 12px 14px;
  background: var(--card);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(29, 26, 22, 0.28);
  overflow-wrap: anywhere;
  max-height: 40vh;
  overflow: auto;
  pointer-events: auto;
}

.chat-toast {
  position: fixed;
  z-index: 5;
  right: 16px;
  bottom: 16px;
  width: min(22rem, calc(100% - 32px));
  display: grid;
  gap: 8px;
  padding: 12px;
  background: var(--card);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(29, 26, 22, 0.28);
}

.chat-toast[hidden] { display: none; }

.chat-toast textarea { min-height: 8rem; }

body.jukebox {
  background: #fff;
  color: #333;
  line-height: 1.5;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

body.jukebox .container {
  max-width: 800px;
  margin: 0 auto;
  padding: 20px;
}

body.jukebox .app-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
}

body.jukebox .app-title {
  font-size: 1.5rem;
  font-weight: 600;
  color: #333;
}

body.jukebox .track-count {
  font-size: 0.85rem;
  font-weight: 400;
  color: #999;
  margin-left: 8px;
}

body.jukebox .track-list { border-top: 1px solid #eee; }

body.jukebox .track-row {
  border-bottom: 1px solid #eee;
  cursor: pointer;
  position: relative;
  transition: background-color 0.2s;
}

body.jukebox .track-row:hover,
body.jukebox .track-row.active { background: #fafafa; }

body.jukebox .track-row.active { cursor: default; }

body.jukebox .track-row.active::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 4px;
  background: #4CAF50;
  border-radius: 0 2px 2px 0;
}

body.jukebox .track-controls-row {
  display: none;
  align-items: center;
  gap: 6px;
  padding: 8px 16px 0 56px;
}

body.jukebox .track-row.active .track-controls-row { display: flex; }

body.jukebox .track-main {
  display: flex;
  align-items: center;
  padding: 12px 16px;
  gap: 12px;
}

body.jukebox .track-number {
  color: #888;
  font-size: 0.85rem;
  min-width: 28px;
  text-align: right;
}

body.jukebox .track-title {
  flex: 1;
  font-size: 0.95rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

body.jukebox .track-row.active .track-title { font-weight: 600; }

body.jukebox .track-player {
  display: none;
  padding: 0 16px 12px 56px;
}

body.jukebox .track-row.active .track-player { display: block; }

body.jukebox .progress-container {
  flex: 1;
  padding: 8px 0;
  cursor: pointer;
}

body.jukebox .player-progress-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

body.jukebox .progress-bar {
  position: relative;
  height: 6px;
  background: #e0e0e0;
  border-radius: 3px;
  overflow: visible;
}

body.jukebox .progress-fill {
  height: 100%;
  background: #4CAF50;
  border-radius: 3px;
  width: 0%;
  transition: width 0.1s linear;
}

body.jukebox .progress-handle {
  position: absolute;
  top: 50%;
  left: 0%;
  width: 14px;
  height: 14px;
  background: #4CAF50;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  opacity: 0;
  transition: opacity 0.2s;
  cursor: grab;
}

body.jukebox .track-row.active:hover .progress-handle,
body.jukebox .progress-handle.dragging { opacity: 1; }

body.jukebox .ctrl-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1rem;
  color: #666;
  padding: 4px 6px;
  border-radius: 4px;
  line-height: 1;
  transition: color 0.15s, background 0.15s;
}

body.jukebox .ctrl-btn:hover {
  color: #333;
  background: #eee;
}

body.jukebox .btn-loop { font-size: 1.1rem; }

body.jukebox .track-row.looping .btn-loop {
  color: #4CAF50;
  background: #e8f5e9;
}

body.jukebox .time-display {
  font-size: 0.75rem;
  color: #888;
  padding-top: 2px;
}

body.jukebox .time-sep { margin: 0 3px; }

body.jukebox #player { display: none; }

.client {
  max-width: 720px;
  margin: 0 auto;
  padding: 28px 16px 48px;
  display: grid;
  gap: 16px;
}

.meta { display: grid; gap: 4px; margin: 0; }

.meta p { margin: 0; }

.client-send { display: grid; gap: 8px; }

.client-send button { justify-self: start; }

#send-status { margin: 0; min-height: 1.2em; }

.memo { display: grid; gap: 6px; }

.memo label { font-weight: 600; }

textarea, .events-memo {
  width: 100%;
  min-width: 0;
  justify-self: stretch;
  box-sizing: border-box;
  font-family: ui-monospace, "Cascadia Code", "Source Code Pro", Menlo, Consolas, monospace;
  background: #1d1a16;
  color: #f3efe6;
  border: 0;
  border-radius: 8px;
  padding: 12px;
  resize: vertical;
}

.notes-label { font-weight: 600; }

.fingerprint-notes {
  min-height: 4.5rem;
  font-family: inherit;
  background: white;
  color: var(--ink);
  border: 1px solid var(--line);
  padding: 8px 10px;
}

.notes-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.notes-status {
  margin: 0;
  color: var(--muted);
  font-size: 0.92rem;
}

.login {
  max-width: 640px;
  margin: 0 auto;
  padding: 48px 16px;
  display: grid;
  gap: 16px;
}

.panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px;
  display: grid;
  gap: 10px;
}

code { font-family: ui-monospace, Menlo, Consolas, monospace; }

.uri {
  display: block;
  overflow-wrap: anywhere;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px;
}

.login form { display: grid; gap: 8px; }

.passphrase { min-height: 6rem; }

.sign-in, .send-form button, .client-send button, .chat-toast button, #start-sound, .logout button {
  border: 0;
  border-radius: 8px;
  background: var(--accent);
  color: white;
  padding: 10px 14px;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
}

button:disabled, input:disabled { cursor: default; opacity: 0.55; }

.error, .warn { color: var(--warn); }

.monitor {
  height: 100vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.monitor-header {
  flex: none;
  padding: 12px 16px;
  background: var(--card);
  border-bottom: 1px solid var(--line);
}

.monitor-header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
}

.monitor-header p { margin: 4px 0 0; }

.who { display: flex; align-items: center; gap: 12px; }

.logout { margin: 0; }

.grid-wrap {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: 12px 16px 16px;
  gap: 8px;
}

.grid {
  flex: 1;
  min-height: 0;
  overflow: auto;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 400px), 1fr));
  gap: 12px;
  align-content: start;
}

.fingerprint-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
  display: grid;
  gap: 8px;
  min-width: 0;
}

.fingerprint-card h2.fingerprint { color: var(--ink); }

.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.connection-tab {
  border: 1px solid var(--line);
  background: transparent;
  border-radius: 999px;
  padding: 4px 10px;
  color: var(--ink);
}

.connection-tab[aria-selected="true"] {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}

.connection {
  background: var(--card);
  border-radius: 8px;
  padding: 8px;
  display: grid;
  gap: 8px;
  min-width: 0;
}

.connection[hidden] { display: none; }

.connection.window-focused { background: white; }

.connection.window-not-visible { background: #c8c8c8; }

.connection.window-visible { background: yellow; }

.connection.window-blurred { background: lightblue; }

.connection.closed { border-color: var(--muted); }

.connection-head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: baseline;
  gap: 4px 12px;
}

.playing { margin: 0; font-weight: 600; overflow-wrap: anywhere; }

.playing:empty { display: none; }

.presence { margin: 0; font-size: 0.85rem; font-weight: 600; }

.place, .where, .screen, .inner, .images, .brand, .opened { margin: 0; overflow-wrap: anywhere; }

.place:empty, .where:empty, .screen:empty, .inner:empty, .images:empty, .brand:empty, .opened:empty { display: none; }

.where, .screen, .inner, .brand { color: var(--muted); }

.geo-credit {
  flex: none;
  margin: 0;
  padding: 6px 16px 10px;
  color: var(--muted);
  font-size: 0.8rem;
}

.connection.closed .presence { color: var(--warn); }

.fingerprint, .send-status {
  margin: 0;
  color: var(--muted);
  font-size: 0.92rem;
}

.send-form, .chat-send { display: flex; gap: 8px; }

.connection-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
}

.chat-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
}

.send-form input, .chat-send input {
  flex: 1;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  background: white;
}

#empty { margin: 0; color: var(--muted); }

.catalog {
  max-width: 1100px;
  margin: 0 auto;
  padding: 28px 16px 48px;
  display: grid;
  gap: 16px;
}

.catalog-sound { display: grid; gap: 6px; justify-items: start; }

.catalog-sound label { font-weight: 600; }

.catalog-sound select {
  width: min(100%, 420px);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  background: white;
  color: var(--ink);
}

.catalog-grid {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 240px), 1fr));
  gap: 12px;
}

.catalog-grid li {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px;
  min-width: 0;
}

.catalog-link {
  display: grid;
  gap: 8px;
  color: inherit;
  text-decoration: none;
}

.catalog-name {
  color: var(--accent);
  font-weight: 600;
  overflow-wrap: anywhere;
}

.catalog-url { font-size: 0.85rem; }
