:root {
  color-scheme: light;
  --bg: #f5f7f9;
  --panel: #ffffff;
  --ink: #17202a;
  --muted: #627083;
  --line: #d9e0e7;
  --accent: #1565c0;
  --accent-dark: #0d47a1;
  --soft: #eef4fb;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: Arial, "PingFang SC", "Microsoft YaHei", sans-serif;
  padding-bottom: 360px;
}

.app-shell {
  width: min(1180px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 28px 0 40px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 28px;
  line-height: 1.2;
}

h2 {
  font-size: 16px;
  margin-bottom: 14px;
}

.topbar p,
.hint {
  color: var(--muted);
  margin-top: 6px;
  line-height: 1.5;
}

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

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
}

.wide,
.result {
  grid-column: 1 / -1;
}

label {
  display: grid;
  gap: 7px;
  color: #344054;
  font-size: 13px;
  margin-bottom: 12px;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid #c8d2dc;
  border-radius: 6px;
  padding: 10px 11px;
  font: inherit;
  color: var(--ink);
  background: #fff;
}

textarea {
  resize: vertical;
}

button {
  border: 0;
  border-radius: 6px;
  padding: 10px 14px;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  cursor: pointer;
}

button:hover {
  background: var(--accent-dark);
}

.full {
  width: 100%;
  margin-bottom: 12px;
}

.secondary {
  background: var(--soft);
  color: var(--accent-dark);
  border: 1px solid #cfe0f4;
}

.secondary:hover {
  background: #dfeefa;
}

details {
  border: 1px dashed var(--line);
  border-radius: 6px;
  padding: 10px 12px;
  background: #fbfdff;
}

summary {
  cursor: pointer;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

details[open] summary {
  margin-bottom: 10px;
}

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

.checks,
.questions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px 16px;
  margin-bottom: 12px;
}

.checks label,
.questions label {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
}

.checks input,
.questions input {
  width: auto;
}

.actions,
.result-title {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.compact-actions {
  justify-content: flex-start;
  margin-bottom: 10px;
}

.inline-actions {
  display: flex;
  gap: 10px;
  margin-bottom: 12px;
}

.stacked-fields {
  display: grid;
  gap: 8px;
  margin: 8px 0 12px;
}

.question-row input {
  flex: 1;
}

.danger {
  color: #9f1d1d;
  border-color: #f0caca;
  background: #fff4f4;
}

.library-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px 14px;
  max-height: 360px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 12px;
  background: #fbfdff;
}

.library-item {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
}

.library-item input {
  width: auto;
}

.campaign-list {
  grid-template-columns: 1fr;
}

.campaign-item span {
  line-height: 1.35;
}

.summary-table {
  margin: 10px 0 16px;
  overflow: auto;
}

.summary-table table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.summary-table th,
.summary-table td {
  border: 1px solid var(--line);
  padding: 9px 10px;
  text-align: left;
  white-space: nowrap;
}

.summary-table th,
.summary-table tfoot {
  background: var(--soft);
  font-weight: 700;
}

.result {
  position: fixed;
  left: 50%;
  right: auto;
  bottom: 12px;
  z-index: 20;
  width: min(1180px, calc(100vw - 32px));
  max-height: 330px;
  transform: translateX(-50%);
  box-shadow: 0 14px 38px rgba(23, 32, 42, 0.22);
}

.result-title {
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.result-actions {
  display: flex;
  gap: 10px;
  align-items: center;
}

pre {
  height: 245px;
  overflow: auto;
  margin: 0;
  padding: 14px;
  border-radius: 6px;
  background: #101828;
  color: #e6edf3;
  line-height: 1.45;
}

@media (max-width: 800px) {
  body {
    padding-bottom: 300px;
  }

  .result {
    bottom: 8px;
    max-height: 280px;
  }

  pre {
    height: 200px;
  }

  .layout,
  .inline,
  .grid-two,
  .checks,
  .questions,
  .library-list {
    grid-template-columns: 1fr;
  }

  .topbar {
    align-items: stretch;
    flex-direction: column;
  }
}
