:root {
  --bg: #0f172a;
  --panel: #111827;
  --panel-2: #1f2937;
  --border: #334155;
  --text: #f8fafc;
  --muted: #cbd5e1;
  --accent: #38bdf8;
  --accent-dark: #0284c7;
  --shadow: 0 12px 30px rgba(0, 0, 0, 0.25);
  --radius: 18px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: Arial, Helvetica, sans-serif;
  background: linear-gradient(180deg, #0b1220 0%, #0f172a 100%);
  color: var(--text);
  min-height: 100vh;
}
body.tutorial-active { overflow-x: hidden; }

.app-shell {
  width: min(1500px, 96vw);
  margin: 20px auto;
}

.topbar {
  background: rgba(17, 24, 39, 0.95);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 24px;
  box-shadow: var(--shadow);
  margin-bottom: 18px;
}
.topbar h1 { margin: 0 0 6px; font-size: 28px; }
.topbar p { margin: 0; color: var(--muted); }

.layout {
  display: grid;
  grid-template-columns: 430px 1fr;
  gap: 18px;
  align-items: start;
}

.panel {
  background: rgba(17, 24, 39, 0.96);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
}

.controls h2,
.preview-panel h2 { margin: 0 0 14px; font-size: 20px; }
.controls h2:not(:first-child) { margin-top: 20px; }
.controls h3 { margin: 0 0 12px; font-size: 16px; }

.field,
.check-field {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 14px;
}
.field span { font-size: 14px; color: var(--muted); }
.field small,
.helper-copy { color: var(--muted); line-height: 1.45; }
.helper-copy { margin: 0; font-size: 13px; }

input[type="file"],
input[type="number"],
input[type="range"],
select,
button { width: 100%; }

input[type="file"],
input[type="number"],
select {
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 12px;
}
input[type="range"] { accent-color: var(--accent); }

.check-field {
  flex-direction: row;
  align-items: center;
  gap: 10px;
}
.check-field input { flex: 0 0 auto; }
.check-field span { color: var(--text); font-size: 14px; }

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.mode-box {
  margin: 12px 0 18px;
  padding: 14px;
  border-radius: 14px;
  background: rgba(31, 41, 55, 0.65);
  border: 1px solid var(--border);
}
.hidden { display: none !important; }

.status-block {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 16px;
}
.info-box {
  padding: 12px;
  border-radius: 12px;
  background: rgba(56, 189, 248, 0.12);
  border: 1px solid rgba(56, 189, 248, 0.3);
  color: #dff5ff;
  font-size: 14px;
  line-height: 1.5;
}
.status {
  padding: 12px;
  border-radius: 12px;
  background: rgba(34, 197, 94, 0.12);
  border: 1px solid rgba(34, 197, 94, 0.3);
  color: #dcfce7;
  font-size: 14px;
}
.status.error {
  background: rgba(248, 113, 113, 0.12);
  border-color: rgba(248, 113, 113, 0.3);
  color: #fee2e2;
}
.status.warn {
  background: rgba(251, 191, 36, 0.12);
  border-color: rgba(251, 191, 36, 0.35);
  color: #fef3c7;
}

.action-row { display: flex; gap: 10px; margin-top: 12px; }
button {
  background: linear-gradient(180deg, var(--accent) 0%, var(--accent-dark) 100%);
  color: white;
  border: none;
  border-radius: 14px;
  padding: 12px 16px;
  font-weight: 700;
  cursor: pointer;
}
button:hover:not(:disabled) { filter: brightness(1.06); }
button:disabled { opacity: 0.45; cursor: not-allowed; }
.secondary-btn { background: #334155; }
.text-btn {
  width: auto;
  background: transparent;
  color: var(--muted);
  padding: 8px 4px;
}

.preview-heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}
.preview-heading h2 { margin: 0; }
.badge,
.eyebrow {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  border-radius: 999px;
  border: 1px solid rgba(56, 189, 248, 0.3);
  background: rgba(56, 189, 248, 0.12);
  color: #dff5ff;
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 700;
}

.preview-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 14px;
}
.preview-card {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 10px;
}
.preview-card h4 { margin: 0 0 8px; font-size: 14px; color: var(--muted); }
.preview-card canvas {
  width: 100%;
  height: auto;
  display: block;
  background: white;
  border-radius: 10px;
}
.preview-empty {
  padding: 20px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.03);
  color: var(--muted);
  border: 1px dashed var(--border);
}

.help-btn {
  position: fixed;
  z-index: 7000;
  right: 20px;
  top: 20px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  padding: 0;
  font-size: 22px;
  box-shadow: var(--shadow);
}

.modal-backdrop,
.help-menu {
  position: fixed;
  inset: 0;
  z-index: 8000;
  background: rgba(2, 6, 23, 0.8);
  display: grid;
  place-items: center;
  padding: 20px;
}
.modal-card,
.help-card {
  width: min(560px, 100%);
  max-height: calc(100vh - 40px);
  overflow-y: auto;
  position: relative;
  background: #111827;
  border: 1px solid #475569;
  border-radius: 20px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.5);
  padding: 24px;
}
.modal-card h2,
.help-card h2 { margin: 12px 0 10px; }
.modal-card p,
.help-card p { color: var(--muted); line-height: 1.55; }
.modal-card small { display: block; color: var(--muted); margin-top: 12px; }
.modal-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 20px;
}
.icon-close {
  position: absolute;
  right: 14px;
  top: 14px;
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: 50%;
  background: #334155;
  font-size: 22px;
}
.help-choice {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  margin-top: 10px;
  text-align: left;
  background: #1f2937;
  border: 1px solid #334155;
}
.help-choice span { font-weight: 400; color: var(--muted); }
.instructions-card { width: min(680px, 100%); }
.instructions-card h3 { margin: 22px 0 6px; }

.tutorial-shade {
  position: fixed;
  inset: 0;
  z-index: 9000;
  pointer-events: none;
  background: rgba(2, 6, 23, 0.74);
}
.tutorial-target {
  position: relative !important;
  z-index: 9002 !important;
  border-radius: 14px;
  box-shadow:
    0 0 0 4px rgba(56, 189, 248, 0.95),
    0 0 0 10px rgba(56, 189, 248, 0.2),
    0 0 32px rgba(56, 189, 248, 0.65);
  background-color: #111827;
}
.tutorial-bubble {
  position: fixed;
  z-index: 9005;
  width: min(360px, calc(100vw - 24px));
  background: #f8fafc;
  color: #0f172a;
  border-radius: 18px;
  padding: 18px;
  box-shadow: 0 20px 55px rgba(0, 0, 0, 0.45);
}
.tutorial-bubble h3 { margin: 6px 0 8px; }
.tutorial-bubble p { margin: 0; line-height: 1.5; }
.tutorial-progress {
  color: #0369a1;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.tutorial-hint {
  min-height: 18px;
  margin-top: 12px;
  color: #475569;
  font-size: 13px;
  font-weight: 700;
}
.tutorial-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 14px;
}
.tutorial-actions button:first-child { flex: 1; }
.tutorial-actions .text-btn {
  color: #64748b;
  background: transparent;
  flex: 0 0 auto;
}
body.tutorial-active .help-btn { display: none; }

@media (max-width: 1100px) {
  .layout { grid-template-columns: 1fr; }
}
@media (max-width: 560px) {
  .grid-2,
  .action-row,
  .modal-actions {
    grid-template-columns: 1fr;
    display: grid;
  }
  .app-shell {
    width: min(100% - 20px, 1500px);
    margin: 10px auto;
  }
  .panel,
  .topbar { padding: 16px; }
  .help-btn { right: 12px; top: 12px; }
}


/* Last Bell Studio website integration */
.site-return-link {
  position: fixed;
  top: 16px;
  left: 16px;
  z-index: 6000;
  display: inline-flex;
  align-items: center;
  min-height: 38px;
  padding: 8px 11px;
  border: 2px solid var(--ink);
  border-radius: 8px;
  color: var(--ink);
  background: rgba(255,255,255,.94);
  box-shadow: 3px 3px 0 rgba(0,0,0,.18);
  font: 800 12px/1 system-ui, sans-serif;
  text-decoration: none;
  letter-spacing: .04em;
}
.site-return-link:hover { transform: translate(-1px,-1px); }
.site-return-link:focus-visible { outline: 3px solid #fff; outline-offset: 3px; }
@media (max-width: 720px) {
  .site-return-link { top: 10px; left: 10px; min-height: 34px; padding: 7px 9px; font-size: 10px; }
}


/* V13 QA: high-contrast Last Bell return control */
.site-return-link{background:#FFBF18!important;color:#101820!important;border-color:#101820!important;font-weight:900;}
.site-return-link:focus-visible{outline-color:#FFBF18;}

/* =========================================================
   V16 — align navigation with the app header
   ========================================================= */
.topbar{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:18px;
}
.topbar-actions{
  display:flex;
  align-items:center;
  justify-content:flex-end;
  gap:12px;
  flex:0 0 auto;
}
.site-return-link{
  position:static!important;
  min-height:44px;
  padding:0 16px;
  border:2px solid #0f172a!important;
  border-radius:11px;
  background:#85DAFF!important;
  color:#0f172a!important;
  box-shadow:4px 4px 0 rgba(0,0,0,.2);
  font-size:12px;
}
.site-return-link:hover{
  background:#A6E6FF!important;
  transform:translate(-1px,-1px);
}
.site-return-link:focus-visible{
  outline:3px solid #85DAFF!important;
  outline-offset:3px;
}
.help-btn{
  position:static!important;
  width:44px!important;
  min-width:44px;
  height:44px;
  flex:0 0 44px;
  margin:0;
}
@media(max-width:720px){
  .topbar{align-items:flex-start;flex-direction:column}
  .topbar-actions{width:100%;justify-content:flex-end}
  .site-return-link{min-height:40px;padding:0 12px;font-size:10px}
}
