:root {
  --bg-top: #eef7ef;
  --bg-bottom: #f8f2e8;
  --surface: rgba(255, 255, 255, 0.95);
  --surface-soft: #f9fcf8;
  --surface-strong: #ffffff;
  --text: #1f2b28;
  --muted: #61706c;
  --line: #d6e1d8;
  --line-strong: #b9cac0;
  --primary: #2f8f63;
  --primary-strong: #1f6948;
  --accent: #d8922f;
  --danger: #a5483d;
  --shadow-soft: 0 14px 36px rgba(31, 43, 40, 0.09);
  --shadow-card: 0 12px 26px rgba(31, 43, 40, 0.1);
  --radius-lg: 22px;
  --radius-md: 14px;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  scrollbar-gutter: stable;
}

body {
  margin: 0;
  font-family: "Hiragino Kaku Gothic ProN", "Yu Gothic", "Noto Sans JP", sans-serif;
  color: var(--text);
  background:
    radial-gradient(900px 420px at -5% -10%, rgba(47, 143, 99, 0.2) 0%, rgba(47, 143, 99, 0) 70%),
    radial-gradient(820px 360px at 110% 6%, rgba(216, 146, 47, 0.16) 0%, rgba(216, 146, 47, 0) 70%),
    linear-gradient(160deg, var(--bg-top) 0%, var(--bg-bottom) 100%);
  min-height: 100vh;
}

.container {
  max-width: 1180px;
  margin: 0 auto;
  padding: 26px 16px 44px;
}

.hero,
.panel {
  border: 1px solid rgba(214, 225, 216, 0.94);
  box-shadow: var(--shadow-soft);
}

.hero {
  display: grid;
  gap: 18px;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.9) 0%, rgba(246, 252, 247, 0.98) 58%),
    linear-gradient(0deg, rgba(47, 143, 99, 0.02), rgba(47, 143, 99, 0.02));
  border-radius: 26px;
  padding: 22px;
}

.hero h1,
.panel h2,
.result-card h3 {
  margin: 0;
}

.hero h1 {
  font-size: clamp(1.6rem, 1.18rem + 1.42vw, 2.4rem);
}

.hero p,
.section-heading p,
.status-message,
.empty-state,
.guide-content li,
.source-meta,
.variant-note {
  line-height: 1.65;
}

.hero-copy p,
.section-heading p,
.status-message,
.empty-state,
.source-meta,
.variant-note,
.dropzone p,
.dropzone span {
  color: var(--muted);
}

.hero-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.hero-badges span {
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(47, 143, 99, 0.08);
  border: 1px solid rgba(47, 143, 99, 0.14);
  color: var(--primary-strong);
  font-weight: 700;
  font-size: 0.92rem;
}

.panel {
  margin-top: 16px;
  padding: 18px;
  border-radius: var(--radius-lg);
  background: linear-gradient(180deg, var(--surface) 0%, var(--surface-soft) 100%);
}

.settings-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  align-items: start;
}

.intake-panel {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) minmax(320px, 400px);
  gap: 16px;
  align-items: stretch;
}

.dropzone-wrap,
.summary-card,
.result-card {
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface-strong);
  min-width: 0;
}

.dropzone-wrap,
.summary-card {
  padding: 14px;
}

.settings-column {
  display: grid;
  grid-template-rows: 1fr 1fr;
  gap: 16px;
  min-width: 0;
}

.dropzone {
  display: grid;
  min-height: 240px;
  padding: 24px;
  border: 2px dashed var(--line-strong);
  border-radius: 18px;
  background:
    linear-gradient(135deg, rgba(47, 143, 99, 0.05), rgba(216, 146, 47, 0.05)),
    #fff;
  cursor: pointer;
  transition: border-color 180ms ease, transform 180ms ease, box-shadow 180ms ease;
}

.dropzone:hover,
.dropzone.is-dragover {
  border-color: var(--primary);
  transform: translateY(-1px);
  box-shadow: var(--shadow-card);
}

.dropzone-prompt {
  display: grid;
  place-items: center;
  min-height: 188px;
  text-align: center;
}

.dropzone strong {
  display: block;
  font-size: 1.18rem;
  color: var(--primary-strong);
}

.dropzone p {
  margin: 8px 0 2px;
}

.dropzone span {
  font-size: 0.92rem;
}

.dropzone input {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.control-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 12px;
}

button {
  border: 0;
  border-radius: 12px;
  padding: 11px 14px;
  font: inherit;
  font-weight: 700;
  color: #173123;
  background: linear-gradient(180deg, #e3f4ea 0%, #cfe8d8 100%);
  box-shadow: 0 2px 8px rgba(31, 43, 40, 0.12);
  cursor: pointer;
}

select {
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  padding: 10px 12px;
  font: inherit;
  background: #fff;
  color: var(--text);
}

input[type="range"] {
  width: 100%;
  accent-color: var(--primary);
}

button:hover:not(:disabled) {
  transform: translateY(-1px);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.secondary-button {
  background: linear-gradient(180deg, #fff5e7 0%, #f4e5ca 100%);
}

.summary-list {
  margin: 10px 0 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 8px 12px;
}

.summary-list div {
  display: grid;
  grid-template-columns: 96px 1fr;
  gap: 8px;
  align-items: baseline;
  padding: 8px 10px;
  border-radius: 10px;
  background: rgba(31, 43, 40, 0.04);
}

.summary-list dt {
  font-weight: 700;
  color: var(--primary-strong);
  white-space: nowrap;
}

.summary-list dd {
  margin: 0;
  font-family: "SFMono-Regular", "Consolas", "Menlo", monospace;
}

.png-settings {
  margin-top: 0;
  padding-top: 0;
  border-top: 0;
}

.png-settings h2 {
  margin-bottom: 10px;
}

.setting-field {
  display: grid;
  gap: 6px;
  margin-top: 10px;
}

.check-field {
  display: flex;
  gap: 10px;
  align-items: center;
  min-height: 42px;
  color: var(--text);
  margin-top: 4px;
  flex-wrap: wrap;
}

.check-field input {
  accent-color: var(--primary);
}

.setting-field span {
  font-size: 0.92rem;
  color: var(--muted);
}

.setting-field-wide {
  width: 100%;
}

.setting-field,
.setting-field select,
.setting-field input[type="range"] {
  width: 100%;
  min-width: 0;
}


.section-heading {
  margin-bottom: 14px;
}

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

.preview-heading-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.preview-heading-text {
  margin: 0;
  color: var(--muted);
  line-height: 1.4;
  text-align: right;
  word-break: break-all;
}

.results-summary {
  margin-bottom: 14px;
  border: 0;
  background: transparent;
  box-shadow: none;
  padding: 0;
}

.preview-nav {
  display: flex;
  gap: 8px;
  flex: none;
}

.preview-nav-button {
  min-width: 44px;
  padding-inline: 0;
  background: #fff;
  border: 1px solid rgba(31, 43, 40, 0.12);
  box-shadow: 0 2px 6px rgba(31, 43, 40, 0.06);
  color: #6f7c78;
}


.status-toast {
  position: fixed;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%) translateY(8px);
  padding: 10px 14px;
  border-radius: 999px;
  background: rgba(31, 43, 40, 0.92);
  color: #fff;
  font-size: 0.9rem;
  line-height: 1;
  opacity: 0;
  pointer-events: none;
  transition: opacity 160ms ease, transform 160ms ease;
  z-index: 60;
}

.status-toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.status-toast.is-error {
  background: rgba(165, 72, 61, 0.96);
}

.section-heading h2 {
  color: var(--primary-strong);
}

.section-heading p {
  margin: 6px 0 0;
}

.empty-state {
  padding: 18px;
  border: 1px dashed var(--line-strong);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.65);
}

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

.dropzone-thumb-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 120px));
  justify-content: start;
  gap: 10px;
  width: 100%;
}

.thumb-card {
  display: grid;
  gap: 8px;
  width: 120px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.82);
  cursor: pointer;
  text-align: left;
}

.dropzone .thumb-card {
  background: rgba(255, 255, 255, 0.92);
}

.thumb-card.is-active {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(47, 143, 99, 0.12);
}

.thumb-preview {
  width: 100px;
  height: 100px;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--line);
}

.thumb-preview img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  background: #fff;
}

.thumb-name {
  font-size: 0.84rem;
  font-weight: 700;
  line-height: 1.4;
  word-break: break-all;
}

.thumb-meta {
  font-size: 0.8rem;
  color: var(--muted);
}

.preview-stage {
  display: grid;
  gap: 14px;
}

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

.preview-meta,
.compare-meta {
  margin: 6px 0 0;
  color: var(--muted);
  line-height: 1.55;
}

.preview-toolbar:empty {
  display: none;
}

.compare-select-row {
  margin-top: 6px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.compare-select-field {
  max-width: 220px;
  margin: 0;
}

.compare-select-field span {
  display: none;
}

.compare-variant-label {
  margin: 0;
  line-height: 1.55;
}

.compare-meta:empty {
  display: none;
}

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

.compare-card {
  margin: 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
}

.compare-card figcaption {
  font-weight: 700;
  color: var(--primary-strong);
  margin-bottom: 10px;
}

.checker {
  background:
    linear-gradient(45deg, #eef1ec 25%, transparent 25%, transparent 75%, #eef1ec 75%, #eef1ec 100%),
    linear-gradient(45deg, #eef1ec 25%, #fff 25%, #fff 75%, #eef1ec 75%, #eef1ec 100%);
  background-size: 24px 24px;
  background-position: 0 0, 12px 12px;
}

.compare-canvas {
  display: grid;
  place-items: center;
  min-height: 320px;
  border-radius: 12px;
  border: 1px solid var(--line);
  overflow: hidden;
}

.compare-canvas img {
  max-width: 100%;
  max-height: 420px;
  width: auto;
  height: auto;
  object-fit: contain;
  display: block;
}

.result-card {
  padding: 16px;
  box-shadow: var(--shadow-card);
}

.result-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: start;
}

.source-meta {
  margin-top: 6px;
  font-size: 0.94rem;
}

.source-chip {
  flex: none;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(47, 143, 99, 0.08);
  color: var(--primary-strong);
  font-weight: 700;
  font-size: 0.86rem;
}

.variant-list {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.variant-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 12px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: linear-gradient(180deg, #fcfefd 0%, #f5faf6 100%);
}

.variant-main {
  display: grid;
  gap: 6px;
}

.variant-title {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.variant-title strong {
  color: var(--primary-strong);
}

.variant-note {
  font-size: 0.92rem;
}

.variant-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  font-family: "SFMono-Regular", "Consolas", "Menlo", monospace;
  font-size: 0.9rem;
}

.variant-stats span {
  padding: 4px 8px;
  border-radius: 999px;
  background: rgba(31, 43, 40, 0.05);
}

.variant-stats .is-negative {
  color: var(--danger);
  background: rgba(165, 72, 61, 0.1);
}

.compare-meta.is-negative {
  color: var(--danger);
  font-weight: 700;
}

.variant-actions {
  display: flex;
  justify-content: flex-end;
}

.download-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 128px;
  padding: 10px 12px;
  border-radius: 10px;
  background: linear-gradient(180deg, #ecf8f0 0%, #d8eddc 100%);
  color: var(--primary-strong);
  text-decoration: none;
  font-weight: 700;
}

.result-card.is-active {
  border-color: rgba(47, 143, 99, 0.4);
  box-shadow: 0 0 0 2px rgba(47, 143, 99, 0.12), var(--shadow-card);
}

.error-card {
  border-color: rgba(165, 72, 61, 0.22);
  background: linear-gradient(180deg, #fff8f7 0%, #fff1ef 100%);
}

.error-card .source-chip {
  background: rgba(165, 72, 61, 0.1);
  color: var(--danger);
}

.guide-content ul {
  margin: 12px 0 0;
  padding-left: 20px;
}

@media (max-width: 860px) {
  .intake-panel {
    grid-template-columns: 1fr;
  }

  .settings-column,
  .settings-row {
    grid-template-columns: 1fr;
  }

  .preview-heading {
    flex-direction: column;
    align-items: flex-start;
  }

  .preview-heading-actions {
    width: 100%;
    justify-content: space-between;
  }
}

@media (max-width: 680px) {
  .container {
    padding-inline: 12px;
  }

  .result-head,
  .variant-card {
    grid-template-columns: 1fr;
  }

  .preview-toolbar,
  .compare-grid {
    grid-template-columns: 1fr;
    display: grid;
  }

  .source-chip,
  .variant-actions {
    justify-self: start;
  }
}
