/* === RESET & BASE === */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

[hidden] {
  display: none !important;
}

:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface2: #f9fafb;
  --border: #e2e4e9;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-text: #ffffff;
  --secondary: #6b7280;
  --secondary-hover: #4b5563;
  --text: #111827;
  --text-muted: #6b7280;
  --danger: #dc2626;
  --success: #16a34a;
  --warning: #d97706;
  --diff-add: #d1fae5;
  --diff-add-char: #6ee7b7;
  --diff-del: #fee2e2;
  --diff-del-char: #fca5a5;
  --diff-same: transparent;
  --radius: 8px;
  --radius-sm: 4px;
  --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 6px rgba(0,0,0,0.07), 0 2px 4px rgba(0,0,0,0.04);
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --editor-font: 'Iowan Old Style', 'Palatino Linotype', Palatino, Georgia, serif;
  --mono: 'SF Mono', 'Fira Code', 'Cascadia Code', Consolas, monospace;
}

html { font-size: 15px; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* === HEADER === */
header {
  background: linear-gradient(180deg, #ffffff 0%, #fafbff 100%);
  border-bottom: 1px solid #dbe3f1;
  padding: 0.7rem 1.5rem;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 6px rgba(15, 23, 42, 0.06);
}

.header-inner {
  max-width: 1400px;
  width: 100%;
  margin: 0 auto;
  /* Aligner sur le même axe horizontal que le bloc options-bar (gutter de main). */
  padding-inline: 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.7rem 1rem;
  flex-wrap: wrap;
}

.brand-block {
  display: flex;
  align-items: center;
  gap: 0.62rem;
  min-width: 0;
}

.brand-copy {
  display: flex;
  flex-direction: column;
  min-width: 0;
  gap: 0.08rem;
}

.brand-row {
  display: flex;
  align-items: center;
  gap: 0.42rem;
  min-width: 0;
}

.brand-title {
  font-size: 1.64rem;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -0.02em;
  line-height: 1;
}

.header-mark {
  display: block;
  width: 1.92rem;
  height: 1.92rem;
  flex-shrink: 0;
  border-radius: 999px;
  overflow: visible;
  filter: drop-shadow(0 3px 8px rgba(29, 78, 216, 0.28));
}

.header-claim {
  color: #4b5563;
  font-size: 0.75rem;
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: 0.01em;
}

.version-tag {
  display: inline-block;
  margin-left: 0;
  padding: 0.12rem 0.44rem;
  border: 1px solid #c7d7f5;
  border-radius: 999px;
  color: #335ea8;
  background: #f1f6ff;
  font-size: 0.66rem;
  font-weight: 700;
  line-height: 1.2;
}

.header-sub {
  display: inline-flex;
  align-items: center;
  gap: 0.38rem;
  padding: 0.28rem 0.56rem;
  border: 1px solid #d7dfea;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.88);
  font-size: 0.76rem;
  color: var(--text-muted);
  line-height: 1.2;
  white-space: nowrap;
}

.header-sub-dot {
  width: 0.42rem;
  height: 0.42rem;
  border-radius: 999px;
  background: #22c55e;
  box-shadow: 0 0 0 2px rgba(34, 197, 94, 0.16);
  flex-shrink: 0;
}

/* === MAIN === */
main {
  max-width: 1400px;
  width: 100%;
  margin: 0 auto;
  padding: 1rem 1.5rem 2rem;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

/* === OPTIONS BAR === */
.options-bar {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.6rem 1rem 0.5rem;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.5rem;
  box-shadow: var(--shadow);
  transition: padding-bottom 0.2s ease, gap 0.2s ease;
}

.options-bar.compact {
  padding-bottom: 0.32rem;
  gap: 0.22rem;
}

.option-group {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  position: relative;
  z-index: 1;
}

.option-group:hover,
.option-group:focus-within,
.option-group.tip-active {
  z-index: 2600;
}

.option-group-mode {
  flex-direction: column;
  align-items: flex-start;
  gap: 0.3rem;
  min-width: 280px;
  width: 100%;
}

.mode-toolbar {
  display: flex;
  align-items: center;
  gap: 0.75rem 1rem;
  width: 100%;
  flex-wrap: wrap;
}

.mode-row {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: wrap;
}

#preset-row {
  width: 100%;
}

.preset-context {
  position: relative;
  display: grid;
  align-items: center;
  margin-left: 0.55rem;
  min-width: 0;
  min-height: 32px;
}

.preset-context > * {
  grid-area: 1 / 1;
}

.option-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.mode-description {
  font-size: 0.74rem;
  color: var(--text-muted);
  line-height: 1.35;
}

.mode-description-inline {
  margin-left: 0;
  text-align: left;
  max-width: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  opacity: 1;
  transform: translateY(0);
  transition: opacity 0.2s ease, transform 0.22s ease;
}

.preset-context.show-config .mode-description-inline {
  opacity: 0;
  transform: translateY(-4px);
  pointer-events: none;
}

.manual-options {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 0.45rem 0.85rem;
  border-top: 1px dashed transparent;
  margin-top: 0;
  padding-top: 0;
  max-height: 0;
  opacity: 0;
  transform: translateY(-6px);
  overflow: hidden;
  pointer-events: none;
  transition: max-height 0.25s ease, opacity 0.2s ease, padding-top 0.2s ease, margin-top 0.2s ease, transform 0.22s ease;
}

.manual-options.open {
  border-top-color: var(--border);
  margin-top: 0.2rem;
  padding-top: 0.65rem;
  max-height: 2200px;
  opacity: 1;
  transform: translateY(0);
  overflow: visible;
  pointer-events: auto;
}

.manual-options .option-group {
  justify-content: space-between;
  min-width: 0;
}

.manual-options .toggle-label {
  min-width: 0;
}

.manual-options-head {
  display: none;
}

/* Mode toggle */
.mode-toggle {
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
  background: var(--bg);
  border-radius: 6px;
  padding: 2px;
  border: 1px solid var(--border);
  width: fit-content;
}

.mode-btn {
  border: none;
  background: transparent;
  padding: 0.25rem 0.75rem;
  border-radius: 4px;
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  color: var(--secondary);
  transition: all 0.15s;
}

.mode-btn.active {
  background: var(--primary);
  color: white;
  box-shadow: 0 1px 2px rgba(0,0,0,0.12);
}

.mode-btn[role="radio"]:focus-visible {
  outline: 2px solid #93c5fd;
  outline-offset: 1px;
}

/* Toggle switch */
.toggle-label {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  cursor: pointer;
  font-size: 0.82rem;
  color: var(--text);
  user-select: none;
}

.toggle-label input[type="checkbox"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-switch {
  position: relative;
  display: inline-block;
  width: 32px;
  height: 18px;
  background: var(--border);
  border-radius: 9px;
  transition: background 0.2s;
  flex-shrink: 0;
}

.toggle-switch::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 14px;
  height: 14px;
  background: white;
  border-radius: 50%;
  transition: transform 0.2s;
  box-shadow: 0 1px 2px rgba(0,0,0,0.2);
}

.toggle-label input:checked + .toggle-switch {
  background: var(--primary);
}

.toggle-label input:checked + .toggle-switch::after {
  transform: translateX(14px);
}

/* Aides contextuelles */
.help-tip {
  width: 20px;
  height: 20px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--text-muted);
  font-size: 0.74rem;
  font-weight: 700;
  cursor: help;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  position: relative;
  transition: all 0.15s;
  z-index: 2;
  --tip-shift-left: 0px;
  --tip-shift-right: 0px;
}

.help-tip.open {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
  z-index: 2000;
}

.help-tip:focus-visible {
  outline: 2px solid #93c5fd;
  outline-offset: 1px;
}

.help-tip::before {
  content: '';
  position: absolute;
  left: 50%;
  bottom: calc(100% + 2px);
  transform: translateX(calc(-50% - var(--tip-shift-left) + var(--tip-shift-right))) translateY(4px);
  border-width: 6px;
  border-style: solid;
  border-color: #1f2937 transparent transparent transparent;
  opacity: 0;
  pointer-events: none;
  transition: all 0.15s;
  z-index: 2001;
}

.help-tip::after {
  content: attr(data-help);
  position: absolute;
  left: 50%;
  bottom: calc(100% + 8px);
  transform: translateX(calc(-50% - var(--tip-shift-left) + var(--tip-shift-right))) translateY(4px);
  width: 260px;
  max-width: min(82vw, 320px);
  background: #1f2937;
  color: #fff;
  font-size: 0.74rem;
  line-height: 1.35;
  text-align: left;
  padding: 0.5rem 0.6rem;
  border-radius: 6px;
  box-shadow: var(--shadow-md);
  opacity: 0;
  pointer-events: none;
  transition: all 0.15s;
  z-index: 2002;
}

.help-tip.tip-below::before {
  bottom: auto;
  top: calc(100% + 2px);
  border-color: transparent transparent #1f2937 transparent;
  transform: translateX(calc(-50% - var(--tip-shift-left) + var(--tip-shift-right))) translateY(-4px);
}

.help-tip.tip-below::after {
  bottom: auto;
  top: calc(100% + 8px);
  transform: translateX(calc(-50% - var(--tip-shift-left) + var(--tip-shift-right))) translateY(-4px);
}

.help-tip.open::before,
.help-tip.open::after {
  opacity: 1;
  transform: translateX(calc(-50% - var(--tip-shift-left) + var(--tip-shift-right))) translateY(0);
}

/* === EDITOR AREA === */
.editor-area {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  align-items: start;
}

.editor-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow);
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.45rem 0.6rem;
  min-height: 50px;
  padding: 0.6rem 0.75rem;
  border-bottom: 1px solid var(--border);
  background: var(--surface2);
  border-radius: var(--radius) var(--radius) 0 0;
}

.panel-header h2 {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  min-width: 0;
}

.panel-inline-status {
  display: none;
  align-items: center;
  gap: 0.28rem;
  margin-left: auto;
  padding: 0.22rem 0.52rem;
  border-radius: 999px;
  border: 1px solid transparent;
  font-size: 0.74rem;
  font-weight: 600;
  color: var(--text-muted);
  background: var(--surface);
  opacity: 0;
  transform: translateY(-2px) scale(0.98);
  transition: opacity 0.18s ease, transform 0.18s ease;
  white-space: nowrap;
  pointer-events: none;
}

.panel-inline-status.show {
  display: inline-flex;
  opacity: 1;
  transform: translateY(0) scale(1);
}

.panel-inline-status.tone-success {
  color: #166534;
  background: #ecfdf3;
  border-color: #86efac;
}

.panel-inline-status.tone-warning {
  color: #92400e;
  background: #fffbeb;
  border-color: #fcd34d;
}

.panel-inline-status.tone-error {
  color: #991b1b;
  background: #fef2f2;
  border-color: #fca5a5;
}

.panel-inline-status.tone-info {
  color: #0c4a6e;
  background: #f0f9ff;
  border-color: #7dd3fc;
}

#input-inline-status {
  order: 4;
  margin-left: 0.25rem;
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
}

#output-inline-status {
  margin-left: auto;
}

.panel-actions {
  display: flex;
  align-items: center;
  min-height: 28px;
  gap: 0.4rem;
  flex-wrap: wrap;
  justify-content: flex-end;
  margin-left: auto;
}

.output-header-actions {
  display: flex;
  align-items: center;
  gap: 0.42rem;
  margin-left: auto;
}

.btn-recopy {
  display: inline-block;
}

.btn-edit-input {
  display: none;
}

.text-surface {
  position: relative;
}

.editor-panel textarea {
  display: block;
  width: 100%;
  border: none;
  outline: none;
  resize: none;
  overflow-y: hidden;
  padding: 0.75rem;
  font-family: var(--editor-font);
  font-size: 0.82rem;
  line-height: 1.6;
  letter-spacing: 0.01em;
  font-variant-ligatures: none;
  color: var(--text);
  background: transparent;
  min-height: 220px;
}

/* === BUTTONS === */
.btn-primary {
  background: var(--primary);
  color: var(--primary-text);
  border: none;
  padding: 0.6rem 1.25rem;
  border-radius: var(--radius);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
  font-family: var(--font);
  white-space: nowrap;
  box-shadow: 0 2px 4px rgba(37,99,235,0.3);
}

.btn-primary:hover { background: var(--primary-hover); }
.btn-primary:active { transform: scale(0.97); }

.btn-clean-panel {
  padding: 0.34rem 0.8rem;
  font-size: 0.78rem;
  box-shadow: 0 1px 3px rgba(37,99,235,0.25);
}

.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 0.3rem 0.65rem;
  border-radius: var(--radius-sm);
  font-size: 0.78rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
  font-family: var(--font);
}

.btn-secondary:hover { background: var(--surface2); border-color: var(--secondary); }
.btn-secondary:disabled { opacity: 0.45; cursor: default; }
.btn-secondary.is-active {
  background: var(--primary);
  border-color: var(--primary);
  color: var(--primary-text);
}

.mobile-view-switch {
  display: none;
}

.mobile-cleanbar {
  display: none;
}

.impact-bar {
  margin: 0.55rem 0.75rem 0.15rem;
  padding: 0.38rem 0.45rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface2);
  display: flex;
  align-items: center;
  gap: 0.55rem;
}

.impact-track {
  flex: 1;
  height: 8px;
  border-radius: 999px;
  background: #e5e7eb;
  overflow: hidden;
}

.impact-fill {
  display: block;
  height: 100%;
  width: 0;
  border-radius: 999px;
  transition: width 0.18s ease;
}

.impact-text {
  font-size: 0.74rem;
  color: var(--text-muted);
  white-space: nowrap;
}

.impact-bar.impact-none .impact-fill { width: 8%; background: #9ca3af; }
.impact-bar.impact-light .impact-fill { width: 36%; background: #16a34a; }
.impact-bar.impact-medium .impact-fill { width: 68%; background: #d97706; }
.impact-bar.impact-high .impact-fill { width: 100%; background: #dc2626; }

/* === RESPONSIVE === */
@media (max-width: 1100px) {
  header {
    padding: 0.64rem 1.2rem;
  }

  .header-inner {
    gap: 0.55rem 0.9rem;
  }

  .brand-title {
    font-size: 1.42rem;
  }

  .header-claim {
    font-size: 0.72rem;
  }

  .header-sub {
    font-size: 0.73rem;
    padding: 0.24rem 0.5rem;
  }

  .option-group-mode {
    gap: 0.4rem;
  }

  .mode-toolbar {
    flex-direction: column;
    align-items: stretch;
    gap: 0.4rem;
  }

  .mode-row {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.18rem;
    width: 100%;
  }

  #preset-row {
    flex-direction: row;
    align-items: center;
    gap: 0.4rem;
    flex-wrap: wrap;
  }

  .preset-context {
    margin-left: 0.45rem;
    flex: 1 1 320px;
    min-width: 260px;
  }

  .mode-description-inline {
    max-width: 32ch;
    text-align: left;
  }

  .mode-toggle {
    width: 100%;
  }

  .mode-btn {
    flex: 1 1 0;
    text-align: center;
    padding: 0.24rem 0.5rem;
    font-size: 0.78rem;
    white-space: nowrap;
  }

  .mode-description {
    margin-top: 0;
  }
}

@media (max-width: 900px) {
  header {
    padding: 0.58rem 0.92rem;
  }

  .header-inner {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.34rem;
    padding-inline: 0.92rem;
  }

  .brand-title {
    font-size: 1.28rem;
  }

  .header-mark {
    width: 1.72rem;
    height: 1.72rem;
  }

  .header-claim {
    font-size: 0.7rem;
  }

  .header-sub {
    white-space: normal;
    max-width: 100%;
  }

  main {
    padding-bottom: calc(5.2rem + env(safe-area-inset-bottom, 0px));
    gap: 0.58rem;
  }

  body.mobile-view-output main,
  body.mobile-manual-open main {
    padding-bottom: calc(1rem + env(safe-area-inset-bottom, 0px));
  }

  .manual-options {
    grid-template-columns: 1fr;
  }

  .options-bar {
    padding: 0.48rem 0.68rem 0.42rem;
  }

  .options-bar.compact {
    padding-bottom: 0.3rem;
  }

  .option-group-mode {
    gap: 0.26rem;
  }

  .mode-toolbar {
    gap: 0.28rem 0.52rem;
  }

  #preset-row {
    gap: 0.26rem;
  }

  .preset-context {
    margin-left: 0.22rem;
    min-height: 26px;
  }

  .mode-description-inline {
    font-size: 0.72rem;
    line-height: 1.26;
    max-width: none;
    white-space: normal;
    overflow: visible;
    text-overflow: clip;
  }

  .editor-area {
    grid-template-columns: 1fr;
    gap: 0.65rem;
  }

  .mobile-view-switch {
    display: flex;
    gap: 0.35rem;
    padding: 0.28rem;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--surface);
    box-shadow: var(--shadow);
  }

  .mobile-view-switch .btn-secondary {
    flex: 1 1 0;
    text-align: center;
    font-weight: 600;
    padding: 0.34rem 0.56rem;
  }

  .mobile-view-switch .btn-secondary:disabled {
    opacity: 0.6;
    cursor: default;
  }

  .btn-edit-input {
    display: inline-block;
  }

  #input-panel {
    display: flex;
  }

  #output-panel {
    display: none;
  }

  body.mobile-view-output #input-panel {
    display: none;
  }

  body.mobile-view-output #output-panel {
    display: flex;
  }

  .editor-panel.mobile-enter {
    animation: mobile-panel-in 0.22s ease;
  }

  #btn-clean {
    display: none;
  }

  .mobile-cleanbar {
    display: block;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 130;
    padding: 0.55rem 0.75rem calc(0.55rem + env(safe-area-inset-bottom, 0px));
    background: rgba(244, 245, 247, 0.96);
    border-top: 1px solid var(--border);
    box-shadow: 0 -8px 16px rgba(17, 24, 39, 0.08);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
  }

  .mobile-cleanbar .btn-primary {
    width: 100%;
    padding: 0.58rem 0.8rem;
    font-size: 0.88rem;
    box-shadow: 0 1px 3px rgba(37, 99, 235, 0.24);
    position: relative;
    transition: background 0.16s ease, transform 0.16s ease;
  }

  .mobile-cleanbar .btn-primary.is-loading {
    background: #1d4ed8;
  }

  .mobile-cleanbar .btn-primary.is-loading::before {
    content: '';
    width: 12px;
    height: 12px;
    border: 2px solid rgba(255,255,255,0.55);
    border-top-color: #fff;
    border-radius: 50%;
    display: inline-block;
    vertical-align: -2px;
    margin-right: 0.45rem;
    animation: mobile-spin 0.9s linear infinite;
  }

  .mobile-cleanbar .btn-primary.is-success {
    background: #16a34a;
    box-shadow: 0 1px 3px rgba(22,163,74,0.32);
  }

  body.mobile-view-output .mobile-cleanbar,
  body.mobile-manual-open .mobile-cleanbar {
    display: none;
  }

  body.mobile-manual-open .mobile-view-switch {
    visibility: hidden;
  }

  body.mobile-manual-open .options-bar > .option-group.option-group-mode {
    visibility: hidden;
    pointer-events: none;
    z-index: 0 !important;
  }

  .manual-options.open {
    position: fixed;
    inset: 0;
    z-index: 4000;
    margin: 0;
    padding: 0.72rem 0.72rem calc(0.9rem + env(safe-area-inset-bottom, 0px));
    max-height: none;
    border-top: none;
    background: var(--bg);
    opacity: 1;
    transform: none;
    overflow: auto;
    pointer-events: auto;
    display: block;
  }

  .manual-options.open .manual-options-head {
    position: sticky;
    top: 0;
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    margin: 0 0 0.55rem;
    padding: 0.5rem 0.55rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: var(--shadow);
  }

  .manual-options.open .manual-options-head h3 {
    font-size: 0.82rem;
    font-weight: 700;
    color: var(--text);
    letter-spacing: 0.02em;
  }

  .btn-manual-close {
    padding: 0.26rem 0.58rem;
    font-size: 0.75rem;
  }

  .manual-options.open .option-group {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0.45rem 0.55rem;
    box-shadow: var(--shadow);
  }

  .manual-options.open .option-group + .option-group {
    margin-top: 0.44rem;
  }

  .panel-header {
    min-height: 44px;
    padding: 0.46rem 0.56rem;
  }

  .panel-actions {
    width: 100%;
    min-height: 0;
    justify-content: flex-start;
    margin-left: 0;
    gap: 0.32rem;
  }

  .btn-secondary {
    padding: 0.28rem 0.56rem;
    font-size: 0.76rem;
  }

  .btn-recopy {
    padding: 0.27rem 0.52rem;
    font-size: 0.75rem;
  }

  .panel-inline-status {
    width: auto;
    margin-left: 0;
    margin-right: 0;
    white-space: nowrap;
  }

  #input-inline-status {
    order: 99;
    max-width: none;
  }

  .output-header-actions {
    width: 100%;
    justify-content: flex-start;
    margin-left: 0;
    gap: 0.32rem;
  }

  #input-panel textarea,
  #output-panel textarea {
    min-height: 100px;
  }

  #input-panel textarea { min-height: 96px; }
  #output-panel textarea { min-height: 88px; }
  .editor-panel textarea { padding: 0.64rem; }

  .impact-bar {
    flex-direction: row;
    align-items: center;
    gap: 0.45rem;
    margin: 0.45rem 0.6rem 0.15rem;
  }

  .impact-track {
    flex: 1 1 auto;
    min-width: 90px;
    height: 8px;
  }

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

@media (max-width: 600px) {
  main { padding: 0.62rem 0.62rem calc(5.2rem + env(safe-area-inset-bottom, 0px)); }
  body.mobile-view-output main,
  body.mobile-manual-open main { padding-bottom: calc(0.85rem + env(safe-area-inset-bottom, 0px)); }
  .options-bar { padding: 0.42rem 0.58rem; gap: 0.34rem 0.62rem; }
  .options-bar.compact { padding-bottom: 0.28rem; gap: 0.2rem; }
  .option-group-mode { min-width: 100%; }
  .mode-description { max-width: none; }
  .preset-context { margin-left: 0; width: 100%; min-width: 0; }
  .mode-description-inline { width: 100%; margin-left: 0; text-align: left; font-size: 0.7rem; line-height: 1.2; max-width: none; white-space: normal; overflow: visible; text-overflow: clip; }
  header { padding: 0.5rem 0.62rem; }
  .header-inner { gap: 0.24rem; padding-inline: 0.62rem; }
  .brand-block { gap: 0.5rem; }
  .brand-title { font-size: 1.12rem; }
  .header-mark { width: 1.58rem; height: 1.58rem; }
  .header-claim { font-size: 0.66rem; }
  .version-tag { font-size: 0.62rem; padding: 0.1rem 0.38rem; }
  .header-sub { font-size: 0.7rem; padding: 0.2rem 0.44rem; }
  .panel-header { min-height: 42px; padding: 0.4rem 0.5rem; }
  .mobile-view-switch { gap: 0.3rem; padding: 0.24rem; }
  .mobile-view-switch .btn-secondary { padding: 0.32rem 0.48rem; font-size: 0.77rem; }
  .mode-btn {
    font-size: 0.79rem;
    padding: 0.28rem 0.52rem;
  }
  .mobile-cleanbar { padding: 0.5rem 0.62rem calc(0.5rem + env(safe-area-inset-bottom, 0px)); }
  .mobile-cleanbar .btn-primary { font-size: 0.9rem; }
}

@keyframes mobile-spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

@keyframes mobile-panel-in {
  from {
    opacity: 0;
    transform: translateX(16px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}
