:root {
  color-scheme: light;
  --bg-top: #eef6f8;
  --bg-mid: #f7f2f6;
  --bg-bottom: #edf6ee;
  --ink: #172025;
  --muted: #5e6970;
  --subtle: #7d878d;
  --glass: rgba(255, 255, 255, 0.68);
  --glass-strong: rgba(255, 255, 255, 0.82);
  --line: rgba(93, 110, 118, 0.2);
  --line-strong: rgba(58, 78, 88, 0.34);
  --accent: #2374ab;
  --accent-strong: #155d8d;
  --accent-soft: rgba(35, 116, 171, 0.13);
  --ok: #1f8a5b;
  --ok-soft: rgba(31, 138, 91, 0.14);
  --empty: #9a5b1c;
  --empty-soft: rgba(154, 91, 28, 0.13);
  --danger: #b44343;
  --danger-soft: rgba(180, 67, 67, 0.12);
  --shadow: 0 24px 70px rgba(41, 55, 64, 0.15);
  --radius-panel: 20px;
  --radius-card: 8px;
  --font: "Microsoft YaHei", "PingFang SC", "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  min-width: 320px;
  margin: 0;
  color: var(--ink);
  font-family: var(--font);
  line-height: 1.5;
  background:
    linear-gradient(145deg, var(--bg-top) 0%, var(--bg-mid) 48%, var(--bg-bottom) 100%);
}

button,
input,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  width: min(1480px, calc(100% - 32px));
  min-height: 100vh;
  margin: 0 auto;
  padding: 24px 0 32px;
}

.glass-panel {
  border: 1px solid var(--line);
  background: var(--glass);
  box-shadow: var(--shadow);
  backdrop-filter: blur(24px) saturate(1.25);
  -webkit-backdrop-filter: blur(24px) saturate(1.25);
}

.topbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  padding: 24px;
  border-radius: var(--radius-panel);
}

.title-block {
  min-width: 0;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--accent-strong);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
}

h1,
h2,
h3,
p {
  overflow-wrap: anywhere;
}

h1,
h2,
h3 {
  margin: 0;
  line-height: 1.16;
  letter-spacing: 0;
}

h1 {
  font-size: clamp(28px, 4vw, 52px);
}

h2 {
  font-size: 22px;
}

h3 {
  font-size: 17px;
}

.subtitle {
  max-width: 760px;
  margin: 10px 0 0;
  color: var(--muted);
}

.top-actions,
.editor-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
}

.primary-button,
.secondary-button,
.danger-button {
  min-height: 40px;
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 9px 16px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.72);
  transition: transform 160ms ease, border-color 160ms ease, background 160ms ease;
}

.primary-button {
  color: #fff;
  background: linear-gradient(180deg, var(--accent), var(--accent-strong));
  box-shadow: 0 12px 28px rgba(35, 116, 171, 0.28);
}

.secondary-button {
  border-color: var(--line);
}

.danger-button {
  color: var(--danger);
  border-color: rgba(180, 67, 67, 0.28);
  background: var(--danger-soft);
}

.primary-button:hover,
.secondary-button:hover,
.danger-button:hover {
  transform: translateY(-1px);
  border-color: var(--line-strong);
}

.primary-button:focus-visible,
.secondary-button:focus-visible,
.danger-button:focus-visible,
input:focus-visible,
textarea:focus-visible,
.species-capsule:focus-visible,
.prompt-card:focus-visible {
  outline: 3px solid rgba(35, 116, 171, 0.28);
  outline-offset: 2px;
}

.species-strip {
  margin-top: 18px;
  padding: 18px;
  border-radius: var(--radius-panel);
}

.section-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.compact-heading {
  align-items: center;
}

.species-form {
  display: grid;
  grid-template-columns: minmax(120px, 170px) minmax(140px, 190px) auto;
  gap: 10px;
  align-items: end;
}

.species-form label,
.editor-field {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.species-form input,
.editor-field textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.7);
}

.species-form input {
  height: 40px;
  padding: 0 12px;
}

.species-capsules {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.species-capsule {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 14px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.62);
}

.species-capsule[aria-selected="true"] {
  border-color: rgba(35, 116, 171, 0.48);
  background: var(--accent-soft);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.7);
}

.species-capsule code {
  color: var(--subtle);
  font-size: 12px;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(380px, 0.95fr) minmax(420px, 1.05fr);
  gap: 18px;
  margin-top: 18px;
  align-items: start;
}

.prompt-board,
.editor-panel {
  border-radius: var(--radius-panel);
  padding: 18px;
}

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

.prompt-card {
  display: grid;
  gap: 10px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
  padding: 14px;
  text-align: left;
  color: var(--ink);
  background: var(--glass-strong);
}

.prompt-card[aria-pressed="true"] {
  border-color: rgba(35, 116, 171, 0.54);
  background: rgba(235, 247, 252, 0.86);
}

.prompt-card-title-row,
.prompt-card-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.prompt-card-title {
  min-width: 0;
  font-size: 17px;
  font-weight: 800;
}

.prompt-card-key {
  width: fit-content;
  max-width: 100%;
  padding: 3px 7px;
  border-radius: 7px;
  color: #34525f;
  background: rgba(35, 116, 171, 0.09);
  font-size: 12px;
  overflow-wrap: anywhere;
}

.prompt-card-meta {
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 13px;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 28px;
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.status-badge.filled {
  color: var(--ok);
  background: var(--ok-soft);
}

.status-badge.empty {
  color: var(--empty);
  background: var(--empty-soft);
}

.editor-panel {
  position: sticky;
  top: 16px;
}

.editor-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}

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

.mapping-list div {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: rgba(255, 255, 255, 0.58);
}

.mapping-list dt {
  margin: 0 0 5px;
  color: var(--subtle);
  font-size: 12px;
  font-weight: 800;
}

.mapping-list dd {
  margin: 0;
  color: var(--ink);
  font-size: 13px;
  overflow-wrap: anywhere;
}

code {
  font-family: "Cascadia Mono", "Consolas", monospace;
}

.editor-field textarea {
  min-height: 280px;
  padding: 14px;
  resize: vertical;
}

.editor-actions {
  justify-content: flex-start;
  margin-top: 12px;
}

.history-panel {
  margin-top: 22px;
}

.history-list {
  display: grid;
  gap: 8px;
}

.history-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: rgba(255, 255, 255, 0.58);
}

.history-title {
  margin: 0;
  font-weight: 800;
}

.history-time {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.empty-history {
  margin: 0;
  border: 1px dashed var(--line-strong);
  border-radius: 8px;
  padding: 14px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.5);
}

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  max-width: min(420px, calc(100vw - 40px));
  margin: 0;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.86);
  box-shadow: 0 12px 40px rgba(41, 55, 64, 0.18);
  opacity: 0;
  transform: translateY(8px);
  pointer-events: none;
  transition: opacity 160ms ease, transform 160ms ease;
}

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

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

  .top-actions {
    justify-content: flex-start;
  }

  .species-form,
  .workspace,
  .mapping-list {
    grid-template-columns: 1fr;
  }

  .editor-panel {
    position: static;
  }
}

@media (max-width: 640px) {
  .app-shell {
    width: min(100% - 18px, 1480px);
    padding: 10px 0 18px;
  }

  .topbar,
  .species-strip,
  .prompt-board,
  .editor-panel {
    padding: 14px;
    border-radius: 16px;
  }

  h1 {
    font-size: 30px;
  }

  .primary-button,
  .secondary-button,
  .danger-button,
  .species-capsule {
    width: 100%;
    justify-content: center;
  }

  .prompt-card-title-row,
  .prompt-card-meta,
  .editor-header,
  .history-item {
    align-items: flex-start;
    grid-template-columns: 1fr;
    flex-direction: column;
  }

  .toast {
    right: 9px;
    bottom: 9px;
    max-width: calc(100vw - 18px);
    border-radius: 14px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.001ms !important;
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
  }
}
