:root {
  color-scheme: dark;
  --studio-border: rgba(190, 153, 255, .22);
  --studio-panel: rgba(20, 20, 31, .96);
  --studio-muted: rgba(255, 255, 255, .62);
  --studio-purple: #a975ff;
  --studio-purple-soft: #d8c0ff;
}

* { box-sizing: border-box; }

button, input, select { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .42; }

body.image-studio-page { min-height: 100vh; }

.studio-main {
  width: min(1780px, calc(100% - 28px));
  min-height: calc(100vh - 160px);
  margin: 0 auto;
  padding: 108px 0 66px;
}

.studio-hero {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 20px;
  padding: 0 4px;
}

.studio-kicker {
  margin: 0;
  color: #c9adff;
  font-size: 12px;
  font-weight: 900;
  letter-spacing: .14em;
  text-transform: uppercase;
}

.studio-hero h1 {
  margin: 6px 0 8px;
  font-size: clamp(38px, 5.2vw, 68px);
  line-height: .95;
}

.studio-hero p:last-child {
  max-width: 740px;
  margin: 0;
  color: var(--studio-muted);
  font-size: clamp(15px, 1.5vw, 18px);
  line-height: 1.5;
}

.hero-actions, .toolbar-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
}

.primary-action,
.secondary-action,
.editor-toolbar button,
.transform-grid button,
.preset-grid button,
.small-button {
  min-height: 42px;
  border-radius: 11px;
  font-weight: 850;
}

.primary-action {
  border: 1px solid rgba(224, 206, 255, .42);
  background: linear-gradient(145deg, #7542ca, #442273);
  box-shadow: inset 0 1px rgba(255,255,255,.14), 0 12px 28px rgba(62, 24, 112, .28);
  color: #fff;
  padding: 0 18px;
}

.primary-action:hover:not(:disabled),
.primary-action:focus-visible:not(:disabled) { filter: brightness(1.12); }

.secondary-action,
.editor-toolbar button,
.transform-grid button,
.preset-grid button,
.small-button {
  border: 1px solid rgba(255,255,255,.12);
  background: rgba(255,255,255,.055);
  color: rgba(255,255,255,.9);
  padding: 0 14px;
}

.secondary-action:hover:not(:disabled),
.editor-toolbar button:hover:not(:disabled),
.transform-grid button:hover:not(:disabled),
.preset-grid button:hover:not(:disabled),
.small-button:hover:not(:disabled) {
  border-color: rgba(193, 157, 255, .48);
  background: rgba(121, 70, 206, .2);
}

.visually-hidden-input {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
}

.studio-workspace {
  display: grid;
  grid-template-columns: minmax(240px, 290px) minmax(480px, 1fr) minmax(290px, 340px);
  gap: 14px;
  align-items: stretch;
  min-height: 720px;
}

.studio-panel,
.editor-card {
  border: 1px solid var(--studio-border);
  border-radius: 18px;
  background:
    radial-gradient(circle at 12% 0%, rgba(111, 66, 190, .12), transparent 32%),
    var(--studio-panel);
  box-shadow: 0 22px 70px rgba(0,0,0,.32);
  overflow: hidden;
}

.studio-panel {
  padding: 15px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(151, 105, 228, .56) transparent;
}

.files-panel { max-height: 820px; }
.controls-panel { max-height: 820px; }

.image-drop-zone {
  display: grid;
  place-items: center;
  min-height: 132px;
  padding: 18px;
  border: 1px dashed rgba(200, 173, 246, .38);
  border-radius: 14px;
  background: rgba(86, 46, 148, .1);
  text-align: center;
  transition: border-color .15s ease, background .15s ease, transform .15s ease;
}

.image-drop-zone:hover,
.image-drop-zone:focus-visible,
.image-drop-zone.dragging {
  border-color: rgba(221, 205, 255, .78);
  background: rgba(114, 65, 196, .2);
  outline: none;
}

.image-drop-zone.dragging { transform: scale(1.012); }
.image-drop-zone strong { font-size: 17px; }
.image-drop-zone span { color: var(--studio-purple-soft); font-size: 12px; font-weight: 800; }
.image-drop-zone small { color: var(--studio-muted); font-size: 11px; }

.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.panel-heading h2,
.control-section > h2 {
  margin: 0;
  font-size: 15px;
}

.queue-heading { margin: 16px 2px 9px; }
.queue-heading span { color: var(--studio-muted); font-size: 11px; }
.small-button { min-height: 32px; padding: 0 11px; font-size: 12px; }

.image-queue {
  display: grid;
  gap: 8px;
}

.queue-empty {
  padding: 24px 8px;
  color: rgba(255,255,255,.44);
  font-size: 13px;
  text-align: center;
}

.queue-item {
  display: grid;
  grid-template-columns: 54px minmax(0, 1fr) 28px;
  gap: 10px;
  align-items: center;
  width: 100%;
  padding: 8px;
  border: 1px solid rgba(255,255,255,.075);
  border-radius: 11px;
  background: rgba(255,255,255,.028);
  color: #fff;
  text-align: left;
}

.queue-item.active {
  border-color: rgba(188, 150, 255, .55);
  background: rgba(102, 55, 177, .2);
  box-shadow: inset 3px 0 #a975ff;
}

.queue-select {
  display: contents;
  color: inherit;
  text-align: inherit;
}

.queue-thumb {
  width: 54px;
  height: 48px;
  border-radius: 8px;
  background: #0a0a0e;
  object-fit: cover;
}

.queue-copy { min-width: 0; }
.queue-name { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; font-weight: 850; }
.queue-meta { display: block; margin-top: 4px; color: var(--studio-muted); font-size: 10px; }
.queue-remove {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: rgba(255,255,255,.52);
  font-size: 18px;
}
.queue-remove:hover { background: rgba(255, 83, 111, .15); color: #ff9aad; }

.editor-card {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  min-height: 720px;
}

.editor-toolbar,
.editor-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 12px 14px;
  background: rgba(9, 9, 15, .7);
}

.editor-toolbar { border-bottom: 1px solid rgba(255,255,255,.08); }
.editor-footer { border-top: 1px solid rgba(255,255,255,.08); color: var(--studio-muted); font-size: 11px; }

.toolbar-title { min-width: 0; }
.toolbar-title strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.toolbar-title span { display: block; margin-top: 4px; color: var(--studio-muted); font-size: 11px; }
.editor-toolbar button { min-height: 34px; padding: 0 10px; font-size: 11px; }
.editor-toolbar button.active { border-color: rgba(215, 194, 255, .66); background: rgba(120, 66, 207, .35); color: #fff; }

.canvas-shell {
  position: relative;
  min-height: 570px;
  overflow: hidden;
  background-color: #101117;
  background-image:
    linear-gradient(45deg, #181922 25%, transparent 25%),
    linear-gradient(-45deg, #181922 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #181922 75%),
    linear-gradient(-45deg, transparent 75%, #181922 75%);
  background-size: 24px 24px;
  background-position: 0 0, 0 12px, 12px -12px, -12px 0;
  touch-action: none;
}

#editor-canvas { display: block; width: 100%; height: 100%; min-height: 570px; }

.canvas-empty,
.busy-layer {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 8px;
  padding: 24px;
  background: rgba(10, 10, 16, .66);
  text-align: center;
}

.canvas-empty span { color: var(--studio-muted); font-size: 13px; }
.empty-image-mark {
  display: grid;
  place-items: center;
  width: 82px;
  height: 64px;
  margin-bottom: 8px;
  border: 1px solid rgba(203, 177, 248, .35);
  border-radius: 14px;
  background: linear-gradient(145deg, rgba(110,63,188,.85), rgba(48,28,82,.9));
  font-size: 22px;
  font-weight: 950;
}

.crop-help {
  position: absolute;
  left: 50%;
  bottom: 16px;
  transform: translateX(-50%);
  padding: 8px 12px;
  border: 1px solid rgba(220,201,255,.38);
  border-radius: 999px;
  background: rgba(22, 14, 38, .9);
  box-shadow: 0 8px 26px rgba(0,0,0,.35);
  color: #eadfff;
  font-size: 11px;
  font-weight: 800;
  pointer-events: none;
}

.hidden { display: none !important; }

.busy-layer { z-index: 5; background: rgba(7,7,12,.78); }
.spinner {
  width: 34px;
  height: 34px;
  border: 3px solid rgba(255,255,255,.14);
  border-top-color: #b88bff;
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.control-section {
  padding: 0 0 15px;
  margin: 0 0 15px;
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.control-section:last-child { margin-bottom: 0; border-bottom: 0; }
.control-section h2 { margin-bottom: 10px; }
.text-button {
  border: 0;
  background: transparent;
  color: var(--studio-purple-soft);
  font-size: 11px;
  font-weight: 800;
}
.text-button:hover:not(:disabled) { color: #fff; }

.preset-grid,
.transform-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}
.preset-grid button,
.transform-grid button { min-height: 34px; padding: 0 6px; font-size: 11px; }
.preset-grid button.active { border-color: rgba(218, 197, 255, .66); background: rgba(123, 69, 210, .38); }
.transform-grid { grid-template-columns: repeat(2, 1fr); margin-top: 9px; }

.two-field-grid,
.four-field-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}
.four-field-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); margin-top: 8px; }

.control-section label {
  color: var(--studio-muted);
  font-size: 11px;
  font-weight: 700;
}

.control-section input[type="number"],
.control-section select,
.control-section input[type="color"] {
  width: 100%;
  height: 36px;
  margin-top: 5px;
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 9px;
  background: rgba(255,255,255,.055);
  color: #fff;
  padding: 0 9px;
}
.control-section input[type="color"] { padding: 4px; }
.control-section select option { background: #1c1b27; color: #fff; }

.lock-label { display: flex; align-items: center; gap: 5px; }
.lock-label input { accent-color: #9d6cf2; }

.adjustment-section > label,
.export-section > label {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-top: 9px;
}
.adjustment-section output,
.export-section output { color: var(--studio-purple-soft); }

input[type="range"] {
  width: 100%;
  height: 20px;
  margin: 0;
  accent-color: #9361e7;
}

.export-fields { margin-bottom: 7px; }
.export-note { margin: 10px 0; color: rgba(255,255,255,.48); font-size: 10px; line-height: 1.45; }
.full-width { width: 100%; margin-top: 7px; }
.batch-progress { margin-top: 10px; }
.progress-track { height: 7px; overflow: hidden; border-radius: 999px; background: rgba(255,255,255,.08); }
.progress-track span { display: block; width: 0; height: 100%; border-radius: inherit; background: linear-gradient(90deg, #7041bd, #c6a7ff); transition: width .18s ease; }
#progress-text { display: block; margin-top: 6px; color: var(--studio-muted); font-size: 10px; }

.agn-site-footer {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 18px 0 32px;
  color: rgba(255,255,255,.5);
  font-size: 12px;
  text-align: center;
}
.agn-site-footer nav { display: flex; justify-content: center; flex-wrap: wrap; gap: 14px; }
.agn-site-footer a { color: rgba(255,255,255,.68); }

@media (max-width: 1180px) {
  .studio-workspace { grid-template-columns: 250px minmax(430px, 1fr); }
  .controls-panel { grid-column: 1 / -1; max-height: none; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 22px; }
  .controls-panel .control-section:nth-last-child(-n+2) { border-bottom: 0; }
}

@media (max-width: 780px) {
  .studio-main { width: min(100% - 14px, 1780px); padding-top: 78px; }
  .studio-hero { align-items: stretch; flex-direction: column; gap: 14px; }
  .hero-actions { width: 100%; }
  .hero-actions button { flex: 1; }
  .studio-workspace { display: flex; flex-direction: column; min-height: 0; }
  .files-panel, .controls-panel { max-height: none; }
  .files-panel { order: 2; }
  .editor-card { order: 1; min-height: 540px; }
  .controls-panel { order: 3; display: block; }
  .canvas-shell, #editor-canvas { min-height: 430px; }
  .editor-toolbar { align-items: flex-start; flex-direction: column; }
  .toolbar-actions { width: 100%; }
  .toolbar-actions button { flex: 1; }
  .editor-footer { align-items: flex-start; flex-direction: column; }
}

@media (max-width: 480px) {
  .studio-hero h1 { font-size: 38px; }
  .canvas-shell, #editor-canvas { min-height: 350px; }
  .editor-card { min-height: 470px; }
  .four-field-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .preset-grid { grid-template-columns: repeat(3, 1fr); }
}


/* v191: JS-assisted dropdown open state, stable on mouse + touch. */
.site-header, .chess-header { overflow: visible !important; }
.nav-dropdown.is-open > .nav-dropdown-menu { display: block !important; opacity: 1 !important; visibility: visible !important; pointer-events: auto !important; }
.nav-dropdown.is-open > .nav-dropbtn { background: rgba(255,255,255,0.12) !important; color: #fff !important; }
.nav-tools-menu { min-width: 220px; }
@media (hover: none), (pointer: coarse), (max-width: 760px) {
  .nav-dropdown:hover > .nav-dropdown-menu { display: none; }
  .nav-dropdown.is-open > .nav-dropdown-menu { display: block !important; }
}
