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

html[data-theme="dark"] {
  --bg: #000000;
  --surface: #000000;
  --code: #111111;
  --line: rgba(255, 255, 255, .16);
  --text: #e5e7eb;
  --sub: #d9b8a0;
  --topbar: #000000;
  --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;
}

.dt-logotop {
  width: 500px;
  max-width: 100%;
  height: auto;
  display: block;
}

.dt-title {
  color: var(--sub);
  font-weight: 700;
}

.dt-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

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

.dt-secondary-btn:hover,
button:hover {
  border-color: var(--primary);
  color: var(--primary);
}

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

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

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

.km-stage {
  min-height: 620px;
}

.km-output-card {
  height: 100%;
  min-height: 590px;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 18px;
  background:
    linear-gradient(to right, rgba(127, 127, 127, .08) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(127, 127, 127, .08) 1px, transparent 1px),
    color-mix(in srgb, var(--surface) 94%, transparent);
  background-size: 24px 24px, 24px 24px, auto;
}

.km-output-head {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 14px;
}

.km-output-head h1,
.km-panel h2 {
  margin: 0 0 8px;
  color: var(--sub);
  font-weight: 600;
}

.km-output-head p {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}

.km-output-label,
label,
legend {
  display: block;
  font-size: 12px;
  font-weight: 700;
}

input[type="text"],
input[type="url"],
select,
textarea {
  width: 100%;
  margin-top: 6px;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 9px 10px;
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
}

textarea {
  min-height: 420px;
  resize: vertical;
  background: var(--code);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  line-height: 1.5;
}

.km-row {
  display: grid;
  gap: 10px;
  margin-bottom: 12px;
}

.km-fieldset {
  margin: 0 0 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
}

.km-fieldset legend {
  padding: 0 6px;
  color: var(--sub);
}

.km-radio {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  font-weight: 600;
}

.km-radio input {
  margin: 0;
}

.km-note {
  margin-top: 18px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.km-note code {
  display: block;
  margin-top: 8px;
  white-space: normal;
  word-break: break-word;
  color: var(--text);
}

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

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

  .km-stage {
    min-height: auto;
  }

  .km-output-card {
    min-height: 420px;
  }
}

@media (max-width: 720px) {
  .km-output-head {
    flex-direction: column;
  }

  .dt-title {
    display: none;
  }
}
