﻿:root {
  color-scheme: light;
  --bg: #eef7f3;
  --surface: rgba(255, 255, 255, 0.92);
  --surface-solid: #ffffff;
  --surface-soft: #f6fbf8;
  --surface-warm: #fffaf0;
  --line: #d8e7e0;
  --line-strong: #b8cec5;
  --text: #12352f;
  --muted: #5f716a;
  --muted-strong: #435f56;
  --focus: #0f766e;
  --accent: #f0a83a;
  --accent-soft: #fff2d2;
  --danger: #b42318;
  --success: #0f766e;
  --shadow: 0 18px 46px rgba(39, 72, 62, 0.1);
  --shadow-soft: 0 8px 24px rgba(39, 72, 62, 0.08);
  --radius: 14px;
  --font: Inter, "Segoe UI", "Microsoft YaHei", Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  overflow-x: hidden;
  min-height: 100vh;
  min-height: 100dvh;
  background:
    radial-gradient(circle at 12% 0%, rgba(177, 225, 207, 0.42), transparent 28%),
    linear-gradient(180deg, #fbfefd 0%, var(--bg) 56%, #f6f4ed 100%);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
}

.skip-link {
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 10000;
  padding: 10px 14px;
  border-radius: 4px;
  color: #ffffff;
  background: var(--text);
  transform: translateY(-160%);
}

.skip-link:focus-visible {
  transform: none;
}

button,
input,
select {
  font: inherit;
  touch-action: manipulation;
}

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

button {
  cursor: pointer;
}

.app {
  width: min(1440px, 100%);
  margin: 0 auto;
  padding: 28px;
  overflow-x: hidden;
}

.topbar {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 16px;
  align-items: end;
  margin-bottom: 24px;
}

.title {
  margin: 0;
  font-size: 28px;
  font-weight: 800;
  letter-spacing: 0;
}

.subtitle {
  margin: 4px 0 0;
  color: var(--muted);
  max-width: 760px;
  overflow-wrap: anywhere;
}

.shell {
  display: grid;
  grid-template-columns: minmax(300px, 360px) minmax(0, 1fr);
  gap: 22px;
  align-items: start;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--line);
}

.panel-heading {
  display: grid;
  gap: 4px;
}

.panel-title {
  margin: 0;
  font-size: 16px;
  font-weight: 800;
}

.panel-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
  max-width: 540px;
}

.panel-body {
  padding: 20px;
}

.stack {
  display: grid;
  gap: 18px;
}

.field {
  display: grid;
  gap: 8px;
}

.field label,
.label {
  color: var(--muted-strong);
  font-size: 13px;
  font-weight: 600;
}

.control-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
}

.input,
.select {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: #fff;
  color: var(--text);
  padding: 9px 12px;
  outline: none;
  transition: border-color 160ms ease, box-shadow 160ms ease;
}

.input:focus-visible,
.select:focus-visible {
  border-color: var(--focus);
  box-shadow: 0 0 0 4px rgba(15, 118, 110, 0.12);
}

.button {
  min-height: 40px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: #fff;
  color: var(--text);
  padding: 8px 12px;
  font-weight: 650;
  transition: background 160ms ease, border-color 160ms ease, color 160ms ease, transform 160ms ease, box-shadow 160ms ease;
}

.button:hover {
  background: var(--surface-soft);
  border-color: #86b7aa;
  transform: translateY(-1px);
  box-shadow: var(--shadow-soft);
}

.button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

.button.primary {
  background: linear-gradient(180deg, #128078, #0f766e);
  border-color: #0f766e;
  color: #fff;
  box-shadow: 0 10px 24px rgba(15, 118, 110, 0.24);
}

.button.primary:hover {
  background: linear-gradient(180deg, #168d83, #0e6f68);
  border-color: #0e6f68;
}

.button.small {
  min-height: 34px;
  padding: 6px 10px;
  font-size: 12px;
}

.segmented {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
}

.segment {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  color: var(--muted-strong);
  font-weight: 650;
}

.segment.active {
  background: #0f766e;
  border-color: #0f766e;
  color: #fff;
}

.upload {
  position: relative;
  display: grid;
  gap: 10px;
  place-items: center;
  min-height: 150px;
  padding: 18px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  background:
    linear-gradient(180deg, rgba(246, 251, 248, 0.88), rgba(255, 250, 240, 0.56));
  text-align: center;
}

.upload:hover {
  border-color: #0f766e;
  background: #f4fbf7;
}

.upload input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.upload strong {
  display: block;
  position: relative;
  font-size: 14px;
}

.upload strong::before {
  content: "↥";
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  margin: 0 auto 10px;
  border: 1px solid rgba(15, 118, 110, 0.28);
  border-radius: 50%;
  background: #ffffff;
  color: #0f766e;
  font-size: 23px;
  line-height: 1;
}

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

.image-preview {
  display: none;
  width: 100%;
  max-height: 190px;
  object-fit: cover;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-soft);
  box-shadow: var(--shadow-soft);
}

.history {
  display: grid;
  gap: 10px;
}

.history-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

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

.history-empty {
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface-soft);
  color: var(--muted);
  padding: 12px;
  font-size: 12px;
  text-align: center;
}

.history-item {
  position: relative;
  display: grid;
  gap: 8px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.78);
  padding: 10px;
  color: var(--text);
  text-align: left;
  box-shadow: 0 5px 16px rgba(39, 72, 62, 0.05);
}

.history-item:hover {
  background: var(--surface-solid);
  border-color: #86b7aa;
}

.history-item.favorite {
  border-color: rgba(240, 168, 58, 0.62);
  background: linear-gradient(180deg, #ffffff, var(--surface-warm));
}

.history-restore {
  display: grid;
  gap: 8px;
  width: 100%;
  border: 0;
  background: transparent;
  color: inherit;
  padding: 0 34px 0 0;
  text-align: left;
}

.history-favorite {
  position: absolute;
  top: 8px;
  right: 8px;
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: #fff;
  color: #9aa9a4;
  font-size: 14px;
  line-height: 1;
}

.history-favorite:hover,
.history-favorite.active {
  border-color: rgba(240, 168, 58, 0.8);
  background: var(--accent-soft);
  color: #b36b00;
}

.history-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
}

.history-meta span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-base {
  color: var(--text);
  font-family: "Cascadia Mono", Consolas, monospace;
  font-weight: 700;
}

.history-swatches {
  display: grid;
  grid-template-columns: repeat(var(--swatch-count, 5), 1fr);
  overflow: hidden;
  min-height: 22px;
  border: 1px solid rgba(17, 24, 39, 0.1);
  border-radius: 8px;
}

.history-swatch {
  min-height: 22px;
}

.notice {
  min-height: 20px;
  color: var(--muted);
  font-size: 12px;
  overflow-wrap: anywhere;
}

.notice.error {
  color: var(--danger);
  font-weight: 600;
}

.results {
  display: grid;
  gap: 20px;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  min-height: 222px;
}

.metric {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: linear-gradient(180deg, #ffffff, var(--surface-soft));
  box-shadow: 0 8px 20px rgba(39, 72, 62, 0.05);
}

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

.metric strong {
  display: block;
  margin-top: 4px;
  color: var(--text);
  font-size: 18px;
}

.professional-check {
  display: grid;
  min-height: 363px;
}

.professional-section {
  display: grid;
  gap: 14px;
}

.professional-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.professional-header h3,
.contrast-table h4,
.simulation-table h4 {
  margin: 0;
  color: var(--text);
  font-size: 14px;
  font-weight: 800;
}

.professional-header span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

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

.professional-card {
  display: grid;
  gap: 4px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: linear-gradient(180deg, #ffffff, var(--surface-soft));
  padding: 12px;
}

.professional-card span,
.professional-card small {
  color: var(--muted);
  font-size: 12px;
}

.professional-card strong {
  color: var(--text);
  font-size: 18px;
}

.professional-columns {
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr);
  gap: 12px;
}

.contrast-table,
.simulation-table {
  display: grid;
  align-content: start;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.76);
  padding: 12px;
}

.contrast-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 10px;
  align-items: center;
  color: var(--muted-strong);
  font-size: 12px;
}

.contrast-color {
  display: inline-flex;
  min-width: 0;
  align-items: center;
  gap: 8px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.contrast-color i {
  flex: 0 0 auto;
  width: 16px;
  height: 16px;
  border: 1px solid rgba(18, 53, 47, 0.14);
  border-radius: 5px;
}

.wcag-badge {
  display: inline-flex;
  width: fit-content;
  min-height: 24px;
  align-items: center;
  border-radius: 999px;
  padding: 3px 8px;
  font-size: 11px;
  font-weight: 800;
}

.wcag-badge.excellent {
  background: #e1f2ef;
  color: #0b625b;
}

.wcag-badge.good {
  background: #e3f6e9;
  color: #0b6b39;
}

.wcag-badge.warn {
  background: var(--accent-soft);
  color: #9a5b00;
}

.wcag-badge.fail {
  background: rgba(180, 35, 24, 0.1);
  color: var(--danger);
}

.accessibility-line {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  color: var(--muted);
  font-size: 12px;
}

.simulation-row {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  color: var(--muted-strong);
  font-size: 12px;
}

.simulation-swatches {
  display: grid;
  grid-template-columns: repeat(var(--swatch-count, 5), 1fr);
  overflow: hidden;
  min-height: 28px;
  border: 1px solid rgba(18, 53, 47, 0.12);
  border-radius: 10px;
}

.simulation-swatches i {
  min-height: 28px;
}

.palette-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(205px, 1fr));
  gap: 14px;
  min-height: 650px;
}

.color-card {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-solid);
  box-shadow: 0 10px 24px rgba(39, 72, 62, 0.07);
  transition: border-color 160ms ease, box-shadow 160ms ease, transform 160ms ease, opacity 160ms ease;
}

.color-card:hover {
  border-color: #86b7aa;
  box-shadow: 0 16px 34px rgba(39, 72, 62, 0.11);
}

.color-card.dragging {
  opacity: 0.55;
  transform: scale(0.985);
}

.swatch {
  min-height: 96px;
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 10px;
  padding: 13px;
}

.swatch-label {
  padding: 6px 9px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.86);
  color: var(--text);
  font-size: 12px;
  font-weight: 800;
  box-shadow: 0 4px 12px rgba(18, 53, 47, 0.08);
}

.swatch-label.dark {
  background: rgba(18, 53, 47, 0.82);
  color: #fff;
}

.color-info {
  display: grid;
  gap: 7px;
  padding: 12px;
}

.usage {
  color: var(--muted-strong);
  font-weight: 800;
}

.value-row {
  display: grid;
  grid-template-columns: 42px 1fr auto;
  gap: 8px;
  align-items: center;
  color: var(--muted);
  font-size: 12px;
}

.value-row code {
  overflow: hidden;
  color: var(--text);
  font-family: "Cascadia Mono", Consolas, monospace;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.copy {
  min-width: 54px;
  min-height: 28px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--muted-strong);
  font-size: 12px;
  font-weight: 700;
}

.copy:hover {
  border-color: #0f766e;
  color: #0f766e;
}

.copy.done {
  border-color: rgba(4, 120, 87, 0.28);
  background: rgba(16, 185, 129, 0.12);
  color: var(--success);
}

.card-action {
  min-height: 32px;
  border: 1px solid rgba(15, 118, 110, 0.2);
  border-radius: 9px;
  background: rgba(15, 118, 110, 0.08);
  color: #0f766e;
  font-size: 12px;
  font-weight: 800;
}

.card-action:hover {
  background: #0f766e;
  color: #fff;
}

.export-output {
  display: none;
  max-height: 220px;
  margin: 14px 0 0;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #12352f;
  color: #f6fbf8;
  padding: 14px;
  font-family: "Cascadia Mono", Consolas, monospace;
  font-size: 12px;
  line-height: 1.6;
  white-space: pre-wrap;
}

.export-output.active {
  display: block;
}

.preview-grid {
  display: grid;
  grid-template-columns: 1.15fr 0.85fr;
  gap: 14px;
}

.poster,
.ui-preview,
.title-preview,
.background-preview,
.contrast-preview {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--surface-solid);
  box-shadow: 0 10px 24px rgba(39, 72, 62, 0.07);
}

.poster {
  min-height: 300px;
  display: grid;
  grid-template-rows: 1fr auto;
}

.poster-visual {
  display: grid;
  align-content: end;
  gap: 12px;
  min-height: 210px;
  padding: 22px;
}

.poster-kicker {
  width: fit-content;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
  box-shadow: 0 6px 16px rgba(18, 53, 47, 0.12);
}

.poster-title {
  max-width: 420px;
  margin: 0;
  font-size: 34px;
  line-height: 1.06;
  letter-spacing: 0;
}

.poster-footer {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  padding: 14px 18px;
  border-top: 1px solid rgba(18, 53, 47, 0.1);
  font-size: 12px;
  background: rgba(255, 255, 255, 0.72);
}

.side-previews {
  display: grid;
  gap: 14px;
}

.ui-preview {
  padding: 18px;
}

.preview-label {
  display: inline-flex;
  width: fit-content;
  min-height: 24px;
  align-items: center;
  border-radius: 999px;
  padding: 4px 9px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0;
}

.preview-title {
  margin: 0 0 12px;
  font-size: 14px;
  font-weight: 750;
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.demo-button {
  min-height: 38px;
  border: 0;
  border-radius: 10px;
  padding: 8px 14px;
  font-weight: 750;
}

.demo-button.secondary {
  border: 1px solid currentColor;
  background: transparent;
}

.headline-demo {
  margin: 16px 0 0;
  font-size: 22px;
  font-weight: 800;
  line-height: 1.2;
}

.title-preview {
  display: grid;
  gap: 12px;
  padding: 18px;
}

.title-preview h3 {
  margin: 0;
  font-size: 26px;
  line-height: 1.12;
  letter-spacing: 0;
}

.title-preview p {
  margin: 0;
  max-width: 520px;
  font-size: 13px;
}

.background-preview {
  display: grid;
  gap: 10px;
  padding: 18px;
}

.background-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.background-sample {
  min-height: 78px;
  display: grid;
  align-content: end;
  gap: 3px;
  border: 1px solid rgba(18, 53, 47, 0.1);
  border-radius: 12px;
  padding: 10px;
}

.background-sample strong {
  font-size: 12px;
}

.background-sample span {
  font-size: 11px;
  opacity: 1;
}

.contrast-preview {
  display: grid;
  grid-template-columns: 1fr 1fr;
}

.contrast-cell {
  min-height: 126px;
  padding: 16px;
  display: grid;
  align-content: center;
  gap: 6px;
}

.contrast-cell strong {
  font-size: 18px;
}

.contrast-cell span {
  font-size: 12px;
  opacity: 0.82;
}

.extracted {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 10px;
}

.chip {
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr);
  gap: 8px;
  align-items: center;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
}

.chip-swatch {
  width: 32px;
  height: 32px;
  border: 1px solid rgba(17, 24, 39, 0.12);
  border-radius: 6px;
}

.chip strong {
  display: block;
  overflow: hidden;
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chip span {
  display: block;
  color: var(--muted);
  font-size: 11px;
}

.hidden-canvas {
  display: none;
}

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

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

  .topbar .button {
    width: fit-content;
  }
}
@media (max-width: 720px) {
  .app {
    padding: 14px;
  }

  .title {
    font-size: 26px;
  }

  .subtitle {
    max-width: 34ch;
  }

  .metrics,
  .professional-grid,
  .segmented,
  .background-grid,
  .contrast-preview {
    grid-template-columns: 1fr 1fr;
  }

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

  .metrics {
    min-height: 240px;
  }

  .professional-check {
    min-height: 720px;
  }

  .palette-grid {
    min-height: 1640px;
  }

  .poster-title {
    font-size: 28px;
  }

  .panel-header {
    align-items: start;
  }

  .panel-actions {
    width: 100%;
    justify-content: flex-start;
  }

  .panel-actions .button {
    flex: 1 1 120px;
  }

  .history-meta {
    align-items: start;
    flex-direction: column;
    gap: 2px;
  }
}

@media (max-width: 520px) {
  .app {
    padding: 14px 14px 18px;
  }

  .subtitle {
    max-width: 30ch;
    line-height: 1.65;
  }

  .metrics,
  .professional-grid,
  .segmented,
  .control-row,
  .background-grid,
  .contrast-preview {
    grid-template-columns: 1fr;
  }

  .professional-header {
    align-items: start;
    flex-direction: column;
  }

  .contrast-row {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .contrast-row .wcag-badge {
    grid-column: 1 / -1;
  }

  .panel-header {
    align-items: start;
    flex-direction: column;
  }

  .topbar .button {
    width: 100%;
  }

  .poster-footer {
    flex-direction: column;
    gap: 6px;
  }

  .value-row {
    grid-template-columns: 38px minmax(0, 1fr);
  }

  .value-row .copy {
    grid-column: 1 / -1;
    width: 100%;
  }
}

