:root {
  color-scheme: light;
  --bg: #f4f1eb;
  --panel: #fffdf8;
  --panel-strong: #f9f2e5;
  --ink: #26221d;
  --muted: #756f66;
  --line: #ddd4c7;
  --accent: #a44932;
  --accent-dark: #743222;
  --green: #58725b;
  --gold: #a8752b;
  --danger: #bb3f36;
  --shadow: 0 18px 42px rgba(49, 37, 22, 0.08);
  font-family: "Microsoft YaHei", "PingFang SC", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
}

button,
input,
select,
textarea {
  font: inherit;
  min-width: 0;
}

button {
  cursor: pointer;
}

.app-shell {
  width: min(1440px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 24px 0 40px;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(360px, 0.9fr) minmax(420px, 1.1fr);
  gap: 16px;
  align-items: start;
}

.panel {
  min-width: 0;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.input-panel,
.output-panel,
.image-workbench,
.library {
  padding: 18px;
}

.image-workbench,
.library {
  margin-top: 16px;
}

.panel-heading {
  margin-bottom: 18px;
}

.compact-heading {
  margin-bottom: 12px;
}

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

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(26px, 3vw, 36px);
  line-height: 1.15;
}

h2 {
  margin-bottom: 0;
  font-size: 18px;
  line-height: 1.35;
}

h3 {
  margin-bottom: 8px;
  font-size: 15px;
}

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

.field {
  min-width: 0;
  display: grid;
  gap: 6px;
}

.field span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.span-2 {
  grid-column: span 2;
}

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

input::placeholder,
textarea::placeholder {
  color: #aaa095;
}

input,
select {
  min-height: 42px;
  padding: 9px 11px;
}

textarea {
  min-height: 84px;
  padding: 10px 11px;
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(164, 73, 50, 0.14);
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 16px;
}

.button-row.compact {
  margin-top: 10px;
}

.button-row.vertical {
  flex-direction: column;
}

.link-confirm-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 10px;
  align-items: center;
}

.inline-status {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.inline-status.warning {
  color: var(--accent-dark);
}

.field-help {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.55;
}

.status-line {
  margin-top: 12px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff7e8;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}

.status-line.warning {
  border-color: rgba(164, 73, 50, 0.32);
  background: #fff0e6;
  color: var(--accent-dark);
}

.primary-button,
.secondary-button,
.ghost-button,
.copy-button,
.tab {
  min-height: 40px;
  border-radius: 6px;
  border: 1px solid transparent;
  padding: 9px 14px;
  font-weight: 700;
  white-space: nowrap;
}

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

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

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

.ghost-button,
.copy-button {
  background: #fff;
  border-color: var(--line);
  color: var(--ink);
}

.ghost-button:hover,
.copy-button:hover {
  border-color: var(--accent);
  color: var(--accent);
}

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

.metrics-row div {
  min-width: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel-strong);
}

.metrics-row span {
  display: block;
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 12px;
}

.metrics-row strong {
  display: block;
  overflow-wrap: anywhere;
  font-size: 18px;
}

.tabs {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 16px;
}

.tab {
  background: #f1ece4;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
}

.tab.active {
  background: var(--ink);
  color: #fff;
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: 0 0 12px;
}

.title-list {
  display: grid;
  gap: 8px;
  margin: 0 0 20px;
  padding-left: 22px;
}

.title-list li {
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
}

.note-stack,
.prompt-list,
.shot-list,
.saved-list {
  display: grid;
  gap: 10px;
}

.note-card,
.prompt-card,
.shot-card,
.saved-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 12px;
}

.note-card p,
.prompt-card p,
.shot-card p,
.saved-card p {
  margin-bottom: 0;
  color: var(--muted);
  line-height: 1.7;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.note-card footer {
  margin-top: 10px;
  color: var(--gold);
  font-size: 13px;
  font-weight: 700;
}

.card-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 6px;
}

.risk-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 12px 0;
}

.risk-badge {
  border-radius: 999px;
  padding: 6px 9px;
  color: #fff;
  font-size: 12px;
  font-weight: 700;
}

.risk-badge.high {
  background: var(--danger);
}

.risk-badge.medium {
  background: var(--gold);
}

.risk-badge.safe {
  background: var(--green);
}

.text-output {
  min-height: 110px;
  margin: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #2c2925;
  color: #fff6e8;
  line-height: 1.7;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.image-layout {
  display: grid;
  grid-template-columns: minmax(260px, 360px) 1fr;
  gap: 16px;
  align-items: start;
}

.image-controls {
  min-width: 0;
  display: grid;
  gap: 12px;
}

.canvas-shell {
  min-width: 0;
  width: min(100%, 540px);
  justify-self: center;
  border-radius: 8px;
  background: #2c2925;
  padding: 10px;
}

canvas {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 6px;
  background: #eee6da;
}

.saved-card {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
}

.saved-card strong {
  display: block;
  margin-bottom: 4px;
}

.saved-actions {
  display: flex;
  gap: 8px;
}

.empty-state {
  color: var(--muted);
  padding: 14px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: #fff;
}

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

@media (max-width: 700px) {
  .app-shell {
    width: min(100vw - 20px, 680px);
    padding-top: 12px;
  }

  .input-panel,
  .output-panel,
  .image-workbench,
  .library {
    padding: 14px;
  }

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

  .span-2 {
    grid-column: span 1;
  }

  .section-title,
  .saved-card {
    align-items: stretch;
    flex-direction: column;
    grid-template-columns: 1fr;
  }

  .copy-button,
  .primary-button,
  .secondary-button,
  .ghost-button {
    width: 100%;
  }

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