:root {
  --res-bg: #ecebdd;
  --res-ink: #13120a;
  --res-muted: rgba(19, 18, 10, 0.58);
  --res-hairline: rgba(19, 18, 10, 0.15);
  --res-panel: rgba(19, 18, 10, 0.045);
  --res-panel-strong: rgba(19, 18, 10, 0.08);
  --res-accent: #284b63;
  --res-action-bg: #13120a;
  --res-action-ink: #f6f1e3;
  --res-shadow: rgba(19, 18, 10, 0.18);
}

html.dark:not(.navy) {
  --res-bg: #13120a;
  --res-ink: #f6f1e3;
  --res-muted: rgba(246, 241, 227, 0.58);
  --res-hairline: rgba(246, 241, 227, 0.14);
  --res-panel: rgba(246, 241, 227, 0.045);
  --res-panel-strong: rgba(246, 241, 227, 0.085);
  --res-accent: #9eb7c8;
  --res-action-bg: #f6f1e3;
  --res-action-ink: #13120a;
  --res-shadow: rgba(0, 0, 0, 0.34);
}

html.navy {
  --res-bg: #061830;
  --res-ink: #f4f8ff;
  --res-muted: rgba(244, 248, 255, 0.62);
  --res-hairline: rgba(220, 235, 255, 0.16);
  --res-panel: rgba(220, 235, 255, 0.055);
  --res-panel-strong: rgba(220, 235, 255, 0.095);
  --res-accent: #a8c7dc;
  --res-action-bg: #f4f8ff;
  --res-action-ink: #061830;
  --res-shadow: rgba(0, 0, 0, 0.36);
}

html.pastel {
  --res-bg: var(--pastelle-pastel-bg);
  --res-ink: var(--pastelle-pastel-ink);
  --res-muted: var(--pastelle-pastel-muted);
  --res-hairline: var(--pastelle-pastel-hairline);
  --res-panel: var(--pastelle-pastel-panel);
  --res-panel-strong: var(--pastelle-pastel-panel-strong);
  --res-accent: var(--pastelle-pastel-accent);
  --res-action-bg: var(--pastelle-pastel-ink);
  --res-action-ink: var(--pastelle-pastel-bg);
  --res-shadow: color-mix(in srgb, var(--pastelle-pastel-accent) 20%, transparent);
}

body.resonance-page {
  margin: 0;
  min-width: 320px;
  min-height: 100dvh;
  overflow-x: hidden;
  background: var(--res-bg) !important;
  color: var(--res-ink) !important;
  font-family: Manrope, sans-serif;
  transition: background-color 0.35s ease, color 0.35s ease;
}

.resonance-page *,
.resonance-page *::before,
.resonance-page *::after {
  box-sizing: border-box;
}

.resonance-main {
  width: 100%;
  padding: clamp(6.75rem, 9vw, 8.5rem) clamp(1rem, 3.2vw, 3rem) clamp(5rem, 9vw, 9rem);
}

.studio-grid {
  --art-size: min(60vw, calc(100dvh - 10rem), 68.75rem);
  display: grid;
  grid-template-columns: minmax(0, var(--art-size)) minmax(320px, 400px);
  align-items: start;
  justify-content: center;
  gap: clamp(2rem, 4vw, 5rem);
  width: 100%;
  max-width: 100rem;
  margin: 0 auto;
}

.art-column {
  width: min(100%, var(--art-size));
  max-width: none;
  min-width: 0;
}

.art-frame {
  position: relative;
  width: 100%;
  aspect-ratio: 1;
  overflow: hidden;
  background: #1a1a1a;
  border: 1px solid var(--res-hairline);
  box-shadow: 0 24px 64px -36px var(--res-shadow);
}

.art-frame iframe {
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
  background: #1a1a1a;
}

.art-loading,
.art-error {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 2rem;
  background: #1a1a1a;
  color: rgba(255, 255, 255, 0.8);
  text-align: center;
  z-index: 2;
}

.art-loading[hidden],
.art-error[hidden] {
  display: none;
}

.art-loading::before {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(255, 255, 255, 0.025);
  animation: resonance-breathe 1.8s ease-in-out infinite;
}

.art-loading span,
.art-error {
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.11em;
  text-transform: uppercase;
}

.art-caption {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  padding-top: 0.85rem;
  color: var(--res-muted);
  font-size: 0.68rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.art-caption strong {
  color: var(--res-ink);
  font-weight: 600;
}

.control-rail {
  container-type: inline-size;
  width: 100%;
  max-width: 400px;
  min-width: 0;
  justify-self: end;
}

.studio-heading {
  padding-bottom: 0.5rem;
}

.studio-eyebrow {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.65rem;
  margin: 0 0 1.1rem;
  color: var(--res-muted);
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

.studio-eyebrow span:not(:last-child)::after {
  content: '/';
  padding-left: 0.65rem;
  opacity: 0.45;
}

.studio-title {
  margin: 0;
  color: var(--res-ink);
  font-size: clamp(3.2rem, 18cqi, 5.4rem);
  font-weight: 600;
  letter-spacing: 0;
  line-height: 0.88;
  white-space: nowrap;
}

.studio-description {
  max-width: 36ch;
  margin: 1.4rem 0 0;
  color: var(--res-muted);
  font-size: 0.95rem;
  line-height: 1.65;
}

.mode-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 1.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--res-hairline);
}

.mode-indicator {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--res-muted);
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.mode-indicator::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--res-accent);
  animation: resonance-pulse 2.4s ease-in-out infinite;
}

.text-link {
  color: var(--res-ink);
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-decoration: none;
  text-transform: uppercase;
}

.text-link:hover {
  opacity: 0.62;
}

.control-section {
  position: relative;
  padding: 1.25rem 0 1.4rem;
  border-top: 1px solid var(--res-hairline);
}

.control-section:last-child {
  border-bottom: 1px solid var(--res-hairline);
}

.control-label,
.seed-field label {
  display: block;
  margin: 0 0 0.75rem;
  color: var(--res-muted);
  font-size: 0.64rem;
  font-weight: 600;
  letter-spacing: 0.11em;
  text-transform: uppercase;
}

.wallet-row {
  display: flex;
  align-items: center;
  gap: 0.55rem;
}

.button,
.icon-button {
  min-height: 42px;
  border: 1px solid var(--res-hairline);
  border-radius: 6px;
  background: transparent;
  color: var(--res-ink);
  font: inherit;
  font-size: 0.74rem;
  font-weight: 600;
  letter-spacing: 0;
  cursor: pointer;
  transition: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease, transform 0.2s ease, opacity 0.2s ease;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.72rem 1rem;
}

.button:hover:not(:disabled),
.icon-button:hover:not(:disabled) {
  background: var(--res-panel-strong);
  border-color: color-mix(in srgb, var(--res-ink) 26%, transparent);
}

.button:active:not(:disabled),
.icon-button:active:not(:disabled) {
  transform: translateY(1px) scale(0.985);
}

.button:disabled,
.icon-button:disabled {
  cursor: not-allowed;
  opacity: 0.34;
}

.button-primary {
  background: var(--res-action-bg);
  border-color: var(--res-action-bg);
  color: var(--res-action-ink);
}

.button-primary:hover:not(:disabled) {
  background: color-mix(in srgb, var(--res-action-bg) 88%, transparent);
  border-color: transparent;
}

.button-wallet {
  flex: 1 1 auto;
}

.button-wallet[data-connected='true'] {
  justify-content: flex-start;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

.button-quiet {
  flex: 0 0 auto;
  padding-inline: 0.85rem;
}

.wallet-menu {
  position: absolute;
  top: calc(100% - 0.65rem);
  left: 0;
  right: 0;
  z-index: 6;
  padding: 0.45rem;
  border: 1px solid var(--res-hairline);
  border-radius: 6px;
  background: color-mix(in srgb, var(--res-bg) 94%, transparent);
  box-shadow: 0 22px 48px -28px var(--res-shadow);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}

.wallet-menu[hidden] {
  display: none;
}

.wallet-option {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  width: 100%;
  min-height: 44px;
  padding: 0.55rem 0.65rem;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--res-ink);
  font: inherit;
  font-size: 0.8rem;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
}

.wallet-option:hover {
  background: var(--res-panel-strong);
}

.wallet-option img {
  border-radius: 6px;
}

.wallet-empty {
  margin: 0;
  padding: 0.8rem;
  color: var(--res-muted);
  font-size: 0.75rem;
  line-height: 1.5;
}

.seed-control-grid {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) 42px;
  gap: 0.5rem;
  align-items: end;
}

.icon-button {
  display: grid;
  place-items: center;
  width: 42px;
  padding: 0;
}

.icon-button svg {
  width: 17px;
  height: 17px;
}

.seed-field {
  min-width: 0;
}

.seed-input-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  min-height: 42px;
  overflow: hidden;
  border: 1px solid var(--res-hairline);
  border-radius: 6px;
  background: var(--res-panel);
}

.seed-input-row:focus-within {
  border-color: color-mix(in srgb, var(--res-ink) 42%, transparent);
}

.seed-input-row input {
  width: 100%;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--res-ink);
  padding: 0 0.75rem;
  font: 600 0.86rem/1 ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

.seed-input-row button {
  border: 0;
  border-left: 1px solid var(--res-hairline);
  background: transparent;
  color: var(--res-ink);
  padding: 0 0.75rem;
  font: 600 0.64rem/1 Manrope, sans-serif;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
}

.seed-input-row button:hover {
  background: var(--res-panel-strong);
}

.field-error {
  min-height: 1.1rem;
  margin: 0.45rem 0 0;
  color: #b0443c;
  font-size: 0.7rem;
}

.seed-actions {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 0.55rem;
  margin-top: 0.8rem;
}

.action-help {
  min-height: 2.4rem;
  margin: 0.65rem 0 0;
  color: var(--res-muted);
  font-size: 0.7rem;
  line-height: 1.5;
}

.token-data {
  margin: 0;
}

.token-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: baseline;
  gap: 1rem;
  padding: 0.68rem 0;
  border-top: 1px solid var(--res-hairline);
}

.token-row:first-child {
  border-top: 0;
  padding-top: 0;
}

.token-row:last-child {
  padding-bottom: 0;
}

.token-row dt {
  color: var(--res-muted);
  font-size: 0.68rem;
}

.token-row dd {
  margin: 0;
  color: var(--res-ink);
  font: 600 0.72rem/1.3 ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  text-align: right;
}

.key-map {
  display: grid;
  gap: 0.55rem;
}

.key-row {
  display: grid;
  grid-template-columns: 5.2rem minmax(0, 1fr);
  align-items: center;
  gap: 0.85rem;
  color: var(--res-muted);
  font-size: 0.7rem;
}

.key-combo {
  display: flex;
  gap: 0.3rem;
}

kbd {
  display: inline-grid;
  min-width: 1.85rem;
  min-height: 1.75rem;
  place-items: center;
  padding: 0 0.4rem;
  border: 1px solid var(--res-hairline);
  border-bottom-color: color-mix(in srgb, var(--res-ink) 32%, transparent);
  border-radius: 4px;
  background: var(--res-panel);
  color: var(--res-ink);
  font: 600 0.64rem/1 ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

.studio-notice {
  margin: 0;
  padding-left: 0.75rem;
  border-left: 2px solid var(--res-hairline);
  color: var(--res-muted);
  font-size: 0.76rem;
  line-height: 1.55;
}

.notice-section[hidden] {
  display: none;
}

.studio-notice[data-tone='success'] {
  border-left-color: #4f8a67;
}

.studio-notice[data-tone='warning'] {
  border-left-color: #b78b39;
}

.studio-notice[data-tone='error'] {
  border-left-color: #b0443c;
}

.transaction-link {
  display: inline-block;
  margin-top: 0.8rem;
}

.transaction-link[hidden] {
  display: none;
}

.examples-section {
  width: 100%;
  max-width: 1600px;
  margin: clamp(6rem, 12vw, 12rem) auto 0;
}

.history-section {
  width: 100%;
  max-width: 1600px;
  margin: clamp(6rem, 10vw, 10rem) auto 0;
}

.history-section[hidden],
.history-status[hidden] {
  display: none;
}

.history-status {
  margin: 0;
  padding: 1.1rem 0;
  border-top: 1px solid var(--res-hairline);
  border-bottom: 1px solid var(--res-hairline);
  color: var(--res-muted);
  font-size: 0.76rem;
  line-height: 1.5;
}

.history-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: clamp(0.7rem, 1.2vw, 1.2rem);
}

.history-item {
  display: grid;
  min-width: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--res-ink);
  text-align: left;
  cursor: pointer;
}

.history-media {
  position: relative;
  display: block;
  width: 100%;
  aspect-ratio: 1;
  overflow: hidden;
  border: 1px solid transparent;
  background: var(--res-panel);
  transition: border-color 0.25s ease, transform 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

.history-media::before {
  content: 'Rendering';
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: var(--res-muted);
  font-size: 0.62rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.history-media img,
.history-preview-frame {
  position: relative;
  z-index: 1;
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
  object-fit: cover;
  background: #1a1a1a;
}

.history-preview-frame {
  pointer-events: none;
}

.history-meta {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  padding-top: 0.7rem;
  color: var(--res-muted);
  font-size: 0.64rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.history-meta strong {
  overflow: hidden;
  color: var(--res-ink);
  font: 600 0.68rem/1.2 ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  text-overflow: ellipsis;
}

.history-item:hover .history-media,
.history-item:focus-visible .history-media {
  transform: translateY(-2px);
  border-color: var(--res-accent);
}

.examples-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(260px, 34rem);
  align-items: end;
  gap: 3rem;
  margin-bottom: clamp(2rem, 4vw, 3.5rem);
  padding-top: 1.25rem;
  border-top: 1px solid var(--res-hairline);
}

.examples-kicker {
  margin: 0 0 0.7rem;
  color: var(--res-muted);
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.examples-title {
  margin: 0;
  color: var(--res-ink);
  font-size: clamp(2rem, 4.4vw, 4.8rem);
  font-weight: 600;
  letter-spacing: 0;
  line-height: 0.95;
}

.examples-description {
  margin: 0;
  color: var(--res-muted);
  font-size: 0.9rem;
  line-height: 1.65;
}

.examples-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: clamp(0.7rem, 1.2vw, 1.2rem);
}

.example-button {
  display: block;
  min-width: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--res-ink);
  text-align: left;
  cursor: pointer;
}

.example-image {
  position: relative;
  display: block;
  width: 100%;
  aspect-ratio: 1;
  overflow: hidden;
  border: 1px solid transparent;
  background: var(--res-panel);
  transition: border-color 0.25s ease, transform 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

.example-image img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.7s cubic-bezier(0.16, 1, 0.3, 1), filter 0.25s ease;
}

.example-button:hover .example-image {
  transform: translateY(-2px);
  border-color: var(--res-hairline);
}

.example-button:hover img {
  transform: scale(1.018);
}

.example-button.is-selected .example-image {
  border-color: var(--res-accent);
}

.resonance-footer {
  display: flex;
  justify-content: space-between;
  gap: 2rem;
  width: 100%;
  max-width: 1600px;
  margin: clamp(6rem, 10vw, 10rem) auto 0;
  padding-top: 1.25rem;
  border-top: 1px solid var(--res-hairline);
  color: var(--res-muted);
  font-size: 0.68rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

@keyframes resonance-breathe {
  0%,
  100% {
    opacity: 0.35;
  }
  50% {
    opacity: 1;
  }
}

@keyframes resonance-pulse {
  0%,
  100% {
    opacity: 1;
    transform: scale(1);
  }
  50% {
    opacity: 0.35;
    transform: scale(0.82);
  }
}

@media (max-width: 1080px) {
  .studio-grid {
    grid-template-columns: minmax(0, 1fr) minmax(300px, 360px);
    gap: clamp(1.5rem, 3.5vw, 2.5rem);
  }

  .art-column {
    width: min(100%, var(--art-size));
    justify-self: center;
  }

  .control-rail {
    max-width: 360px;
  }
}

@media (max-width: 860px) {
  .resonance-main {
    padding-top: 6.5rem;
  }

  .studio-grid {
    grid-template-columns: 1fr;
    gap: 2.5rem;
  }

  .control-rail {
    display: contents;
  }

  .studio-heading {
    grid-row: 1;
    padding-bottom: 0;
  }

  .art-column {
    grid-row: 2;
    width: 100%;
    max-width: none;
  }

  .control-stack {
    grid-row: 3;
  }

  .studio-description {
    max-width: 55ch;
  }

  .studio-title {
    font-size: clamp(3.2rem, 10vw, 5rem);
    white-space: normal;
  }

  .examples-header {
    grid-template-columns: 1fr;
    gap: 1rem;
  }
}

@media (max-width: 640px) {
  .resonance-main {
    padding-inline: 1rem;
    padding-bottom: 4rem;
  }

  .studio-title {
    font-size: clamp(3rem, 16vw, 4.5rem);
  }

  .studio-description {
    font-size: 0.88rem;
  }

  .art-caption {
    align-items: flex-start;
    flex-direction: column;
    gap: 0.35rem;
  }

  .seed-actions {
    grid-template-columns: 1fr 1fr;
  }

  .button {
    padding-inline: 0.75rem;
  }

  .examples-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.8rem;
  }

  .history-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.8rem;
  }

  .resonance-footer {
    align-items: flex-start;
    flex-direction: column;
    gap: 0.65rem;
  }
}

.token-studio-page .studio-title {
  font-size: clamp(2.6rem, 13cqi, 4.8rem);
  line-height: 0.98;
  white-space: normal;
}

@media (max-width: 860px) {
  .token-studio-page .studio-title {
    font-size: clamp(2.5rem, 9vw, 4.5rem);
  }
}

@media (max-width: 640px) {
  .token-studio-page .studio-title {
    font-size: clamp(2.35rem, 12vw, 3.75rem);
  }
}

@media (prefers-reduced-motion: reduce) {
  .resonance-page *,
  .resonance-page *::before,
  .resonance-page *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
