:root {
  --bg: #ffffff;
  --surface: #ffffff;
  --code: #ffffff;
  --line: rgba(0, 0, 0, .12);
  --text: #111827;
  --sub: #856259;
  --topbar: #ffffff;
  --primary: #fa9403;
  --muted: #667085;
  --ok: #22c55e;
  --warn: #f59e0b;
}

html[data-theme="dark"] {
  --bg: #000;
  --surface: #000;
  --code: #202020;
  --line: rgba(255, 255, 255, .16);
  --text: #e5e7eb;
  --sub: #d9b8a0;
  --topbar: #000;
  --muted: #9ca3af;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
}

.dt-topbar {
  height: 100px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  background: var(--topbar);
  border-bottom: 1px solid var(--line);
}
.dt-brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.dt-logo { display: block; flex: 0 1 auto; }
.dt-logotop {
  width: 500px;
  max-width: 100%;
  height: auto;
  display: block;
}
.dt-title { color: var(--sub); font-weight: 700; white-space: nowrap; }
.dt-actions { display: flex; gap: 8px; align-items: center; }

button,
.dt-secondary-btn {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  border-radius: 10px;
  padding: 9px 12px;
  font-weight: 700;
  cursor: pointer;
}
button:hover,
.dt-secondary-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
}
button:disabled {
  opacity: .45;
  cursor: not-allowed;
}
button:disabled:hover {
  border-color: var(--line);
  color: var(--text);
}

.dt-main {
  width: 100%;
  margin: 18px 0;
  padding: 0 14px 40px;
}

.lg-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 430px;
  gap: 16px;
  align-items: start;
}

.lg-stage,
.lg-panel {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px;
  background: var(--surface);
}

.lg-panel h1,
.lg-panel h2,
.lg-stage h2 {
  margin: 0 0 10px;
  color: var(--sub);
  font-weight: 600;
}
.lg-panel h2 { margin-top: 16px; }

.lg-stage-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.lg-preview-wrap,
.lg-generated-wrap {
  position: relative;
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
  display: grid;
  place-items: center;
  background:
    linear-gradient(45deg, color-mix(in srgb, var(--muted) 12%, transparent) 25%, transparent 25%),
    linear-gradient(-45deg, color-mix(in srgb, var(--muted) 12%, transparent) 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, color-mix(in srgb, var(--muted) 12%, transparent) 75%),
    linear-gradient(-45deg, transparent 75%, color-mix(in srgb, var(--muted) 12%, transparent) 75%),
    var(--code);
  background-position: 0 0, 0 14px, 14px -14px, -14px 0;
  background-size: 28px 28px;
}
.lg-preview-wrap {
  min-height: 520px;
  padding: 24px;
  user-select: none;
}
.lg-generated-wrap {
  min-height: 260px;
  padding: 20px;
}

.lg-empty {
  display: grid;
  gap: 6px;
  place-items: center;
  text-align: center;
  color: var(--muted);
  min-height: 160px;
}
.lg-empty strong {
  color: var(--text);
}
.lg-empty.compact {
  min-height: 130px;
}

.lg-image-box {
  position: relative;
  width: 240px;
  height: 240px;
  max-width: 100%;
  display: block;
  cursor: crosshair;
}
.lg-preview-canvas {
  display: block;
  width: 100%;
  height: 100%;
}
.lg-center-point {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 30px;
  height: 30px;
  border: 2px solid #ffffff;
  border-radius: 999px;
  transform: translate(-50%, -50%);
  box-shadow: 0 0 0 2px var(--primary), 0 4px 16px rgba(0, 0, 0, .2);
  pointer-events: none;
}
.lg-center-point::before,
.lg-center-point::after {
  content: '';
  position: absolute;
  background: var(--primary);
}
.lg-center-point::before {
  left: 50%;
  top: -10px;
  bottom: -10px;
  width: 2px;
  transform: translateX(-50%);
}
.lg-center-point::after {
  top: 50%;
  left: -10px;
  right: -10px;
  height: 2px;
  transform: translateY(-50%);
}

.lg-output-box {
  margin-top: 14px;
}
.lg-generated-preview {
  max-width: min(100%, 320px);
  max-height: 320px;
  image-rendering: auto;
}

.lg-dropzone {
  border: 2px dashed var(--line);
  border-radius: 12px;
  min-height: 126px;
  display: grid;
  place-items: center;
  text-align: center;
  gap: 4px;
  cursor: pointer;
  padding: 14px;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
}
.lg-dropzone span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}
.lg-dropzone.dragover {
  border-color: var(--primary);
  color: var(--primary);
}

.lg-row {
  display: grid;
  gap: 10px;
  margin-bottom: 12px;
}
.lg-row.two {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
label {
  display: block;
  font-size: 12px;
  font-weight: 700;
}
input[type="range"] {
  width: 100%;
  margin-top: 6px;
}
input[type="text"],
select {
  width: 100%;
  margin-top: 6px;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 9px 10px;
  background: var(--code);
  color: var(--text);
  font-size: 13px;
}

.lg-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 8px 0 12px;
}
.lg-actions.main button:first-child {
  border-color: var(--primary);
  color: var(--primary);
}
.lg-mini,
.lg-meta {
  color: var(--muted);
  font-size: 12px;
}
.lg-meta {
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.lg-status {
  min-height: 22px;
  color: var(--ok);
  font-weight: 700;
  margin: 12px 0 0;
}
.lg-status.warn { color: var(--warn); }

.lg-progress {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  margin: 0 0 12px;
}
.lg-progress[aria-hidden="true"] {
  display: none;
}
.lg-progress-track {
  height: 10px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--muted) 18%, transparent);
  overflow: hidden;
}
.lg-progress-bar {
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--primary), #2563eb);
  transition: width .16s ease;
}
.lg-progress-text {
  min-width: 44px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-align: right;
}

.is-hidden { display: none !important; }

@media (max-width: 1200px) {
  .lg-shell { grid-template-columns: 1fr; }
}

@media (max-width: 760px) {
  .dt-topbar {
    height: auto;
    min-height: 88px;
    align-items: flex-start;
    padding: 12px 14px;
    gap: 10px;
  }
  .dt-brand {
    align-items: flex-start;
    flex-direction: column;
    gap: 6px;
  }
  .dt-logotop { width: min(500px, 72vw); }
  .dt-title { white-space: normal; }
  .lg-row.two { grid-template-columns: 1fr; }
  .lg-preview-wrap { min-height: 360px; padding: 14px; }
  .lg-stage-head {
    align-items: flex-start;
    flex-direction: column;
  }
}
