*{margin:0;padding:0;box-sizing:border-box}
:root{--bg:#060609;--surface:#0d0d12;--surface2:#14141b;--border:#1e1e2a;--text:#e0e0e0;--text2:#888;--accent:#ff4d4d;--accent2:#ff6b6b;--success:#4dff88;--success-bg:rgba(77,255,136,.08);--font:'JetBrains Mono',monospace;color-scheme:dark}
:root[data-theme="light"]{--bg:#fafafa;--surface:#ffffff;--surface2:#f3f4f6;--border:#e5e7eb;--text:#1f2937;--text2:#6b7280;--accent:#dc2626;--accent2:#ef4444;--success:#16a34a;--success-bg:rgba(22,163,74,.08);color-scheme:light}
body{background:var(--bg);color:var(--text);font-family:var(--font);line-height:1.6;min-height:100vh}
a{color:var(--accent)}
header{text-align:center;padding:3rem 1rem 2rem;border-bottom:1px solid var(--border)}
header h1{font-size:2rem;color:var(--accent);margin-bottom:.3rem}
header p{color:var(--text2);font-size:.85rem}
.grid{max-width:1200px;margin:2rem auto;padding:0 1rem;display:grid;grid-template-columns:repeat(auto-fill,minmax(540px,1fr));gap:1.5rem}
@media(max-width:600px){.grid{grid-template-columns:1fr}}
.card{background:var(--surface);border:1px solid var(--border);border-radius:12px;padding:1.5rem;transition:border-color .2s}
.card:hover{border-color:var(--accent)}
.card h2{font-size:1rem;color:var(--accent);margin-bottom:1rem;display:flex;align-items:center;gap:.5rem}
.card h2 span{font-size:1.2rem}
textarea,input[type=text],input[type=number],select{width:100%;background:var(--surface2);border:1px solid var(--border);color:var(--text);font-family:var(--font);font-size:.85rem;padding:.6rem;border-radius:6px;resize:vertical;outline:none;transition:border-color .2s}
textarea:focus,input:focus,select:focus{border-color:var(--accent)}
textarea{min-height:80px}
.row{display:flex;gap:.5rem;margin-top:.5rem;flex-wrap:wrap;align-items:center}
.row>*{flex:1;min-width:0}
button{background:var(--accent);color:#fff;border:none;font-family:var(--font);font-size:.8rem;padding:.5rem 1rem;border-radius:6px;cursor:pointer;font-weight:600;transition:background .2s;white-space:nowrap;flex:none}
button:hover{background:var(--accent2)}
button.secondary{background:var(--surface2);border:1px solid var(--border)}
button.secondary:hover{border-color:var(--accent)}
label{font-size:.75rem;color:var(--text2);display:block;margin-top:.5rem;margin-bottom:.25rem}
.output{background:var(--surface2);border:1px solid var(--border);border-radius:6px;padding:.6rem;font-size:.85rem;min-height:40px;word-break:break-all;margin-top:.5rem;white-space:pre-wrap}
.error{color:var(--accent)}
.success{color:var(--success)}
.match{background:rgba(255,77,77,.25);border-radius:2px;padding:0 1px}
footer{text-align:center;padding:2rem;color:var(--text2);font-size:.75rem;border-top:1px solid var(--border);margin-top:2rem}
.color-preview{height:40px;border-radius:6px;margin-top:.5rem;border:1px solid var(--border)}
.output-scroll{max-height:300px;overflow:auto}
.output-copyable{cursor:pointer}
.output-wrapper{position:relative;margin-top:.5rem}
.output-wrapper .output{margin-top:0}
.copy-btn{position:absolute;top:6px;right:6px;background:var(--surface);border:1px solid var(--border);color:var(--text2);font-family:var(--font);font-size:.7rem;padding:2px 8px;border-radius:4px;cursor:pointer;display:flex;align-items:center;gap:4px;opacity:0;transition:opacity .2s,border-color .2s,color .2s;z-index:1}
.output-wrapper:hover .copy-btn,.copy-btn:focus{opacity:1}
.copy-btn:hover{border-color:var(--accent);color:var(--text)}
.copy-btn.copied{color:var(--success);border-color:var(--success);opacity:1}
.copy-btn svg{width:14px;height:14px;fill:none;stroke:currentColor;stroke-width:2;stroke-linecap:round;stroke-linejoin:round}
.flex-2{flex:2}
.flex-none{flex:none}
.pt-row{padding-top:1.2rem}
.regex-info{font-size:.75rem;color:var(--text2);margin-top:.3rem}
.card-wide{grid-column:1/-1}
.md-split{display:flex;gap:1rem}
.md-split .md-pane{flex:1;min-width:0;display:flex;flex-direction:column}
.md-split textarea{flex:1;min-height:250px;resize:vertical}
.md-preview{min-height:250px;max-height:500px;overflow:auto;line-height:1.7;word-break:break-word;white-space:normal}
.md-preview h1,.md-preview h2,.md-preview h3,.md-preview h4,.md-preview h5,.md-preview h6{color:var(--accent);margin:.8em 0 .4em;line-height:1.3}
.md-preview h1{font-size:1.5rem;border-bottom:1px solid var(--border);padding-bottom:.3rem}
.md-preview h2{font-size:1.25rem;border-bottom:1px solid var(--border);padding-bottom:.2rem}
.md-preview h3{font-size:1.1rem}
.md-preview p{margin:.5em 0}
.md-preview a{color:var(--accent2);text-decoration:underline}
.md-preview code{background:var(--bg);padding:.15em .4em;border-radius:3px;font-size:.9em}
.md-preview pre{background:var(--bg);padding:.8rem;border-radius:6px;overflow-x:auto;margin:.5em 0}
.md-preview pre code{background:none;padding:0}
.md-preview blockquote{border-left:3px solid var(--accent);padding:.5rem 1rem;margin:.5em 0;color:var(--text2);background:var(--bg)}
.md-preview ul,.md-preview ol{margin:.5em 0;padding-left:1.5em}
.md-preview li{margin:.2em 0}
.md-preview strong{color:var(--text)}
.md-preview hr{border:none;border-top:1px solid var(--border);margin:1em 0}
@media(max-width:600px){.md-split{flex-direction:column}}
.diff-inputs{display:flex;gap:.75rem;margin-bottom:.5rem}
.diff-col{flex:1;min-width:0}
.diff-col label{font-size:.75rem;color:var(--text2);display:block;margin-bottom:.25rem}
@media(max-width:600px){.diff-inputs{flex-direction:column}}
.diff-add{color:var(--success);background:var(--success-bg)}
.diff-del{color:var(--accent);background:rgba(255,77,77,.08)}
.diff-eq{color:var(--text2)}
#search-input{max-width:400px;margin:1rem auto 0;display:block;font-size:.9rem;padding:.7rem 1rem;border-radius:8px;background:var(--surface2);border:1px solid var(--border);color:var(--text);font-family:var(--font);outline:none;transition:border-color .2s}
#search-input:focus{border-color:var(--accent)}
#search-input::placeholder{color:var(--text2)}
.card.hidden{display:none}
.card.highlighted{border-color:var(--accent);box-shadow:0 0 20px rgba(255,77,77,.3)}
/* Mobile UX */
@media(max-width:768px){
header{position:sticky;top:0;z-index:100;background:var(--bg);padding:1rem 1rem .8rem}
header h1{font-size:1.4rem}
header p{font-size:.75rem}
#search-input{margin-top:.6rem;font-size:1rem;padding:.8rem 1rem}
.grid{margin-top:1rem}
.card{padding:1rem}
.card h2{margin-bottom:0;cursor:pointer;user-select:none;padding:.3rem 0;min-height:44px;position:relative}
.card h2::after{content:'▸';position:absolute;right:0;transition:transform .2s;font-size:.8rem;color:var(--text2)}
.card.open h2::after{transform:rotate(90deg)}
.card .card-body{display:none;padding-top:.8rem}
.card.open .card-body{display:block}
button{font-size:.9rem;padding:.7rem 1.2rem;min-height:44px}
textarea,input[type=text],input[type=number],select{font-size:1rem;padding:.8rem;min-height:44px}
textarea{min-height:100px}
}
/* Help overlay */
#help-overlay{display:none;position:fixed;top:0;left:0;width:100%;height:100%;background:rgba(6,6,9,.85);z-index:1000;justify-content:center;align-items:center;backdrop-filter:blur(4px)}
#help-overlay.visible{display:flex}
#help-overlay .help-modal{background:var(--surface);border:1px solid var(--border);border-radius:12px;padding:2rem;max-width:420px;width:90%}
#help-overlay .help-modal h2{color:var(--accent);font-size:1.1rem;margin-bottom:1rem}
#help-overlay .help-modal table{width:100%;border-collapse:collapse}
#help-overlay .help-modal td{padding:.4rem 0;font-size:.85rem}
#help-overlay .help-modal td:first-child{color:var(--text2);white-space:nowrap;padding-right:1.5rem}
#help-overlay .help-modal kbd{background:var(--surface2);border:1px solid var(--border);border-radius:4px;padding:.15rem .4rem;font-family:var(--font);font-size:.8rem}
#help-overlay .help-modal .help-close{color:var(--text2);font-size:.75rem;margin-top:1rem;text-align:center}
.stat{display:flex;flex-direction:column;align-items:center;flex:1;padding:.75rem;background:var(--surface2);border-radius:8px;border:1px solid var(--border)}
.stat-value{font-size:1.5rem;font-weight:700;color:var(--accent)}
.stat-label{font-size:.75rem;color:var(--text2);margin-top:.25rem}

/* Diff output mono pre-wrap (#336 — was inline style="white-space:pre;...") */
.output-diff {
  white-space: pre;
  word-break: normal;
  overflow-x: auto;
}

/* Clipboard fallback textarea hidden off-screen (#337 — was inline style.cssText) */
.clipboard-fallback {
  position: fixed;
  opacity: 0;
  pointer-events: none;
}

/* copyText flash effect (#337 — was inline style.borderColor) */
.copy-flash {
  border-color: var(--accent) !important;
  transition: border-color 0.3s;
}

/* Markdown image max-width (#337 — was inline style="max-width:100%") */
.md-img {
  max-width: 100%;
}

/* JWT expiration info margin (#337 — was inline style="margin-top:.5rem") */
.jwt-exp-info {
  margin-top: 0.5rem;
}

/* a11y skip-link (#342): off-screen until focused */
.skip-link {
  position: absolute;
  top: -9999px;
  left: 0;
  z-index: 10000;
  padding: 0.75rem 1rem;
  background: var(--accent);
  color: var(--bg);
  text-decoration: none;
  border-radius: 0 0 6px 0;
  font-weight: 600;
}
.skip-link:focus {
  top: 0;
  outline: 2px solid var(--bg);
  outline-offset: 2px;
}

/* Theme toggle button (#344) */
.theme-toggle {
  position: absolute;
  top: 1rem;
  right: 1rem;
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  font-family: var(--font);
  font-size: 1.1rem;
  padding: 0.4rem 0.7rem;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s;
  line-height: 1;
}
.theme-toggle:hover {
  border-color: var(--accent);
}
.theme-toggle:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Header relative positioning so toggle absolute works */
header {
  position: relative;
}

/* ─── Unit Converter (t-00509) ──────────────────────────────────── */
.conv-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 12px;
}

.conv-tabs button {
  padding: 6px 12px;
  font-size: 13px;
  font-family: inherit;
  background: transparent;
  border: 1px solid currentColor;
  border-radius: 999px;
  color: inherit;
  cursor: pointer;
  opacity: 0.7;
  transition: opacity 0.15s ease, background 0.15s ease, color 0.15s ease;
}

.conv-tabs button:hover,
.conv-tabs button:focus-visible {
  opacity: 1;
  outline: none;
}

.conv-tabs button.active {
  background: var(--accent, #ff4d4d);
  color: #fff;
  border-color: var(--accent, #ff4d4d);
  opacity: 1;
}

.conv-row {
  display: grid;
  grid-template-columns: 1fr 1fr auto 1fr;
  gap: 8px;
  align-items: center;
  margin-bottom: 12px;
}

.conv-row input,
.conv-row select {
  padding: 8px 10px;
  font: inherit;
  font-family: inherit;
}

.conv-swap {
  width: 38px;
  height: 38px;
  padding: 0;
  font-size: 18px;
  line-height: 1;
  border-radius: 50%;
  border: 1px solid currentColor;
  background: transparent;
  cursor: pointer;
  color: inherit;
}

.conv-swap:hover,
.conv-swap:focus-visible {
  background: var(--accent, #ff4d4d);
  color: #fff;
  border-color: var(--accent, #ff4d4d);
  outline: none;
}

@media (max-width: 520px) {
  .conv-row {
    grid-template-columns: 1fr;
  }
  .conv-swap {
    justify-self: center;
  }
}
