:root {
  --profile-panel-standard-width: clamp(320px, 31vw, 460px);
  --profile-panel-expanded-width: clamp(400px, 42.857vw, 640px);
  --quilt-cream: #eee1c3;
  --quilt-ink: #26211d;
}

.quilt-page {
  min-height: 100vh;
  overflow: hidden;
}

.quilt-site-header {
  position: relative;
  z-index: 20;
}

.quilt-dev-tag {
  margin-left: 0.2rem;
  color: #d4b96c;
  font-size: 0.55rem;
  font-weight: 800;
  letter-spacing: 0.08em;
}

.quilt-dev-planned {
  align-self: center;
  color: var(--muted);
  cursor: not-allowed;
  font-size: 0.78rem;
  opacity: 0.5;
}

.public-quilt {
  height: calc(100vh - 74px);
  min-height: 32rem;
  background: #111114;
}

.quilt-shell {
  position: relative;
  height: 100%;
  overflow: hidden;
}

.quilt-viewport {
  position: absolute;
  inset: 0;
  overflow: hidden;
  background: #151518;
}

.quilt-canvas {
  display: block;
  width: 100%;
  height: 100%;
  cursor: grab;
  outline: none;
  touch-action: none;
  user-select: none;
}

.quilt-canvas.is-dragging {
  cursor: grabbing;
}

.quilt-canvas.is-placing,
.quilt-canvas.is-placing.is-dragging,
.quilt-canvas.is-panel-editing,
.quilt-canvas.is-panel-editing.is-dragging {
  cursor: crosshair;
}

.quilt-canvas:focus-visible {
  box-shadow: inset 0 0 0 3px rgba(238, 225, 195, 0.76);
}

.quilt-prototype-label,
.quilt-controls,
.quilt-render-stats,
.quilt-debug-panel {
  position: absolute;
  z-index: 5;
}

.quilt-prototype-label {
  top: 1rem;
  left: 1rem;
  display: grid;
  max-width: min(28rem, calc(100vw - 2rem));
  padding: 0.62rem 0.75rem;
  border: 1px solid rgba(238, 225, 195, 0.28);
  background: rgba(24, 22, 22, 0.8);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.22);
  color: var(--quilt-cream);
  pointer-events: none;
  backdrop-filter: blur(8px);
}

.quilt-prototype-label span {
  color: rgba(238, 225, 195, 0.64);
  font-size: 0.67rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.quilt-prototype-label strong {
  margin-top: 0.18rem;
  font-size: 0.86rem;
}

.quilt-controls {
  top: 1rem;
  right: 1rem;
  display: flex;
  flex-wrap: nowrap;
  justify-content: flex-end;
  max-width: min(36rem, calc(100vw - 2rem));
  border: 1px solid rgba(238, 225, 195, 0.28);
  background: rgba(24, 22, 22, 0.86);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.22);
  backdrop-filter: blur(8px);
}

.quilt-controls button {
  min-width: 2.65rem;
  min-height: 2.45rem;
  padding: 0.42rem 0.68rem;
  border: 0;
  border-left: 1px solid rgba(238, 225, 195, 0.18);
  background: transparent;
  color: var(--quilt-cream);
  cursor: pointer;
  font: inherit;
  font-size: 0.78rem;
  font-weight: 700;
}

.quilt-controls button:first-child {
  border-left: 0;
}

.quilt-controls button:hover,
.quilt-controls button:focus-visible,
.quilt-controls button[aria-pressed="true"] {
  background: rgba(238, 225, 195, 0.14);
}

.quilt-render-stats {
  right: 1rem;
  bottom: 1rem;
  padding: 0.5rem 0.65rem;
  border: 1px solid rgba(238, 225, 195, 0.22);
  background: rgba(24, 22, 22, 0.78);
  color: rgba(238, 225, 195, 0.76);
  font: 600 0.7rem/1.35 "Inter", Arial, sans-serif;
  pointer-events: none;
  backdrop-filter: blur(8px);
}

.quilt-debug-panel {
  right: 1rem;
  bottom: 3.55rem;
  display: none;
  min-width: 19rem;
  margin: 0;
  padding: 0.75rem;
  border: 1px solid rgba(238, 225, 195, 0.28);
  background: rgba(16, 15, 16, 0.9);
  color: #d9e2bf;
  font: 0.72rem/1.55 "Inter", Arial, sans-serif;
  pointer-events: none;
}

.quilt-debug-panel[data-open] {
  display: block;
}

.quilt-generator-panel {
  position: absolute;
  z-index: 7;
  top: 0;
  bottom: 0;
  left: 0;
  width: min(430px, calc(100vw - 1rem));
  overflow: hidden;
  border-right: 1px solid rgba(238, 225, 195, 0.28);
  background: rgba(19, 18, 19, 0.985);
  box-shadow: 18px 0 46px rgba(0, 0, 0, 0.34);
  color: var(--text);
  transform: translateX(-102%);
  visibility: hidden;
}

.quilt-generator-panel.is-open {
  transform: translateX(0);
  visibility: visible;
}

.quilt-landmark-panel {
  z-index: 8;
  width: min(470px, calc(100vw - 1rem));
}

.quilt-panel-manager {
  z-index: 9;
  width: min(500px, calc(100vw - 1rem));
}

.quilt-generator-heading,
.world-generator-section-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
}

.quilt-generator-heading {
  padding: 1rem;
  border-bottom: 1px solid var(--border);
}

.quilt-generator-heading h2,
.world-generator-section h3,
.world-generator-section-heading p {
  margin: 0;
}

.quilt-generator-heading h2 {
  font: 600 1.15rem/1.2 "Inter", Arial, sans-serif;
}

.quilt-generator-heading button,
.world-generator-section-heading button,
.world-generator-add,
.world-generator-primary-actions button,
.world-rule-remove {
  border: 1px solid rgba(238, 225, 195, 0.2);
  background: rgba(238, 225, 195, 0.06);
  color: var(--quilt-cream);
  cursor: pointer;
  font: inherit;
}

.quilt-generator-heading button {
  width: 2.35rem;
  height: 2.35rem;
  padding: 0;
  font-size: 1.35rem;
}

.quilt-generator-content {
  height: calc(100% - 72px);
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 1rem;
}

.world-generator-help,
.world-generator-section-heading p,
.world-generator-summary,
.world-generator-status {
  color: var(--muted);
  font-size: 0.76rem;
}

.world-generator-help {
  margin: 0 0 0.8rem;
}

.world-generator-section {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

details.world-generator-section > summary {
  cursor: pointer;
  font-size: 0.84rem;
  font-weight: 700;
}

details.world-generator-section[open] > summary {
  margin-bottom: 0.65rem;
}

.world-generator-grid,
.world-rule-fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.55rem;
}

.world-generator-field {
  display: grid;
  min-width: 0;
  gap: 0.22rem;
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 700;
}

.world-generator-field-wide {
  margin-top: 0.75rem;
}

.world-generator-field input,
.world-generator-field select,
.world-rule-heading > input {
  min-width: 0;
  width: 100%;
  padding: 0.42rem 0.48rem;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 0;
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  font: inherit;
}

.world-generator-field select {
  appearance: auto;
}

.world-generator-field input[type="color"] {
  min-height: 2rem;
  padding: 0.18rem;
}

.world-generator-section-heading button,
.world-generator-add,
.world-generator-primary-actions button {
  padding: 0.42rem 0.58rem;
  font-size: 0.7rem;
  font-weight: 700;
}

.world-generator-section-heading p {
  margin-top: 0.15rem;
}

.quilt-generator-panel[data-resize-edge="right"] > .dev-resize-handle {
  right: 0;
}

.sidebar-section-content {
  margin-top: 0.7rem;
}

.sidebar-section-toggle {
  flex: 0 0 auto;
  min-width: 3.2rem;
}

.world-rule-list {
  display: grid;
  gap: 0.65rem;
  margin-top: 0.7rem;
}

.world-rule-card {
  padding: 0.65rem;
  border: 1px solid rgba(238, 225, 195, 0.18);
  background: rgba(255, 255, 255, 0.025);
}

.world-rule-heading {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 0.45rem;
  margin-bottom: 0.6rem;
}

.world-rule-heading > input {
  font-weight: 700;
}

.district-assignment-heading {
  grid-template-columns: minmax(0, 1fr) auto;
}

.district-assignment-heading span {
  color: var(--muted);
  font-size: 0.64rem;
}

.world-rule-enabled,
.world-generator-checkbox {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  color: var(--muted);
  font-size: 0.68rem;
}

.world-rule-remove {
  padding: 0.3rem 0.4rem;
  color: #dba9a9;
  font-size: 0.62rem;
}

.world-generator-add {
  width: 100%;
  margin-top: 0.65rem;
}

.world-generator-primary-actions {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.5rem;
  margin-top: 1rem;
}

.world-generator-primary-actions button:first-child {
  border-color: rgba(238, 225, 195, 0.48);
  background: rgba(238, 225, 195, 0.14);
}

.world-generator-status {
  display: block;
  min-height: 1.3rem;
  margin-top: 0.7rem;
}

.world-generator-summary {
  margin: 0.3rem 0 2rem;
}

.landmark-manager-actions,
.landmark-editor-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.landmark-manager-actions button,
.landmark-editor-actions button {
  padding: 0.48rem 0.62rem;
  border: 1px solid rgba(238, 225, 195, 0.24);
  background: rgba(238, 225, 195, 0.08);
  color: var(--quilt-cream);
  cursor: pointer;
  font: inherit;
  font-size: 0.7rem;
  font-weight: 700;
}

.landmark-manager-actions button,
.landmark-editor-actions button[data-landmark-action="save"] {
  border-color: rgba(238, 225, 195, 0.48);
  background: rgba(238, 225, 195, 0.14);
}

.landmark-editor-actions button[data-landmark-action="delete"] {
  margin-left: auto;
  color: #dba9a9;
}

.landmark-editor-actions button:disabled {
  cursor: not-allowed;
  opacity: 0.38;
}

.landmark-filter-section {
  margin-top: 0.8rem;
}

.landmark-filter-section + .world-generator-summary {
  margin: 0.7rem 0 0.45rem;
}

.landmark-manager-list {
  display: grid;
  max-height: min(34vh, 22rem);
  overflow-y: auto;
  border: 1px solid rgba(238, 225, 195, 0.14);
  overscroll-behavior: contain;
}

.panel-manager-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  max-height: min(28vh, 18rem);
  overflow-y: auto;
  border: 1px solid rgba(238, 225, 195, 0.14);
  overscroll-behavior: contain;
}

.panel-list-item {
  display: grid;
  gap: 0.12rem;
  min-width: 0;
  padding: 0.55rem 0.62rem;
  border: 0;
  border-right: 1px solid rgba(238, 225, 195, 0.08);
  border-bottom: 1px solid rgba(238, 225, 195, 0.08);
  background: rgba(255, 255, 255, 0.018);
  color: var(--text);
  cursor: pointer;
  text-align: left;
}

.panel-list-item:hover,
.panel-list-item:focus-visible,
.panel-list-item.is-selected {
  background: rgba(238, 225, 195, 0.12);
}

.panel-list-item strong,
.panel-list-item span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.panel-list-item strong {
  font-size: 0.75rem;
}

.panel-list-item span,
.panel-coordinate-inspector {
  color: var(--muted);
  font-size: 0.65rem;
}

.panel-editor-actions,
.panel-paint-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-top: 0.7rem;
}

.panel-editor-actions button,
.panel-paint-tools button {
  padding: 0.46rem 0.58rem;
  border: 1px solid rgba(238, 225, 195, 0.24);
  background: rgba(238, 225, 195, 0.07);
  color: var(--quilt-cream);
  cursor: pointer;
  font: inherit;
  font-size: 0.68rem;
  font-weight: 700;
}

.panel-editor-actions button:first-child,
.panel-paint-tools button[aria-pressed="true"] {
  border-color: rgba(238, 225, 195, 0.55);
  background: rgba(238, 225, 195, 0.16);
}

.panel-editor-actions button:disabled {
  cursor: not-allowed;
  opacity: 0.35;
}

.panel-lock-toggle,
.panel-brush-options {
  margin-top: 0.7rem;
}

.panel-coordinate-inspector {
  min-height: 3.3rem;
  margin: 0.75rem 0 0;
  padding: 0.62rem;
  border: 1px solid rgba(238, 225, 195, 0.14);
  background: rgba(255, 255, 255, 0.025);
  line-height: 1.45;
}

.landmark-list-item {
  display: grid;
  gap: 0.14rem;
  width: 100%;
  padding: 0.55rem 0.62rem;
  border: 0;
  border-bottom: 1px solid rgba(238, 225, 195, 0.1);
  background: rgba(255, 255, 255, 0.018);
  color: var(--text);
  cursor: pointer;
  text-align: left;
}

.landmark-list-item:hover,
.landmark-list-item:focus-visible,
.landmark-list-item.is-selected {
  background: rgba(238, 225, 195, 0.12);
}

.landmark-list-item strong {
  overflow: hidden;
  font-size: 0.78rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.landmark-list-item span,
.landmark-list-limit {
  color: var(--muted);
  font-size: 0.66rem;
}

.landmark-list-limit {
  margin: 0;
  padding: 0.65rem;
}

.landmark-editor-section {
  min-height: 12rem;
}

.landmark-coordinate-grid {
  margin-top: 0.55rem;
}

.landmark-editor-actions {
  margin-top: 0.75rem;
}

.quilt-canvas-error {
  position: absolute;
  inset: 50% auto auto 50%;
  transform: translate(-50%, -50%);
  color: var(--quilt-cream);
}

.quilt-eyebrow {
  margin: 0 0 0.15rem;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.patch-notes {
  position: absolute;
  z-index: 10;
  top: 0;
  right: 0;
  bottom: 0;
  width: var(--profile-panel-standard-width);
  overflow: hidden;
  border-left: 1px solid var(--border);
  background: rgba(20, 20, 23, 0.985);
  box-shadow: -16px 0 40px rgba(0, 0, 0, 0.3);
  transform: translateX(100%);
  visibility: hidden;
}

.patch-notes[data-capacity="expanded"] {
  width: var(--profile-panel-expanded-width);
}

.patch-notes.is-open {
  transform: translateX(0);
  visibility: visible;
}

.world-generator-remote-save {
  display: grid;
  grid-column: 1 / -1;
  gap: 0.22rem;
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 700;
}

.world-generator-remote-save select {
  min-width: 0;
  width: 100%;
  padding: 0.42rem 0.48rem;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 0;
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  font: inherit;
}

.patch-notes[data-resize-edge="left"] > .dev-resize-handle {
  left: 0;
}

.patch-notes-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1rem 0.85rem;
  border-bottom: 1px solid var(--border);
}

.patch-notes-heading h2 {
  margin: 0;
}

.patch-notes-close,
.patch-notes-retry {
  min-height: 2.25rem;
  padding: 0.4rem 0.65rem;
  border: 1px solid var(--border);
  border-radius: 0;
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
  cursor: pointer;
  font: inherit;
}

.patch-notes-close {
  width: 2.35rem;
  padding: 0;
  font-size: 1.35rem;
}

.patch-notes-content {
  height: calc(100% - 74px);
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 1rem;
}

.patch-notes-loading,
.patch-notes-error {
  display: grid;
  gap: 0.65rem;
}

.patch-notes-error {
  justify-items: start;
}

.patch-notes-skeleton {
  height: 1rem;
  background: rgba(255, 255, 255, 0.08);
}

.patch-notes-skeleton:first-child {
  width: 42%;
  height: 7rem;
}

.patch-profile-header {
  display: grid;
  grid-template-columns: 5.5rem 1fr;
  align-items: center;
  gap: 1rem;
}

.patch-profile-preview {
  display: grid;
  width: 5.5rem;
  aspect-ratio: 1;
  place-items: center;
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--patch-color, #526e49);
  color: rgba(255, 255, 255, 0.84);
  font-weight: 700;
}

.patch-profile-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.patch-profile-header h3 {
  margin: 0 0 0.3rem;
}

.patch-profile-location,
.patch-profile-block p,
.patch-profile-empty,
.patch-profile-meta {
  color: var(--muted);
}

.patch-profile-block {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

.patch-profile-block h4 {
  margin: 0 0 0.65rem;
}

.patch-profile-pin,
.patch-profile-build,
.patch-profile-history {
  padding: 0.75rem;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.03);
}

.patch-profile-build + .patch-profile-build {
  margin-top: 0.5rem;
}

.patch-profile-socials {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.patch-profile-socials a {
  padding: 0.45rem 0.6rem;
  border: 1px solid var(--border);
  color: var(--text);
  text-decoration: none;
}

@media (prefers-reduced-motion: no-preference) {
  .patch-notes,
  .quilt-generator-panel {
    transition: transform 180ms ease, visibility 180ms;
  }
}

@media (max-width: 900px) {
  .quilt-prototype-label {
    top: 0.65rem;
    left: 0.65rem;
  }

  .quilt-controls {
    top: auto;
    right: auto;
    bottom: 3.3rem;
    left: 0.65rem;
    flex-wrap: wrap;
    justify-content: flex-start;
    max-width: calc(100vw - 1.3rem);
  }

  .quilt-render-stats {
    right: 0.65rem;
    bottom: 0.65rem;
    left: 0.65rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .quilt-debug-panel {
    right: 0.65rem;
    bottom: 6.4rem;
    min-width: 0;
  }

  .quilt-generator-panel {
    width: min(430px, calc(100vw - 0.65rem)) !important;
  }

  .patch-notes,
  .patch-notes[data-capacity="expanded"] {
    top: auto;
    width: 100% !important;
    height: min(68vh, 620px);
    padding-bottom: env(safe-area-inset-bottom);
    border-top: 1px solid var(--border);
    border-left: 0;
    transform: translateY(100%);
  }

  .patch-notes.is-open {
    transform: translateY(0);
  }
}

@media (max-width: 600px) {
  .public-quilt {
    height: calc(100dvh - 64px);
  }

  .quilt-prototype-label {
    right: 0.65rem;
    max-width: none;
  }

  .quilt-prototype-label strong {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .quilt-controls button[data-quilt-action="debug"] {
    display: none;
  }

  .patch-notes,
  .patch-notes[data-capacity="expanded"] {
    height: min(72dvh, 640px);
  }
}
