:root {
  color-scheme: dark;

  /* «Матовий графіт + Soft UI» (AI Lokalizator Studio palette) */
  --bg-canvas: #121316;
  --bg-sidebar: #16181D;
  --bg-surface: #1C1F26;
  --bg-tactile: #232730;
  --bg-tactile-hover: #2A2F3A;
  --bg-tactile-active: #1E222A;

  --accent-primary: #C89B6E;
  --accent-bronze-soft: rgba(200, 155, 110, 0.14);
  --accent-bronze-border: rgba(200, 155, 110, 0.35);
  --status-approved: #6EC4A7;
  --status-warning: #D9A75A;
  --red: #E06C75;

  --text-primary: #EAECEF;
  --text-muted: #8B92A0;
  --border: rgba(255, 255, 255, 0.08);
  --border-subtle: rgba(255, 255, 255, 0.06);
  --border-tactile: rgba(255, 255, 255, 0.08);
  --tactile-bevel: inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

* {
  box-sizing: border-box;
  scrollbar-width: thin;
  scrollbar-color: #2E3440 transparent;
}

::-webkit-scrollbar {
  width: 5px;
  height: 5px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: rgba(139, 146, 160, 0.22);
  border-radius: 999px;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(200, 155, 110, 0.55);
}

body {
  margin: 0;
  background: var(--bg-canvas);
  color: var(--text-primary);
  font: 13.5px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

/* 1. Top Bar (52px) */
.studio-header,
header.topbar {
  min-height: 52px;
  background: var(--bg-sidebar);
  border-bottom: 1px solid var(--border-subtle);
  padding: 6px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  position: sticky;
  top: 0;
  z-index: 100;
}

.topbar-group {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.brand-box {
  display: flex;
  align-items: center;
  gap: 9px;
}

.brand-mark {
  width: 26px;
  height: 26px;
  border-radius: 6px;
  background: linear-gradient(145deg, #2D323E, #1D2028);
  border: 1px solid var(--accent-bronze-border);
  box-shadow: var(--tactile-bevel);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--accent-primary);
  font-weight: 700;
  font-size: 11.5px;
  letter-spacing: 0.03em;
}

h1 {
  margin: 0;
  font-size: 14.5px;
  font-weight: 600;
  color: var(--text-primary);
}

h2 {
  margin: 0;
  font-size: 11.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

.ver-badge,
.badge-v2 {
  padding: 2px 9px;
  border-radius: 999px;
  background: var(--accent-bronze-soft);
  color: var(--accent-primary);
  border: 1px solid var(--accent-bronze-border);
  font-family: ui-monospace, Consolas, monospace;
  font-size: 11px;
  font-weight: 600;
}

.divider-v {
  width: 1px;
  height: 20px;
  background: var(--border-subtle);
  margin: 0 2px;
}

.port-badge {
  font-family: ui-monospace, Consolas, monospace;
  font-size: 11.5px;
  color: var(--text-muted);
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  padding: 3px 8px;
  border-radius: 6px;
}

.muted {
  color: var(--text-muted);
  font-weight: 400;
  font-size: 12px;
}

.ai-engine-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: var(--bg-surface);
  border: 1px solid var(--border-tactile);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
  padding: 5px 11px;
  border-radius: 7px;
  font-size: 12px;
  color: var(--text-primary);
  font-weight: 500;
}

.ai-engine-pill.busy {
  border-color: var(--accent-bronze-border);
  color: var(--accent-primary);
}

.sage-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--status-approved);
  box-shadow: 0 0 6px rgba(110, 196, 167, 0.65);
}

.sage-dot.busy {
  background: var(--status-warning);
  box-shadow: 0 0 7px rgba(217, 167, 90, 0.75);
}

.ui-lang-switcher {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  background: var(--bg-canvas);
  border: 1px solid var(--border-tactile);
  border-radius: 7px;
  padding: 2px;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.4);
  flex-shrink: 0;
}

.ui-lang-btn {
  height: 24px;
  min-width: 30px;
  padding: 0 7px;
  border: 1px solid transparent;
  border-radius: 5px;
  background: transparent;
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.03em;
  box-shadow: none;
}

.ui-lang-btn:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.05);
  border-color: transparent;
  color: var(--text-primary);
}

.ui-lang-btn.active,
.ui-lang-btn.active:hover:not(:disabled) {
  background: var(--bg-tactile);
  border-color: var(--accent-bronze-border);
  color: var(--accent-primary);
  box-shadow: var(--tactile-bevel);
}

/* 2. Studio Layout */
.studio-shell {
  display: grid;
  grid-template-columns: minmax(420px, 490px) 1fr;
  height: calc(100vh - 84px);
  background: var(--bg-canvas);
}

.studio-footer {
  min-height: 32px;
  padding: 5px 16px;
  background: var(--bg-sidebar);
  border-top: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
  font-size: 11.5px;
}

.studio-footer-sep {
  color: var(--text-muted);
  opacity: 0.55;
}

.studio-footer-link {
  color: var(--text-muted);
  text-decoration: none;
  transition: color 0.14s ease;
}

.studio-footer-link:hover {
  color: var(--accent-primary);
  text-decoration: underline;
}

.studio-sidebar {
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  padding: 12px 14px 0;
  gap: 12px;
}

.tabs {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(0, 1fr);
  gap: 4px;
  background: var(--bg-canvas);
  border: 1px solid var(--border-tactile);
  border-radius: 8px;
  padding: 3px;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.4);
  position: sticky;
  top: -12px;
  z-index: 10;
}

.tab {
  background: transparent;
  border: 1px solid transparent;
  box-shadow: none;
  color: var(--text-muted);
  padding: 6px 10px;
  height: 30px;
  border-radius: 6px;
  cursor: pointer;
  font: inherit;
  font-size: 12.5px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: all 0.14s ease;
}

.tab:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.04);
}

.tab.active {
  background: var(--bg-tactile);
  border-color: var(--border-tactile);
  color: var(--accent-primary);
  box-shadow: var(--tactile-bevel);
}

.count-pill {
  font-family: ui-monospace, Consolas, monospace;
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-muted);
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 11px;
}

.tab.active .count-pill {
  background: var(--accent-bronze-soft);
  color: var(--accent-primary);
}

.pane { display: flex; flex-direction: column; gap: 12px; padding-bottom: 12px; }
.pane.hidden, .hidden { display: none !important; }

.card-block {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 12px 13px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
  box-shadow: var(--tactile-bevel);
}

.sec-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.inline-actions { display: flex; gap: 6px; flex-wrap: wrap; }

.design-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 9px;
}

.design-grid > * {
  min-width: 0;
}

.design-grid .span-2 {
  grid-column: 1 / -1;
}

label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
  font-size: 11.5px;
  color: var(--text-muted);
}

input, select, textarea {
  width: 100%;
  min-width: 0;
  max-width: 100%;
  box-sizing: border-box;
  background: var(--bg-canvas);
  border: 1px solid var(--border);
  color: var(--text-primary);
  border-radius: 6px;
  padding: 7px 9px;
  font: inherit;
  font-size: 13px;
  transition: border-color 0.14s ease, box-shadow 0.14s ease;
}

select option {
  background: var(--bg-surface);
  color: var(--text-primary);
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 1px var(--accent-primary);
}

input[type="checkbox"] {
  width: auto;
  flex-shrink: 0;
  accent-color: var(--accent-primary);
  padding: 0;
  cursor: pointer;
}

textarea {
  font-family: ui-monospace, Consolas, monospace;
  font-size: 12.5px;
  resize: vertical;
  line-height: 1.5;
}

#desc-text,
#pane-editor textarea {
  font-family: inherit;
  font-size: 13px;
  background: var(--bg-canvas);
}

/* Visual Editor Accordions & Cards */
.ed-accordion {
  padding: 0;
  gap: 0;
}

.ed-acc-head {
  list-style: none;
  cursor: pointer;
  padding: 11px 13px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  font-size: 11.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  user-select: none;
}

.ed-acc-head::-webkit-details-marker {
  display: none;
}

.ed-accordion[open] .ed-acc-head {
  color: var(--accent-primary);
  border-bottom: 1px solid var(--border-subtle);
}

.ed-cards-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 11px 13px 13px;
}

.ed-item-card {
  background: var(--bg-tactile);
  border: 1px solid var(--border-tactile);
  border-radius: 8px;
  padding: 10px 11px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  box-shadow: var(--tactile-bevel);
}

.ed-item-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--accent-primary);
}

.ed-del-btn {
  width: 24px;
  height: 24px;
  padding: 0;
  border-radius: 5px;
  font-size: 15px;
  line-height: 1;
  background: transparent;
  border: 1px solid var(--border-subtle);
  color: var(--text-muted);
  box-shadow: none;
  flex-shrink: 0;
}

.ed-del-btn:hover:not(:disabled) {
  color: #F08D96;
  border-color: rgba(224, 108, 117, 0.5);
  background: rgba(224, 108, 117, 0.14);
}

.ed-acc-actions {
  padding: 0 13px 13px;
  display: flex;
}

.ed-add-btn {
  width: 100%;
  border-style: dashed;
}

.ed-row-2 {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 90px;
  gap: 8px;
}

.ed-row-2-eq {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 8px;
}

/* Catalog item specs mini-editor */
.ed-specs-block {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding-top: 4px;
  border-top: 1px dashed var(--border-subtle);
}

.ed-specs-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  font-size: 11.5px;
  color: var(--text-muted);
}

.ed-specs-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.ed-spec-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 24px;
  gap: 6px;
  align-items: center;
}

/* Editor PRO Media Controls */
.ed-media-box {
  background: var(--bg-canvas);
  border: 1px solid var(--border-subtle);
  border-radius: 7px;
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.ed-media-box.is-locked {
  border-style: dashed;
  border-color: var(--accent-bronze-border);
}

.ed-media-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  font-size: 11.5px;
  color: var(--text-muted);
}

.ed-pro-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--accent-bronze-soft);
  border: 1px solid var(--accent-bronze-border);
  color: var(--accent-primary);
  font-family: ui-monospace, Consolas, monospace;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.03em;
}

.ed-media-row {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.ed-media-preview {
  width: 56px;
  height: 56px;
  flex-shrink: 0;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--bg-surface);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 18px;
}

.ed-media-preview.is-empty {
  border-style: dashed;
}

.ed-media-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.ed-media-controls {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.ed-media-name {
  font-size: 11.5px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ed-media-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.ed-media-btn.is-locked,
.ed-add-btn.is-locked {
  border-color: var(--accent-bronze-border);
  color: var(--accent-primary);
  background: rgba(200, 155, 110, 0.08);
  opacity: 0.88;
  cursor: pointer;
}

.ed-media-btn.is-locked:hover:not(:disabled),
.ed-add-btn.is-locked:hover:not(:disabled) {
  background: rgba(200, 155, 110, 0.16);
  border-color: var(--accent-primary);
}

.ed-media-lock-hint {
  font-size: 11px;
  color: var(--accent-primary);
  line-height: 1.35;
}

.accent-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 10px;
  align-items: end;
}

.color-combo {
  display: flex;
  gap: 6px;
  align-items: center;
}

.color-combo input[type="color"] {
  width: 36px;
  flex-shrink: 0;
  height: 33px;
  padding: 2px;
  cursor: pointer;
  background: var(--bg-tactile);
}

.color-combo input:not([type="color"]) { flex: 1; min-width: 0; }

.swatches-wrap { display: flex; flex-direction: column; gap: 5px; }
.swatch-row { display: flex; gap: 6px; flex-wrap: wrap; }
.swatch-btn {
  width: 24px;
  height: 24px;
  padding: 0;
  border-radius: 999px;
  border: 2px solid var(--border);
  cursor: pointer;
  box-shadow: none;
}
.swatch-btn.active {
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 2px rgba(200, 155, 110, 0.35);
  transform: scale(1.1);
}

.check-inline {
  flex-direction: row;
  align-items: center;
  gap: 8px;
  color: var(--text-primary);
  font-size: 12.5px;
  cursor: pointer;
}

.sections-block { display: flex; flex-direction: column; gap: 6px; }
.sections-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
}

.sec-chip {
  flex-direction: row;
  align-items: center;
  gap: 6px;
  background: var(--bg-tactile);
  border: 1px solid var(--border-tactile);
  border-radius: 6px;
  padding: 5px 8px;
  color: var(--text-muted);
  font-size: 11.5px;
  cursor: pointer;
  box-shadow: var(--tactile-bevel);
  transition: border-color 0.14s ease, color 0.14s ease, background 0.14s ease;
}

.sec-chip:hover {
  background: var(--bg-tactile-hover);
  color: var(--text-primary);
}

.sec-chip:has(input:checked) {
  border-color: var(--accent-bronze-border);
  color: var(--text-primary);
  background: linear-gradient(180deg, rgba(200, 155, 110, 0.12), rgba(35, 39, 48, 0.95));
}

.sec-chip.sec-empty {
  opacity: 0.62;
  border-style: dashed;
}

.upload-box {
  position: relative;
  border-style: dashed;
  border-color: rgba(255, 255, 255, 0.14);
  overflow: hidden;
  margin-bottom: 8px;
}

input[type="file"] {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
}

.file-input-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.file-picker-btn {
  width: 100%;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  color: var(--text-primary);
  font-size: 12.5px;
  cursor: pointer;
}

.file-picker-btn:hover {
  background: var(--bg-tactile-hover);
  border-color: rgba(255, 255, 255, 0.14);
}

.upload-hint {
  margin: 0;
  line-height: 1.4;
  font-size: 11.5px;
}

.file-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.file-chip {
  background: var(--bg-tactile);
  border: 1px solid var(--accent-bronze-border);
  border-radius: 999px;
  padding: 2px 9px;
  font-size: 11.5px;
  color: var(--accent-primary);
}

.image-thumb-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(92px, 1fr));
  gap: 8px;
}

.image-thumb-card {
  position: relative;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--bg-tactile);
  display: flex;
  flex-direction: column;
}

.image-thumb-card.is-main {
  border-color: var(--accent-bronze-border);
}

.image-thumb-img {
  width: 100%;
  height: 74px;
  object-fit: cover;
  display: block;
  background: var(--bg-canvas);
}

.image-main-badge {
  position: absolute;
  top: 4px;
  left: 4px;
  padding: 1px 6px;
  border-radius: 999px;
  background: rgba(18, 19, 22, 0.88);
  border: 1px solid var(--accent-bronze-border);
  color: var(--accent-primary);
  font-size: 10px;
  font-weight: 600;
  line-height: 1.3;
}

.image-remove-btn {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 20px;
  height: 20px;
  padding: 0;
  border-radius: 50%;
  background: rgba(18, 19, 22, 0.88);
  border: 1px solid rgba(255, 255, 255, 0.18);
  color: #EAECEF;
  font-size: 13px;
  line-height: 1;
  box-shadow: none;
}

.image-remove-btn:hover:not(:disabled) {
  background: rgba(224, 108, 117, 0.9);
  border-color: rgba(224, 108, 117, 0.95);
  color: #fff;
}

.image-thumb-name {
  padding: 3px 6px;
  font-size: 10.5px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.actions-sticky {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  position: sticky;
  bottom: 0;
  background: var(--bg-sidebar);
  padding: 10px 0 14px;
  border-top: 1px solid var(--border-subtle);
  box-shadow: 0 -8px 16px rgba(18, 19, 22, 0.72);
  z-index: 8;
}

/* Tactile Buttons */
button,
.btn-tactile {
  height: 34px;
  background: var(--bg-tactile);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0 12px;
  cursor: pointer;
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  box-shadow: var(--tactile-bevel);
  transition: background 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

button:hover:not(:disabled) {
  background: var(--bg-tactile-hover);
  border-color: rgba(255, 255, 255, 0.14);
}

button:active:not(:disabled) {
  background: var(--bg-tactile-active);
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.35);
}

button.sm {
  height: 28px;
  padding: 0 9px;
  font-size: 12px;
}

button.primary,
button.btn-primary-bronze {
  background: linear-gradient(180deg, #D1A579 0%, #B98B5E 100%);
  color: #141518;
  border: 1px solid rgba(255, 255, 255, 0.22);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.35), 0 2px 6px rgba(0, 0, 0, 0.4);
  font-weight: 600;
  flex: 1;
}

button.primary:hover:not(:disabled),
button.btn-primary-bronze:hover:not(:disabled) {
  background: linear-gradient(180deg, #DAB086 0%, #C49668 100%);
  border-color: rgba(255, 255, 255, 0.3);
}

button.danger {
  background: rgba(224, 108, 117, 0.16);
  border-color: rgba(224, 108, 117, 0.4);
  color: #F08D96;
}

button.danger:hover:not(:disabled) {
  background: rgba(224, 108, 117, 0.26);
  border-color: rgba(224, 108, 117, 0.6);
}

button.ghost {
  background: transparent;
  border-color: var(--border-subtle);
  box-shadow: none;
  color: var(--text-muted);
}

button.ghost:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-primary);
}

button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

/* Build Cards */
.build-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 11px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 8px;
  box-shadow: var(--tactile-bevel);
}

.build-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.build-head strong { color: var(--text-primary); font-size: 13.5px; }
.build-meta { font-family: ui-monospace, Consolas, monospace; font-size: 11px; color: var(--text-muted); }
.build-actions { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }

.link-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 30px;
  padding: 0 11px;
  border-radius: 6px;
  background: linear-gradient(180deg, #D1A579 0%, #B98B5E 100%);
  color: #141518;
  border: 1px solid rgba(255, 255, 255, 0.22);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.35), 0 1px 3px rgba(0, 0, 0, 0.35);
  text-decoration: none;
  font-size: 12px;
  font-weight: 600;
}

.link-btn:hover {
  background: linear-gradient(180deg, #DAB086 0%, #C49668 100%);
}

.link-btn.sec {
  background: var(--bg-tactile);
  color: var(--text-primary);
  border: 1px solid var(--border);
  box-shadow: var(--tactile-bevel);
  font-weight: 500;
}

.link-btn.sec:hover {
  background: var(--bg-tactile-hover);
  border-color: rgba(255, 255, 255, 0.14);
}

.link-btn.disabled { opacity: 0.45; pointer-events: none; }

/* 3. Right Live Preview Pane */
.preview-pane {
  display: flex;
  flex-direction: column;
  background: var(--bg-canvas);
  min-width: 0;
  min-height: 0;
}

.preview-toolbar {
  min-height: 44px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 6px 14px;
  border-bottom: 1px solid var(--border-subtle);
  background: var(--bg-surface);
  flex-wrap: wrap;
}

.preview-info { display: flex; align-items: center; gap: 8px; }
.preview-info strong { color: var(--accent-primary); font-size: 13px; }
.preview-controls { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.device-toggle {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
  flex-shrink: 0;
  background: var(--bg-canvas);
  border: 1px solid var(--border-tactile);
  border-radius: 7px;
  padding: 2px;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.4);
}

.device-toggle button {
  flex: 0 0 auto;
  height: auto;
  min-height: 26px;
  border: none;
  border-radius: 5px;
  padding: 5px 10px;
  font-size: 11.5px;
  line-height: 1.2;
  white-space: nowrap;
  font-weight: 600;
  background: transparent;
  color: var(--text-muted);
  box-shadow: none;
}

.device-toggle button:hover {
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-primary);
}

.device-toggle button.active {
  background: var(--bg-tactile);
  color: var(--accent-primary);
  box-shadow: var(--tactile-bevel);
}

.preview-stage {
  flex: 1;
  padding: 12px;
  display: flex;
  justify-content: center;
  align-items: stretch;
  overflow: auto;
}

#preview-frame {
  width: 100%;
  height: 100%;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fff;
  transition: width 0.2s ease;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
}

.preview-stage.mobile-mode #preview-frame {
  width: 390px;
  max-width: 100%;
  border: 4px solid var(--bg-tactile);
  border-radius: 22px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.65);
}

.preview-empty {
  margin: auto;
  text-align: center;
  max-width: 390px;
  color: var(--text-muted);
  background: var(--bg-surface);
  border: 1px dashed var(--accent-bronze-border);
  border-radius: 10px;
  padding: 28px;
  box-shadow: var(--tactile-bevel);
}

.preview-empty p {
  margin: 0;
  line-height: 1.5;
}

.preview-empty-actions {
  margin-top: 16px;
  display: flex;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
}

#toast {
  position: fixed;
  bottom: 18px;
  right: 18px;
  background: var(--bg-surface);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 16px;
  display: none;
  z-index: 40;
  max-width: 460px;
  line-height: 1.45;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.55), var(--tactile-bevel);
}

#toast.err {
  border-color: rgba(224, 108, 117, 0.6);
  color: #F08D96;
}

#toast.warn {
  border-color: rgba(217, 167, 90, 0.65);
  color: #F2D091;
}

#toast.ok {
  border-color: rgba(110, 196, 167, 0.55);
  color: var(--status-approved);
}

.gen-limit-pill {
  cursor: help;
}

.gen-limit-exhausted {
  border-color: rgba(224, 108, 117, 0.55);
  color: #F08D96;
  background: rgba(224, 108, 117, 0.12);
  cursor: pointer;
}

.gen-limit-paid {
  border-color: rgba(110, 196, 167, 0.45);
  color: var(--status-approved);
  background: rgba(110, 196, 167, 0.12);
  cursor: pointer;
}

.topbar-upgrade-actions {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.topbar-upgrade-actions .btn-primary-bronze,
.limit-notice-actions .btn-primary-bronze {
  flex: 0 0 auto;
}

.topbar-code-link,
.limit-code-link {
  background: transparent;
  border: none;
  box-shadow: none;
  height: auto;
  padding: 2px 4px;
  color: var(--accent-primary);
  font-size: 12px;
  font-weight: 600;
  text-decoration: underline;
  cursor: pointer;
}

.topbar-code-link:hover:not(:disabled),
.limit-code-link:hover:not(:disabled) {
  background: transparent;
  color: #E2B98D;
}

.limit-notice {
  background: rgba(217, 167, 90, 0.1);
  border: 1px solid rgba(217, 167, 90, 0.35);
  border-radius: 8px;
  padding: 10px 11px;
  color: var(--text-primary);
  font-size: 12px;
  line-height: 1.45;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.limit-notice strong {
  color: var(--status-warning);
}

.limit-notice a {
  color: var(--accent-primary);
  font-weight: 600;
  text-decoration: underline;
}

.limit-notice-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(10, 11, 14, 0.72);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.modal-card {
  width: 100%;
  max-width: 440px;
  background: var(--bg-surface);
  border: 1px solid var(--accent-bronze-border);
  border-radius: 12px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.65), var(--tactile-bevel);
}

.modal-card p {
  margin: 0;
  line-height: 1.5;
}

.paywall-consent {
  flex-direction: row;
  align-items: flex-start;
  gap: 9px;
  padding: 9px 10px;
  border-radius: 8px;
  background: var(--bg-canvas);
  border: 1px solid var(--border);
  font-size: 12px;
  line-height: 1.45;
  color: var(--text-primary);
  cursor: pointer;
}

.paywall-consent input[type="checkbox"] {
  margin-top: 2px;
  flex-shrink: 0;
  cursor: pointer;
}

.modal-card-legal {
  max-width: 580px;
  max-height: 85vh;
}

.legal-body {
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow-y: auto;
  padding-right: 4px;
}

.legal-section {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding-top: 10px;
  border-top: 1px solid var(--border-subtle);
}

.legal-section:first-child {
  padding-top: 0;
  border-top: none;
}

.legal-section h3 {
  margin: 0;
  font-size: 13px;
  font-weight: 600;
  color: var(--accent-primary);
}

.legal-email-link {
  color: var(--accent-primary);
  text-decoration: underline;
}

.modal-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.modal-actions .link-btn {
  flex: 1;
}

.modal-token-row {
  display: flex;
  gap: 8px;
  align-items: center;
}

.modal-token-row input {
  flex: 1;
}

@media (max-width: 1080px) {
  .studio-shell { grid-template-columns: 1fr; height: auto; }
  .studio-sidebar { border-right: none; border-bottom: 1px solid var(--border-subtle); }
  .preview-stage { min-height: 70vh; }
  .sections-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* Step 4: Order Banner, Stripe Paywall Modal & Mobile Admin UI */
.order-banner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  padding: 8px 14px;
  background: linear-gradient(90deg, rgba(110, 196, 167, 0.12), rgba(200, 155, 110, 0.08));
  border-bottom: 1px solid rgba(110, 196, 167, 0.32);
}

.order-banner-info {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  font-size: 12.5px;
}

.order-banner-code {
  font-family: ui-monospace, Consolas, monospace;
  font-size: 12.5px;
  font-weight: 700;
  color: var(--accent-primary);
  background: var(--bg-canvas);
  border: 1px solid var(--accent-bronze-border);
  padding: 2px 8px;
  border-radius: 5px;
}

.order-banner-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.paywall-price-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: 8px 11px;
  background: var(--bg-canvas);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.paywall-price {
  font-size: 18px;
  font-weight: 700;
  color: var(--accent-primary);
}

.paywall-perks {
  margin: 0;
  padding-left: 18px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  color: var(--text-primary);
  font-size: 12.5px;
  line-height: 1.45;
}

.paywall-perks code {
  font-family: ui-monospace, Consolas, monospace;
  color: var(--accent-primary);
}

.paywall-divider {
  border-top: 1px solid var(--border-subtle);
  padding-top: 11px;
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.paywall-status {
  padding: 8px 10px;
  border-radius: 7px;
  font-size: 12px;
  line-height: 1.4;
  background: rgba(224, 108, 117, 0.14);
  border: 1px solid rgba(224, 108, 117, 0.45);
  color: #F08D96;
}

.paywall-status.is-ok {
  background: rgba(110, 196, 167, 0.14);
  border-color: rgba(110, 196, 167, 0.45);
  color: var(--status-approved);
}

.status-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 999px;
  font-family: ui-monospace, Consolas, monospace;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.status-paid {
  background: rgba(110, 196, 167, 0.16);
  border: 1px solid rgba(110, 196, 167, 0.42);
  color: var(--status-approved);
}

.status-pending {
  background: rgba(217, 167, 90, 0.16);
  border: 1px solid rgba(217, 167, 90, 0.42);
  color: #F2D091;
}

.status-refunded {
  background: rgba(224, 108, 117, 0.16);
  border: 1px solid rgba(224, 108, 117, 0.42);
  color: #F08D96;
}

.admin-shell {
  max-width: 920px;
  margin: 0 auto;
  padding: 16px 14px 36px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.admin-login-card {
  max-width: 440px;
  width: 100%;
  margin: 32px auto;
}

.admin-login-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.admin-dashboard {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.admin-search-row {
  display: grid;
  grid-template-columns: 1fr 200px auto;
  gap: 8px;
  align-items: center;
}

.admin-summary-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.admin-orders-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.admin-order-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.admin-order-id-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.admin-order-id {
  font-family: ui-monospace, Consolas, monospace;
  font-size: 14px;
  color: var(--accent-primary);
}

.admin-order-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px 12px;
}

.admin-order-field {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  word-break: break-word;
}

.admin-mono {
  font-family: ui-monospace, Consolas, monospace;
  font-size: 12px;
}

.admin-link-row {
  display: flex;
  gap: 8px;
  align-items: center;
}

.admin-link-row input {
  flex: 1;
  font-family: ui-monospace, Consolas, monospace;
  font-size: 12px;
}

.admin-order-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

.admin-tap-btn {
  min-height: 40px;
}

@media (max-width: 680px) {
  .admin-search-row {
    grid-template-columns: 1fr;
  }
  .admin-order-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .admin-link-row {
    flex-direction: column;
    align-items: stretch;
  }
  .admin-order-actions > button {
    width: 100%;
  }
}
