:root {
  color-scheme: dark;
  --bg: #121316;
  --panel: #1c1f24;
  --panel-soft: #242830;
  --text: #f5f0e8;
  --muted: #a9adb8;
  --line: #333842;
  --accent: #23b38e;
  --accent-2: #f1b84b;
  --danger: #ff6b6b;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.28);
}

:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f4f1ea;
  --panel: #ffffff;
  --panel-soft: #f1f4f2;
  --text: #171819;
  --muted: #677078;
  --line: #dce0df;
  --accent: #167a68;
  --accent-2: #b35f1b;
  --danger: #c74343;
  --shadow: 0 16px 42px rgba(30, 35, 38, 0.12);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  width: min(1440px, 100%);
  margin: 0 auto;
  padding: max(18px, env(safe-area-inset-top)) 18px max(24px, env(safe-area-inset-bottom));
}

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

.eyebrow {
  margin: 0 0 5px;
  color: var(--accent-2);
  font-size: 12px;
  font-weight: 750;
  letter-spacing: 0;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(26px, 5vw, 40px);
  line-height: 1.1;
}

h2 {
  margin-bottom: 5px;
  font-size: 20px;
}

p {
  color: var(--muted);
  line-height: 1.5;
}

.workspace {
  display: grid;
  grid-template-columns: 380px minmax(0, 1fr) 360px;
  gap: 14px;
  align-items: start;
}

.panel {
  min-height: 280px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.panel-head,
.editor-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  padding: 18px;
  border-bottom: 1px solid var(--line);
}

.panel-head p {
  margin-bottom: 0;
  font-size: 13px;
}

.stats-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  padding: 14px 18px 6px;
}

.stat {
  padding: 10px;
  border-radius: 8px;
  background: var(--panel-soft);
}

.stat strong {
  display: block;
  font-size: 22px;
}

.stat span {
  color: var(--muted);
  font-size: 12px;
}

.segmented {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  padding: 12px 18px;
}

.segment,
.secondary,
.primary,
.icon-button {
  border: 1px solid var(--line);
  border-radius: 8px;
  min-height: 42px;
}

.segment {
  background: transparent;
  color: var(--muted);
  font-size: 13px;
}

.segment.active {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}

.question-list {
  display: grid;
  gap: 10px;
  padding: 0 18px 18px;
  max-height: calc(100vh - 270px);
  overflow: auto;
}

.question-item {
  width: 100%;
  text-align: left;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
  color: var(--text);
  padding: 12px;
}

.question-item.active {
  border-color: var(--accent);
  outline: 2px solid color-mix(in srgb, var(--accent), transparent 74%);
}

.question-item.selected {
  box-shadow: inset 4px 0 0 var(--accent-2);
}

.question-text {
  margin-bottom: 8px;
  color: var(--text);
  font-size: 15px;
}

.meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--muted);
  font-size: 12px;
}

.private-pill {
  color: var(--accent-2);
}

.empty-state {
  display: grid;
  min-height: 132px;
  place-content: center;
  padding: 22px;
  text-align: center;
}

.empty-state h2 {
  font-size: 18px;
}

.empty-state p {
  margin-bottom: 0;
  font-size: 14px;
}

.editor {
  padding: 0 18px 18px;
}

#editorQuestion {
  font-size: 24px;
  line-height: 1.28;
}

.field-label {
  display: grid;
  gap: 8px;
  margin: 16px 0 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

textarea,
input,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
  color: var(--text);
  padding: 12px;
  outline: none;
}

textarea:focus,
input:focus,
select:focus {
  border-color: var(--accent);
}

textarea {
  resize: vertical;
  line-height: 1.55;
}

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

.secret-box {
  margin-top: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: color-mix(in srgb, var(--panel-soft), transparent 24%);
  overflow: hidden;
}

.secret-box summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 48px;
  padding: 0 12px;
  color: var(--text);
  font-weight: 780;
  list-style: none;
  cursor: pointer;
}

.secret-box summary::-webkit-details-marker {
  display: none;
}

.secret-hint {
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

#privateAnswerInput {
  width: calc(100% - 24px);
  margin: 0 12px 12px;
}

.tool-grid {
  grid-template-columns: 1fr;
  padding: 0 18px 14px;
}

.button-row {
  display: flex;
  gap: 10px;
  margin-top: 16px;
}

.primary,
.secondary,
.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 14px;
  font-weight: 760;
}

.primary {
  border-color: var(--accent);
  background: var(--accent);
  color: white;
}

.secondary,
.icon-button {
  background: var(--panel-soft);
  color: var(--text);
}

.compact {
  min-height: 38px;
}

.full {
  width: calc(100% - 36px);
  margin: 0 18px 16px;
}

.icon-button {
  width: 42px;
  padding: 0;
  font-size: 20px;
}

.danger {
  color: var(--danger);
}

.preview-strip {
  display: grid;
  gap: 14px;
  padding: 0 18px 18px;
}

.preview-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: var(--panel-soft);
}

.preview-card img {
  display: block;
  width: 100%;
}

.preview-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 10px;
}

.preview-buttons {
  display: flex;
  align-items: center;
  gap: 8px;
}

.preview-actions a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  background: var(--panel);
  color: var(--accent);
  font-weight: 760;
  text-decoration: none;
}

dialog {
  width: min(520px, calc(100vw - 28px));
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--text);
  box-shadow: var(--shadow);
}

dialog::backdrop {
  background: rgba(0, 0, 0, 0.58);
}

.dialog-body {
  padding: 18px;
}

@media (max-width: 1080px) {
  .workspace {
    grid-template-columns: 1fr;
  }

  .question-list {
    max-height: none;
  }

  .panel {
    min-height: auto;
  }
}

@media (max-width: 560px) {
  .app-shell {
    padding-left: 12px;
    padding-right: 12px;
  }

  .topbar {
    align-items: flex-start;
  }

  h1 {
    font-size: 28px;
  }

  .stats-row,
  .segmented {
    padding-left: 12px;
    padding-right: 12px;
  }

  .segmented {
    grid-template-columns: repeat(2, 1fr);
  }

  .question-list,
  .tool-grid,
  .preview-strip {
    padding-left: 12px;
    padding-right: 12px;
  }

  .editor-grid {
    grid-template-columns: 1fr;
  }

  .button-row {
    flex-direction: column;
  }

  .button-row button {
    width: 100%;
  }

  .full {
    width: calc(100% - 24px);
    margin-left: 12px;
    margin-right: 12px;
  }
}
