.tool-header {
  margin-bottom: 28px;
}

.tool-breadcrumb {
  margin: 0 0 12px;
  color: var(--text-faint);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.tool-header h1 {
  margin: 0;
  max-width: 760px;
  font-size: clamp(34px, 5vw, 52px);
  line-height: 1.02;
  letter-spacing: -0.045em;
}

.tool-description {
  max-width: 680px;
  margin: 14px 0 0;
  color: var(--text-muted);
  font-size: 16px;
  line-height: 1.65;
}

.tool-workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  align-items: start;
  gap: 18px;
  transition: grid-template-columns 180ms ease;
}

.tool-workspace.has-result {
  grid-template-columns: minmax(0, 1fr) minmax(340px, 0.82fr);
}

.tool-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.input-card {
  padding: clamp(22px, 4vw, 34px);
}

.card-heading {
  margin-bottom: 26px;
}

.card-heading h2 {
  margin: 0;
  font-size: 20px;
  line-height: 1.25;
  letter-spacing: -0.02em;
}

.card-heading p {
  margin: 7px 0 0;
  color: var(--text-muted);
  font-size: 13px;
  line-height: 1.55;
}

.qr-form {
  display: grid;
  gap: 20px;
}

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

.field label {
  font-size: 13px;
  font-weight: 750;
}

.field input {
  width: 100%;
  min-height: 50px;
  padding: 0 15px;
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  outline: none;
  background: var(--surface);
  color: var(--text);
  font-size: 15px;
  transition: border-color 140ms ease, box-shadow 140ms ease, background 140ms ease;
}

.field input::placeholder {
  color: #aaa9a4;
}

.field input:hover {
  border-color: #bcbcb5;
}

.field input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--focus);
}

.field-help {
  margin: 0;
  color: var(--text-faint);
  font-size: 12px;
  line-height: 1.45;
}

.primary-button,
.download-button {
  min-height: 50px;
  border-radius: 12px;
  font-weight: 800;
  cursor: pointer;
  transition: transform 140ms ease, opacity 140ms ease, background 140ms ease;
}

.primary-button {
  width: 100%;
  margin-top: 2px;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: var(--accent-contrast);
}

.primary-button:hover,
.download-button:hover:not(:disabled) {
  transform: translateY(-1px);
}

.primary-button:active,
.download-button:active:not(:disabled) {
  transform: translateY(0) scale(0.99);
}

.form-status {
  min-height: 18px;
  margin: -6px 0 0;
  color: var(--text-muted);
  font-size: 12px;
  line-height: 1.45;
}

.form-status.is-error {
  color: var(--danger);
}

.result-card {
  min-width: 0;
  overflow: hidden;
  animation: result-in 180ms ease both;
}

@keyframes result-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.result-topbar {
  padding: 20px 22px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.result-title-wrap h2 {
  margin: 0;
  font-size: 17px;
  line-height: 1.25;
}

.result-title-wrap p {
  margin: 4px 0 0;
  color: var(--text-muted);
  font-size: 11px;
}

.ready-badge,
.stale-badge {
  flex: 0 0 auto;
  padding: 6px 9px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 800;
}

.ready-badge {
  background: #edf7f1;
  color: var(--success);
}

.stale-badge {
  background: #fff3e7;
  color: #9a5d1d;
}

.preview-area {
  padding: 26px;
  display: grid;
  place-items: center;
  background: var(--surface-subtle);
  position: relative;
}

.qr-frame {
  width: min(100%, 350px);
  aspect-ratio: 1;
  padding: clamp(15px, 5vw, 24px);
  border: 1px solid var(--border);
  border-radius: 18px;
  background: #ffffff;
  display: grid;
  place-items: center;
  transition: opacity 140ms ease, filter 140ms ease;
}

.qr-frame.is-stale {
  opacity: 0.36;
  filter: grayscale(1);
}

.qr-frame canvas {
  display: block;
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
}

.stale-overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  pointer-events: none;
}

.stale-overlay span {
  max-width: 220px;
  padding: 10px 12px;
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.95);
  box-shadow: var(--shadow-sm);
  color: var(--text);
  font-size: 11px;
  font-weight: 800;
  text-align: center;
}

.result-meta {
  padding: 17px 22px;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}

.meta-label {
  margin: 0 0 6px;
  color: var(--text-faint);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.meta-value {
  margin: 0;
  overflow: hidden;
  color: var(--text-muted);
  font-size: 12px;
  line-height: 1.45;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.download-area {
  padding: 20px 22px 22px;
}

.download-label {
  margin: 0 0 10px;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 700;
}

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

.download-button {
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
}

.download-button.primary-download {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--accent-contrast);
}

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

.download-status {
  min-height: 17px;
  margin: 10px 0 0;
  color: var(--text-muted);
  font-size: 11px;
  line-height: 1.45;
}

.privacy-note {
  margin-top: 16px;
  display: flex;
  align-items: flex-start;
  gap: 9px;
  color: var(--text-muted);
  font-size: 11px;
  line-height: 1.5;
}

.privacy-icon {
  width: 18px;
  height: 18px;
  flex: 0 0 18px;
  border: 1px solid var(--border-strong);
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: var(--text);
  font-size: 10px;
  font-weight: 800;
}

@media (max-width: 1040px) {
  .tool-workspace.has-result {
    grid-template-columns: minmax(0, 1fr) minmax(300px, 0.86fr);
  }
}

@media (max-width: 900px) {
  .tool-workspace.has-result {
    grid-template-columns: minmax(0, 1fr);
  }

  .result-card {
    max-width: 640px;
  }
}

@media (max-width: 520px) {
  .tool-header {
    margin-bottom: 22px;
  }

  .tool-header h1 {
    font-size: clamp(30px, 10vw, 42px);
  }

  .tool-description {
    font-size: 14px;
  }

  .input-card {
    padding: 20px 16px;
  }

  .preview-area {
    padding: 18px;
  }

  .result-topbar,
  .result-meta,
  .download-area {
    padding-inline: 17px;
  }
}

@media (max-width: 320px) {
  .tool-breadcrumb,
  .card-heading p,
  .privacy-note,
  .result-title-wrap p {
    font-size: 10px;
  }

  .field input,
  .primary-button,
  .download-button {
    min-height: 46px;
  }

  .download-actions {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 230px) {
  .tool-header h1 {
    font-size: 27px;
  }

  .input-card,
  .result-topbar,
  .result-meta,
  .download-area {
    padding-inline: 12px;
  }

  .preview-area {
    padding: 10px;
  }
}

/* Mobile step flow -------------------------------------------------------- */
.mobile-stepper,
.mobile-back-button {
  display: none;
}

.download-button span,
.download-button small {
  display: block;
}

.download-button small {
  margin-top: 3px;
  font-size: 10px;
  font-weight: 600;
  opacity: 0.62;
}

@media (max-width: 820px) {
  .tool-header {
    margin-bottom: 18px;
  }

  .mobile-stepper {
    margin-bottom: 18px;
    display: grid;
    grid-template-columns: minmax(0, 1fr) 26px minmax(0, 1fr);
    align-items: center;
  }

  .step-item {
    min-width: 0;
    padding: 0;
    border: 0;
    background: transparent;
    color: var(--text-faint);
    display: flex;
    align-items: center;
    gap: 9px;
    text-align: left;
    cursor: pointer;
  }

  .step-item:disabled {
    cursor: default;
    opacity: 0.52;
  }

  .step-number {
    width: 30px;
    height: 30px;
    flex: 0 0 30px;
    border: 1px solid var(--border-strong);
    border-radius: 50%;
    background: var(--surface);
    display: grid;
    place-items: center;
    font-size: 11px;
    font-weight: 800;
    transition: border-color 150ms ease, background 150ms ease, color 150ms ease;
  }

  .step-copy {
    min-width: 0;
  }

  .step-copy strong,
  .step-copy small {
    display: block;
  }

  .step-copy strong {
    color: inherit;
    font-size: 12px;
    line-height: 1.25;
  }

  .step-copy small {
    margin-top: 2px;
    overflow: hidden;
    font-size: 9px;
    line-height: 1.25;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .step-item.is-active {
    color: var(--text);
  }

  .step-item.is-active .step-number {
    border-color: var(--accent);
    background: var(--accent);
    color: var(--accent-contrast);
  }

  .step-line {
    width: 100%;
    height: 1px;
    background: var(--border-strong);
  }

  .tool-workspace.has-result {
    grid-template-columns: minmax(0, 1fr);
  }

  .tool-workspace.mobile-step-input .result-card {
    display: none;
  }

  .tool-workspace.mobile-step-result .input-card {
    display: none;
  }

  .tool-workspace.mobile-step-result .result-card:not([hidden]) {
    display: block;
    width: 100%;
    max-width: none;
  }

  .mobile-back-button {
    min-height: 34px;
    padding: 0 10px;
    border: 1px solid var(--border);
    border-radius: 9px;
    background: var(--surface);
    color: var(--text);
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    font-weight: 750;
    cursor: pointer;
  }

  .mobile-back-button:active {
    transform: scale(0.98);
  }

  .result-topbar {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
  }

  .result-title-wrap {
    min-width: 0;
  }

  .download-actions {
    grid-template-columns: 1fr 1fr;
  }

  .download-button {
    min-height: 56px;
  }
}

@media (max-width: 420px) {
  .tool-breadcrumb {
    margin-bottom: 8px;
    font-size: 10px;
  }

  .tool-header h1 {
    font-size: clamp(28px, 9vw, 36px);
  }

  .tool-description {
    margin-top: 10px;
    font-size: 13px;
    line-height: 1.5;
  }

  .mobile-stepper {
    grid-template-columns: minmax(0, 1fr) 18px minmax(0, 1fr);
  }

  .step-copy small {
    display: none;
  }

  .input-card {
    padding: 20px 16px;
  }

  .card-heading {
    margin-bottom: 22px;
  }

  .result-topbar {
    padding: 14px 14px 13px;
    gap: 8px;
  }

  .result-title-wrap h2 {
    font-size: 15px;
  }

  .result-title-wrap p {
    margin-top: 2px;
    font-size: 9px;
  }

  .ready-badge,
  .stale-badge {
    padding: 5px 7px;
    font-size: 9px;
  }

  .preview-area {
    padding: 16px;
  }

  .qr-frame {
    width: min(100%, 320px);
    border-radius: 16px;
  }

  .result-meta,
  .download-area {
    padding-inline: 16px;
  }

  .meta-value {
    white-space: normal;
    overflow-wrap: anywhere;
  }
}

@media (max-width: 310px) {
  .mobile-stepper {
    grid-template-columns: minmax(0, 1fr) 12px minmax(0, 1fr);
  }

  .step-item {
    gap: 6px;
  }

  .step-number {
    width: 26px;
    height: 26px;
    flex-basis: 26px;
  }

  .step-copy strong {
    font-size: 10px;
  }

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

  .mobile-back-button {
    grid-column: 1 / -1;
    justify-self: start;
  }

  .download-actions {
    grid-template-columns: 1fr;
  }
}
