:root {
  --paper: #edf1ed;
  --ink: #211f1b;
  --muted: #667066;
  --line: #cbd4ca;
  --panel: #fbfcf7;
  --panel-strong: #e4eadf;
  --teal: #0b746d;
  --teal-dark: #07514d;
  --amber: #c7831c;
  --red: #b83b35;
  --shadow: 0 14px 34px rgba(30, 45, 36, 0.12);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  height: 100vh;
  overflow: hidden;
  color: var(--ink);
  background:
    linear-gradient(90deg, rgba(11, 116, 109, 0.06) 1px, transparent 1px),
    linear-gradient(0deg, rgba(199, 131, 28, 0.05) 1px, transparent 1px),
    var(--paper);
  background-size: 32px 32px;
  font-family: "Microsoft YaHei UI", "Microsoft YaHei", "Segoe UI", sans-serif;
}

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

button {
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-columns: 190px minmax(0, 1fr);
  height: 100vh;
  min-height: 0;
}

.side-rail {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 14px;
  color: #f8f1e5;
  background: #20261f;
  border-right: 1px solid rgba(255, 255, 255, 0.08);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border-radius: var(--radius);
  color: #1c1a16;
  background: var(--amber);
  font-weight: 900;
}

.brand strong,
.brand small {
  display: block;
}

.brand small,
.storage-note span,
.metric span {
  color: rgba(248, 241, 229, 0.65);
}

.metric-stack {
  display: grid;
  gap: 8px;
}

.metric {
  padding: 10px 12px;
  border: 1px solid rgba(248, 241, 229, 0.14);
  border-radius: var(--radius);
  background: rgba(248, 241, 229, 0.06);
}

.metric strong {
  display: block;
  margin-top: 3px;
  font-size: 26px;
  line-height: 1;
}

.metric.accent {
  border-color: rgba(216, 138, 29, 0.45);
}

.storage-note {
  margin-top: auto;
  display: grid;
  gap: 8px;
  font-size: 12px;
}

.storage-note code {
  display: block;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: #f8f1e5;
}

.workspace {
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  min-width: 0;
  height: 100vh;
  min-height: 0;
  overflow: hidden;
  padding: 10px;
  gap: 8px;
}

.topbar,
.control-strip,
.list-pane,
.editor-pane {
  background: rgba(255, 250, 240, 0.86);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 12px;
  border-radius: var(--radius);
}

.topbar h1 {
  font-size: 20px;
}

.topbar h1,
.editor-head h2 {
  margin: 0;
  letter-spacing: 0;
}

.eyebrow {
  margin: 0 0 2px;
  color: var(--teal);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.top-actions,
.action-cluster,
.bulk-actions,
.section-title,
.list-head,
.editor-head,
.option-row {
  display: flex;
  align-items: center;
}

.top-actions,
.action-cluster {
  gap: 10px;
}

.solid-button,
.ghost-button,
.danger-button,
.tiny-button,
.tab {
  min-height: 32px;
  padding: 0 11px;
  border-radius: var(--radius);
  border: 1px solid transparent;
  font-weight: 700;
  white-space: nowrap;
}

.solid-button {
  color: #fff;
  background: var(--teal);
}

.solid-button:hover {
  background: var(--teal-dark);
}

.ghost-button,
.tiny-button {
  color: var(--ink);
  border-color: var(--line);
  background: rgba(255, 255, 255, 0.55);
}

.danger-button {
  color: var(--red);
  border-color: rgba(184, 59, 53, 0.28);
  background: rgba(184, 59, 53, 0.08);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

.tiny-button {
  min-height: 30px;
  padding: 0 10px;
  font-size: 12px;
}

.control-strip {
  display: grid;
  grid-template-columns: auto minmax(220px, 1fr) 160px auto;
  gap: 8px;
  align-items: center;
  padding: 8px;
  border-radius: var(--radius);
}

.bulk-actions {
  justify-content: flex-end;
  gap: 8px;
}

.tabs {
  display: inline-flex;
  padding: 3px;
  border-radius: var(--radius);
  background: var(--panel-strong);
}

.tab {
  border: 0;
  background: transparent;
  color: var(--muted);
}

.tab.active {
  color: #fff;
  background: #24211c;
}

.search-box,
.select-box,
.field {
  display: grid;
  gap: 6px;
}

.search-box span,
.select-box span,
.field span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--ink);
  background: rgba(255, 255, 255, 0.72);
  outline: none;
}

input,
select {
  height: 32px;
  padding: 0 9px;
}

textarea {
  resize: vertical;
  padding: 10px;
  line-height: 1.6;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(11, 116, 109, 0.14);
}

.work-grid {
  display: grid;
  grid-template-columns: minmax(360px, 0.9fr) minmax(420px, 1.1fr);
  min-height: 0;
  height: 100%;
  gap: 8px;
}

.list-pane,
.editor-pane {
  min-height: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  border-radius: var(--radius);
  overflow: hidden;
}

.editor-pane {
  grid-template-rows: minmax(0, 1fr);
}

.list-head {
  justify-content: space-between;
  padding: 9px 12px;
  border-bottom: 1px solid var(--line);
  background: rgba(240, 231, 214, 0.72);
}

.list-head span {
  color: var(--muted);
  font-size: 13px;
}

.question-list {
  min-height: 0;
  height: auto;
  overflow: auto;
  padding: 6px;
}

.question-item {
  width: 100%;
  display: grid;
  gap: 6px;
  margin-bottom: 5px;
  padding: 8px;
  text-align: left;
  border: 1px solid transparent;
  border-radius: var(--radius);
  color: var(--ink);
  background: transparent;
  cursor: pointer;
}

.question-item.has-selector {
  grid-template-columns: 24px minmax(0, 1fr);
  align-items: start;
}

.item-selector {
  width: 18px;
  height: 18px;
  margin-top: 2px;
  accent-color: var(--teal);
}

.question-body {
  display: grid;
  min-width: 0;
  gap: 8px;
}

.question-item:hover,
.question-item.active {
  border-color: var(--line);
  background: rgba(255, 255, 255, 0.68);
}

.question-item.active {
  box-shadow: inset 3px 0 0 var(--teal);
}

.question-title {
  display: -webkit-box;
  overflow: hidden;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  font-weight: 700;
  line-height: 1.35;
  font-size: 13px;
}

.question-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  color: var(--muted);
  font-size: 11px;
}

.tag {
  display: inline-flex;
  align-items: center;
  min-height: 20px;
  padding: 0 7px;
  border-radius: 999px;
  background: var(--panel-strong);
}

.tag.ok {
  color: #fff;
  background: var(--teal);
}

.editor-pane {
  position: relative;
}

.empty-editor {
  height: 100%;
  min-height: 0;
  display: grid;
  place-content: center;
  gap: 8px;
  padding: 32px;
  text-align: center;
  color: var(--muted);
}

.empty-editor strong {
  color: var(--ink);
  font-size: 20px;
}

.editor-form {
  min-height: 0;
  height: auto;
  overflow: auto;
  display: grid;
  align-content: start;
  gap: 9px;
  padding: 10px;
}

.editor-head {
  justify-content: space-between;
  gap: 16px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line);
}

.state-pill {
  display: inline-flex;
  min-height: 24px;
  align-items: center;
  padding: 0 10px;
  color: #fff;
  border-radius: 999px;
  background: #24211c;
  font-size: 12px;
  font-weight: 800;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 100px 1fr;
  gap: 8px;
}

.option-section {
  display: grid;
  gap: 7px;
}

.section-title {
  justify-content: space-between;
}

.option-list {
  display: grid;
  gap: 6px;
}

.option-row {
  gap: 6px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.52);
}

.option-row input[type="checkbox"],
.option-row input[type="radio"] {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
  accent-color: var(--teal);
}

.option-row input[type="text"] {
  flex: 1;
}

.remove-option {
  width: 34px;
  height: 34px;
  border: 1px solid rgba(184, 59, 53, 0.24);
  border-radius: var(--radius);
  color: var(--red);
  background: rgba(184, 59, 53, 0.06);
}

.editor-actions {
  position: sticky;
  bottom: -18px;
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin: 2px -10px -10px;
  padding: 9px 10px;
  border-top: 1px solid var(--line);
  background: rgba(255, 250, 240, 0.96);
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  transform: translateY(16px);
  max-width: min(420px, calc(100vw - 36px));
  padding: 12px 14px;
  border-radius: var(--radius);
  color: #fff;
  background: #24211c;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s ease;
  box-shadow: var(--shadow);
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.login-body {
  display: grid;
  place-items: center;
  padding: 18px;
}

.login-shell {
  width: min(420px, 100%);
}

.login-panel {
  display: grid;
  gap: 14px;
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(251, 252, 247, 0.92);
  box-shadow: var(--shadow);
}

.login-mark {
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  border-radius: var(--radius);
  color: #20261f;
  background: var(--amber);
  font-weight: 900;
}

.login-panel h1 {
  margin: 0;
  font-size: 24px;
}

.login-form {
  display: grid;
  gap: 12px;
}

.login-form .solid-button {
  width: 100%;
}

.status-line {
  min-height: 22px;
  color: var(--muted);
  font-size: 12px;
}

.status-line.error {
  color: var(--red);
}

.hidden {
  display: none !important;
}

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

  .side-rail {
    display: none;
  }

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

  .question-list,
  .editor-form {
    height: auto;
    max-height: none;
  }
}

@media (max-width: 720px) {
  .workspace {
    padding: 12px;
  }

  .topbar,
  .control-strip {
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .topbar {
    display: grid;
  }

  .top-actions {
    justify-content: stretch;
  }

  .top-actions button {
    flex: 1;
  }

  .control-strip {
    display: grid;
  }

  .bulk-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .form-row {
    grid-template-columns: 1fr;
  }

  .editor-actions {
    display: grid;
  }

  .action-cluster {
    display: grid;
  }
}
