:root {
  color-scheme: light;
  --bg: #f6f7f4;
  --panel: #ffffff;
  --panel-alt: #eef4f1;
  --ink: #17201c;
  --muted: #66736e;
  --border: #d9ded9;
  --accent: #0f766e;
  --accent-strong: #0b5e58;
  --accent-soft: #d9f1ec;
  --warn: #b45309;
  --dirty: #fff3d6;
  --shadow: 0 10px 30px rgba(23, 32, 28, 0.08);
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Microsoft YaHei", "PingFang SC", "Segoe UI", Arial, sans-serif;
  letter-spacing: 0;
}

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

button {
  border: 0;
}

.app-shell {
  display: grid;
  grid-template-rows: auto 1fr;
  min-height: 100vh;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  min-height: 76px;
  padding: 14px 22px;
  background: #ffffff;
  border-bottom: 1px solid var(--border);
}

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

.brand-mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 8px;
  background: var(--accent);
  color: #ffffff;
  font-size: 22px;
  font-weight: 700;
}

.brand h1 {
  margin: 0;
  font-size: 18px;
  line-height: 1.2;
}

.brand p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.actions,
.tool-group {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.upload-button,
.primary-button,
.secondary-button,
.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 40px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.16s ease, color 0.16s ease, border-color 0.16s ease, opacity 0.16s ease;
}

.upload-button,
.secondary-button,
.icon-button {
  color: var(--ink);
  background: #ffffff;
  border: 1px solid var(--border);
}

.upload-button,
.primary-button,
.secondary-button {
  padding: 0 14px;
}

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

.primary-button:hover:not(:disabled) {
  background: var(--accent-strong);
}

.upload-button:hover,
.secondary-button:hover:not(:disabled),
.icon-button:hover:not(:disabled) {
  background: var(--panel-alt);
  border-color: #c4d2cc;
}

.icon-button {
  width: 40px;
  padding: 0;
}

button:disabled,
.upload-button.disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.upload-button input {
  position: absolute;
  inline-size: 1px;
  block-size: 1px;
  opacity: 0;
  pointer-events: none;
}

svg {
  width: 18px;
  height: 18px;
  stroke-width: 2;
}

.workspace {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr) 360px;
  min-height: calc(100vh - 76px);
}

.left-panel,
.right-panel {
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--panel);
  border-color: var(--border);
}

.left-panel {
  border-right: 1px solid var(--border);
}

.right-panel {
  border-left: 1px solid var(--border);
}

.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px;
  border-bottom: 1px solid var(--border);
}

.panel-heading h2 {
  margin: 0;
  font-size: 15px;
}

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

.badge {
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--panel-alt);
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.badge.dirty {
  background: var(--dirty);
  color: var(--warn);
}

.search-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 12px 16px;
  padding: 0 10px;
  min-height: 38px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #ffffff;
}

.search-row input {
  width: 100%;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
}

.search-row svg {
  color: var(--muted);
}

.text-list {
  min-height: 0;
  overflow: auto;
  padding: 0 10px 14px;
}

.text-row {
  width: 100%;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: start;
  margin: 0 0 8px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #ffffff;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
}

.text-row:hover,
.text-row.active {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.text-row strong {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
}

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

.text-row .dot {
  width: 8px;
  height: 8px;
  margin-top: 4px;
  border-radius: 99px;
  background: #c5cbc6;
}

.canvas-area {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  min-width: 0;
  min-height: 0;
}

.canvas-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  background: #fbfcfa;
}

.status-line {
  min-width: 0;
  color: var(--muted);
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.canvas-stage {
  position: relative;
  min-width: 0;
  min-height: 0;
  overflow: auto;
  padding: 24px;
  background:
    linear-gradient(45deg, #e6e9e5 25%, transparent 25%),
    linear-gradient(-45deg, #e6e9e5 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #e6e9e5 75%),
    linear-gradient(-45deg, transparent 75%, #e6e9e5 75%);
  background-color: #f7f8f6;
  background-size: 24px 24px;
  background-position: 0 0, 0 12px, 12px -12px, -12px 0;
}

.canvas-stage.dragover {
  outline: 2px solid var(--accent);
  outline-offset: -8px;
}

#editorCanvas {
  display: none;
  max-width: 100%;
  height: auto;
  background: #ffffff;
  box-shadow: var(--shadow);
  cursor: crosshair;
}

.empty-state {
  position: absolute;
  inset: 24px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 10px;
  border: 1px dashed #aebbb4;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.72);
  color: var(--muted);
  text-align: center;
}

.empty-state svg {
  width: 42px;
  height: 42px;
  color: var(--accent);
}

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

.empty-state span {
  max-width: 320px;
  line-height: 1.5;
}

.empty-panel {
  display: grid;
  place-items: center;
  align-content: center;
  gap: 10px;
  min-height: 180px;
  padding: 22px;
  color: var(--muted);
  text-align: center;
}

.task-form {
  display: grid;
  gap: 12px;
  padding: 16px;
  background: #fbfcfa;
}

.field {
  display: grid;
  gap: 7px;
  min-width: 0;
  color: var(--muted);
  font-size: 13px;
}

.span-full {
  grid-column: 1 / -1;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #ffffff;
  color: var(--ink);
  outline: 0;
}

.field input,
.field select {
  min-height: 38px;
  padding: 0 10px;
}

.field textarea {
  resize: vertical;
  min-height: 96px;
  padding: 10px;
  line-height: 1.5;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.15);
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 22px;
  transform: translateX(-50%) translateY(18px);
  max-width: min(520px, calc(100vw - 32px));
  padding: 10px 14px;
  border-radius: 8px;
  background: #17201c;
  color: #ffffff;
  font-size: 14px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s ease;
  box-shadow: var(--shadow);
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

@media (max-width: 1180px) {
  .workspace {
    grid-template-columns: 260px minmax(0, 1fr);
  }

  .right-panel {
    grid-column: 1 / -1;
    border-left: 0;
    border-top: 1px solid var(--border);
  }
}

@media (max-width: 780px) {
  .topbar {
    align-items: stretch;
    flex-direction: column;
  }

  .actions {
    justify-content: stretch;
  }

  .upload-button,
  .primary-button {
    flex: 1 1 150px;
  }

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

  .left-panel,
  .right-panel {
    border: 0;
    border-top: 1px solid var(--border);
  }

  .canvas-area {
    min-height: 58vh;
  }

  .canvas-toolbar {
    align-items: flex-start;
    flex-direction: column;
  }
}
