:root {
  --black: #050504;
  --panel: rgba(9, 9, 8, .88);
  --panel-2: rgba(19, 18, 15, .86);
  --gold: #dba62c;
  --gold-light: #ffe49a;
  --silver: #d8dde3;
  --silver-dark: #7e8790;
  --text: #f7f5ef;
  --muted: #aaa69c;
  --line: rgba(222, 170, 50, .4);
  --radius: 20px;
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--black); }
body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  overflow-x: hidden;
}

button, input, select { font: inherit; }
button { -webkit-tap-highlight-color: transparent; }

.backdrop {
  position: fixed;
  inset: 0;
  z-index: -3;
  background: url("assets/gold-city-background.jpg") center 55% / cover no-repeat;
  transform: scale(1.02);
}

.vignette {
  position: fixed;
  inset: 0;
  z-index: -2;
  background:
    radial-gradient(circle at 50% 20%, transparent 0 25%, rgba(0,0,0,.42) 70%),
    linear-gradient(180deg, rgba(0,0,0,.22), rgba(0,0,0,.8));
  backdrop-filter: blur(1px);
}

.shell { width: min(1240px, calc(100% - 28px)); margin: 26px auto 18px; }

.brand-card {
  width: min(455px, 88vw);
  margin: 0 auto 20px;
  padding: 8px;
  border: 1px solid rgba(255, 229, 157, .5);
  border-radius: 25px;
  background: linear-gradient(135deg, rgba(255,255,255,.08), rgba(0,0,0,.75));
  box-shadow: 0 20px 80px rgba(0,0,0,.65), 0 0 45px rgba(218,164,38,.12);
}

.brand-logo { display: block; width: 100%; border-radius: 18px; }

.workspace {
  display: grid;
  grid-template-columns: minmax(280px, 380px) minmax(0, 1fr);
  gap: 18px;
}

.panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: linear-gradient(145deg, rgba(23,22,19,.93), rgba(4,4,4,.94));
  box-shadow: 0 24px 70px rgba(0,0,0,.55), inset 0 1px rgba(255,255,255,.07);
  backdrop-filter: blur(16px);
}

.controls-panel { padding: 22px; }
.panel-heading { display: flex; gap: 13px; align-items: flex-start; margin-bottom: 18px; }
.step {
  display: grid; place-items: center; width: 43px; height: 43px; flex: 0 0 43px;
  color: #16120a; font-weight: 900; border-radius: 12px;
  background: linear-gradient(135deg, var(--gold-light), var(--gold) 55%, #7a4c00);
  box-shadow: 0 0 22px rgba(219,166,44,.25);
}
h1, h2, p { margin: 0; }
h1 { font-size: 1.22rem; letter-spacing: .02em; }
h2 { font-size: 1.35rem; }
.panel-heading p, .modal-card p { margin-top: 5px; color: var(--muted); font-size: .88rem; line-height: 1.45; }

.upload-zone {
  width: 100%; min-height: 145px; padding: 18px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 5px;
  color: var(--text); border: 1px dashed rgba(255,224,139,.55); border-radius: 16px;
  background: radial-gradient(circle at 50% 15%, rgba(218,164,38,.14), rgba(255,255,255,.025));
  cursor: pointer; transition: .2s ease;
}
.upload-zone:hover, .upload-zone.dragover { transform: translateY(-2px); border-color: var(--gold-light); background-color: rgba(218,164,38,.08); }
.upload-icon { font-size: 2rem; line-height: 1; color: var(--gold-light); }
.upload-zone strong { color: var(--gold-light); }
.upload-zone small { color: var(--muted); }

.field-label { display: block; margin: 18px 0 7px; font-size: .78rem; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; color: var(--silver); }
.text-input {
  width: 100%; min-height: 44px; padding: 0 12px; color: var(--text);
  border: 1px solid rgba(216,221,227,.22); border-radius: 10px;
  background: rgba(0,0,0,.45); outline: none;
}
.text-input:focus { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(219,166,44,.12); }
select.text-input { cursor: pointer; }

.control-row { display: flex; align-items: end; justify-content: space-between; gap: 15px; }
.control-row .field-label { margin-bottom: 2px; }
.control-row small { color: var(--muted); font-size: .73rem; }
.control-row output { color: var(--gold-light); font-weight: 800; }
.range { width: 100%; margin: 14px 0 1px; accent-color: var(--gold); }

.button-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 19px; }
.btn {
  min-height: 46px; padding: 10px 14px; border-radius: 11px; cursor: pointer;
  border: 1px solid transparent; font-weight: 800; transition: .2s ease;
}
.btn:hover:not(:disabled) { transform: translateY(-2px); filter: brightness(1.08); }
.btn.secondary { color: var(--silver); border-color: rgba(216,221,227,.2); background: linear-gradient(180deg, rgba(255,255,255,.08), rgba(255,255,255,.025)); }
.btn.primary {
  width: 100%; min-height: 60px; margin-top: 10px; color: #171108;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  background: linear-gradient(120deg, #8b5a05, #f8d676 34%, #bd7b0b 68%, #ffe89f);
  box-shadow: 0 10px 28px rgba(219,166,44,.16);
}
.btn.primary small { font-size: .7rem; font-weight: 650; opacity: .7; }
.btn:disabled { cursor: not-allowed; opacity: .45; filter: grayscale(.7); }
.status { min-height: 20px; margin-top: 12px; color: var(--muted); font-size: .78rem; text-align: center; }
.status.success { color: #e9d18e; }
.status.error { color: #ffaaa0; }

.preview-panel { min-width: 0; padding: 16px; }
.preview-header { min-height: 62px; display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 0 3px 13px; }
.eyebrow { display: block; color: var(--gold); font-size: .68rem; font-weight: 900; letter-spacing: .18em; margin-bottom: 4px; }
.tabs { display: flex; padding: 4px; border: 1px solid rgba(255,255,255,.1); border-radius: 12px; background: rgba(0,0,0,.5); }
.tab { min-width: 58px; padding: 8px 12px; border: 0; border-radius: 8px; color: var(--muted); background: transparent; cursor: pointer; font-weight: 850; }
.tab.active { color: #1b1305; background: linear-gradient(135deg, var(--gold-light), var(--gold)); }

.preview-stage {
  position: relative; min-height: 510px; display: grid; place-items: center; overflow: hidden;
  border: 1px solid rgba(255,224,139,.25); border-radius: 16px;
  background:
    linear-gradient(45deg, rgba(255,255,255,.03) 25%, transparent 25%, transparent 75%, rgba(255,255,255,.03) 75%),
    linear-gradient(45deg, rgba(255,255,255,.03) 25%, transparent 25%, transparent 75%, rgba(255,255,255,.03) 75%), #050505;
  background-size: 28px 28px; background-position: 0 0, 14px 14px;
}
canvas { display: block; max-width: 100%; max-height: 68vh; width: auto; height: auto; object-fit: contain; }
.loading-overlay { position: absolute; inset: 0; display: flex; flex-direction: column; gap: 12px; align-items: center; justify-content: center; background: rgba(0,0,0,.72); backdrop-filter: blur(6px); }
.loading-overlay[hidden] { display: none; }
.loader { width: 48px; height: 48px; border: 4px solid rgba(255,255,255,.16); border-top-color: var(--gold); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.preview-details { display: flex; justify-content: space-between; gap: 12px; margin-top: 11px; color: var(--muted); font-size: .72rem; letter-spacing: .05em; }
.preview-details span:last-child { color: var(--gold); font-weight: 800; }

footer { display: flex; justify-content: space-between; gap: 12px; padding: 15px 5px 4px; color: rgba(255,255,255,.58); font-size: .66rem; letter-spacing: .11em; text-transform: uppercase; }
footer span:first-child { color: var(--gold); font-weight: 900; }

.modal { position: fixed; inset: 0; z-index: 20; padding: 18px; display: grid; place-items: center; background: rgba(0,0,0,.86); backdrop-filter: blur(10px); }
.modal[hidden] { display: none; }
.modal-card { width: min(920px, 100%); max-height: calc(100vh - 36px); overflow: auto; padding: 18px; border: 1px solid var(--line); border-radius: 18px; background: #090908; box-shadow: 0 24px 90px #000; }
.modal-heading { display: flex; align-items: center; justify-content: space-between; margin-bottom: 13px; }
.close-button { width: 42px; height: 42px; border-radius: 50%; border: 1px solid rgba(255,255,255,.16); color: var(--silver); background: rgba(255,255,255,.05); cursor: pointer; font-size: 1.6rem; }
.modal-card img { display: block; width: 100%; max-height: 65vh; object-fit: contain; border-radius: 12px; border: 1px solid rgba(255,255,255,.12); }

@media (max-width: 850px) {
  .shell { width: min(100% - 18px, 680px); margin-top: 10px; }
  .brand-card { width: min(390px, 86vw); }
  .workspace { grid-template-columns: 1fr; }
  .preview-panel { order: -1; }
  .preview-stage { min-height: min(76vw, 520px); }
  canvas { max-height: 70vh; }
}

@media (max-width: 500px) {
  .controls-panel, .preview-panel { padding: 13px; }
  .brand-card { margin-bottom: 10px; }
  .preview-header { align-items: flex-end; }
  .preview-stage { min-height: 86vw; }
  .button-grid { grid-template-columns: 1fr; }
  .preview-details, footer { flex-direction: column; text-align: center; align-items: center; }
}
