:root {
  --gallery-line: rgba(159, 212, 226, 0.12);
  --gallery-panel: rgba(11, 17, 24, 0.88);
  --gallery-panel-2: rgba(18, 26, 35, 0.92);
  --gallery-soft: rgba(238, 245, 253, 0.08);
}

.capability-gallery-shell {
  padding-bottom: 6rem;
}

.capability-hero {
  gap: 1.25rem;
}

.gallery-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

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

.studio-sidebar,
.studio-readout,
.studio-stage-shell {
  position: relative;
  overflow: hidden;
  border-radius: 28px;
  border: 1px solid rgba(145, 184, 206, 0.14);
  background:
    linear-gradient(180deg, rgba(16, 22, 30, 0.94), rgba(8, 11, 16, 0.98)),
    linear-gradient(135deg, rgba(255, 255, 255, 0.03), transparent 45%);
  box-shadow: 0 24px 46px rgba(0, 0, 0, 0.28);
}

.studio-sidebar::before,
.studio-readout::before,
.studio-stage-shell::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.04), transparent 28%, transparent 72%, rgba(159, 212, 226, 0.03));
  pointer-events: none;
}

.studio-sidebar {
  display: grid;
  gap: 0.9rem;
  padding: 1rem;
}

.template-picker {
  display: grid;
  gap: 0.7rem;
}

.template-thumb {
  display: grid;
  grid-template-columns: 112px minmax(0, 1fr);
  gap: 0.75rem;
  align-items: center;
  width: 100%;
  padding: 0.7rem;
  border-radius: 20px;
  border: 1px solid rgba(145, 184, 206, 0.14);
  background: rgba(255, 255, 255, 0.03);
  color: var(--console-text);
  text-align: left;
  cursor: pointer;
  transition: transform 180ms ease, border-color 180ms ease, box-shadow 180ms ease;
}

.template-thumb:hover {
  transform: translateY(-1px);
  border-color: rgba(216, 163, 90, 0.34);
  box-shadow: 0 14px 28px rgba(0, 0, 0, 0.22);
}

.template-thumb.is-active {
  border-color: rgba(216, 163, 90, 0.7);
  box-shadow: 0 18px 34px rgba(216, 163, 90, 0.18);
}

.template-thumb-art {
  width: 100%;
  height: 74px;
  object-fit: cover;
  border-radius: 14px;
  border: 1px solid rgba(145, 184, 206, 0.16);
  background: #0b1117;
}

.template-thumb-copy {
  display: grid;
  gap: 0.2rem;
}

.template-thumb-copy strong {
  font-size: 0.92rem;
}

.template-thumb-copy span {
  color: var(--console-muted);
  font-size: 0.78rem;
  line-height: 1.45;
}

.studio-toolbar {
  display: grid;
  gap: 0.55rem;
}

.file-button {
  display: inline-flex;
  justify-content: center;
}

.hidden-file-input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.studio-readout {
  padding: 1rem;
}

.studio-status {
  border-color: rgba(216, 163, 90, 0.18);
}

.studio-main {
  display: grid;
  gap: 1rem;
}

.studio-stage-shell {
  padding: 1rem;
}

.studio-stage-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.9rem;
}

.studio-stage-header h3 {
  margin: 0.3rem 0 0;
  font-family: "Cinzel", Georgia, serif;
  font-size: 1.3rem;
}

.studio-stage {
  position: relative;
  container-type: inline-size;
  min-height: 760px;
  border-radius: 24px;
  border: 1px solid rgba(145, 184, 206, 0.12);
  background:
    linear-gradient(rgba(255, 255, 255, 0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.03) 1px, transparent 1px),
    radial-gradient(circle at 50% 28%, rgba(216, 163, 90, 0.06), transparent 34%),
    linear-gradient(180deg, rgba(14, 21, 29, 0.98), rgba(6, 10, 15, 1));
  background-size: 54px 54px, 54px 54px, auto, auto;
  overflow: hidden;
}

.studio-stage-shell:fullscreen {
  padding: 1.5rem;
  border-radius: 0;
}

.studio-stage-shell:fullscreen .studio-stage {
  min-height: calc(100vh - 11rem);
}

.studio-stage.is-editing {
  cursor: grab;
}

.studio-stage.is-editing .studio-item {
  cursor: grab;
}

.studio-stage.is-editing .studio-item.is-dragging {
  cursor: grabbing;
}

.studio-item {
  position: absolute;
  display: grid;
  align-items: center;
  gap: 0.35rem;
  padding: 0.55rem 0.72rem;
  border-radius: 18px;
  border-style: solid;
  border-width: clamp(1px, calc(var(--item-border-width, 1.15) * 0.16cqw), 10px);
  font-size: clamp(8px, calc(var(--item-font-size, 0.84) * 1cqw), 30px);
  background: var(--gallery-panel-2);
  color: var(--console-text);
  text-align: left;
  box-shadow: 0 14px 24px rgba(0, 0, 0, 0.24);
  transition: box-shadow 160ms ease, transform 160ms ease;
  user-select: none;
  appearance: none;
  cursor: pointer;
  overflow: hidden;
}

.studio-item:hover {
  box-shadow: 0 16px 28px rgba(0, 0, 0, 0.28);
}

.studio-item.is-selected {
  box-shadow:
    0 0 0 2px rgba(255, 255, 255, 0.14),
    0 0 0 5px rgba(216, 163, 90, 0.2),
    0 18px 30px rgba(0, 0, 0, 0.3);
}

.studio-item.type-core {
  display: grid;
  place-items: center;
  border-radius: 999px;
  padding: 0;
  text-align: center;
  font-family: "Cinzel", Georgia, serif;
}

.studio-item.type-phase {
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.studio-item.type-label {
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.studio-item.type-capability {
  align-content: start;
}

.studio-lines {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.studio-lines line {
  stroke: rgba(158, 206, 222, 0.22);
}

.item-copy {
  display: grid;
  gap: 0.2em;
  max-width: 100%;
}

.item-token {
  display: block;
  max-width: 100%;
}

.item-token-title,
.item-token-name {
  font-size: 1em;
  font-weight: 800;
  line-height: 1.2;
}

.item-token-short,
.item-token-long,
.item-token-explanation,
.item-token-literal {
  font-size: 0.82em;
  line-height: 1.32;
  color: rgba(238, 245, 253, 0.82);
}

.item-token-explanation {
  color: rgba(239, 179, 109, 0.92);
}

.studio-item.type-core .item-copy,
.studio-item.type-label .item-copy {
  justify-items: center;
  text-align: center;
}

.studio-item.type-core .item-token-title,
.studio-item.type-core .item-token-name {
  font-size: 1.04em;
  letter-spacing: 0.08em;
}

.studio-item.type-core .item-token-short,
.studio-item.type-core .item-token-long {
  font-size: 0.72em;
}

.studio-item.type-label .item-token-title,
.studio-item.type-label .item-token-name {
  font-size: 0.86em;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.studio-item.type-phase .item-token-title,
.studio-item.type-phase .item-token-name {
  font-size: 0.94em;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.item-badge {
  justify-self: start;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2rem;
  height: 1.55rem;
  padding: 0 0.45rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.15);
  font-size: 0.72em;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

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

.item-editor {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.7rem;
}

.item-editor label {
  display: grid;
  gap: 0.35rem;
}

.item-editor label span {
  color: var(--console-muted);
  font-size: 0.78rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.item-editor input {
  width: 100%;
  min-height: 2.4rem;
  padding: 0.55rem 0.7rem;
  border-radius: 12px;
  border: 1px solid rgba(145, 184, 206, 0.18);
  background: rgba(255, 255, 255, 0.05);
  color: var(--console-text);
}

.item-editor input[type="color"] {
  padding: 0.2rem;
}

.item-editor input:disabled {
  opacity: 0.5;
}

.editor-actions {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 0.7rem;
  margin-top: 0.9rem;
}

.editor-actions .button {
  width: 100%;
}

.editor-actions .button-secondary,
.editor-actions .file-button {
  color: var(--console-text);
  background: linear-gradient(180deg, rgba(25, 43, 60, 0.96), rgba(12, 23, 34, 0.92));
  border-color: rgba(159, 212, 226, 0.22);
}

.editor-actions .button-secondary:hover,
.editor-actions .file-button:hover {
  color: #f6fbff;
  background: linear-gradient(180deg, rgba(35, 58, 78, 0.98), rgba(16, 31, 45, 0.96));
  border-color: rgba(216, 163, 90, 0.32);
}

.capability-index-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 1rem;
}

.source-preview-dialog {
  width: min(1120px, calc(100vw - 2rem));
  max-width: none;
  padding: 0;
  border: 1px solid rgba(145, 184, 206, 0.18);
  border-radius: 28px;
  background: transparent;
  box-shadow: 0 28px 60px rgba(0, 0, 0, 0.44);
}

.source-preview-dialog::backdrop {
  background: rgba(2, 6, 10, 0.72);
  backdrop-filter: blur(6px);
}

.source-preview-shell {
  display: grid;
  gap: 1rem;
  margin: 0;
  padding: 1rem;
  border-radius: 28px;
  background:
    linear-gradient(180deg, rgba(16, 22, 30, 0.98), rgba(8, 11, 16, 1)),
    linear-gradient(135deg, rgba(255, 255, 255, 0.03), transparent 45%);
}

.source-preview-header,
.source-preview-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.source-preview-header h3 {
  margin: 0.25rem 0 0;
  font-family: "Cinzel", Georgia, serif;
  font-size: 1.15rem;
}

.source-preview-frame {
  width: 100%;
  min-height: min(78vh, 880px);
  border: 1px solid rgba(145, 184, 206, 0.14);
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.02);
}

.phase-index-card {
  position: relative;
  overflow: hidden;
  padding: 1rem;
  border-radius: 28px;
  border: 1px solid rgba(145, 184, 206, 0.14);
  background:
    linear-gradient(180deg, rgba(16, 22, 30, 0.94), rgba(8, 11, 16, 0.98)),
    linear-gradient(135deg, rgba(255, 255, 255, 0.03), transparent 45%);
  box-shadow: 0 24px 46px rgba(0, 0, 0, 0.28);
}

.phase-index-card::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.04), transparent 28%, transparent 72%, rgba(159, 212, 226, 0.03));
  pointer-events: none;
}

.index-phase-header {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  margin-bottom: 0.85rem;
}

.phase-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2.15rem;
  height: 2.15rem;
  padding: 0 0.55rem;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #07131d;
}

.phase-chip.phase-P {
  background: var(--console-red);
}

.phase-chip.phase-I,
.phase-chip.phase-C,
.phase-chip.phase-A {
  background: var(--console-sand);
}

.phase-chip.phase-R {
  background: #cf9478;
}

.phase-chip.phase-D {
  background: var(--console-green);
}

.index-phase-header h4 {
  margin: 0;
  font-size: 1rem;
}

.index-phase-summary {
  margin: 0.3rem 0 0;
  color: var(--console-muted);
  line-height: 1.55;
}

.index-cap-list {
  display: grid;
  gap: 0.65rem;
}

.index-cap-card {
  padding: 0.85rem;
  border-radius: 18px;
  border: 1px solid var(--gallery-line);
  background: rgba(255, 255, 255, 0.03);
}

.index-cap-top {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  align-items: center;
  margin-bottom: 0.55rem;
}

.index-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 1.6rem;
  padding: 0 0.5rem;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.05);
  color: var(--console-text);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.index-cap-card h5 {
  margin: 0 0 0.45rem;
  font-size: 0.95rem;
}

.index-cap-card p {
  margin: 0;
  color: var(--console-muted);
  line-height: 1.55;
}

.index-cap-note {
  margin-top: 0.55rem;
  padding-top: 0.55rem;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

@media (max-width: 1100px) {
  .studio-layout {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 860px) {
  .studio-panel-grid,
  .item-editor,
  .editor-actions {
    grid-template-columns: 1fr;
  }

  .studio-stage {
    min-height: 620px;
  }
}

@media (max-width: 640px) {
  .gallery-actions {
    display: grid;
  }

  .template-thumb {
    grid-template-columns: 1fr;
  }

  .studio-stage {
    min-height: 540px;
  }

  .capability-index-grid {
    grid-template-columns: 1fr;
  }
}
