:root {
  color-scheme: light;
  --bg: #f8fafc;
  --panel: #ffffff;
  --ink: #0f172a;
  --muted: #64748b;
  --line: #d9e2ec;
  --red: #dc2626;
  --green: #047857;
  --amber: #b45309;
  --blue: #2563eb;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

a {
  color: inherit;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  min-height: 64px;
  padding: 0 28px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.92);
  position: sticky;
  top: 0;
  z-index: 5;
}

.brand {
  display: inline-flex;
  align-items: baseline;
  gap: 8px;
  text-decoration: none;
  font-weight: 800;
}

.brand-mark {
  color: var(--red);
}

.brand-sub {
  color: var(--ink);
}

.topnav,
.footer-links {
  display: flex;
  gap: 14px;
  color: var(--muted);
  font-size: 14px;
  align-items: center;
  flex-wrap: wrap;
}

.topnav a,
.footer-links a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  text-decoration: none;
}

.shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 24px;
  width: min(1280px, calc(100vw - 40px));
  margin: 26px auto;
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 22px;
  align-items: center;
  margin-bottom: 22px;
}

.hero h1 {
  font-size: clamp(34px, 5vw, 72px);
  line-height: 0.95;
  margin: 0 0 16px;
  letter-spacing: 0;
}

.hero p,
.panel p {
  color: var(--muted);
  line-height: 1.6;
}

.hero-art {
  min-height: 240px;
  border: 1px solid var(--line);
  background: #eef2f7;
  display: grid;
  place-items: center;
  border-radius: 8px;
  overflow: hidden;
}

.hero-art svg {
  width: 90%;
  height: auto;
}

.controls {
  display: grid;
  gap: 14px;
  margin-bottom: 18px;
}

.search {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 14px;
  font: inherit;
}

.segments {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.segment,
.tool-card,
.primary-btn,
.secondary-btn {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--ink);
  font: inherit;
}

.segment {
  min-height: 44px;
  padding: 0 12px;
  color: var(--muted);
}

.segment.is-active {
  border-color: var(--ink);
  color: var(--ink);
  background: #eef2f7;
}

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

.tool-card {
  min-height: 154px;
  padding: 14px;
  text-align: left;
  display: grid;
  gap: 8px;
  align-content: start;
}

.tool-card.is-selected {
  border-color: var(--red);
  box-shadow: inset 0 0 0 1px var(--red);
}

.tool-category,
.tool-status {
  font-size: 12px;
  color: var(--muted);
}

.tool-title {
  font-weight: 800;
  font-size: 18px;
}

.tool-summary {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.45;
}

.workspace {
  position: sticky;
  top: 88px;
  align-self: start;
}

.panel {
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: 8px;
  padding: 18px;
}

.upload-box {
  display: grid;
  gap: 12px;
  margin: 18px 0;
}

.upload-box input {
  width: 100%;
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 18px;
  background: #f8fafc;
}

.file-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 8px;
}

.file-list li {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
}

.tool-options {
  display: grid;
  gap: 8px;
  margin-bottom: 14px;
}

.tool-options:empty {
  display: none;
}

.tool-options label {
  font-size: 13px;
  font-weight: 700;
}

.tool-options input,
.tool-options select {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  background: #fff;
  color: var(--ink);
  font: inherit;
}

.option-hint {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}

.edit-preview {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #eef2f7;
  padding: 8px;
  overflow: auto;
}

.edit-preview-page {
  position: relative;
  width: 100%;
  min-height: 160px;
  background: #fff;
  border-radius: 6px;
  overflow: hidden;
}

.edit-preview-image {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.edit-text-box {
  position: absolute;
  border: 2px solid rgba(37, 99, 235, 0.75);
  border-radius: 4px;
  background: rgba(37, 99, 235, 0.12);
  min-width: 24px;
  min-height: 18px;
  padding: 0;
}

.edit-text-box.is-selected,
.edit-text-box:focus-visible {
  border-color: var(--red);
  background: rgba(220, 38, 38, 0.18);
  outline: 2px solid rgba(220, 38, 38, 0.28);
  outline-offset: 1px;
}

.primary-btn,
.secondary-btn {
  min-height: 44px;
  padding: 0 14px;
}

.primary-btn {
  background: var(--ink);
  color: #fff;
  border-color: var(--ink);
}

.actions {
  display: flex;
  gap: 10px;
  margin-top: 18px;
}

.status {
  color: var(--green);
  min-height: 24px;
}

.config-banner {
  border: 1px solid #fed7aa;
  background: #fff7ed;
  color: var(--amber);
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 16px;
}

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

.footer {
  width: min(1280px, calc(100vw - 40px));
  margin: 0 auto 32px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  gap: 18px;
  color: var(--muted);
  font-size: 14px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

@media (max-width: 980px) {
  .shell,
  .hero {
    grid-template-columns: 1fr;
  }

  .workspace {
    position: static;
  }

  .tool-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  .topbar,
  .footer {
    flex-direction: column;
    align-items: flex-start;
    padding: 16px 20px;
  }

  .shell,
  .footer {
    width: min(100vw - 28px, 1280px);
  }

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

  .actions {
    flex-direction: column;
  }
}
