:root {
  color-scheme: light;
  --bg: #f6f1e8;
  --panel: #ffffff;
  --ink: #1d2528;
  --muted: #69767c;
  --line: #d9ded8;
  --accent: #0d6b72;
  --accent-strong: #084f55;
  --accent-soft: #d8eeee;
  --warn: #9c3d2d;
  --shadow: 0 22px 70px rgba(29, 37, 40, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  font-family: "Microsoft YaHei", "PingFang SC", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background:
    linear-gradient(135deg, rgba(13, 107, 114, 0.12), transparent 36%),
    linear-gradient(315deg, rgba(181, 85, 48, 0.12), transparent 34%),
    var(--bg);
}

button,
input {
  font: inherit;
}

.app-shell {
  width: min(1040px, calc(100% - 32px));
  min-height: 100vh;
  margin: 0 auto;
  display: grid;
  place-items: center;
  padding: 32px 0;
}

.tool-panel {
  width: 100%;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 24px;
  padding: 28px;
  border: 1px solid rgba(255, 255, 255, 0.84);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.88);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

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

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: clamp(30px, 5vw, 54px);
  line-height: 1.02;
  letter-spacing: 0;
}

.status-pill {
  flex: 0 0 auto;
  min-height: 32px;
  display: inline-flex;
  align-items: center;
  padding: 6px 12px;
  border-radius: 999px;
  color: var(--accent-strong);
  background: var(--accent-soft);
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
}

.input-area {
  display: grid;
  gap: 10px;
}

label {
  font-size: 14px;
  font-weight: 800;
  color: var(--ink);
}

.input-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
}

input {
  width: 100%;
  min-height: 52px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 16px;
  color: var(--ink);
  background: #fbfbf8;
  outline: none;
}

input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(13, 107, 114, 0.14);
}

.primary-button,
.icon-button,
.ghost-button {
  min-height: 44px;
  border: 0;
  border-radius: 8px;
  cursor: pointer;
  transition: transform 150ms ease, box-shadow 150ms ease, background 150ms ease, opacity 150ms ease;
}

.primary-button {
  min-width: 112px;
  padding: 0 22px;
  color: #fff;
  background: var(--accent);
  font-weight: 800;
  box-shadow: 0 12px 24px rgba(13, 107, 114, 0.22);
}

.primary-button:hover,
.icon-button:hover,
.ghost-button:hover {
  transform: translateY(-1px);
}

.primary-button:active,
.icon-button:active,
.ghost-button:active {
  transform: translateY(0);
}

.message {
  min-height: 22px;
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.55;
}

.message.error {
  color: var(--warn);
  font-weight: 700;
}

.link-summary {
  display: grid;
  gap: 6px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfbf8;
}

.link-summary[hidden] {
  display: none;
}

.link-summary span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.link-summary strong {
  min-width: 0;
  overflow-wrap: anywhere;
  font-size: 15px;
  line-height: 1.5;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(260px, 360px) minmax(220px, 1fr);
  align-items: stretch;
  gap: 22px;
}

.preview-frame {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  overflow: hidden;
}

canvas {
  width: min(88%, 340px) !important;
  height: auto !important;
  aspect-ratio: 1 / 1;
  image-rendering: pixelated;
  display: none;
}

canvas.ready {
  display: block;
}

.empty-state {
  position: absolute;
  inset: 22px;
  display: grid;
  place-items: center;
  border: 1px dashed #b8c4be;
  border-radius: 8px;
  color: #8a9894;
}

.empty-state strong {
  font-size: clamp(44px, 12vw, 84px);
  letter-spacing: 0;
}

.empty-state.hidden {
  display: none;
}

.actions {
  min-width: 0;
  display: grid;
  align-content: end;
  gap: 12px;
}

.icon-button,
.ghost-button {
  width: 100%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 0 16px;
  font-weight: 800;
}

.icon-button {
  color: var(--accent-strong);
  background: #eaf5f2;
}

.icon-button span[aria-hidden="true"] {
  min-width: 44px;
  padding: 5px 7px;
  border-radius: 6px;
  color: #fff;
  background: var(--accent);
  font-size: 12px;
  line-height: 1;
}

.ghost-button {
  color: var(--ink);
  background: #f2eee6;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
  transform: none;
  box-shadow: none;
}

@media (max-width: 760px) {
  .app-shell {
    width: min(100% - 20px, 560px);
    align-items: start;
    padding: 14px 0;
  }

  .tool-panel {
    padding: 18px;
    gap: 18px;
  }

  .tool-header {
    display: grid;
  }

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

  .primary-button {
    width: 100%;
  }

  .actions {
    align-content: start;
  }
}
