:root {
  color-scheme: light;
  --paper: #f3efe6;
  --ink: #17202a;
  --muted: #667066;
  --line: rgba(23, 32, 42, 0.16);
  --veil: rgba(247, 243, 232, 0.72);
  --button: rgba(247, 243, 232, 0.54);
  --accent: #8d3f4f;
}

* {
  box-sizing: border-box;
}

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

body {
  overflow: hidden;
  background:
    linear-gradient(90deg, rgba(23, 32, 42, 0.055) 1px, transparent 1px),
    linear-gradient(0deg, rgba(23, 32, 42, 0.045) 1px, transparent 1px),
    var(--paper);
  background-size: 48px 48px;
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

.app-shell,
.stage {
  width: 100vw;
  height: 100vh;
}

.stage {
  position: relative;
}

.stage.gallery-open .view-actions {
  display: none;
}

#topology-canvas {
  display: block;
  width: 100%;
  height: 100%;
  outline: none;
}

.view-actions {
  position: absolute;
  top: 18px;
  right: 18px;
  z-index: 4;
  display: flex;
  gap: 8px;
}

.view-button {
  min-height: 36px;
  padding: 0 14px;
  border: 1px solid rgba(23, 32, 42, 0.14);
  border-radius: 3px;
  background: var(--button);
  color: rgba(23, 32, 42, 0.82);
  font: inherit;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
  backdrop-filter: blur(10px);
  cursor: pointer;
}

.view-button:hover,
.view-button:focus-visible {
  border-color: rgba(141, 63, 79, 0.45);
  color: var(--accent);
  outline: none;
}

.gallery-view {
  position: absolute;
  inset: 0;
  z-index: 3;
  display: grid;
  grid-template-rows: auto auto;
  align-content: start;
  gap: 18px;
  padding: 18px;
  overflow-y: auto;
  background:
    linear-gradient(90deg, rgba(23, 32, 42, 0.05) 1px, transparent 1px),
    linear-gradient(0deg, rgba(23, 32, 42, 0.04) 1px, transparent 1px),
    rgba(243, 239, 230, 0.94);
  background-size: 48px 48px;
  backdrop-filter: blur(16px);
}

.gallery-view[hidden] {
  display: none;
}

.gallery-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 2px 0 0;
}

.gallery-header strong {
  display: block;
  font-size: 21px;
  font-weight: 760;
  letter-spacing: 0;
}

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 190px), 1fr));
  grid-auto-rows: auto;
  align-items: start;
  gap: 14px;
  min-height: min-content;
  padding: 0 2px 18px;
}

.gallery-card {
  display: grid;
  grid-template-rows: auto auto;
  overflow: hidden;
  border: 1px solid rgba(23, 32, 42, 0.12);
  border-radius: 6px;
  background: var(--veil);
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.gallery-card:hover,
.gallery-card:focus-visible {
  border-color: rgba(141, 63, 79, 0.48);
  outline: none;
}

.gallery-card[aria-current="true"] {
  border-color: rgba(141, 63, 79, 0.72);
  box-shadow: inset 0 0 0 1px rgba(141, 63, 79, 0.32);
}

.gallery-card figure {
  display: grid;
  place-items: center;
  min-width: 0;
  margin: 0;
  padding: 14px;
  aspect-ratio: 3 / 4;
}

.gallery-card img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.gallery-meta {
  display: grid;
  gap: 5px;
  padding: 11px 12px 12px;
  border-top: 1px solid rgba(23, 32, 42, 0.08);
}

.gallery-meta strong,
.gallery-meta span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.gallery-meta strong {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 13px;
}

.gallery-meta span {
  color: rgba(102, 112, 102, 0.82);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px;
}

.readout {
  position: absolute;
  left: 22px;
  bottom: 22px;
  display: grid;
  grid-template-columns: repeat(4, minmax(112px, 1fr));
  min-width: min(680px, calc(100vw - 44px));
  max-width: calc(100vw - 44px);
  overflow: hidden;
  border: 1px solid rgba(23, 32, 42, 0.08);
  background: rgba(247, 243, 232, 0.40);
  backdrop-filter: blur(10px);
}

.readout > div {
  min-width: 0;
  padding: 10px 12px;
  border-right: 1px solid rgba(23, 32, 42, 0.065);
}

.readout > div:last-child {
  border-right: 0;
}

.label {
  display: block;
  margin-bottom: 4px;
  color: rgba(102, 112, 102, 0.74);
  font-size: 9px;
  font-weight: 650;
  letter-spacing: 0;
  text-transform: uppercase;
}

.readout strong {
  display: block;
  overflow: hidden;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  font-weight: 650;
  color: rgba(23, 32, 42, 0.82);
  text-overflow: ellipsis;
  white-space: nowrap;
}

@media (max-width: 700px) {
  .view-actions {
    top: 12px;
    right: 12px;
  }

  .view-button {
    min-height: 34px;
    padding: 0 11px;
    font-size: 11px;
  }

  .gallery-view {
    gap: 14px;
    padding: 12px;
  }

  .gallery-header strong {
    font-size: 18px;
  }

  .gallery-grid {
    grid-template-columns: 1fr;
    gap: 11px;
    padding-bottom: 180px;
  }

  .readout {
    left: 12px;
    right: 12px;
    bottom: 12px;
    grid-template-columns: 1fr;
    min-width: 0;
    max-width: none;
  }

  .readout > div {
    border-right: 0;
    border-bottom: 1px solid rgba(23, 32, 42, 0.10);
  }

  .readout > div:last-child {
    border-bottom: 0;
  }
}
