/* ==========================================================================
   Azqato's Tools — shared design system
   Native CSS, no frameworks. Works fully offline.
   ========================================================================== */

:root {
  /* Light theme (default) */
  --bg: #f6f7f9;
  --bg-elev: #ffffff;
  --bg-inset: #eef0f3;
  --border: #e2e5ea;
  --border-strong: #cfd4dc;
  --text: #161a20;
  --text-soft: #4a5260;
  --text-faint: #8a93a2;
  --accent: #5b5bf0;
  --accent-hover: #4a4ad6;
  --accent-soft: #ecedff;
  --success: #1f9d57;
  --danger: #d83a52;
  --shadow: 0 1px 2px rgba(16, 22, 32, .06), 0 8px 24px rgba(16, 22, 32, .06);
  --shadow-sm: 0 1px 2px rgba(16, 22, 32, .08);
  --radius: 14px;
  --radius-sm: 9px;
  --maxw: 1100px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial,
    sans-serif, "Apple Color Emoji", "Segoe UI Emoji";
  --mono: "SF Mono", "JetBrains Mono", "Cascadia Code", ui-monospace, Menlo,
    Consolas, monospace;
}

[data-theme="dark"] {
  --bg: #0e1014;
  --bg-elev: #171a21;
  --bg-inset: #1f242d;
  --border: #262b34;
  --border-strong: #353c47;
  --text: #eef1f5;
  --text-soft: #aab2bf;
  --text-faint: #6c7686;
  --accent: #7c7cff;
  --accent-hover: #9090ff;
  --accent-soft: #20223a;
  --success: #3ec77c;
  --danger: #ff6b80;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 12px 32px rgba(0, 0, 0, .35);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.wrap { max-width: var(--maxw); margin: 0 auto; padding: 0 22px; }

/* ---- Top bar -------------------------------------------------------------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(160%) blur(12px);
  -webkit-backdrop-filter: saturate(160%) blur(12px);
  border-bottom: 1px solid var(--border);
}
.topbar .wrap {
  display: flex;
  align-items: center;
  gap: 16px;
  height: 62px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  letter-spacing: -.02em;
  color: var(--text);
  font-size: 1.05rem;
}
.brand:hover { text-decoration: none; }
.brand .logo {
  width: 30px; height: 30px;
  border-radius: 8px;
  display: grid; place-items: center;
  background: linear-gradient(135deg, var(--accent), #a05bff);
  color: #fff; font-weight: 800; font-size: .95rem;
  box-shadow: var(--shadow-sm);
}
.brand .logo svg { width: 18px; height: 18px; }
.spacer { flex: 1; }

.nav-link {
  color: var(--text-soft);
  font-weight: 500;
  font-size: .92rem;
  padding: 6px 4px;
}
.nav-link:hover { color: var(--text); text-decoration: none; }

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 38px; height: 38px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg-elev);
  color: var(--text-soft);
  cursor: pointer;
  transition: .15s ease;
}
.icon-btn:hover { color: var(--text); border-color: var(--border-strong); }
.icon-btn svg { width: 18px; height: 18px; }
.icon-btn .moon { display: none; }
[data-theme="dark"] .icon-btn .sun { display: none; }
[data-theme="dark"] .icon-btn .moon { display: block; }

/* ---- Buttons -------------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: inherit;
  font-size: .92rem;
  font-weight: 600;
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-elev);
  color: var(--text);
  cursor: pointer;
  transition: .15s ease;
  white-space: nowrap;
}
.btn:hover { border-color: var(--border-strong); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn svg { width: 16px; height: 16px; }
.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.btn.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn.ghost { background: transparent; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.sm { padding: 7px 12px; font-size: .85rem; }

/* ---- Generic surfaces ----------------------------------------------------- */
.card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

.field {
  width: 100%;
  font-family: inherit;
  font-size: .95rem;
  color: var(--text);
  background: var(--bg-elev);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 11px 14px;
  transition: .15s ease;
}
.field:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
textarea.field { resize: vertical; line-height: 1.55; }

label.lbl {
  display: block;
  font-size: .82rem;
  font-weight: 600;
  color: var(--text-soft);
  margin-bottom: 7px;
  letter-spacing: .01em;
}

/* ---- Page scaffold -------------------------------------------------------- */
.page { padding: 34px 0 70px; }
.page-head { margin-bottom: 26px; }
.page-head .crumb {
  font-size: .85rem;
  color: var(--text-faint);
  margin-bottom: 10px;
}
.page-head h1 {
  margin: 0 0 8px;
  font-size: 1.9rem;
  letter-spacing: -.025em;
}
.page-head p { margin: 0; color: var(--text-soft); max-width: 65ch; }

.toast {
  position: fixed;
  bottom: 24px; left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--text);
  color: var(--bg);
  padding: 11px 18px;
  border-radius: 10px;
  font-size: .9rem;
  font-weight: 600;
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transition: .25s ease;
  z-index: 100;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---- Footer --------------------------------------------------------------- */
.footer {
  border-top: 1px solid var(--border);
  padding: 30px 0;
  color: var(--text-faint);
  font-size: .87rem;
}
.footer .wrap { display: flex; flex-wrap: wrap; gap: 14px; align-items: center; }
.footer a { color: var(--text-soft); }

/* ==========================================================================
   Landing page
   ========================================================================== */
.hero { padding: 64px 0 40px; text-align: center; }
.hero .eyebrow {
  display: inline-block;
  font-size: .8rem;
  font-weight: 600;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--accent);
  background: var(--accent-soft);
  padding: 5px 12px;
  border-radius: 999px;
  margin-bottom: 18px;
}
.hero h1 {
  margin: 0 auto 16px;
  font-size: clamp(2.1rem, 5vw, 3.3rem);
  line-height: 1.08;
  letter-spacing: -.035em;
  max-width: 16ch;
}
.hero h1 .grad {
  background: linear-gradient(120deg, var(--accent), #b15bff 70%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}
.hero p {
  margin: 0 auto;
  max-width: 56ch;
  color: var(--text-soft);
  font-size: 1.12rem;
}
.hero-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 22px;
  justify-content: center;
  margin-top: 26px;
  color: var(--text-soft);
  font-size: .9rem;
  font-weight: 500;
}
.hero-badges span { display: inline-flex; align-items: center; gap: 7px; }
.hero-badges svg { width: 16px; height: 16px; color: var(--success); }

.tools-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
  gap: 18px;
  padding-bottom: 30px;
}
.tool-card {
  display: flex;
  flex-direction: column;
  padding: 24px;
  border-radius: var(--radius);
  background: var(--bg-elev);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  transition: .18s ease;
  color: var(--text);
}
.tool-card:hover {
  text-decoration: none;
  transform: translateY(-3px);
  border-color: var(--border-strong);
  box-shadow: var(--shadow);
}
.tool-card .ticon {
  width: 46px; height: 46px;
  border-radius: 12px;
  display: grid; place-items: center;
  background: var(--accent-soft);
  color: var(--accent);
  margin-bottom: 16px;
}
.tool-card .ticon svg { width: 24px; height: 24px; }
.tool-card h3 { margin: 0 0 6px; font-size: 1.12rem; letter-spacing: -.02em; }
.tool-card h3 .ext-tag {
  font-size: .62rem;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--text-faint);
  background: var(--bg-inset);
  border: 1px solid var(--border);
  padding: 2px 7px;
  border-radius: 999px;
  vertical-align: middle;
  margin-left: 6px;
}
.tool-card p { margin: 0; color: var(--text-soft); font-size: .92rem; flex: 1; }
.tool-card .go {
  margin-top: 18px;
  font-size: .88rem;
  font-weight: 600;
  color: var(--accent);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.tool-card:hover .go { gap: 10px; }
.tool-card .go svg { width: 15px; height: 15px; transition: .15s ease; }

.section-label {
  font-size: .82rem;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--text-faint);
  margin: 10px 0 18px;
}

/* ==========================================================================
   Tool: Markdown Editor
   ========================================================================== */
.md-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-bottom: 14px;
}
.md-toolbar .grp {
  display: flex;
  gap: 6px;
  padding: 4px;
  background: var(--bg-inset);
  border-radius: 10px;
}
.md-tool {
  border: none;
  background: transparent;
  color: var(--text-soft);
  font-family: inherit;
  font-size: .85rem;
  font-weight: 600;
  padding: 6px 10px;
  border-radius: 7px;
  cursor: pointer;
  transition: .12s ease;
}
.md-tool:hover { background: var(--bg-elev); color: var(--text); }

.md-split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  min-height: 540px;
}
.md-pane {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--bg-elev);
}
.md-pane .pane-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 9px 14px;
  font-size: .78rem;
  font-weight: 700;
  letter-spacing: .05em;
  text-transform: uppercase;
  color: var(--text-faint);
  background: var(--bg-inset);
  border-bottom: 1px solid var(--border);
}
#md-input {
  flex: 1;
  border: none;
  resize: none;
  padding: 18px;
  font-family: var(--mono);
  font-size: .9rem;
  line-height: 1.6;
  background: transparent;
  color: var(--text);
}
#md-input:focus { outline: none; }
.md-preview {
  flex: 1;
  padding: 22px 24px;
  overflow-y: auto;
}

/* rendered markdown */
.md-body { color: var(--text); word-wrap: break-word; }
.md-body > *:first-child { margin-top: 0; }
.md-body h1, .md-body h2, .md-body h3,
.md-body h4, .md-body h5, .md-body h6 {
  margin: 1.5em 0 .6em; line-height: 1.25; letter-spacing: -.02em;
}
.md-body h1 { font-size: 1.8em; padding-bottom: .3em; border-bottom: 1px solid var(--border); }
.md-body h2 { font-size: 1.45em; padding-bottom: .3em; border-bottom: 1px solid var(--border); }
.md-body h3 { font-size: 1.2em; }
.md-body p { margin: 0 0 1em; }
.md-body a { text-decoration: underline; }
.md-body ul, .md-body ol { margin: 0 0 1em; padding-left: 1.6em; }
.md-body li { margin: .25em 0; }
.md-body blockquote {
  margin: 0 0 1em;
  padding: .2em 1em;
  border-left: 4px solid var(--border-strong);
  color: var(--text-soft);
}
.md-body code {
  font-family: var(--mono);
  font-size: .88em;
  background: var(--bg-inset);
  padding: .15em .4em;
  border-radius: 5px;
}
.md-body pre {
  background: var(--bg-inset);
  padding: 14px 16px;
  border-radius: 10px;
  overflow-x: auto;
  margin: 0 0 1em;
}
.md-body pre code { background: none; padding: 0; font-size: .85em; }
.md-body hr { border: none; border-top: 1px solid var(--border); margin: 1.5em 0; }
.md-body img { max-width: 100%; border-radius: 8px; }
.md-body table { border-collapse: collapse; width: 100%; margin: 0 0 1em; }
.md-body th, .md-body td { border: 1px solid var(--border); padding: 7px 12px; text-align: left; }
.md-body th { background: var(--bg-inset); font-weight: 700; }
.md-body input[type="checkbox"] { margin-right: 6px; }

/* ==========================================================================
   Tool: Favicon Downloader
   ========================================================================== */
.input-row { display: flex; gap: 10px; }
.input-row .field { flex: 1; }
@media (max-width: 560px) { .input-row { flex-direction: column; } }

.fav-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 16px;
  margin-top: 26px;
}
.fav-item {
  text-align: center;
  padding: 20px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-elev);
}
.fav-item .thumb {
  height: 84px;
  display: grid;
  place-items: center;
  margin-bottom: 12px;
}
.fav-item .thumb img {
  image-rendering: -webkit-optimize-contrast;
  border-radius: 6px;
  max-height: 84px;
  max-width: 100%;
}
.fav-item .sz { font-weight: 700; font-size: .95rem; }
.fav-item .src { font-size: .76rem; color: var(--text-faint); margin-bottom: 12px; }

.empty {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-faint);
}
.empty svg { width: 46px; height: 46px; opacity: .5; margin-bottom: 12px; }

/* ==========================================================================
   Tool: Link Cleaner
   ========================================================================== */
.lc-result {
  margin-top: 22px;
  display: none;
}
.lc-result.show { display: block; }
.lc-out {
  font-family: var(--mono);
  font-size: .92rem;
  word-break: break-all;
  background: var(--bg-inset);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  color: var(--text);
}
.lc-removed {
  margin-top: 16px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.chip {
  font-family: var(--mono);
  font-size: .8rem;
  background: color-mix(in srgb, var(--danger) 14%, transparent);
  color: var(--danger);
  border: 1px solid color-mix(in srgb, var(--danger) 30%, transparent);
  padding: 4px 9px;
  border-radius: 999px;
}
.chip.kept {
  background: var(--bg-inset);
  color: var(--text-soft);
  border-color: var(--border);
}
.stat-line {
  margin-top: 14px;
  font-size: .88rem;
  color: var(--text-soft);
}
.stat-line b { color: var(--text); }

@media (max-width: 760px) {
  .md-split { grid-template-columns: 1fr; min-height: 0; }
  #md-input { min-height: 280px; }
  .md-preview { min-height: 280px; }
  .nav-link.hide-sm { display: none; }
}
