:root {
  --ink: #18201f;
  --muted: #5f6f6b;
  --line: #d8e0dd;
  --paper: #fbfcfb;
  --surface: #ffffff;
  --input: #fbfdfc;
  --accent: #147c72;
  --accent-dark: #0d5d56;
  --warm: #c44735;
  --soft: #eef5f3;
  --hover-bg: #dcebe7;
  --active-bg: #18201f;
  --active-text: #ffffff;
  --header-bg: rgba(251, 252, 251, 0.92);
  --footer-bg: #18201f;
  --footer-text: rgba(255, 255, 255, 0.72);
  --shadow: 0 18px 45px rgba(20, 38, 35, 0.12);
}

html[data-theme="dark"] {
  color-scheme: dark;
  --ink: #eef5f3;
  --muted: #a9b8b4;
  --line: #293936;
  --paper: #111816;
  --surface: #18211f;
  --input: #121a18;
  --accent: #55bdae;
  --accent-dark: #76d7ca;
  --warm: #e48776;
  --soft: #21302d;
  --hover-bg: #2f4641;
  --active-bg: #eef5f3;
  --active-text: #111816;
  --header-bg: rgba(17, 24, 22, 0.92);
  --footer-bg: #0d1312;
  --footer-text: rgba(255, 255, 255, 0.74);
  --shadow: 0 18px 45px rgba(0, 0, 0, 0.24);
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.5;
}

button,
textarea,
input {
  font: inherit;
}

a {
  color: inherit;
  text-decoration: none;
}

.site-header {
  align-items: center;
  background: var(--header-bg);
  border-bottom: 1px solid var(--line);
  display: flex;
  gap: 24px;
  justify-content: space-between;
  padding: 18px clamp(18px, 4vw, 56px);
  position: sticky;
  top: 0;
  z-index: 5;
}

.brand,
.top-nav,
.options-row,
.section-title-row,
.result-actions {
  align-items: center;
  display: flex;
}

.brand {
  font-weight: 800;
  gap: 10px;
}

.brand-mark {
  align-items: center;
  background: var(--ink);
  border-radius: 8px;
  color: #ffffff;
  display: inline-flex;
  height: 36px;
  justify-content: center;
  width: 36px;
}

.top-nav {
  gap: 18px;
}

.language-toggle,
.nav-button,
.tab-button,
.primary-button,
.secondary-button,
.legal-link {
  border: 1px solid var(--line);
  border-radius: 8px;
  min-height: 42px;
}

.language-toggle,
.nav-button,
.tab-button,
.secondary-button,
.legal-link {
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  padding: 10px 16px;
}

.theme-switch {
  display: flex;
  gap: 8px;
}

.theme-switch__btn {
  appearance: none;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  cursor: pointer;
  display: grid;
  font-weight: 800;
  min-height: 42px;
  min-width: 42px;
  place-items: center;
}

.nav-button:hover,
.theme-switch__btn:hover {
  background: var(--hover-bg);
  color: var(--ink);
}

.theme-switch__btn.is-active {
  background: var(--active-bg);
  border-color: var(--active-bg);
  color: var(--active-text);
}

.theme-switch__btn[data-theme-mode-option="light"] {
  color: #d89a00;
}

.theme-switch__btn[data-theme-mode-option="light"]:hover {
  background: #fff4cf;
  border-color: #e2b441;
  color: #8a5b00;
}

.theme-switch__btn[data-theme-mode-option="auto"] {
  color: var(--accent);
}

.theme-switch__btn[data-theme-mode-option="auto"]:hover {
  background: var(--hover-bg);
  border-color: var(--accent);
  color: var(--accent-dark);
}

.theme-switch__btn[data-theme-mode-option="dark"] {
  color: #718096;
}

.theme-switch__btn[data-theme-mode-option="dark"]:hover {
  background: #1f2937;
  border-color: #4b5563;
  color: #ffffff;
}

.theme-switch__btn.is-active[data-theme-mode-option="light"] {
  background: #fff4cf;
  border-color: #d89a00;
  color: #7a4f00;
}

.theme-switch__btn.is-active[data-theme-mode-option="auto"] {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--active-text);
}

.theme-switch__btn.is-active[data-theme-mode-option="dark"] {
  background: #111827;
  border-color: var(--warm);
  color: #ffffff;
}

.intro {
  display: grid;
  gap: 36px;
  grid-template-columns: minmax(0, 1.2fr) minmax(280px, 0.8fr);
  padding: clamp(44px, 7vw, 92px) clamp(18px, 4vw, 56px) 32px;
}

.intro-copy {
  max-width: 860px;
}

.eyebrow {
  color: var(--warm);
  font-weight: 800;
  letter-spacing: 0;
  margin: 0 0 14px;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  font-size: 3.35rem;
  line-height: 1;
  margin-bottom: 22px;
  max-width: 920px;
  text-wrap: balance;
}

h2 {
  font-size: 1.45rem;
  line-height: 1.2;
  margin-bottom: 12px;
}

.intro-copy p:last-child {
  color: var(--muted);
  font-size: 1.16rem;
  max-width: 690px;
}

.intro-panel {
  align-self: end;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  display: grid;
  gap: 0;
}

.intro-panel div {
  border-bottom: 1px solid var(--line);
  display: grid;
  gap: 4px;
  padding: 22px;
}

.intro-panel div:last-child {
  border-bottom: 0;
}

.intro-panel strong {
  font-size: 1.1rem;
}

.intro-panel span,
.field-note {
  color: var(--muted);
}

.text-button {
  background: transparent;
  border: 0;
  color: var(--accent-dark);
  cursor: pointer;
  font-weight: 800;
  margin-top: 10px;
  padding: 0;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.text-button:hover {
  color: var(--ink);
}

.extra-html-panel,
.safelist-panel {
  margin-top: 16px;
}

.faq-section {
  padding: 34px clamp(18px, 4vw, 56px) 82px;
}

.faq-head {
  margin: 0 0 28px;
}

.faq-head p:last-child {
  color: var(--muted);
}

.faq-list {
  display: grid;
  gap: 12px;
}

.faq-item {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 0;
}

.faq-item summary {
  cursor: pointer;
  font-weight: 800;
  list-style: none;
  padding: 18px 20px;
}

.faq-item summary::-webkit-details-marker {
  display: none;
}

.faq-item summary::after {
  color: var(--accent);
  content: "+";
  float: right;
  font-weight: 900;
}

.faq-item[open] summary::after {
  content: "-";
}

.faq-item p {
  border-top: 1px solid var(--line);
  color: var(--muted);
  margin: 0;
  padding: 16px 20px 20px;
}

.tool-section {
  padding: 28px clamp(18px, 4vw, 56px) 64px;
}

.mode-tabs {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
}

.tab-button.is-active {
  background: var(--active-bg);
  border-color: var(--active-bg);
  color: var(--active-text);
}

.tool-form,
.results {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: clamp(18px, 3vw, 30px);
}

.tool-form {
  position: relative;
}

label {
  display: inline-block;
  font-weight: 800;
  margin-bottom: 8px;
}

textarea {
  background: var(--input);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  min-height: 130px;
  padding: 14px;
  resize: vertical;
  width: 100%;
}

input[type="url"] {
  background: var(--input);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  min-height: 52px;
  padding: 14px;
  width: 100%;
}

.url-input {
  max-width: 100%;
}

textarea:focus,
button:focus-visible {
  outline: 3px solid rgba(20, 124, 114, 0.28);
  outline-offset: 2px;
}

.editor-grid,
.result-layout {
  display: grid;
  gap: 20px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.result-layout {
  align-items: stretch;
}

.result-layout > div {
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
}

.is-hidden {
  display: none !important;
}

.options-row {
  align-items: end;
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(4, minmax(145px, 1fr)) minmax(120px, auto);
  margin-top: 20px;
}

.check-option {
  align-items: flex-start;
  display: flex;
  gap: 10px;
  margin: 0;
  min-height: 44px;
}

.check-option input {
  flex: 0 0 auto;
  margin-top: 4px;
}

.check-option span {
  line-height: 1.25;
}

.primary-button {
  background: var(--accent);
  border-color: var(--accent);
  color: #ffffff;
  font-weight: 800;
  min-height: 52px;
  white-space: normal;
}

.primary-button:hover {
  background: var(--accent-dark);
}

.back-to-top {
  background: var(--ink);
  border: 1px solid var(--ink);
  border-radius: 8px;
  bottom: 135px;
  box-shadow: var(--shadow);
  color: var(--surface);
  cursor: pointer;
  font-weight: 800;
  min-height: 42px;
  opacity: 0;
  padding: 10px 16px;
  pointer-events: none;
  position: fixed;
  right: 22px;
  transform: translateY(12px);
  transition: opacity 0.2s ease, transform 0.2s ease, background 0.2s ease;
  z-index: 8;
}

.back-to-top.is-visible {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

.back-to-top:hover {
  background: var(--accent);
  border-color: var(--accent);
}

.secondary-button:hover,
.tab-button:hover,
.language-toggle:hover,
.legal-link:hover,
.nav-button:hover {
  background: var(--hover-bg);
  color: var(--ink);
}

.tab-button.is-active:hover {
  background: var(--active-bg);
  color: var(--active-text);
}

.status-area {
  min-height: 0;
  padding: 0 2px;
}

.status-area:not(:empty) {
  min-height: 48px;
  padding: 16px 2px;
}

.status-area[data-type="error"] {
  color: #a73527;
}

.status-area[data-type="success"] {
  color: var(--accent-dark);
}

.donation-panel {
  align-items: center;
  animation: donate-fade 0.18s ease-out;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: flex;
  gap: 16px;
  justify-content: space-between;
  margin: 0 0 18px;
  padding: 12px 16px;
}

.donation-note {
  color: var(--accent);
  font-size: 0.95rem;
  font-weight: 800;
  line-height: 1.5;
  margin: 0;
}

.paypal-donate {
  border-radius: 8px;
  display: inline-block;
  flex: 0 0 auto;
  line-height: 0;
  max-width: 100%;
  transition: filter 0.12s ease, transform 0.12s ease;
}

.paypal-donate:hover,
.paypal-donate:focus-visible {
  filter: brightness(1.04);
  outline: none;
  transform: translateY(-1px);
}

.paypal-donate img {
  display: block;
  height: auto;
  max-width: 100%;
  width: 210px;
}

@keyframes donate-fade {
  from {
    opacity: 0;
    transform: translateY(2px);
  }

  to {
    opacity: 1;
    transform: none;
  }
}

.results {
  margin-top: 10px;
}

.quality-section {
  padding: 24px clamp(18px, 4vw, 56px) 64px;
}

.quality-head {
  margin-bottom: 22px;
}

.quality-head p:last-child {
  color: var(--muted);
  max-width: 760px;
}

.quality-stats {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-bottom: 16px;
}

.quality-stats > div,
.quality-empty,
.quality-group,
.quality-list li {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.quality-stats > div {
  padding: 16px;
}

.quality-stats span {
  color: var(--muted);
  display: block;
  margin-bottom: 4px;
}

.quality-stats strong {
  font-size: 1.5rem;
}

.quality-empty {
  color: var(--muted);
  padding: 16px;
}

.quality-accordion {
  display: grid;
  gap: 10px;
}

.quality-group {
  overflow: hidden;
}

.quality-group > summary {
  align-items: center;
  cursor: pointer;
  display: flex;
  font-weight: 800;
  gap: 12px;
  justify-content: space-between;
  list-style: none;
  padding: 16px;
}

.quality-group > summary::-webkit-details-marker {
  display: none;
}

.quality-group > summary::after {
  color: var(--accent);
  content: "+";
  font-weight: 900;
}

.quality-group[open] > summary::after {
  content: "-";
}

.quality-group.is-empty > summary {
  color: var(--muted);
  cursor: default;
}

.quality-group.is-empty > summary::after {
  content: "";
}

.quality-group > summary strong {
  background: var(--soft);
  border-radius: 8px;
  min-width: 40px;
  padding: 4px 8px;
  text-align: center;
}

.quality-group-empty {
  color: var(--muted);
  margin: 0;
  padding: 0 16px 16px;
}

.quality-list {
  display: grid;
  gap: 10px;
  list-style: none;
  margin: 0;
  padding: 0 16px 16px;
}

.quality-list li {
  padding: 14px 16px;
}

.quality-list details {
  display: grid;
  gap: 10px;
}

.quality-list details > summary {
  align-items: start;
  cursor: pointer;
  display: grid;
  gap: 6px;
  grid-template-columns: auto 1fr;
  list-style: none;
}

.quality-list details > summary::-webkit-details-marker {
  display: none;
}

.quality-list details > summary::after {
  color: var(--accent);
  content: "+";
  font-weight: 900;
  grid-column: 3;
  grid-row: 1;
}

.quality-list details[open] > summary::after {
  content: "-";
}

.quality-list strong,
.quality-detail strong {
  color: var(--ink);
}

.quality-list code {
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  overflow-wrap: anywhere;
}

.quality-list summary code {
  grid-column: 2 / -1;
}

.quality-detail {
  display: grid;
  gap: 8px;
  margin-top: 14px;
}

.quality-detail-head {
  align-items: center;
  display: flex;
  gap: 12px;
  justify-content: space-between;
}

.quality-jump {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  cursor: pointer;
  font: inherit;
  font-size: 0.88rem;
  font-weight: 750;
  min-height: 36px;
  padding: 7px 11px;
}

.quality-jump:hover,
.quality-jump:focus-visible {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--surface);
  outline: none;
}

.quality-detail p {
  color: var(--muted);
  margin-bottom: 8px;
}

.quality-code {
  background: var(--input);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  margin: 0 0 8px;
  overflow: auto;
  padding: 12px;
  white-space: pre-wrap;
}

.quality-code mark {
  background: rgba(216, 154, 0, 0.24);
  border-radius: 4px;
  color: inherit;
  font-weight: 800;
  padding: 0 2px;
}

.quality-badge {
  border-radius: 8px;
  display: inline-flex;
  font-size: 0.82rem;
  font-weight: 800;
  justify-self: start;
  padding: 4px 8px;
}

.quality-badge[data-severity="error"] {
  background: rgba(167, 53, 39, 0.12);
  color: #8f2d21;
}

.quality-badge[data-severity="warning"] {
  background: rgba(216, 154, 0, 0.16);
  color: #7a4f00;
}

.quality-badge[data-severity="hint"] {
  background: var(--soft);
  color: var(--accent-dark);
}

.result-warning {
  background: rgba(167, 53, 39, 0.09);
  border: 1px solid rgba(167, 53, 39, 0.26);
  border-radius: 8px;
  color: #8f2d21;
  font-weight: 800;
  margin-bottom: 18px;
  padding: 14px 16px;
}

.result-stats {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-bottom: 24px;
}

.result-stats > div {
  background: var(--soft);
  border-radius: 8px;
  padding: 16px;
}

.result-stats span {
  color: var(--muted);
  display: block;
  margin-bottom: 4px;
}

.result-stats strong {
  font-size: 1.5rem;
}

.section-title-row {
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.result-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.raw-output {
  height: 1px;
  left: -9999px;
  opacity: 0;
  pointer-events: none;
  position: absolute;
  top: auto;
  width: 1px;
}

.line-view {
  background: var(--input);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  flex: 0 0 auto;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.9rem;
  line-height: 1.55;
  max-height: var(--result-info-height, 560px);
  overflow: auto;
  padding: 10px 0;
  width: 100%;
}

.line-view__row {
  display: grid;
  grid-template-columns: 56px minmax(0, 1fr);
  min-height: 22px;
}

.line-view__number {
  border-right: 1px solid var(--line);
  color: var(--muted);
  padding: 0 12px;
  text-align: right;
  user-select: none;
}

.line-view code {
  color: inherit;
  min-width: 0;
  overflow-wrap: normal;
  overflow-x: auto;
  padding: 0 12px;
  white-space: pre;
}

.line-view__row.is-active-line {
  background: rgba(20, 124, 114, 0.14);
}

.source-list,
.analysis-log,
.protected-list,
.unused-list {
  border-top: 1px solid var(--line);
  list-style: none;
  margin: 0 0 22px;
  max-height: 250px;
  overflow: auto;
  padding: 0;
}

.source-list li,
.analysis-log li,
.protected-list li,
.unused-list li {
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  overflow-wrap: anywhere;
  padding: 10px 0;
}

.empty-list-note {
  color: var(--muted);
  font-style: italic;
}

.source-list strong {
  color: var(--ink);
  display: block;
  margin-bottom: 4px;
}

.source-list span {
  display: block;
}

html[data-theme="dark"] .brand-mark,
html[data-theme="dark"] .tab-button.is-active {
  background: var(--active-bg);
  border-color: var(--active-bg);
  color: var(--active-text);
}

.legal-page {
  padding: clamp(44px, 7vw, 92px) clamp(18px, 4vw, 56px) 70px;
}

.site-footer {
  align-items: center;
  background: var(--footer-bg);
  color: #ffffff;
  display: flex;
  gap: 16px;
  justify-content: space-between;
  margin-top: 18px;
  padding: 34px clamp(18px, 4vw, 56px);
}

.site-footer .legal-link {
  background: transparent;
  border-color: rgba(255, 255, 255, 0.24);
  color: #ffffff;
}

.powered-by {
  color: var(--footer-text);
}

.powered-by a {
  color: #ffffff;
  font-weight: 800;
}

.site-footer .legal-link:hover {
  background: rgba(255, 255, 255, 0.08);
}

.legal-head {
  display: grid;
  gap: 36px;
  grid-template-columns: minmax(0, 1.05fr) minmax(280px, 0.95fr);
}

.legal-summary {
  align-self: end;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  color: var(--muted);
  font-weight: 800;
  padding: 28px;
}

.legal-grid {
  display: grid;
  gap: 18px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-top: 34px;
}

.legal-block {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: clamp(18px, 3vw, 30px);
}

.legal-block a {
  color: var(--accent-dark);
  font-weight: 800;
  text-decoration: underline;
  text-underline-offset: 3px;
}

@media (max-width: 1050px) {
  .result-layout {
    grid-template-columns: 1fr;
  }

  .options-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .options-row .primary-button {
    grid-column: 1 / -1;
    justify-self: stretch;
    width: 100%;
  }
}

@media (max-width: 820px) {
  .site-header,
  .section-title-row,
  .site-footer {
    align-items: stretch;
    flex-direction: column;
  }

  .top-nav {
    justify-content: space-between;
  }

  .intro,
  .legal-head,
  .editor-grid,
  .result-layout {
    grid-template-columns: 1fr;
  }

  .line-view {
    max-height: 420px;
  }

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

  .result-stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .quality-stats {
    grid-template-columns: 1fr;
  }

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

  .primary-button {
    width: 100%;
  }

  .back-to-top {
    bottom: 175px;
    left: 14px;
    right: 14px;
    width: auto;
  }
}

@media (min-width: 1100px) {
  h1 {
    font-size: 5rem;
  }
}

@media (max-width: 700px) {
  h1 {
    font-size: 2.4rem;
  }
}

@media (max-width: 520px) {
  .mode-tabs,
  .top-nav {
    flex-wrap: wrap;
  }

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

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

@media (max-width: 420px) {
  h1 {
    font-size: 2.1rem;
  }
}
