/* =========================================================
   htmllivepreview.com — shared site styles
   Used by every tool page.
   ========================================================= */

:root {
  --bg: #ffffff;
  --bg-soft: #f7f8fa;
  --bg-code: #fbfbfc;
  --border: #e5e7eb;
  --border-strong: #d1d5db;
  --text: #1f2937;
  --text-soft: #4b5563;
  --text-muted: #6b7280;
  --brand: #1d4ed8;
  --brand-hover: #1e40af;
  --accent: #0ea5e9;
  --success: #059669;
  --error: #dc2626;
  --warn: #d97706;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.04);
  --shadow: 0 2px 6px rgba(0,0,0,0.06);
  --radius: 6px;
  --radius-lg: 10px;
  --max: 1280px;
  --header-h: 56px;
  --font-ui: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1115;
    --bg-soft: #161a21;
    --bg-code: #11151c;
    --border: #232a36;
    --border-strong: #2f3847;
    --text: #e5e7eb;
    --text-soft: #cbd1da;
    --text-muted: #9aa3b2;
    --brand: #60a5fa;
    --brand-hover: #93c5fd;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font-ui);
  font-size: 15px;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; display: block; }

/* ---------- Announcement bar ---------- */
.announce-bar {
  display: block;
  text-align: center;
  background: var(--brand);
  color: #fff !important;
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
}
.announce-bar:hover { background: var(--brand-hover); text-decoration: underline; }

/* ---------- Header ---------- */
.site-header {
  height: var(--header-h);
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 50;
}
.site-header .wrap {
  max-width: var(--max);
  margin: 0 auto;
  padding: 0 20px;
  width: 100%;
  display: flex;
  align-items: center;
  gap: 24px;
}
.logo {
  font-weight: 700;
  font-size: 17px;
  letter-spacing: -0.01em;
  color: var(--text);
  text-decoration: none;
  white-space: nowrap;
}
.logo span { color: var(--brand); }
.nav { display: flex; gap: 18px; flex: 1; }
.nav a {
  color: var(--text-soft);
  font-size: 14px;
  font-weight: 500;
}
.nav a:hover { color: var(--brand); text-decoration: none; }
@media (max-width: 720px) {
  .nav { display: none; }
}

/* ---------- Layout ---------- */
.wrap { max-width: var(--max); margin: 0 auto; padding: 0 20px; }
.page { padding: 24px 20px 48px; max-width: var(--max); margin: 0 auto; }

/* Hero / page intro */
.page-intro { margin: 8px 0 20px; }
.page-intro h1 {
  font-size: clamp(24px, 3.4vw, 32px);
  margin: 0 0 6px;
  letter-spacing: -0.015em;
  font-weight: 700;
}
.page-intro p {
  margin: 0;
  color: var(--text-soft);
  font-size: 15px;
  max-width: 720px;
}

/* ---------- Ad slot ---------- */
.ad-slot {
  margin: 16px 0;
  min-height: 90px;
  background: var(--bg-soft);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  overflow: hidden;
}
.ad-slot.ad-rect { min-height: 250px; }
.ad-slot.no-border { border: none; min-height: auto; background: transparent; margin: 0; }

/* Mobile sticky ad */
.mobile-sticky-ad {
  display: none;
}
@media (max-width: 760px) {
  .mobile-sticky-ad {
    display: block;
    position: fixed;
    bottom: 0; left: 0; right: 0;
    background: var(--bg);
    border-top: 1px solid var(--border);
    z-index: 60;
    padding: 4px;
  }
  body { padding-bottom: 70px; } /* avoid sticky ad overlapping content */
}

/* ---------- Tool layout ---------- */
.tool-layout {
  display: grid;
  grid-template-columns: 1fr 280px;
  gap: 24px;
  align-items: start;
}
@media (max-width: 980px) {
  .tool-layout { grid-template-columns: 1fr; }
}

.tool-main { min-width: 0; }

/* ---------- Sidebar ---------- */
.sidebar { display: flex; flex-direction: column; gap: 16px; }
.sidebar-card {
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
}
.sidebar-card h3 {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin: 0 0 10px;
  color: var(--text-muted);
  font-weight: 600;
}
.sidebar-card ul { margin: 0; padding: 0; list-style: none; }
.sidebar-card li { margin: 6px 0; }
.sidebar-card a { font-size: 14px; color: var(--text-soft); }
.sidebar-card a:hover { color: var(--brand); text-decoration: none; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  font-size: 14px;
  font-weight: 500;
  border-radius: var(--radius);
  border: 1px solid var(--border-strong);
  background: var(--bg);
  color: var(--text);
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s;
  font-family: inherit;
}
.btn:hover { background: var(--bg-soft); border-color: var(--text-muted); }
.btn-primary {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
}
.btn-primary:hover {
  background: var(--brand-hover);
  border-color: var(--brand-hover);
  color: #fff;
}
.btn-ghost { border-color: transparent; }
.btn-sm { padding: 5px 10px; font-size: 13px; }

.toolbar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
  margin-bottom: 12px;
}
.toolbar-spacer { flex: 1; }

/* ---------- Status bar ---------- */
.status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--bg-soft);
  color: var(--text-soft);
}
.status.ok { background: #ecfdf5; color: #065f46; }
.status.err { background: #fef2f2; color: #991b1b; }
@media (prefers-color-scheme: dark) {
  .status.ok { background: #052e23; color: #34d399; }
  .status.err { background: #2a0f10; color: #fca5a5; }
}

/* ---------- Article content ---------- */
.article {
  margin-top: 32px;
  max-width: 760px;
  font-size: 16px;
  line-height: 1.75;
  color: var(--text-soft);
}
.article h2 {
  font-size: 22px;
  margin: 32px 0 12px;
  color: var(--text);
  font-weight: 700;
  letter-spacing: -0.01em;
}
.article h3 {
  font-size: 18px;
  margin: 24px 0 8px;
  color: var(--text);
  font-weight: 600;
}
.article p { margin: 12px 0; }
.article code {
  font-family: var(--font-mono);
  font-size: 14px;
  background: var(--bg-soft);
  padding: 2px 6px;
  border-radius: 4px;
  border: 1px solid var(--border);
}
.article pre {
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.55;
}
.article ul, .article ol { padding-left: 24px; }
.article li { margin: 6px 0; }

/* ---------- FAQ ---------- */
.faq { margin-top: 24px; max-width: 760px; }
.faq details {
  border-bottom: 1px solid var(--border);
  padding: 14px 0;
}
.faq summary {
  cursor: pointer;
  font-weight: 600;
  font-size: 16px;
  color: var(--text);
  list-style: none;
  position: relative;
  padding-right: 28px;
}
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after {
  content: "+";
  position: absolute;
  right: 4px;
  top: 0;
  font-size: 20px;
  color: var(--text-muted);
  transition: transform 0.15s;
}
.faq details[open] summary::after { content: "−"; }
.faq details > *:not(summary) {
  margin-top: 10px;
  color: var(--text-soft);
  line-height: 1.7;
}

/* ---------- Footer ---------- */
.site-footer {
  margin-top: 48px;
  border-top: 1px solid var(--border);
  background: var(--bg-soft);
  padding: 28px 0 32px;
}
.site-footer .wrap { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 24px; }
.footer-col h4 {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin: 0 0 10px;
  font-weight: 600;
}
.footer-col ul { list-style: none; padding: 0; margin: 0; }
.footer-col li { margin: 5px 0; }
.footer-col a { font-size: 14px; color: var(--text-soft); }
.footer-col a:hover { color: var(--brand); text-decoration: none; }
.footer-bottom {
  max-width: var(--max);
  margin: 24px auto 0;
  padding: 16px 20px 0;
  border-top: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 13px;
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
}

/* ---------- Tools directory (homepage) ---------- */
.hero {
  padding: 40px 0 24px;
  text-align: center;
}
.hero h1 {
  font-size: clamp(28px, 4vw, 40px);
  margin: 0 0 8px;
  letter-spacing: -0.02em;
  font-weight: 700;
}
.hero p {
  font-size: 17px;
  color: var(--text-soft);
  max-width: 640px;
  margin: 0 auto;
}

.search-box {
  max-width: 520px;
  margin: 24px auto 8px;
}
.search-box input {
  width: 100%;
  padding: 12px 16px;
  font-size: 15px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-ui);
}
.search-box input:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(29, 78, 216, 0.12);
}

.category {
  margin: 32px 0 0;
}
.category h2 {
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  font-weight: 600;
  margin: 0 0 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}
.tool-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 10px;
}
.tool-card {
  display: block;
  padding: 14px 16px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  text-decoration: none;
  transition: border-color 0.12s, transform 0.12s, box-shadow 0.12s;
}
.tool-card:hover {
  border-color: var(--brand);
  transform: translateY(-1px);
  box-shadow: var(--shadow);
  text-decoration: none;
}
.tool-card .name {
  font-weight: 600;
  font-size: 15px;
  color: var(--text);
  margin-bottom: 2px;
}
.tool-card .desc {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.45;
}

/* ---------- Editor / textarea panes ---------- */
.editor-pair {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  min-height: 480px;
}
@media (max-width: 760px) {
  .editor-pair { grid-template-columns: 1fr; min-height: auto; }
  .editor-pair > * { min-height: 280px; }
}
.editor-panel {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-code);
  overflow: hidden;
}
.editor-panel-head {
  padding: 8px 12px;
  background: var(--bg-soft);
  border-bottom: 1px solid var(--border);
  font-size: 12px;
  font-weight: 600;
  color: var(--text-soft);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  display: flex;
  align-items: center;
  gap: 8px;
}
.code-area {
  flex: 1;
  width: 100%;
  border: 0;
  outline: none;
  resize: none;
  padding: 14px;
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.55;
  background: var(--bg-code);
  color: var(--text);
  tab-size: 2;
}
.code-area:focus { outline: none; }
.code-output {
  flex: 1;
  margin: 0;
  padding: 14px;
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.55;
  white-space: pre;
  overflow: auto;
  background: var(--bg-code);
  color: var(--text);
  min-height: 100%;
}

/* JSON syntax tokens */
.tok-key { color: #b45309; }
.tok-string { color: #047857; }
.tok-number { color: #1d4ed8; }
.tok-bool { color: #7c3aed; }
.tok-null { color: var(--text-muted); }
@media (prefers-color-scheme: dark) {
  .tok-key { color: #fbbf24; }
  .tok-string { color: #6ee7b7; }
  .tok-number { color: #93c5fd; }
  .tok-bool { color: #c4b5fd; }
}

/* Toast */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: #111827;
  color: #fff;
  padding: 10px 18px;
  border-radius: 8px;
  font-size: 14px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  z-index: 100;
}
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ---------- Breadcrumbs ---------- */
.breadcrumbs {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.breadcrumbs a {
  color: var(--text-soft);
  text-decoration: none;
}
.breadcrumbs a:hover { color: var(--brand); }
.breadcrumbs span { color: var(--text-muted); }

/* ---------- Mode toggle (encode/decode tabs) ---------- */
.mode-toggle {
  display: inline-flex;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 3px;
  margin-bottom: 12px;
  gap: 2px;
}
.mode-btn {
  padding: 7px 14px;
  font-size: 14px;
  font-weight: 500;
  background: transparent;
  border: 0;
  border-radius: 4px;
  color: var(--text-soft);
  cursor: pointer;
  font-family: inherit;
  transition: background 0.12s, color 0.12s;
}
.mode-btn:hover { color: var(--text); }
.mode-btn.active {
  background: var(--bg);
  color: var(--brand);
  font-weight: 600;
  box-shadow: var(--shadow-sm);
}

/* ---------- Image preview panel (Base64 decoder, etc.) ---------- */
.image-preview {
  border-top: 1px solid var(--border);
  padding: 14px;
  background: var(--bg);
  text-align: center;
}
.image-preview img {
  max-width: 100%;
  max-height: 400px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: repeating-conic-gradient(#e5e7eb 0 25%, #f9fafb 0 50%) 50% / 16px 16px;
  margin: 0 auto;
}
.image-preview-info {
  margin-top: 8px;
  font-size: 12px;
  color: var(--text-muted);
}
@media (prefers-color-scheme: dark) {
  .image-preview img {
    background: repeating-conic-gradient(#1f2937 0 25%, #374151 0 50%) 50% / 16px 16px;
  }
}

/* ---------- Indent selector inline w/ toolbar ---------- */
.indent-select {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--bg);
  font-size: 13px;
  color: var(--text-soft);
}
.indent-select span { white-space: nowrap; }
.indent-select input[type="checkbox"] {
  margin: 0;
  accent-color: var(--brand);
  cursor: pointer;
}
.indent-select select {
  border: 0;
  background: transparent;
  font-size: 13px;
  color: var(--text);
  font-family: inherit;
  outline: none;
  cursor: pointer;
  padding: 2px 4px;
}

/* ---------- kbd styling for keyboard shortcuts ---------- */
kbd {
  display: inline-block;
  padding: 1px 6px;
  font-family: var(--font-mono);
  font-size: 12px;
  background: var(--bg-soft);
  border: 1px solid var(--border-strong);
  border-bottom-width: 2px;
  border-radius: 4px;
  color: var(--text);
  vertical-align: baseline;
}

/* Utility */
.mt-0 { margin-top: 0; }
.mt-2 { margin-top: 16px; }
.mb-2 { margin-bottom: 16px; }
.muted { color: var(--text-muted); }
.hidden { display: none !important; }
