:root {
  --bg: #f7f8fb;
  --panel: #ffffff;
  --text: #1f2937;
  --muted: #64748b;
  --line: #dbe3ef;
  --accent: #2563eb;
  --accent-dark: #1d4ed8;
  --soft: #eef4ff;
  --danger: #b42318;
  --ok: #157f3b;
  --shadow: 0 12px 30px rgba(15, 23, 42, 0.07);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 16px;
  line-height: 1.55;
}

a {
  color: inherit;
  text-decoration: none;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  min-height: 64px;
  padding: 0 32px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(10px);
}

.brand {
  font-weight: 800;
  font-size: 19px;
}

.topbar nav {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.topbar nav a {
  padding: 8px 12px;
  border-radius: 7px;
  color: var(--muted);
  font-size: 14px;
}

.topbar nav a:hover,
.topbar nav .export-link,
.topbar nav .import-link {
  background: var(--soft);
  color: var(--accent);
}

.shell {
  width: min(1180px, calc(100% - 32px));
  margin: 32px auto 64px;
}

.page-head,
.section-title,
.count-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.page-head {
  margin-bottom: 22px;
}

.head-actions,
.card-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--accent);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  line-height: 1.2;
}

h1 {
  font-size: 32px;
}

h2 {
  font-size: 20px;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 0 16px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--panel);
  color: var(--text);
  font-weight: 700;
  cursor: pointer;
}

.button.primary {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

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

.button.subtle:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.editor,
.question-card,
.empty {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.editor {
  padding: 22px;
}

.editor-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(340px, 0.75fr);
  gap: 22px;
  align-items: start;
}

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

label {
  display: grid;
  gap: 8px;
}

label.wide {
  grid-column: 1 / -1;
}

label span {
  color: #334155;
  font-size: 14px;
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  color: var(--text);
  font: inherit;
}

input,
select {
  min-height: 42px;
  padding: 0 12px;
}

textarea {
  resize: vertical;
  min-height: 86px;
  padding: 12px;
}

input:focus,
select:focus,
textarea:focus {
  outline: 3px solid rgba(37, 99, 235, 0.14);
  border-color: var(--accent);
}

.actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 20px;
}

.recent {
  margin-top: 34px;
}

.section-title {
  margin-bottom: 14px;
}

.section-title a {
  color: var(--accent);
  font-weight: 700;
}

.question-list {
  display: grid;
  gap: 16px;
}

.question-list.compact {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.question-card {
  padding: 18px;
}

.question-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 13px;
}

.question-meta span:first-child {
  color: var(--accent);
  font-weight: 800;
}

.card-actions {
  margin-left: auto;
}

.delete-form {
  margin: 0;
}

.small-button,
.delete-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 30px;
  padding: 0 10px;
  border-radius: 7px;
  font-size: 13px;
  font-weight: 800;
}

.small-button {
  border: 1px solid rgba(37, 99, 235, 0.24);
  background: #fff;
  color: var(--accent);
}

.small-button:hover {
  background: var(--soft);
}

.delete-button {
  border: 1px solid rgba(180, 35, 24, 0.24);
  background: #fff;
  color: var(--danger);
  font: inherit;
  cursor: pointer;
}

.delete-button:hover {
  background: #fff1f0;
}

.tag-line {
  padding: 2px 8px;
  border-radius: 999px;
  background: #edf7f3;
  color: #17664a;
}

.rendered p,
.options p {
  margin: 0.25em 0;
}

.rendered h1,
.rendered h2,
.rendered h3 {
  margin: 0.6em 0 0.25em;
  font-size: 18px;
}

.attachment {
  display: block;
  max-width: min(100%, 620px);
  max-height: 420px;
  object-fit: contain;
  margin: 12px 0;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.attachment.tiny {
  max-width: 180px;
  max-height: 120px;
  margin: 0;
}

.image-preview-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
  min-height: 42px;
}

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

.options > div {
  display: grid;
  grid-template-columns: 28px 1fr;
  gap: 6px;
  min-height: 44px;
  padding: 10px;
  border: 1px solid #e7edf6;
  border-radius: 7px;
  background: #fbfcff;
}

.options b {
  color: var(--accent);
}

details {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px dashed var(--line);
}

summary {
  color: var(--accent);
  font-weight: 800;
  cursor: pointer;
}

.live-preview {
  position: sticky;
  top: 86px;
  display: grid;
  gap: 12px;
}

.preview-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: #334155;
  font-weight: 800;
}

.preview-head small {
  color: var(--muted);
  font-weight: 700;
}

.preview-card {
  box-shadow: none;
}

.placeholder {
  color: var(--muted);
}

.count-bar {
  min-height: 44px;
  margin-bottom: 16px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--panel);
  color: var(--muted);
}

.history-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 14px;
}

.day-card {
  display: grid;
  gap: 10px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.day-card:hover {
  border-color: var(--accent);
}

.day-card span {
  color: var(--muted);
}

.day-card strong {
  font-size: 24px;
}

.history-section-title {
  margin: 30px 0 14px;
}

.json-card {
  border-color: rgba(37, 99, 235, 0.22);
}

.compact-empty {
  padding: 20px;
  box-shadow: none;
}

.empty {
  display: grid;
  gap: 12px;
  justify-items: start;
  padding: 28px;
}

.empty p {
  margin: 0;
  color: var(--muted);
}

.import-uploader {
  max-width: 620px;
}

.import-list {
  display: grid;
  gap: 16px;
}

.import-card {
  display: grid;
  gap: 12px;
}

.import-card-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(320px, 0.85fr);
  gap: 22px;
  align-items: start;
}

.import-preview {
  position: sticky;
  top: 86px;
  display: grid;
  gap: 12px;
}

.image-position-button {
  justify-self: start;
  cursor: pointer;
}

.answer-line {
  margin: 0;
  color: var(--accent);
  font-weight: 800;
}

.sticky-actions {
  position: sticky;
  bottom: 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: var(--shadow);
  color: var(--muted);
  font-weight: 700;
}

.messages {
  display: grid;
  gap: 10px;
  margin-bottom: 18px;
}

.message {
  padding: 12px 14px;
  border-radius: 7px;
  border: 1px solid var(--line);
  background: var(--panel);
  font-weight: 700;
}

.message.success {
  border-color: rgba(21, 127, 59, 0.25);
  color: var(--ok);
}

.message.error {
  border-color: rgba(180, 35, 24, 0.25);
  color: var(--danger);
}

code {
  padding: 0.12em 0.3em;
  border-radius: 4px;
  background: #eef2f7;
}

@media (max-width: 820px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
    padding: 14px 16px;
  }

  .shell {
    width: min(100% - 24px, 720px);
    margin-top: 22px;
  }

  .page-head,
  .count-bar,
  .sticky-actions {
    align-items: flex-start;
    flex-direction: column;
  }

  h1 {
    font-size: 26px;
  }

  .editor-layout,
  .import-card-layout,
  .form-grid,
  .question-list.compact,
  .options {
    grid-template-columns: 1fr;
  }

  .live-preview {
    position: static;
  }

  .editor,
  .question-card {
    padding: 16px;
  }
}
