/* ZHH Base64 HTML Decoder — ZHHTools
   Built by Zeeshan Haider (Dev) */

:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #f1f3f6;
  --text: #10151c;
  --muted: #5c6673;
  --border: #e2e6ec;
  --brand: #0f766e;
  --brand-strong: #0b5c56;
  --brand-soft: #e6f4f2;
  --danger: #b42318;
  --danger-soft: #fdeceb;
  --ok: #15803d;
  --shadow: 0 1px 2px rgba(16, 21, 28, .06), 0 12px 28px -18px rgba(16, 21, 28, .35);
  --radius: 14px;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Naskh Arabic", "Noto Sans Devanagari", sans-serif;

  --tok-tag: #0b5c56;
  --tok-attr: #8a5a00;
  --tok-str: #1d4ed8;
  --tok-com: #6b7280;
  --tok-doc: #7c3aed;
}

html[data-theme="dark"] {
  --bg: #0b0f14;
  --surface: #121821;
  --surface-2: #182029;
  --text: #e7edf4;
  --muted: #9aa7b5;
  --border: #232d39;
  --brand: #2dd4bf;
  --brand-strong: #14b8a6;
  --brand-soft: #10241f;
  --danger: #fca5a5;
  --danger-soft: #2a1414;
  --ok: #4ade80;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 18px 40px -24px rgba(0, 0, 0, .9);

  --tok-tag: #5eead4;
  --tok-attr: #fbbf24;
  --tok-str: #93c5fd;
  --tok-com: #7b8794;
  --tok-doc: #c4b5fd;
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  transition: background-color .2s ease, color .2s ease;
}

a { color: inherit; }

.wrap { width: min(1240px, 100%); margin: 0 auto; padding: 0 18px; }

.skip-link {
  position: absolute; left: -9999px; top: 0; z-index: 100;
  background: var(--surface); color: var(--text);
  padding: 10px 14px; border-radius: 8px; border: 1px solid var(--border);
}
.skip-link:focus { left: 12px; top: 12px; }

/* ---------- Header ---------- */
.site-header {
  position: sticky; top: 0; z-index: 40;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--border);
}
.header-inner { display: flex; align-items: center; gap: 14px; min-height: 66px; }

.brand { display: flex; align-items: center; gap: 11px; text-decoration: none; }
.brand-mark {
  width: 38px; height: 38px; border-radius: 11px;
  background: var(--brand); color: #fff;
  display: grid; place-items: center;
  font-weight: 800; font-size: 13px; letter-spacing: .3px;
}
html[data-theme="dark"] .brand-mark { color: #04211e; }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-name { font-weight: 800; letter-spacing: -.2px; }
.brand-sub { font-size: 11.5px; color: var(--muted); }

.nav { margin-left: auto; display: flex; align-items: center; gap: 4px; }
.nav a {
  text-decoration: none; color: var(--muted); font-weight: 600; font-size: 14px;
  padding: 8px 12px; border-radius: 9px; transition: color .15s, background-color .15s;
}
.nav a:hover { color: var(--text); background: var(--surface-2); }

.header-actions { display: flex; align-items: center; gap: 8px; margin-left: 8px; }

.theme-toggle {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 999px; padding: 4px;
}
.theme-toggle button {
  border: 0; background: transparent; color: var(--muted);
  font: inherit; font-size: 12.5px; font-weight: 650;
  padding: 5px 10px; border-radius: 999px; cursor: pointer;
  transition: background-color .15s, color .15s;
}
.theme-toggle button[aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }

.menu-btn {
  display: none; border: 1px solid var(--border); background: var(--surface-2);
  color: var(--text); border-radius: 10px; padding: 8px 10px; cursor: pointer;
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font: inherit; font-size: 13.5px; font-weight: 650;
  padding: 9px 14px; border-radius: 10px; cursor: pointer;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  transition: transform .12s ease, background-color .15s, border-color .15s, opacity .15s;
}
.btn:hover { background: var(--surface-2); }
.btn:active { transform: translateY(1px); }
.btn[disabled] { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
html[data-theme="dark"] .btn-primary { color: #04211e; }
.btn-primary:hover { background: var(--brand-strong); border-color: var(--brand-strong); }
.btn-lg { font-size: 15px; padding: 13px 24px; border-radius: 12px; }
.btn-ghost { background: transparent; }
.btn-sm { font-size: 12.5px; padding: 6px 10px; border-radius: 9px; }

:where(a, button, textarea, input, [tabindex]):focus-visible {
  outline: 2px solid var(--brand); outline-offset: 2px; border-radius: 10px;
}

/* ---------- Hero ---------- */
.hero { padding: 54px 0 30px; text-align: center; }
.pill {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--brand-soft); color: var(--brand-strong);
  border: 1px solid color-mix(in srgb, var(--brand) 25%, transparent);
  font-size: 12.5px; font-weight: 700; padding: 6px 12px; border-radius: 999px;
}
html[data-theme="dark"] .pill { color: var(--brand); }
.hero h1 {
  font-size: clamp(30px, 5.4vw, 50px); line-height: 1.08;
  letter-spacing: -1.3px; margin: 18px 0 12px; font-weight: 820;
}
.hero p { color: var(--muted); max-width: 660px; margin: 0 auto; font-size: 16px; }
.hero .privacy-line { margin-top: 14px; font-weight: 650; color: var(--text); font-size: 14.5px; }

/* ---------- Layout ---------- */
main { padding-bottom: 60px; }
.workspace {
  display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 26px;
}
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden;
}
.card-head {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 13px 15px; border-bottom: 1px solid var(--border); background: var(--surface);
}
.card-title { font-weight: 750; font-size: 14.5px; margin: 0; }
.card-tools { margin-left: auto; display: flex; gap: 6px; flex-wrap: wrap; }
.card-body { padding: 14px 15px 15px; }
.card-foot {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 10px 15px; border-top: 1px solid var(--border);
  color: var(--muted); font-size: 12.5px; background: var(--surface-2);
}

textarea.code, .code-out {
  width: 100%; min-height: 330px; resize: vertical;
  font-family: var(--mono); font-size: 13px; line-height: 1.65;
  background: var(--surface-2); color: var(--text);
  border: 1px solid var(--border); border-radius: 11px; padding: 13px;
  tab-size: 2;
}
textarea.code::placeholder { color: var(--muted); opacity: .75; }
.code-out {
  margin: 0; overflow: auto; white-space: pre-wrap; word-break: break-word;
  min-height: 330px; max-height: 60vh;
}
.code-out .t-tag { color: var(--tok-tag); }
.code-out .t-attr { color: var(--tok-attr); }
.code-out .t-str { color: var(--tok-str); }
.code-out .t-com { color: var(--tok-com); font-style: italic; }
.code-out .t-doc { color: var(--tok-doc); }
.code-out .placeholder { color: var(--muted); }

/* ---------- Action bar ---------- */
.actions {
  position: sticky; bottom: 0; z-index: 30; margin-top: 16px;
  display: flex; align-items: center; justify-content: center; gap: 10px; flex-wrap: wrap;
  padding: 12px; border: 1px solid var(--border); border-radius: var(--radius);
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(8px); box-shadow: var(--shadow);
}
.spinner {
  width: 15px; height: 15px; border-radius: 50%;
  border: 2px solid currentColor; border-right-color: transparent;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { * { animation-duration: .001ms !important; transition: none !important; } }

/* ---------- Tools grid ---------- */
.toolbar {
  margin-top: 16px; display: flex; flex-wrap: wrap; gap: 8px;
  padding: 13px; border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface); box-shadow: var(--shadow);
}
.toolbar .group-label {
  font-size: 12px; font-weight: 750; color: var(--muted);
  text-transform: uppercase; letter-spacing: .6px; align-self: center; margin-right: 4px;
}

/* ---------- Alerts / toast ---------- */
.alert {
  margin-top: 14px; padding: 11px 13px; border-radius: 11px;
  border: 1px solid var(--border); font-size: 13.5px; display: none;
}
.alert.show { display: block; }
.alert.error { background: var(--danger-soft); border-color: color-mix(in srgb, var(--danger) 35%, transparent); color: var(--danger); }
.alert.ok { background: var(--brand-soft); border-color: color-mix(in srgb, var(--brand) 30%, transparent); color: var(--brand-strong); }
html[data-theme="dark"] .alert.ok { color: var(--brand); }

.toasts {
  position: fixed; right: 16px; bottom: 16px; z-index: 90;
  display: flex; flex-direction: column; gap: 8px; pointer-events: none;
}
.toast {
  background: var(--surface); border: 1px solid var(--border); color: var(--text);
  border-radius: 11px; padding: 10px 14px; box-shadow: var(--shadow);
  font-size: 13.5px; font-weight: 620; animation: rise .2s ease;
}
.toast.err { border-color: color-mix(in srgb, var(--danger) 45%, transparent); color: var(--danger); }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ---------- Preview ---------- */
.preview-frame {
  width: 100%; height: 420px; border: 1px solid var(--border);
  border-radius: 11px; background: #fff;
}
.note { color: var(--muted); font-size: 12.8px; margin: 0 0 12px; }

/* ---------- Info cards ---------- */
.info-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-top: 30px; }
.info-card { padding: 18px; }
.info-card h3 { margin: 10px 0 6px; font-size: 16px; }
.info-card p { margin: 0; color: var(--muted); font-size: 13.8px; }
.badge-dot {
  width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center;
  background: var(--brand-soft); color: var(--brand-strong); font-weight: 800;
}
html[data-theme="dark"] .badge-dot { color: var(--brand); }

.prose { margin-top: 34px; }
.prose h2 { font-size: 22px; letter-spacing: -.4px; margin-bottom: 8px; }
.prose h3 { font-size: 16px; margin-bottom: 4px; }
.prose p, .prose li { color: var(--muted); font-size: 14.5px; }

/* ---------- Footer ---------- */
.site-footer { border-top: 1px solid var(--border); background: var(--surface); padding: 28px 0; }
.footer-inner { display: flex; gap: 18px; flex-wrap: wrap; align-items: center; }
.footer-links { margin-left: auto; display: flex; gap: 6px; flex-wrap: wrap; }
.footer-links a { text-decoration: none; color: var(--muted); font-size: 14px; padding: 6px 10px; border-radius: 9px; }
.footer-links a:hover { color: var(--text); background: var(--surface-2); }
.copy { color: var(--muted); font-size: 13px; }

/* ---------- Responsive ---------- */
@media (max-width: 980px) {
  .workspace { grid-template-columns: 1fr; }
  .info-grid { grid-template-columns: 1fr; }
  .nav {
    display: none; position: absolute; top: 66px; left: 0; right: 0;
    flex-direction: column; align-items: stretch; gap: 2px;
    background: var(--surface); border-bottom: 1px solid var(--border); padding: 10px 18px 16px;
  }
  .nav.open { display: flex; }
  .menu-btn { display: inline-flex; order: 3; }
  .header-actions { margin-left: auto; }
  .hero { padding: 34px 0 18px; }
  textarea.code, .code-out { min-height: 240px; }
  .preview-frame { height: 320px; }
}
