/* ===================================================================
   HTMLCleanup — design tokens
   Palette: cool paper + soap green (clean) vs. warm charcoal (dirty)
=================================================================== */
:root {
  --paper:        #F3F6F4;
  --ink:           #12211D;
  --ink-soft:      #4E6059;
  --panel:         #FFFFFF;
  --panel-alt:     #E9F2ED;
  --line:          #D7E4DE;
  --line-strong:   #B9CEC5;

  --accent:        #0E8A67;
  --accent-dark:   #0A6A4F;
  --accent-soft:   #CDEEDF;
  --accent-ink:    #05261C;

  --remove:        #D85A32;

  --dirty-bg:      #1C1712;
  --dirty-bg-alt:  #241D15;
  --dirty-line:    #3B3123;
  --dirty-text:    #E4D6BE;
  --dirty-text-dim:#9C8E77;
  --dirty-accent:  #E7A94A;

  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-xl: 26px;

  --font-display: 'Space Grotesk', 'Inter', sans-serif;
  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;

  --shadow-soft: 0 1px 2px rgba(18,33,29,0.04), 0 8px 24px -12px rgba(18,33,29,0.18);
  --shadow-lift: 0 4px 10px rgba(18,33,29,0.06), 0 16px 40px -16px rgba(18,33,29,0.28);
  --shadow-pop:  0 20px 60px -20px rgba(18,33,29,0.35);
}

* { box-sizing: border-box; }

html { color-scheme: light; }

body {
  margin: 0;
  background:
    radial-gradient(1100px 480px at 12% -8%, rgba(14,138,103,0.08), transparent 60%),
    var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

img { max-width: 100%; }

::selection { background: var(--accent-soft); color: var(--accent-ink); }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

.app {
  max-width: 1240px;
  margin: 0 auto;
  padding: 0 28px 64px;
}

/* ---------- Top bar ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  margin: 0 -28px 26px;
  padding: 14px 28px;
  background: rgba(243,246,244,0.78);
  backdrop-filter: blur(14px) saturate(160%);
  -webkit-backdrop-filter: blur(14px) saturate(160%);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.topbar-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 9px;
  text-decoration: none;
  color: var(--ink);
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 9px;
  background: linear-gradient(155deg, var(--accent), var(--accent-dark));
  color: #fff;
  box-shadow: 0 4px 12px -4px rgba(14,138,103,0.55);
}

.brand-name {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 17px;
  letter-spacing: -0.01em;
}

.nav-toggle {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 4px;
  width: 34px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--panel);
  cursor: pointer;
}

.nav-toggle span {
  display: block;
  width: 16px;
  height: 2px;
  margin: 0 auto;
  background: var(--ink);
  border-radius: 2px;
}

.nav-collapse {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  flex: 1;
  min-width: 0;
}

.nav-links {
  display: flex;
  gap: 4px;
  margin-right: auto;
  flex-wrap: wrap;
}

.nav-link {
  border: none;
  background: transparent;
  color: var(--ink-soft);
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 600;
  padding: 7px 11px;
  border-radius: 999px;
  cursor: pointer;
}

.nav-link:hover { background: var(--panel-alt); color: var(--ink); }

/* ---------- Language switcher (details/summary dropdown) ---------- */

.lang-switcher { position: relative; }

.lang-switcher summary {
  list-style: none;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 11px;
  border-radius: 999px;
  background: var(--panel-alt);
  color: var(--ink);
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: 0.03em;
  cursor: pointer;
  user-select: none;
}

.lang-switcher summary::-webkit-details-marker { display: none; }

.lang-switcher .chev { transition: transform 0.15s ease; }
.lang-switcher[open] .chev { transform: rotate(180deg); }

.lang-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  min-width: 170px;
  padding: 6px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-pop);
  display: flex;
  flex-direction: column;
  gap: 1px;
  z-index: 30;
}

.lang-item {
  display: block;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: var(--ink);
  text-decoration: none;
}

.lang-item:hover { background: var(--panel-alt); }

.lang-item.is-active {
  background: var(--accent-soft);
  color: var(--accent-ink);
  font-weight: 600;
}

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

/* ---------- Toast ---------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: 26px;
  transform: translate(-50%, 12px);
  padding: 11px 18px;
  background: var(--ink);
  color: var(--paper);
  font-size: 13px;
  font-weight: 500;
  border-radius: 999px;
  box-shadow: var(--shadow-pop);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s ease;
  z-index: 50;
}

.toast.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* ---------- Hero ---------- */

.hero {
  padding: 30px 0 26px;
  max-width: 640px;
}

.eyebrow {
  margin: 0 0 10px;
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.14em;
  color: var(--accent-dark);
}

.hero h1 {
  margin: 0 0 12px;
  font-family: var(--font-display);
  font-size: clamp(32px, 4.4vw, 46px);
  line-height: 1.05;
  letter-spacing: -0.02em;
  font-weight: 600;
}

.hero .lead {
  margin: 0;
  color: var(--ink-soft);
  font-size: 16px;
  max-width: 54ch;
}

/* ---------- Options strip (checkboxes on top) ---------- */

.options-strip {
  background: var(--panel);
  border-radius: var(--radius-xl);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-soft);
  padding: 20px 22px;
  margin-bottom: 18px;
}

.options-strip-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.options-strip-head h2 {
  margin: 0 0 2px;
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 600;
}

.options-strip-head p {
  margin: 0;
  font-size: 12.5px;
  color: var(--ink-soft);
}

.options-actions { display: flex; gap: 8px; flex: none; }

.chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 14px 8px 10px;
  border-radius: 999px;
  background: var(--panel-alt);
  border: 1px solid transparent;
  cursor: pointer;
  transition: background 0.12s ease, border-color 0.12s ease;
}

.chip:hover { background: var(--line); }

.chip input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
}

.chip-check {
  display: grid;
  place-items: center;
  width: 18px;
  height: 18px;
  border-radius: 6px;
  background: var(--panel);
  border: 1.5px solid var(--line-strong);
  color: transparent;
  flex: none;
  transition: background 0.12s ease, border-color 0.12s ease, color 0.12s ease;
}

.chip input:checked ~ .chip-check {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.chip:has(input:checked) {
  background: var(--accent-soft);
}

.chip:has(input:focus-visible) {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.chip-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--ink);
  white-space: nowrap;
}

.option-desc {
  margin: 14px 0 0;
  padding: 10px 12px;
  min-height: 16px;
  border-radius: var(--radius-sm);
  background: var(--panel-alt);
  color: var(--ink-soft);
  font-size: 12px;
  line-height: 1.5;
}

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border: none;
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: 13.5px;
  font-weight: 600;
  padding: 10px 16px;
  cursor: pointer;
  transition: transform 0.08s ease, box-shadow 0.15s ease, background 0.15s ease;
  white-space: nowrap;
}

.btn:active { transform: translateY(1px); }

.btn-primary {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 6px 16px -6px rgba(14,138,103,0.55);
}

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

.btn-primary svg { transition: transform 0.15s ease; }
.btn-primary:hover svg { transform: translateX(2px); }

.btn-ghost {
  background: var(--panel-alt);
  color: var(--ink);
}

.btn-ghost:hover { background: var(--line); }

.btn-sm { padding: 7px 12px; font-size: 12.5px; }

.btn[disabled] { opacity: 0.5; cursor: not-allowed; transform: none; box-shadow: none; }

/* ---------- Workspace grid ---------- */

.workspace {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  align-items: start;
}

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

.panel {
  background: var(--panel);
  border-radius: var(--radius-lg);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-soft);
}

/* ---------- Shared panel chrome ---------- */

.panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  padding: 16px 18px 12px;
}

.panel-head h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 600;
}

.panel-sub {
  margin: 2px 0 0;
  font-size: 12px;
}

.panel-stat {
  flex: none;
  font-family: var(--font-mono);
  font-size: 11px;
  padding: 4px 9px;
  border-radius: 999px;
  white-space: nowrap;
  margin-top: 1px;
}

/* ---------- Dirty panel ---------- */

.panel-dirty {
  background: var(--dirty-bg);
  border-color: var(--dirty-line);
  background-image:
    radial-gradient(circle at 15% 8%, rgba(231,169,74,0.07), transparent 45%),
    radial-gradient(circle at 85% 92%, rgba(231,169,74,0.05), transparent 40%);
}

.panel-dirty .panel-head h2 { color: var(--dirty-text); }
.panel-dirty .panel-sub { color: var(--dirty-text-dim); }

.panel-dirty .panel-stat {
  background: rgba(231,169,74,0.14);
  color: var(--dirty-accent);
}

.editor-frame {
  position: relative;
  height: 360px;
  margin: 0 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.panel-dirty .editor-frame { border-color: var(--dirty-line); }

/* ---------- Clean panel ---------- */

.panel-clean .panel-stat {
  background: var(--accent-soft);
  color: var(--accent-dark);
}

.tabs {
  display: flex;
  gap: 2px;
  padding: 3px;
  background: var(--panel-alt);
  border-radius: 999px;
}

.tab {
  border: none;
  background: transparent;
  padding: 6px 13px;
  font-family: var(--font-body);
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink-soft);
  border-radius: 999px;
  cursor: pointer;
}

.tab.is-active {
  background: var(--panel);
  color: var(--ink);
  box-shadow: var(--shadow-soft);
}

.tab-panels {
  position: relative;
  height: 360px;
  margin: 0 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.tab-pane {
  display: none;
  width: 100%;
  height: 100%;
}

.tab-pane.is-active { display: block; }

/* ---------- Jodit containers ---------- */
/* Jodit renders its own chrome (toolbar + editable area) as a sibling of
   the textarea it replaces; our .editor-frame / .tab-panels boxes already
   provide the border, radius and clipping, so strip Jodit's own and let
   it fill the box exactly. */

.editor-frame .jodit-container,
.tab-pane .jodit-container {
  border: none !important;
  border-radius: 0 !important;
  box-shadow: none !important;
  height: 100% !important;
}

.code-area {
  display: block;
  width: 100%;
  height: 100%;
  resize: none;
  border: none;
  padding: 14px 16px;
  font-family: var(--font-mono);
  font-size: 12.5px;
  line-height: 1.6;
  background: var(--panel);
  color: var(--ink);
}

.code-area:focus { outline: none; }

.panel-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 18px 18px;
}

.panel-hint {
  font-size: 11.5px;
  color: var(--ink-soft);
}

.panel-foot-actions { display: flex; gap: 8px; }

/* ---------- Explainer article ---------- */

.explainer {
  margin-top: 56px;
  padding-top: 36px;
  border-top: 1px solid var(--line);
  max-width: 760px;
}

.explainer h2 {
  font-family: var(--font-display);
  font-size: 24px;
  margin: 44px 0 12px;
}

.explainer h2:first-child { margin-top: 0; }

.explainer p {
  color: var(--ink-soft);
  margin: 0 0 12px;
}

.explainer h3 {
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 600;
  margin: 20px 0 10px;
}

.feature-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.feature-list li {
  position: relative;
  padding-left: 22px;
  color: var(--ink-soft);
  font-size: 13.5px;
  line-height: 1.5;
}

.feature-list li::before {
  content: '';
  position: absolute;
  left: 0;
  top: 7px;
  width: 8px;
  height: 8px;
  border-radius: 2px;
  background: var(--accent);
}

.option-glossary {
  margin: 24px 0 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px 28px;
}

@media (max-width: 640px) {
  .option-glossary { grid-template-columns: 1fr; }
}

.glossary-item dt {
  font-family: var(--font-mono);
  font-size: 12.5px;
  font-weight: 500;
  color: var(--accent-dark);
  margin-bottom: 3px;
}

.glossary-item dd {
  margin: 0;
  font-size: 13px;
  color: var(--ink-soft);
}

/* ---------- Why grid ---------- */

.why-grid {
  margin-top: 20px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

@media (max-width: 640px) {
  .why-grid { grid-template-columns: 1fr; }
}

.why-item {
  padding: 16px 18px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
}

.why-item h3 {
  margin: 0 0 6px;
  font-family: var(--font-display);
  font-size: 14.5px;
  font-weight: 600;
  color: var(--ink);
}

.why-item p {
  margin: 0;
  font-size: 12.5px;
  color: var(--ink-soft);
}

/* ---------- FAQ accordion ---------- */

.faq-list {
  margin-top: 18px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.faq-item {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 4px 4px;
}

.faq-item summary {
  list-style: none;
  cursor: pointer;
  padding: 12px 14px;
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 600;
  color: var(--ink);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

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

.faq-item summary::after {
  content: '+';
  font-size: 18px;
  color: var(--ink-soft);
  flex: none;
  margin-left: 12px;
}

.faq-item[open] summary::after { content: '\2212'; }

.faq-item p {
  margin: 0;
  padding: 0 14px 14px 14px;
  font-size: 13px;
}

/* ---------- Footer ---------- */

.site-footer {
  margin-top: 40px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.site-footer p {
  margin: 0;
  font-size: 12px;
  color: var(--ink-soft);
}

/* ---------- Modals (About / About developer) ---------- */

.modal {
  border: none;
  border-radius: var(--radius-lg);
  padding: 0;
  max-width: 480px;
  width: calc(100% - 40px);
  box-shadow: var(--shadow-pop);
}

.modal::backdrop {
  background: rgba(18,33,29,0.45);
  backdrop-filter: blur(2px);
}

.modal-form { margin: 0; }

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 20px 22px 12px;
}

.modal-head h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 19px;
  font-weight: 600;
}

.modal-close {
  border: none;
  background: var(--panel-alt);
  width: 30px;
  height: 30px;
  border-radius: 999px;
  font-size: 18px;
  line-height: 1;
  color: var(--ink-soft);
  cursor: pointer;
  flex: none;
}

.modal-close:hover { background: var(--line); color: var(--ink); }

.modal-body {
  padding: 4px 22px 24px;
}

.modal-body p {
  margin: 0 0 12px;
  font-size: 13.5px;
  color: var(--ink-soft);
}

.modal-body p:last-child { margin-bottom: 0; }

.dev-contact a {
  display: inline-flex;
  align-items: center;
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: 500;
  color: var(--accent-dark);
  text-decoration: none;
  border-bottom: 1px solid var(--accent-soft);
}

.dev-contact a:hover { border-color: var(--accent-dark); }

/* ---------- Feedback form (About developer modal) ---------- */

.feedback-form {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.feedback-form label {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink);
}

.feedback-form textarea {
  width: 100%;
  resize: vertical;
  min-height: 84px;
  padding: 10px 12px;
  font-family: var(--font-body);
  font-size: 13px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--panel-alt);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
}

.feedback-form textarea:focus {
  outline: none;
  border-color: var(--accent);
}

.feedback-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.feedback-status {
  font-size: 12px;
  color: var(--ink-soft);
}

.feedback-status.is-success { color: var(--accent-dark); }
.feedback-status.is-error { color: var(--remove); }

/* ---------- Responsive nav ---------- */

@media (max-width: 760px) {
  .app { padding: 0 18px 48px; }
  .topbar { margin: 0 -18px 20px; padding: 12px 18px; flex-direction: column; align-items: stretch; }

  .nav-toggle { display: flex; }

  .nav-collapse {
    display: none;
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
    flex: none;
    margin-top: 12px;
  }

  .nav-collapse.is-open { display: flex; }

  .nav-links { margin-right: 0; flex-wrap: wrap; }
  .lang-switcher summary { justify-content: space-between; }
  .lang-menu { position: static; margin-top: 6px; box-shadow: none; border: 1px solid var(--line); }
  .nav-actions { flex-direction: column; }
  .nav-actions .btn { width: 100%; }
}
