:root {
  --accent: #0f8b8d;
  --accent-ink: #ffffff;
  --forge-ink: #102a2c;
  --forge-muted: #607475;
  --forge-mint: #d9efec;
  --forge-lime: #c7f464;
}

body {
  background:
    linear-gradient(rgba(15, 139, 141, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(15, 139, 141, 0.035) 1px, transparent 1px),
    #f5f7f2;
  background-size: 32px 32px;
}

main { padding-top: clamp(2.5rem, 7vw, 6rem); }

.hero { padding-bottom: clamp(3rem, 7vw, 6rem); }

.hero__label {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  margin-bottom: 1.25rem;
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 850;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.hero__label span { width: 2.5rem; height: 2px; background: currentColor; }

.hero h1 {
  max-width: 13ch;
  margin-bottom: clamp(2rem, 5vw, 4rem);
  color: var(--forge-ink);
  font-size: clamp(3rem, 9vw, 7.5rem);
  letter-spacing: -0.075em;
  line-height: 0.88;
}

.hero h1 em { color: var(--accent); font-family: Georgia, 'Times New Roman', serif; font-weight: 500; }

.hero__footer { display: flex; align-items: center; justify-content: space-between; gap: 2rem; }
.hero__footer > p { max-width: 43rem; margin: 0; font-size: clamp(1rem, 2vw, 1.25rem); }

.privacy-stamp {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 0.8rem;
  border: 1px solid #b4d8d4;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.65);
  padding: 0.65rem 1rem 0.65rem 0.7rem;
}

.privacy-stamp__icon { display: grid; width: 2.3rem; aspect-ratio: 1; place-items: center; border-radius: 50%; background: var(--accent); color: white; font-size: 1.4rem; }
.privacy-stamp span:last-child { display: grid; color: var(--forge-muted); font-size: 0.73rem; line-height: 1.25; }
.privacy-stamp strong { color: var(--forge-ink); font-size: 0.82rem; }

.forge {
  overflow: hidden;
  border: 1px solid #cddbd7;
  border-radius: clamp(1rem, 3vw, 1.8rem);
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 28px 75px rgba(16, 42, 44, 0.12);
}

.forge__heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 2rem;
  border-bottom: 1px solid #dce5e2;
  padding: clamp(1.25rem, 4vw, 2.3rem);
}

.forge__heading h2, .forge__heading p { margin-bottom: 0; }

.step-track { display: flex; margin: 0; padding: 0; list-style: none; }
.step-track li { display: flex; align-items: center; gap: 0.45rem; color: #879596; font-size: 0.8rem; font-weight: 750; }
.step-track li:not(:last-child)::after { width: clamp(1rem, 4vw, 3rem); height: 1px; margin-inline: 0.55rem; background: #cbd5d2; content: ''; }
.step-track span { display: grid; width: 1.7rem; aspect-ratio: 1; place-items: center; border: 1px solid #cbd5d2; border-radius: 50%; font-size: 0.7rem; }
.step-track .is-active { color: var(--forge-ink); }
.step-track .is-active span { border-color: var(--accent); background: var(--accent); color: white; }

.forge-error { margin: 1rem clamp(1rem, 4vw, 2.3rem) 0; background: #fff4f2; }

.forge-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.08fr) minmax(0, 1fr); }
.forge-grid > section { min-width: 0; padding: clamp(1rem, 3vw, 2rem); }
.forge-grid > section + section { border-left: 1px solid #dce5e2; }

.column-heading { display: flex; gap: 0.85rem; margin-bottom: 1.4rem; }
.column-heading > span { display: grid; flex: 0 0 auto; width: 2rem; aspect-ratio: 1; place-items: center; border-radius: 50%; background: var(--forge-ink); color: white; font-size: 0.66rem; font-weight: 850; }
.column-heading h3 { margin: 0 0 0.25rem; font-size: 1.05rem; }
.column-heading p { margin: 0; font-size: 0.75rem; }

.drop-zone {
  display: grid;
  min-height: 18rem;
  place-items: center;
  align-content: center;
  gap: 0.35rem;
  border: 1.5px dashed #8dbab6;
  border-radius: 1rem;
  background: #f2faf8;
  color: var(--forge-muted);
  cursor: pointer;
  text-align: center;
  transition: border-color 160ms ease, background 160ms ease, transform 160ms ease;
}

.drop-zone:hover, .drop-zone.is-dragging { border-color: var(--accent); background: var(--forge-mint); transform: translateY(-2px); }
.drop-zone input { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; }
.drop-zone strong { color: var(--forge-ink); }
.drop-zone > span:last-child { font-size: 0.82rem; }
.drop-zone__glyph { display: grid; width: 3.4rem; aspect-ratio: 1; place-items: center; margin-bottom: 0.65rem; border-radius: 1rem; background: var(--accent); color: white; font-size: 1.8rem; box-shadow: 0 12px 24px rgba(15, 139, 141, 0.2); }

.file-card { display: grid; grid-template-columns: 3.2rem minmax(0, 1fr) auto; align-items: center; gap: 0.75rem; margin-top: 0.8rem; border: 1px solid #dce5e2; border-radius: 0.8rem; padding: 0.65rem; }
.file-card img { width: 3.2rem; height: 3.2rem; border-radius: 0.55rem; object-fit: cover; background: #eef2f0; }
.file-card__copy { display: grid; min-width: 0; }
.file-card__copy strong { overflow: hidden; font-size: 0.78rem; text-overflow: ellipsis; white-space: nowrap; }
.file-card__copy span { color: var(--forge-muted); font-size: 0.68rem; }
.file-card__ready { border-radius: 999px; background: var(--forge-mint); padding: 0.25rem 0.45rem; color: #116c60; font-size: 0.62rem; font-weight: 800; text-transform: uppercase; }

.clear-button {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 2.7rem;
  margin-top: 0.65rem;
  border-color: #c6d5d1;
  background: transparent;
  color: var(--forge-muted);
  font-size: 0.78rem;
}

.clear-button:hover { border-color: var(--danger); color: var(--danger); }
.clear-button span { margin-right: 0.35rem; font-size: 1.1rem; line-height: 1; }

.settings-form { display: grid; gap: 1.15rem; }
.settings-form fieldset { display: grid; gap: 0.75rem; margin: 0; border: 0; border-bottom: 1px solid #e1e8e6; padding: 0 0 1.15rem; }
.settings-form legend { margin-bottom: 0.75rem; padding: 0; color: var(--forge-ink); font-size: 0.78rem; font-weight: 850; text-transform: uppercase; }
.settings-form label { font-size: 0.78rem; }
.settings-form label span { color: var(--forge-muted); font-size: 0.68rem; }

.dimension-grid { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); align-items: end; gap: 0.55rem; }
.dimension-x { padding-bottom: 0.75rem; color: #849190; }
.settings-form input[type='number'], .settings-form select { min-width: 0; background: #fbfcfb; }

.check-row { display: flex !important; align-items: flex-start; justify-content: flex-start; gap: 0.65rem; border-radius: 0.7rem; background: #f4f7f5; padding: 0.7rem; }
.check-row input { flex: 0 0 auto; width: 1.1rem; min-height: 1.1rem; margin: 0.2rem 0 0; accent-color: var(--accent); }
.check-row > span { display: grid; color: var(--forge-ink) !important; }
.check-row small { color: var(--forge-muted); font-weight: 500; }

.quality-heading { display: flex; align-items: center; justify-content: space-between; }
.quality-heading legend { margin: 0; }
.quality-heading output { color: var(--accent); font-weight: 850; }
input[type='range'] { min-height: 1.5rem; padding: 0; accent-color: var(--accent); }
.range-labels { display: flex; justify-content: space-between; color: var(--forge-muted); font-size: 0.66rem; }
.field-error { margin: 0; color: var(--danger); font-size: 0.78rem; font-weight: 750; }

.forge-button, .download-button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 3.35rem;
  border-radius: 0.8rem;
  background: var(--forge-ink);
  padding: 0.7rem 1rem;
  color: white;
  font-weight: 800;
  text-decoration: none;
}

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

.result-column { background: #f6f9f7; }
.empty-result { display: grid; min-height: 18rem; place-items: center; align-content: center; gap: 0.65rem; border: 1px solid #dfe7e4; border-radius: 1rem; background: rgba(255, 255, 255, 0.68); padding: 1rem; text-align: center; }
.empty-result > span { display: grid; width: 3rem; aspect-ratio: 1; place-items: center; border: 1px solid #b7c8c4; border-radius: 50%; color: var(--accent); font-size: 1.5rem; }
.empty-result strong { max-width: 15rem; }
.empty-result p { max-width: 15rem; margin: 0; font-size: 0.78rem; }

.result-card { display: grid; gap: 1rem; }
.result-preview-wrap { display: grid; min-height: 12rem; place-items: center; overflow: hidden; border-radius: 0.9rem; background: linear-gradient(45deg, #e7ece9 25%, transparent 25%), linear-gradient(-45deg, #e7ece9 25%, transparent 25%), linear-gradient(45deg, transparent 75%, #e7ece9 75%), linear-gradient(-45deg, transparent 75%, #e7ece9 75%), white; background-position: 0 0, 0 8px, 8px -8px, -8px 0; background-size: 16px 16px; }
.result-preview-wrap img { max-height: 17rem; object-fit: contain; }
.result-specs { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.65rem; margin: 0; }
.result-specs > div { border: 1px solid #dce5e2; border-radius: 0.65rem; background: white; padding: 0.65rem; }
.result-specs dt { color: var(--forge-muted); font-size: 0.65rem; text-transform: uppercase; }
.result-specs dd { margin: 0.15rem 0 0; overflow-wrap: anywhere; font-size: 0.82rem; font-weight: 820; }
.size-change { margin: 0; color: #15745d; font-size: 0.75rem; font-weight: 750; }
.size-change[data-direction='up'] { color: var(--warning); }
.download-button { background: var(--accent); }

.assurances { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1.5rem; margin-top: clamp(3rem, 7vw, 6rem); }
.assurances article { border-top: 2px solid var(--forge-ink); padding-top: 1rem; }
.assurances article > span { color: var(--accent); font-size: 0.7rem; font-weight: 850; }
.assurances h3 { margin: 0.8rem 0 0.45rem; }
.assurances p { margin: 0; font-size: 0.85rem; }

@media (max-width: 62rem) {
  .forge-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .result-column { grid-column: 1 / -1; border-top: 1px solid #dce5e2; border-left: 0 !important; }
  .result-card { grid-template-columns: minmax(12rem, 0.8fr) minmax(14rem, 1fr); }
  .result-card > :not(.result-preview-wrap) { grid-column: 2; }
  .result-preview-wrap { grid-row: 1 / span 4; }
}

@media (max-width: 44rem) {
  .hero__footer, .forge__heading { align-items: flex-start; flex-direction: column; }
  .privacy-stamp { align-self: flex-start; }
  .forge-grid { grid-template-columns: 1fr; }
  .forge-grid > section + section { border-top: 1px solid #dce5e2; border-left: 0; }
  .result-column { grid-column: auto; }
  .result-card { grid-template-columns: 1fr; }
  .result-card > :not(.result-preview-wrap) { grid-column: auto; }
  .result-preview-wrap { grid-row: auto; }
  .assurances { grid-template-columns: 1fr; }
}

@media (max-width: 28rem) {
  .hero h1 { font-size: clamp(2.1rem, 8vw, 3.2rem); line-height: 1.02; }
  .forge-mode-tabs { width: 100%; display: grid; grid-template-columns: 1fr 1fr; }
  .forge-mode-tab { min-height: 44px; text-align: center; }
  .step-track { width: 100%; justify-content: space-between; flex-wrap: wrap; gap: 0.35rem; }
  .step-track li { gap: 0.25rem; font-size: 0.68rem; }
  .step-track li:not(:last-child)::after { display: none; }
  .dimension-grid { grid-template-columns: 1fr; }
  .dimension-x { display: none; }
  .drop-zone { min-height: 14rem; }
}

/* Mode Switcher Tabs */
.forge-mode-tabs {
  display: inline-flex;
  gap: 0.35rem;
  padding: 0.3rem;
  background: #e6eee9;
  border: 1px solid #c9d7d2;
  border-radius: 0.85rem;
}

.forge-mode-tab {
  padding: 0.45rem 0.95rem;
  border: none;
  background: transparent;
  color: var(--forge-muted);
  font-size: 0.82rem;
  font-weight: 750;
  border-radius: 0.6rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

.forge-mode-tab:hover {
  color: var(--forge-ink);
}

.forge-mode-tab.is-active,
.forge-mode-tab[aria-selected="true"] {
  background: white;
  color: var(--accent);
  box-shadow: 0 4px 12px rgba(15, 139, 141, 0.15);
}

/* Target File Size Controls */
.target-kb-fieldset {
  margin-top: 0.5rem;
  background: #f8fbfa;
  border: 1px dashed #b9d8d3;
}

.target-kb-fieldset label {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--forge-ink);
}

.kb-presets {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-top: 0.45rem;
  flex-wrap: wrap;
}

.kb-presets__label {
  font-size: 0.72rem;
  color: var(--forge-muted);
  font-weight: 600;
}

.kb-preset-chip {
  padding: 0.2rem 0.55rem;
  border: 1px solid #b8d2cc;
  border-radius: 999px;
  background: white;
  color: #102a2c;
  font-size: 0.72rem;
  font-weight: 750;
  cursor: pointer;
  transition: all 0.15s ease;
}

.kb-preset-chip:hover,
.kb-preset-chip.is-active {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}

.target-kb-status {
  display: block;
  font-size: 0.75rem;
  font-weight: 700;
  color: #15745d;
  margin-top: 0.35rem;
}

/* PDF Forge Grid & Panel */
.pdf-forge-panel {
  display: block;
}

.pdf-forge-panel[hidden] {
  display: none !important;
}

.pdf-forge-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr) minmax(0, 1fr);
}

.pdf-forge-grid > section {
  min-width: 0;
  padding: clamp(1rem, 3vw, 2rem);
}

.pdf-forge-grid > section + section {
  border-left: 1px solid #dce5e2;
}

.pdf-files-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 0.75rem;
  padding: 0.5rem 0.75rem;
  background: #eef6f4;
  border-radius: 0.5rem;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--forge-ink);
}

.button-text {
  background: transparent;
  border: none;
  color: #c0392b;
  font-size: 0.72rem;
  font-weight: 750;
  cursor: pointer;
  text-decoration: underline;
}

.pdf-files-list {
  list-style: none;
  margin: 0.75rem 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-height: 20rem;
  overflow-y: auto;
}

.pdf-file-item {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.5rem;
  background: white;
  border: 1px solid #dce5e2;
  border-radius: 0.5rem;
  font-size: 0.78rem;
}

.pdf-file-item img {
  width: 2.4rem;
  height: 2.4rem;
  object-fit: cover;
  border-radius: 0.35rem;
  border: 1px solid #cbd5d2;
}

.pdf-file-info {
  flex-grow: 1;
  min-width: 0;
}

.pdf-file-name {
  display: block;
  font-weight: 750;
  color: var(--forge-ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pdf-file-meta {
  font-size: 0.7rem;
  color: var(--forge-muted);
}

.pdf-file-remove {
  background: transparent;
  border: none;
  color: #879596;
  font-size: 1.1rem;
  cursor: pointer;
  padding: 0.2rem 0.4rem;
  line-height: 1;
}

.pdf-file-remove:hover {
  color: #c0392b;
}

.pdf-badge {
  display: inline-block;
  padding: 0.25rem 0.65rem;
  background: #d4edda;
  color: #155724;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 800;
  margin-bottom: 0.5rem;
}

#pdf-result-title {
  margin: 0 0 0.75rem;
  font-size: 1.05rem;
  color: var(--forge-ink);
  word-break: break-all;
}

@media (max-width: 62rem) {
  .pdf-forge-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .pdf-result-column { grid-column: 1 / -1; border-top: 1px solid #dce5e2; border-left: 0 !important; }
}

@media (max-width: 44rem) {
  .pdf-forge-grid { grid-template-columns: 1fr; }
  .pdf-forge-grid > section + section { border-top: 1px solid #dce5e2; border-left: 0; }
  .pdf-result-column { grid-column: auto; }
}

/* Quick Scale & Social Media Presets */
.preset-group {
  margin-top: 0.85rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.preset-group-title {
  font-size: 0.74rem;
  font-weight: 750;
  color: var(--forge-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.scale-presets,
.social-presets,
.kb-presets {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  align-items: center;
}

.scale-chip,
.social-chip,
.kb-preset-chip {
  padding: 0.28rem 0.65rem;
  border: 1px solid #d0ded9;
  border-radius: 999px;
  background: #f7faf8;
  color: #3b504b;
  font-size: 0.74rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.scale-chip:hover,
.social-chip:hover,
.kb-preset-chip:hover {
  background: #e8f3ef;
  border-color: #a4c4ba;
  color: var(--forge-ink);
}

.scale-chip.is-active,
.social-chip.is-active,
.kb-preset-chip.is-active {
  background: #15745d;
  border-color: #15745d;
  color: white;
  box-shadow: 0 2px 6px rgba(21, 116, 93, 0.25);
}

.kb-presets__label {
  font-size: 0.74rem;
  color: var(--forge-muted);
  font-weight: 700;
  margin-right: 0.25rem;
}

.target-kb-status {
  display: block;
  font-size: 0.76rem;
  font-weight: 700;
  margin-top: 0.35rem;
  min-height: 1.1em;
}

/* Background Removal Fieldset */
.bg-remove-fieldset {
  border: 1px solid #e0dfd5;
  border-radius: 0.75rem;
  padding: 0.85rem 1rem;
  background: #fbfbf9;
  margin-top: 0.5rem;
}

.bg-remove-options {
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px dashed #d5d5cb;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.bg-remove-options[hidden] {
  display: none !important;
}

.bg-mode-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.radio-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.35rem 0.65rem;
  border: 1px solid #d8d8cc;
  border-radius: 0.5rem;
  background: white;
  font-size: 0.75rem;
  font-weight: 700;
  color: #444;
  cursor: pointer;
  transition: all 0.15s ease;
}

.radio-chip:has(input:checked) {
  border-color: #15745d;
  background: #eaf5f1;
  color: #15745d;
}

.bg-hint {
  font-size: 0.74rem;
  color: #78350f;
  margin: 0;
  font-weight: 600;
}

/* Checkerboard pattern for transparent preview */
.result-preview-wrap.has-transparency,
.has-transparency img {
  background: repeating-conic-gradient(#e6e6e6 0% 25%, #ffffff 0% 50%) 50% / 16px 16px !important;
}

