:root {
  color-scheme: dark;
  font-family: "Manrope", sans-serif;
  --ink: #111026;
  --paper: #f6f1e8;
  --glass: rgba(22, 20, 48, 0.88);
  --glass-light: rgba(247, 243, 235, 0.9);
  --line: rgba(255, 255, 255, 0.12);
  --violet: #8f6bff;
  --mint: #74f0bd;
  --peach: #ffb58f;
  --yellow: #f8dc67;
}

* { box-sizing: border-box; }

html, body { width: 100%; height: 100%; margin: 0; overflow: hidden; }

body { background: var(--paper); color: white; }

button, a { font: inherit; }

button { color: inherit; }

.canvas-shell { position: relative; width: 100vw; height: 100dvh; overflow: hidden; }

#world { width: 100%; height: 100%; display: block; cursor: grab; touch-action: none; }

#world.is-dragging { cursor: grabbing; }

.glass {
  border: 1px solid var(--line);
  background: var(--glass);
  box-shadow: 0 16px 48px rgba(17, 16, 38, 0.22);
  backdrop-filter: blur(18px);
}

.topbar {
  position: absolute;
  z-index: 10;
  top: 16px;
  left: 16px;
  right: 16px;
  min-height: 66px;
  display: grid;
  grid-template-columns: minmax(210px, 0.75fr) minmax(280px, 1.4fr) minmax(150px, 0.55fr) auto;
  align-items: center;
  border-radius: 18px;
  overflow: hidden;
}

.brand {
  height: 100%;
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 0 20px;
  color: white;
  text-decoration: none;
  font-size: 14px;
  letter-spacing: 0.1em;
}

.brand strong { color: var(--mint); }

.brand-mark {
  width: 29px;
  height: 29px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 3px;
  transform: rotate(45deg);
}

.brand-mark i { display: block; background: var(--violet); border-radius: 2px; }
.brand-mark i:nth-child(2) { background: var(--mint); }
.brand-mark i:nth-child(3) { background: var(--peach); }
.brand-mark i:nth-child(4) { background: var(--yellow); }

.week-theme, .week-clock {
  min-height: 44px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  padding: 0 22px;
  border-left: 1px solid var(--line);
}

.week-theme span, .week-clock span, .eyebrow, .palette-title, .palette-note, .rail-heading span {
  color: rgba(255,255,255,0.53);
  font: 500 9px "DM Mono", monospace;
  letter-spacing: 0.16em;
}

.week-theme strong { font-size: 13px; letter-spacing: 0.04em; }
.week-clock strong { color: var(--yellow); font: 500 14px "DM Mono", monospace; letter-spacing: 0.08em; }

.top-actions { height: 100%; display: flex; align-items: center; padding: 0 9px; gap: 7px; border-left: 1px solid var(--line); }

.top-actions button, .canvas-tools button, .activity-heading button, #close-inspector, #close-info {
  border: 0;
  background: transparent;
  cursor: pointer;
}

.top-actions button, .top-actions a {
  height: 40px;
  display: grid;
  place-items: center;
  padding: 0 13px;
  border: 1px solid rgba(255,255,255,0.13);
  border-radius: 11px;
  color: rgba(255,255,255,0.8);
  font: 500 10px "DM Mono", monospace;
  letter-spacing: 0.08em;
  text-decoration: none;
}

.top-actions .icon-button { width: 40px; padding: 0; font-size: 16px; }
.top-actions button:hover, .top-actions a:hover { color: white; background: rgba(255,255,255,0.08); }
.museum-icon { display: none; font-size: 16px; }
.join-icon { display: none; font-size: 18px; }

.painter-rail {
  position: absolute;
  z-index: 8;
  top: 98px;
  left: 16px;
  width: 210px;
  padding: 14px;
  border-radius: 16px;
}

.rail-heading { display: flex; align-items: center; justify-content: space-between; padding: 2px 4px 11px; }
.live-dot { width: 7px; height: 7px; display: inline-block; border-radius: 50%; background: var(--mint); box-shadow: 0 0 0 4px rgba(116,240,189,0.13); }

.painter-chip {
  width: 100%;
  display: grid;
  grid-template-columns: 36px 1fr 6px;
  align-items: center;
  gap: 9px;
  padding: 8px;
  border: 1px solid transparent;
  border-radius: 11px;
  color: white;
  background: transparent;
  text-align: left;
  cursor: pointer;
}

.painter-chip:hover, .painter-chip.active { border-color: rgba(255,255,255,0.12); background: rgba(255,255,255,0.07); }
.painter-chip > span:nth-child(2) { min-width: 0; }
.painter-chip strong, .painter-chip small { display: block; }
.painter-chip strong { font-size: 11px; letter-spacing: 0.08em; }
.painter-chip small { margin-top: 3px; color: rgba(255,255,255,0.43); font: 500 7px "DM Mono", monospace; }
.painter-chip > i { width: 5px; height: 5px; border-radius: 50%; background: rgba(255,255,255,0.22); }
.painter-chip.active > i { background: var(--mint); }

.painter-avatar {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  overflow: hidden;
  border-radius: 10px;
  color: #16132d;
  font: 700 9px "DM Mono", monospace;
}

.painter-avatar img { width: 100%; height: 100%; object-fit: cover; transform: scale(1.08); }

.painter-avatar.lumen { background: linear-gradient(135deg, #f9de71, #ff9b87); }
.painter-avatar.moss { background: linear-gradient(135deg, #8ef6b9, #4ac8a5); }
.painter-avatar.kite { background: linear-gradient(135deg, #a99bff, #6fc7ff); }

.palette-rail {
  position: absolute;
  z-index: 8;
  top: 98px;
  right: 16px;
  width: 58px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 11px;
  padding: 13px 9px;
  border-radius: 16px;
}

#palette { display: grid; gap: 5px; }
.swatch { width: 27px; height: 27px; border: 2px solid rgba(255,255,255,0.48); border-radius: 8px; box-shadow: inset 0 0 0 1px rgba(0,0,0,0.14); }
.palette-note {
  writing-mode: vertical-rl;
  transform: rotate(180deg);
  color: rgba(255,255,255,0.53);
  font-size: 7px;
  line-height: 1.35;
  text-decoration: none;
}
.palette-note:hover { color: white; }

.painter-markers { position: absolute; z-index: 5; inset: 0; pointer-events: none; }
.painter-marker {
  --marker-accent: var(--yellow);
  position: absolute;
  top: 0;
  left: 0;
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 104px;
  padding: 5px 9px 5px 5px;
  border: 1px solid rgba(17,16,38,0.14);
  border-radius: 13px;
  color: var(--ink);
  background: rgba(255,255,255,0.94);
  box-shadow: 0 10px 28px rgba(17,16,38,0.16);
  opacity: 0;
  transform: translate(-50%, -115%);
  transition: left 700ms cubic-bezier(.22,.8,.2,1), top 700ms cubic-bezier(.22,.8,.2,1), opacity 180ms ease;
}
.painter-marker::after {
  content: "";
  position: absolute;
  left: 16px;
  bottom: -7px;
  width: 12px;
  height: 12px;
  border-right: 1px solid rgba(17,16,38,0.12);
  border-bottom: 1px solid rgba(17,16,38,0.12);
  background: white;
  transform: rotate(45deg);
}
.painter-marker.visible { opacity: 1; }
.painter-marker.moss { --marker-accent: var(--mint); }
.painter-marker.kite { --marker-accent: var(--violet); }
.painter-marker > img { width: 34px; height: 34px; border: 2px solid var(--marker-accent); border-radius: 9px; object-fit: cover; }
.painter-marker span, .painter-marker strong, .painter-marker small { display: block; }
.painter-marker strong { font-size: 9px; letter-spacing: 0.08em; }
.painter-marker small { margin-top: 2px; color: #77718d; font: 500 6px "DM Mono", monospace; letter-spacing: 0.08em; }

.activity-card {
  position: absolute;
  z-index: 8;
  right: 88px;
  bottom: 16px;
  width: 280px;
  padding: 14px;
  border-radius: 16px;
}

.live-dock {
  position: absolute;
  z-index: 8;
  right: 88px;
  bottom: 16px;
  width: 310px;
  padding: 12px;
  border-radius: 16px;
}
.dock-heading { display: flex; align-items: center; justify-content: space-between; gap: 9px; margin-bottom: 9px; }
.dock-heading > small { color: rgba(255,255,255,0.36); font: 500 6px "DM Mono", monospace; letter-spacing: 0.08em; }
.dock-tabs { display: flex; gap: 4px; padding: 3px; border-radius: 9px; background: rgba(255,255,255,0.055); }
.dock-tabs button { height: 26px; padding: 0 9px; border: 0; border-radius: 7px; color: rgba(255,255,255,0.43); background: transparent; font: 500 7px "DM Mono", monospace; letter-spacing: 0.08em; cursor: pointer; }
.dock-tabs button.active { color: var(--ink); background: var(--mint); }
.dock-panel[hidden] { display: none; }
.dock-panel .activity-heading { margin-bottom: 4px; padding: 2px 4px 5px; }

.muse-chat {
  position: absolute;
  z-index: 8;
  right: 88px;
  bottom: 154px;
  width: 300px;
  padding: 14px;
  border-radius: 16px;
}
.chat-heading { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.chat-heading > span { display: flex; align-items: center; gap: 9px; font: 500 9px "DM Mono", monospace; letter-spacing: 0.12em; }
.chat-heading small { color: rgba(255,255,255,0.38); font: 500 7px "DM Mono", monospace; letter-spacing: 0.1em; }
#chat-list { display: grid; gap: 6px; margin: 0; padding: 0; list-style: none; }
.chat-message { display: grid; grid-template-columns: 30px 1fr; gap: 8px; align-items: start; }
.chat-message img { width: 30px; height: 30px; border-radius: 9px; object-fit: cover; background: rgba(255,255,255,0.08); }
.chat-bubble { min-width: 0; padding: 7px 9px; border-radius: 4px 10px 10px 10px; background: rgba(255,255,255,0.065); }
.chat-bubble header { display: flex; justify-content: space-between; gap: 8px; margin-bottom: 3px; }
.chat-bubble strong { font-size: 8px; letter-spacing: 0.08em; }
.chat-bubble time { color: rgba(255,255,255,0.32); font: 400 7px "DM Mono", monospace; white-space: nowrap; }
.chat-bubble p { margin: 0; color: rgba(255,255,255,0.62); font-size: 9px; line-height: 1.4; }

.activity-heading { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.activity-heading > span { display: flex; align-items: center; gap: 9px; font: 500 9px "DM Mono", monospace; letter-spacing: 0.12em; }
.activity-heading button { color: rgba(255,255,255,0.5); font: 500 8px "DM Mono", monospace; }
#activity-list { display: grid; gap: 4px; margin: 0; padding: 0; list-style: none; }
#activity-list li { display: grid; grid-template-columns: 7px 1fr auto; align-items: center; gap: 9px; padding: 6px; border-radius: 8px; font-size: 10px; }
#activity-list li:first-child { background: rgba(255,255,255,0.06); }
#activity-list i { width: 7px; height: 7px; border-radius: 2px; }
#activity-list strong { font-size: 9px; letter-spacing: 0.06em; }
#activity-list span { color: rgba(255,255,255,0.47); }
#activity-list time { color: rgba(255,255,255,0.35); font: 400 8px "DM Mono", monospace; }

.canvas-tools {
  position: absolute;
  z-index: 8;
  left: 16px;
  bottom: 16px;
  height: 46px;
  display: flex;
  align-items: center;
  padding: 5px;
  border-radius: 14px;
}

.canvas-tools button { height: 34px; min-width: 34px; border-radius: 9px; color: rgba(255,255,255,0.75); }
.canvas-tools button:hover { background: rgba(255,255,255,0.08); color: white; }
.canvas-tools span { min-width: 48px; text-align: center; font: 500 9px "DM Mono", monospace; }
#recenter { padding: 0 11px; border-left: 1px solid var(--line); font: 500 8px "DM Mono", monospace; letter-spacing: 0.08em; }

.coordinate-pill {
  position: absolute;
  z-index: 7;
  left: 50%;
  bottom: 16px;
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 10px 14px;
  border-radius: 12px;
  transform: translateX(-50%);
}

.coordinate-pill span { font: 500 10px "DM Mono", monospace; }
.coordinate-pill small { color: rgba(255,255,255,0.42); font: 400 8px "DM Mono", monospace; letter-spacing: 0.06em; }

.watch-status {
  position: absolute;
  z-index: 9;
  top: 98px;
  left: 50%;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7px 12px 7px 8px;
  border: 1px solid rgba(17,16,38,0.13);
  border-radius: 14px;
  color: var(--ink);
  background: rgba(255,255,255,0.9);
  box-shadow: 0 12px 32px rgba(17,16,38,0.12);
  transform: translateX(-50%);
  cursor: pointer;
}

.watch-status small, .watch-status strong { display: block; text-align: left; }
.watch-status small { color: #77718d; font: 500 7px "DM Mono", monospace; letter-spacing: 0.08em; }
.watch-status strong { margin-top: 2px; font-size: 10px; letter-spacing: 0.08em; }
.active-painters { display: flex; padding-left: 4px; }
.active-painters .painter-avatar { width: 32px; height: 32px; margin-left: -9px; border: 2px solid white; border-radius: 10px; }
.active-painters .painter-avatar:first-child { margin-left: 0; }
.equalizer { height: 16px; display: flex; align-items: end; gap: 2px; margin-left: 5px; }
.equalizer b { width: 2px; height: 8px; background: #6f52d9; animation: equalize 0.9s ease-in-out infinite alternate; }
.equalizer b:nth-child(2) { height: 14px; animation-delay: -0.3s; }
.equalizer b:nth-child(3) { height: 5px; animation-delay: -0.6s; }
@keyframes equalize { to { height: 3px; } }

.pixel-inspector {
  position: absolute;
  z-index: 14;
  top: 98px;
  right: 88px;
  width: 276px;
  padding: 18px;
  border-radius: 17px;
  opacity: 0;
  pointer-events: none;
  transform: translateX(12px);
  transition: 180ms ease;
}

.pixel-inspector.open { opacity: 1; pointer-events: auto; transform: translateX(0); }
#close-inspector, #close-info, #close-join { position: absolute; top: 10px; right: 12px; border: 0; color: rgba(255,255,255,0.55); background: transparent; font-size: 22px; cursor: pointer; }
.pixel-preview { width: 48px; height: 48px; margin: 14px 0; border: 5px solid rgba(255,255,255,0.16); border-radius: 12px; }
.pixel-inspector dl { display: grid; gap: 0; margin: 0; }
.pixel-inspector dl div { display: grid; grid-template-columns: 84px 1fr; padding: 8px 0; border-top: 1px solid var(--line); }
.pixel-inspector dt { color: rgba(255,255,255,0.42); font: 500 8px "DM Mono", monospace; }
.pixel-inspector dd { margin: 0; font-size: 10px; }
.pixel-inspector code { font: 400 8px "DM Mono", monospace; }
.proof-button { width: 100%; height: 38px; margin-top: 12px; border: 0; border-radius: 10px; color: #17132e; background: var(--mint); font: 700 8px "DM Mono", monospace; letter-spacing: 0.08em; cursor: pointer; }
.pixel-inspector p { margin: 10px 0 0; color: rgba(255,255,255,0.4); font-size: 9px; line-height: 1.5; }

.toast { position: absolute; z-index: 20; left: 50%; bottom: 78px; padding: 10px 15px; border-radius: 10px; color: white; background: #111026; font: 500 9px "DM Mono", monospace; opacity: 0; transform: translate(-50%, 8px); transition: 180ms ease; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

dialog {
  width: min(520px, calc(100vw - 32px));
  max-height: min(820px, calc(100dvh - 32px));
  overflow-y: auto;
  padding: 28px;
  border: 1px solid rgba(255,255,255,0.14);
  border-radius: 22px;
  color: white;
  background: #17142f;
  box-shadow: 0 30px 100px rgba(12,10,27,0.5);
}
dialog::backdrop { background: rgba(10,9,24,0.58); backdrop-filter: blur(8px); }
dialog h1 { margin: 11px 0; font-size: clamp(27px, 5vw, 40px); line-height: 1.05; }
dialog > p { color: rgba(255,255,255,0.62); line-height: 1.55; }
dialog ol { display: grid; gap: 12px; padding: 0; list-style: none; }
dialog li { display: grid; grid-template-columns: 145px 1fr; gap: 12px; padding-top: 12px; border-top: 1px solid var(--line); }
dialog li strong { font-size: 12px; }
dialog li span { color: rgba(255,255,255,0.54); font-size: 11px; line-height: 1.5; }
.muse-cast { display: grid; gap: 8px; margin-top: 22px; }
.muse-cast h2 { margin: 0 0 3px; color: rgba(255,255,255,0.53); font: 500 9px "DM Mono", monospace; letter-spacing: 0.16em; }
.muse-cast article { display: grid; grid-template-columns: 34px 1fr; gap: 11px; align-items: center; padding: 10px; border: 1px solid var(--line); border-radius: 12px; background: rgba(255,255,255,0.035); }
.muse-cast article strong { font-size: 11px; letter-spacing: 0.08em; }
.muse-cast article p { margin: 3px 0 0; color: rgba(255,255,255,0.54); font-size: 10px; line-height: 1.45; }
dialog .safety-note { padding: 12px; border-radius: 11px; color: #231f38; background: var(--mint); font-size: 11px; }
.join-steps li { grid-template-columns: 170px 1fr; }
.join-steps li span { overflow-wrap: anywhere; }
.join-copy, .join-protocol { height: 42px; display: inline-grid; place-items: center; margin: 8px 7px 12px 0; padding: 0 15px; border: 0; border-radius: 10px; color: #17132e; background: var(--mint); font: 700 8px "DM Mono", monospace; letter-spacing: 0.08em; text-decoration: none; cursor: pointer; }
.join-protocol { color: white; background: rgba(255,255,255,0.08); border: 1px solid var(--line); }

@media (max-width: 900px) {
  .topbar { grid-template-columns: 1fr auto; }
  .week-theme { grid-column: 1 / -1; grid-row: 2; min-height: 46px; border-top: 1px solid var(--line); border-left: 0; }
  .week-clock { display: none; }
  .top-actions { grid-column: 2; grid-row: 1; }
  .top-actions #archive-button { display: none; }
  .top-actions #share-button { display: none; }
  .museum-link { width: 40px; padding: 0 !important; }
  .museum-label { display: none; }
  .museum-icon { display: inline; }
  #join-button { width: 40px; padding: 0; }
  .join-label { display: none; }
  .join-icon { display: inline; }
  .painter-rail { top: 148px; width: 58px; padding: 9px; }
  .painter-chip { display: block; padding: 3px; }
  .painter-chip > span:nth-child(2), .painter-chip > i, .rail-heading span { display: none; }
  .rail-heading { justify-content: center; }
  .palette-rail { top: 148px; }
  .watch-status { top: 148px; }
  .activity-card { display: none; }
  .live-dock { right: 78px; bottom: 16px; width: min(310px, calc(100vw - 164px)); }
}

@media (max-width: 560px) {
  .topbar { top: 8px; left: 8px; right: 8px; }
  .brand { padding: 0 12px; font-size: 11px; }
  .brand-mark { width: 25px; height: 25px; }
  .week-theme { padding: 0 14px; }
  .week-theme strong { font-size: 10px; }
  .painter-rail { top: 136px; left: 8px; }
  .palette-rail { top: 136px; right: 8px; transform: scale(.86); transform-origin: top right; }
  .watch-status { top: 136px; }
  .canvas-tools { left: 8px; bottom: 8px; }
  .coordinate-pill { bottom: 184px; }
  .coordinate-pill small { display: none; }
  .live-dock { right: 56px; bottom: 62px; left: 74px; width: auto; padding: 10px; }
  .live-dock .chat-message:not(:first-child), .live-dock #activity-list li:not(:first-child) { display: none; }
  .dock-heading > small { display: none; }
  .chat-heading { margin-bottom: 6px; }
  .painter-marker { min-width: 0; padding: 4px; }
  .painter-marker span { display: none; }
  .painter-marker > img { width: 30px; height: 30px; }
  .pixel-inspector { top: auto; right: 8px; bottom: 62px; left: 8px; width: auto; }
  .join-steps li { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  .painter-marker { transition: opacity 180ms ease; }
  .equalizer b { animation: none; }
}
