:root {
  color-scheme: dark;
  --bg: #070a0e;
  --panel: rgba(15, 22, 31, 0.92);
  --panel-strong: #101821;
  --panel-soft: #141e29;
  --border: rgba(157, 180, 205, 0.14);
  --border-strong: rgba(157, 180, 205, 0.26);
  --text: #f2f7fb;
  --muted: #8ea0b2;
  --accent: #28d7bd;
  --accent-soft: rgba(40, 215, 189, 0.13);
  --accent-strong: #13bfa6;
  --danger: #ff6b7e;
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.32);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  min-height: 100%;
  background: var(--bg);
}

body {
  min-width: 320px;
  min-height: 100vh;
  color: var(--text);
  background:
    radial-gradient(circle at 14% -8%, rgba(40, 215, 189, 0.12), transparent 30rem),
    radial-gradient(circle at 86% 4%, rgba(91, 104, 255, 0.12), transparent 28rem),
    linear-gradient(180deg, #080c11 0%, var(--bg) 55%, #06080b 100%);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.5;
}

button,
input,
textarea {
  color: inherit;
  font: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

a {
  color: inherit;
  text-decoration: none;
}

button {
  border: 0;
}

.commons-topbar {
  position: sticky;
  z-index: 20;
  top: 0;
  border-bottom: 1px solid var(--border);
  background: rgba(7, 10, 14, 0.82);
  backdrop-filter: blur(18px);
}

.topbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: min(1280px, calc(100% - 40px));
  min-height: 68px;
  margin: 0 auto;
  gap: 24px;
}

.commons-brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: 0.96rem;
  font-weight: 800;
  letter-spacing: 0.16em;
}

.brand-mark {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border: 1px solid rgba(40, 215, 189, 0.34);
  border-radius: 9px;
  color: #09110f;
  background: var(--accent);
  box-shadow: 0 0 26px rgba(40, 215, 189, 0.2);
  font-size: 0.67rem;
  letter-spacing: -0.04em;
}

.commons-nav {
  display: flex;
  align-items: center;
  gap: 6px;
}

.commons-nav a {
  padding: 8px 11px;
  border-radius: 8px;
  color: var(--muted);
  font-size: 0.83rem;
  font-weight: 650;
  transition: color 160ms ease, background 160ms ease;
}

.commons-nav a:hover,
.commons-nav a:focus-visible {
  color: var(--text);
  background: rgba(255, 255, 255, 0.05);
  outline: none;
}

.commons-nav a.is-active {
  color: var(--accent);
  background: var(--accent-soft);
}

.commons-shell {
  width: min(1280px, calc(100% - 40px));
  margin: 0 auto;
  padding: 52px 0 72px;
}

.commons-hero {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 36px;
  margin-bottom: 30px;
}

.eyebrow,
.section-kicker {
  display: block;
  color: var(--accent);
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.commons-hero h1 {
  max-width: 760px;
  margin-top: 9px;
  font-size: clamp(2.2rem, 5vw, 4.35rem);
  line-height: 1.02;
  letter-spacing: -0.055em;
}

.commons-hero h1 span {
  color: var(--muted);
  font-weight: 650;
}

.commons-hero p {
  max-width: 660px;
  margin-top: 18px;
  color: var(--muted);
  font-size: clamp(0.96rem, 1.5vw, 1.08rem);
}

.sync-pill {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 9px;
  min-width: 128px;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--muted);
  background: rgba(13, 19, 26, 0.82);
  font-size: 0.78rem;
  font-weight: 700;
}

.sync-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #758495;
  box-shadow: 0 0 0 4px rgba(117, 132, 149, 0.1);
}

.sync-pill.is-live {
  color: #baf8eb;
  border-color: rgba(40, 215, 189, 0.24);
}

.sync-pill.is-live .sync-dot {
  background: var(--accent);
  box-shadow: 0 0 0 4px rgba(40, 215, 189, 0.12), 0 0 16px rgba(40, 215, 189, 0.48);
}

.sync-pill.is-offline {
  color: #ffd3d8;
  border-color: rgba(255, 107, 126, 0.25);
}

.sync-pill.is-offline .sync-dot {
  background: var(--danger);
}

.commons-stats {
  display: flex;
  gap: 10px;
  margin-bottom: 18px;
}

.stat-chip {
  display: inline-flex;
  align-items: baseline;
  gap: 7px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--muted);
  background: rgba(13, 19, 26, 0.7);
  font-size: 0.74rem;
}

.stat-chip strong {
  color: var(--text);
  font-size: 0.88rem;
}

.commons-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 330px;
  align-items: start;
  gap: 18px;
}

.canvas-card,
.control-card {
  border: 1px solid var(--border);
  border-radius: 13px;
  background: linear-gradient(145deg, rgba(16, 24, 33, 0.96), rgba(11, 17, 24, 0.96));
  box-shadow: var(--shadow);
  overflow: hidden;
}

.card-heading {
  display: flex;
  min-height: 74px;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 17px 18px;
  border-bottom: 1px solid var(--border);
}

.card-heading h2 {
  margin-top: 3px;
  font-size: 1.05rem;
  letter-spacing: -0.02em;
}

.zoom-controls {
  display: flex;
  align-items: center;
  gap: 5px;
}

.zoom-controls button {
  min-width: 34px;
  height: 32px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: 7px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.035);
  cursor: pointer;
  font-size: 0.76rem;
  font-weight: 750;
}

.zoom-controls button:hover,
.zoom-controls button:focus-visible {
  color: var(--text);
  border-color: var(--border-strong);
  background: rgba(255, 255, 255, 0.07);
  outline: none;
}

.canvas-viewport {
  position: relative;
  width: 100%;
  aspect-ratio: 1;
  overflow: auto;
  overscroll-behavior: contain;
  background:
    linear-gradient(45deg, rgba(255, 255, 255, 0.018) 25%, transparent 25%),
    linear-gradient(-45deg, rgba(255, 255, 255, 0.018) 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, rgba(255, 255, 255, 0.018) 75%),
    linear-gradient(-45deg, transparent 75%, rgba(255, 255, 255, 0.018) 75%),
    #0b1016;
  background-position: 0 0, 0 8px, 8px -8px, -8px 0;
  background-size: 16px 16px;
  scrollbar-color: rgba(142, 160, 178, 0.4) transparent;
}

.pixel-canvas {
  display: block;
  width: 100%;
  height: auto;
  background: #111827;
  cursor: crosshair;
  image-rendering: pixelated;
  outline: none;
  touch-action: pan-x pan-y;
}

.pixel-canvas:focus-visible {
  box-shadow: inset 0 0 0 3px var(--accent);
}

.selection-strip {
  display: flex;
  min-height: 66px;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  background: rgba(8, 12, 17, 0.72);
}

.selection-swatch {
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 7px;
  background: #111827;
  box-shadow: inset 0 0 0 2px rgba(0, 0, 0, 0.12);
}

.selection-copy {
  display: flex;
  min-width: 0;
  flex: 1;
  flex-direction: column;
}

.selection-copy span {
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 750;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.selection-copy strong {
  overflow: hidden;
  margin-top: 2px;
  font-size: 0.83rem;
  font-weight: 620;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.keyboard-tip {
  color: #68798a;
  font-size: 0.68rem;
}

.control-rail {
  display: grid;
  gap: 18px;
}

.control-card {
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.22);
}

.composer-card {
  padding-bottom: 16px;
}

.selected-coordinate {
  padding: 5px 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.035);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.68rem;
}

.field-block {
  position: relative;
  display: block;
  margin: 16px 16px 0;
}

.field-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
  color: #c6d2dd;
  font-size: 0.73rem;
  font-weight: 750;
}

.field-label em {
  color: #647586;
  font-size: 0.64rem;
  font-style: normal;
  font-weight: 650;
}

.palette {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 7px;
}

.palette-button {
  position: relative;
  aspect-ratio: 1;
  min-width: 0;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 7px;
  cursor: pointer;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.1);
  transition: transform 120ms ease, box-shadow 120ms ease;
}

.palette-button:hover {
  transform: translateY(-1px);
}

.palette-button:focus-visible {
  outline: 2px solid var(--text);
  outline-offset: 2px;
}

.palette-button.is-selected {
  box-shadow:
    0 0 0 2px var(--panel-strong),
    0 0 0 4px var(--accent),
    inset 0 0 0 1px rgba(0, 0, 0, 0.1);
}

.field-block input,
.field-block textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  background: rgba(5, 9, 13, 0.62);
  outline: none;
  transition: border-color 160ms ease, box-shadow 160ms ease;
}

.field-block input {
  height: 42px;
  padding: 0 12px;
}

.field-block textarea {
  min-height: 82px;
  padding: 10px 12px 24px;
  resize: vertical;
  line-height: 1.4;
}

.field-block input::placeholder,
.field-block textarea::placeholder {
  color: #526171;
}

.field-block input:focus,
.field-block textarea:focus {
  border-color: rgba(40, 215, 189, 0.55);
  box-shadow: 0 0 0 3px rgba(40, 215, 189, 0.08);
}

.character-count {
  position: absolute;
  right: 9px;
  bottom: 7px;
  color: #5e6e7e;
  font-size: 0.62rem;
}

.place-button {
  position: relative;
  width: calc(100% - 32px);
  min-height: 45px;
  margin: 16px 16px 0;
  overflow: hidden;
  border-radius: 8px;
  color: #06110f;
  background: var(--accent);
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: 850;
  letter-spacing: 0.01em;
  transition: transform 140ms ease, filter 140ms ease, opacity 140ms ease;
}

.place-button:hover:not(:disabled) {
  filter: brightness(1.08);
  transform: translateY(-1px);
}

.place-button:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 3px;
}

.place-button:disabled {
  color: #71808e;
  background: #1c2732;
  cursor: not-allowed;
  opacity: 0.78;
}

.cooldown-track {
  width: calc(100% - 32px);
  height: 2px;
  margin: 6px 16px 0;
  overflow: hidden;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.04);
}

.cooldown-track span {
  display: block;
  width: 100%;
  height: 100%;
  background: var(--accent);
  transform: scaleX(0);
  transform-origin: left;
}

.privacy-note {
  margin: 13px 16px 0;
  color: #657586;
  font-size: 0.66rem;
  line-height: 1.5;
}

.activity-card {
  min-height: 210px;
}

.activity-list {
  display: grid;
  max-height: 340px;
  overflow: auto;
  padding: 7px;
  scrollbar-color: rgba(142, 160, 178, 0.35) transparent;
}

.activity-item {
  display: grid;
  grid-template-columns: 27px minmax(0, 1fr);
  gap: 10px;
  width: 100%;
  padding: 10px;
  border-radius: 8px;
  color: inherit;
  background: transparent;
  cursor: pointer;
  text-align: left;
}

.activity-item:hover,
.activity-item:focus-visible {
  background: rgba(255, 255, 255, 0.045);
  outline: none;
}

.activity-swatch {
  width: 27px;
  height: 27px;
  margin-top: 1px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 6px;
}

.activity-copy {
  min-width: 0;
}

.activity-copy strong {
  display: block;
  overflow: hidden;
  font-size: 0.74rem;
  font-weight: 650;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.activity-copy span {
  display: block;
  margin-top: 2px;
  color: #697a8b;
  font-size: 0.64rem;
}

.empty-activity {
  padding: 24px 12px;
  color: #657586;
  font-size: 0.74rem;
  text-align: center;
}

.canvas-tooltip {
  position: fixed;
  z-index: 50;
  max-width: 240px;
  padding: 8px 10px;
  border: 1px solid var(--border-strong);
  border-radius: 7px;
  color: var(--text);
  background: rgba(5, 8, 12, 0.94);
  box-shadow: 0 12px 34px rgba(0, 0, 0, 0.4);
  pointer-events: none;
  font-size: 0.7rem;
  line-height: 1.4;
}

.toast {
  position: fixed;
  z-index: 60;
  right: 22px;
  bottom: 22px;
  max-width: min(360px, calc(100vw - 44px));
  padding: 12px 15px;
  border: 1px solid rgba(40, 215, 189, 0.25);
  border-radius: 9px;
  color: #d9fff7;
  background: rgba(10, 25, 23, 0.96);
  box-shadow: 0 18px 44px rgba(0, 0, 0, 0.38);
  font-size: 0.77rem;
  font-weight: 700;
}

.toast.is-error {
  color: #ffe0e4;
  border-color: rgba(255, 107, 126, 0.3);
  background: rgba(35, 13, 18, 0.96);
}

.noscript-message {
  position: fixed;
  right: 20px;
  bottom: 20px;
  left: 20px;
  z-index: 100;
  padding: 14px;
  border: 1px solid rgba(255, 107, 126, 0.3);
  border-radius: 9px;
  color: #ffe0e4;
  background: #231016;
  text-align: center;
}

@media (max-width: 980px) {
  .commons-layout {
    grid-template-columns: minmax(0, 1fr) 300px;
  }

  .keyboard-tip {
    display: none;
  }

  .commons-nav a:nth-child(2),
  .commons-nav a:nth-child(3) {
    display: none;
  }
}

@media (max-width: 820px) {
  .topbar-inner,
  .commons-shell {
    width: min(100% - 28px, 720px);
  }

  .commons-shell {
    padding-top: 34px;
  }

  .commons-hero {
    align-items: flex-start;
    flex-direction: column;
    gap: 20px;
  }

  .commons-layout {
    grid-template-columns: 1fr;
  }

  .canvas-viewport {
    height: min(64vh, 560px);
    aspect-ratio: auto;
  }

  .control-rail {
    grid-template-columns: minmax(0, 1fr);
  }

  .composer-card {
    position: relative;
  }
}

@media (max-width: 560px) {
  .topbar-inner {
    min-height: 60px;
  }

  .commons-brand > span:last-child {
    display: none;
  }

  .commons-nav {
    gap: 2px;
  }

  .commons-nav a {
    padding: 7px 8px;
    font-size: 0.74rem;
  }

  .commons-nav a:first-child {
    display: none;
  }

  .commons-shell {
    width: min(100% - 20px, 520px);
    padding: 28px 0 48px;
  }

  .commons-hero h1 {
    font-size: clamp(2rem, 12vw, 3rem);
  }

  .commons-stats {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .stat-chip {
    align-items: flex-start;
    flex-direction: column;
    gap: 0;
    padding: 8px 9px;
  }

  .stat-chip span {
    line-height: 1.2;
  }

  .canvas-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .zoom-controls {
    width: 100%;
  }

  .zoom-controls button {
    flex: 1;
  }

  .canvas-viewport {
    height: min(58vh, 480px);
  }

  .selection-strip {
    padding: 10px 12px;
  }

  .selection-copy strong {
    max-width: 230px;
  }

  .toast {
    right: 10px;
    bottom: 10px;
    max-width: calc(100vw - 20px);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}
