:root {
  color-scheme: light;
  --bg: #f6f7f4;
  --surface: #ffffff;
  --surface-2: #f0f4ee;
  --ink: #18201c;
  --muted: #647067;
  --line: #dde4db;
  --green: #1f7a4d;
  --green-2: #e1f0e8;
  --amber: #a96516;
  --rose: #9b3d54;
  --blue: #2d638f;
  --shadow: 0 18px 40px rgba(24, 32, 28, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    "PingFang SC", "Microsoft YaHei", sans-serif;
}

button,
input,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

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

.sidebar {
  border-right: 1px solid var(--line);
  background: #fbfcfa;
  padding: 22px 18px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: auto;
}

.brand {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 14px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 8px;
  background: var(--green);
  color: #fff;
  font-weight: 800;
}

.brand h1,
.brand p,
.catalog-head h2,
.panel-head h2 {
  margin: 0;
}

.brand h1 {
  font-size: 17px;
  line-height: 1.25;
}

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

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

.category-button {
  border: 1px solid transparent;
  background: transparent;
  color: var(--ink);
  width: 100%;
  min-height: 38px;
  border-radius: 8px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  text-align: left;
}

.category-button span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.category-button strong {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.category-button:hover,
.category-button.active {
  background: var(--green-2);
  border-color: #b7d8c7;
}

.workspace {
  padding: 22px;
  min-width: 0;
}

.toolbar {
  display: grid;
  grid-template-columns: minmax(320px, 430px) minmax(0, 1fr);
  gap: 18px;
  align-items: stretch;
  margin-bottom: 18px;
}

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

.stats div {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 13px 14px;
  box-shadow: var(--shadow);
}

.stats strong {
  display: block;
  font-size: 24px;
  line-height: 1;
  margin-bottom: 7px;
}

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

.tools {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto;
  align-items: end;
  gap: 14px;
  box-shadow: var(--shadow);
}

.search-box {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 12px;
}

.search-box input {
  width: 100%;
  min-height: 40px;
  border-radius: 8px;
  border: 1px solid var(--line);
  padding: 0 12px;
  color: var(--ink);
  background: #fff;
}

.search-box input:focus {
  outline: 2px solid #b7d8c7;
  border-color: var(--green);
}

.toggle {
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 0 4px;
  white-space: nowrap;
}

.toggle input {
  width: 18px;
  height: 18px;
  accent-color: var(--green);
}

.content-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 18px;
  align-items: start;
}

.catalog,
.selection-panel {
  min-width: 0;
}

.catalog-head,
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.catalog-head h2,
.panel-head h2 {
  font-size: 16px;
}

.item-list {
  display: grid;
  gap: 10px;
}

.item-card {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr);
  gap: 10px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
}

.item-card.selected {
  border-color: #94c9ab;
  box-shadow: inset 4px 0 0 var(--green);
}

.item-check {
  display: grid;
  place-items: start center;
  padding-top: 2px;
}

.item-check input {
  width: 20px;
  height: 20px;
  accent-color: var(--green);
}

.item-title-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: start;
}

.item-title-row h2 {
  margin: 0;
  font-size: 17px;
  line-height: 1.3;
}

.item-title-row p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.category-pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  max-width: 190px;
  border-radius: 8px;
  padding: 3px 8px;
  color: var(--blue);
  background: #e5eef5;
  font-size: 12px;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.item-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px 14px;
  margin: 13px 0 0;
}

.item-grid div {
  min-width: 0;
}

.item-grid dt {
  color: var(--muted);
  font-size: 12px;
}

.item-grid dd {
  margin: 3px 0 0;
  font-size: 13px;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.item-more {
  margin-top: 12px;
  border-top: 1px solid var(--line);
  padding-top: 10px;
  color: #344039;
  font-size: 13px;
  line-height: 1.65;
}

.item-more summary {
  color: var(--amber);
  cursor: pointer;
  font-weight: 700;
}

.item-more p {
  margin: 8px 0 0;
}

.selection-panel {
  position: sticky;
  top: 22px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  box-shadow: var(--shadow);
}

.selected-list {
  list-style: none;
  padding: 0;
  margin: 14px 0 0;
  display: grid;
  gap: 8px;
  max-height: calc(100vh - 500px);
  overflow: auto;
}

.submitter-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fbfcfa;
}

.submitter-card h3 {
  margin: 0 0 10px;
  color: var(--ink);
  font-size: 14px;
}

.submitter-card label {
  display: grid;
  gap: 5px;
  margin-top: 8px;
  color: var(--muted);
  font-size: 12px;
}

.submitter-card label span {
  display: flex;
  align-items: center;
  gap: 3px;
}

.submitter-card strong {
  color: var(--rose);
}

.submitter-card input {
  width: 100%;
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 10px;
  color: var(--ink);
  background: #fff;
}

.submitter-card input:focus {
  outline: 2px solid #b7d8c7;
  border-color: var(--green);
}

.selected-list li {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr);
  gap: 8px;
  align-items: start;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px;
  background: #fbfcfa;
}

.selected-list .selected-empty {
  display: block;
  color: var(--muted);
  text-align: center;
  padding: 24px 10px;
}

.selected-remove,
.icon-button {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--rose);
  border-radius: 8px;
  width: 28px;
  height: 28px;
  line-height: 1;
  display: grid;
  place-items: center;
  font-size: 20px;
}

.selected-list strong {
  display: block;
  font-size: 13px;
  line-height: 1.35;
}

.selected-list span {
  display: block;
  color: var(--muted);
  margin-top: 3px;
  font-size: 12px;
  line-height: 1.35;
}

.panel-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 14px;
}

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

.primary-button,
.secondary-button {
  min-height: 38px;
  border-radius: 8px;
  border: 1px solid transparent;
  padding: 0 12px;
  font-weight: 700;
}

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

.secondary-button {
  background: #fff;
  color: var(--green);
  border-color: #b7d8c7;
}

.primary-button:disabled,
.secondary-button:disabled,
.icon-button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.empty-state {
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 36px;
  text-align: center;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.7);
}

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  background: #1f2a24;
  color: #fff;
  border-radius: 8px;
  padding: 10px 14px;
  box-shadow: var(--shadow);
  z-index: 10;
}

.manual-copy-dialog {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 22px;
  background: rgba(24, 32, 28, 0.42);
}

.manual-copy-dialog[hidden] {
  display: none;
}

.manual-copy-card {
  width: min(560px, 100%);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 24px 70px rgba(24, 32, 28, 0.24);
  padding: 18px;
}

.manual-copy-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.manual-copy-head h2 {
  margin: 0;
  font-size: 18px;
}

.manual-copy-card p {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.manual-copy-text {
  width: 100%;
  min-height: 220px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fbfcfa;
  color: var(--ink);
  line-height: 1.65;
}

.manual-copy-text:focus {
  outline: 2px solid #b7d8c7;
  border-color: var(--green);
}

.manual-copy-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 14px;
}

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

  .toolbar,
  .content-grid {
    grid-template-columns: 1fr;
  }

  .selection-panel {
    position: static;
  }
}

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

  .sidebar {
    position: static;
    height: auto;
    max-height: 42vh;
  }

  .workspace {
    padding: 16px;
  }

  .toolbar,
  .tools,
  .stats,
  .item-title-row,
  .item-grid,
  .panel-actions,
  .manual-copy-actions {
    grid-template-columns: 1fr;
  }

  .category-pill {
    max-width: 100%;
    justify-self: start;
  }
}
