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

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

* { 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;
  gap: 12px;
  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-logotop { width: 300px; max-width: 100%; height: auto; display: block; }
.dt-title { color: var(--sub); font-weight: 700; white-space: nowrap; }
.dt-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: flex-end; }

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);
}

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

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

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

.sb-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.sb-cell {
  display: flex;
  flex-direction: column;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px;
  background: color-mix(in srgb, var(--surface) 95%, transparent);
}
.sb-cell > span,
.sb-output-head > span {
  font-size: 12px;
  font-weight: 700;
  color: var(--sub);
}

textarea,
input[type="text"],
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px;
  background: var(--code);
  color: var(--text);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 13px;
}

#htmlInput,
#cssInput,
#jsInput {
  min-height: 320px;
  resize: vertical;
}

.sb-output-cell { min-height: 360px; }
.sb-output-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.sb-output-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.sb-output {
  flex: 1;
  width: 100%;
  min-height: 310px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #ffffff;
}

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

.sb-panel label {
  display: block;
  font-size: 12px;
  font-weight: 700;
  margin-bottom: 10px;
}

.sb-actions-row {
  display: grid;
  grid-template-columns: 140px minmax(0, 1fr);
  gap: 10px;
  align-items: end;
  margin-bottom: 12px;
}

.sb-select-wrap {
  margin: 0;
}

.sb-description {
  min-height: 110px;
  resize: vertical;
}

.sb-version-list,
.sb-favorite-list {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px;
  min-height: 90px;
  max-height: 260px;
  overflow: auto;
  margin-bottom: 14px;
}

.sb-version-item,
.sb-favorite-item {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px;
  margin-bottom: 8px;
  background: color-mix(in srgb, var(--surface) 96%, transparent);
}
.sb-version-item:last-child,
.sb-favorite-item:last-child { margin-bottom: 0; }

.sb-version-head {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: center;
  margin-bottom: 6px;
}
.sb-version-title {
  font-size: 12px;
  color: var(--muted);
}

.sb-version-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.sb-like-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border-radius: 8px;
}
.sb-like-btn img {
  width: 16px;
  height: 16px;
  display: block;
  opacity: .45;
}
.sb-like-btn.is-active img { opacity: 1; }

.sb-mini-btn {
  font-size: 12px;
  padding: 6px 9px;
}

.sb-badge {
  display: inline-block;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 11px;
  color: var(--muted);
}

.sb-feedback {
  min-height: 20px;
  color: #22c55e;
  font-weight: 700;
  margin: 8px 0 0;
}

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

@media (max-width: 900px) {
  .dt-topbar { height: auto; padding: 10px 12px; flex-direction: column; align-items: flex-start; }
  .dt-actions { width: 100%; }
  .sb-grid { grid-template-columns: 1fr; }
  #htmlInput,
  #cssInput,
  #jsInput,
  .sb-output { min-height: 240px; }
  .sb-actions-row { grid-template-columns: 1fr; }
}
