/* ============================================
   TOOLCRATE — editorial / studio minimal
   Near-monochrome. One sans-serif throughout.
   Hierarchy carried by weight, size, and gray —
   not color, not decoration.
   ============================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

:root {
  --ink: #141414;
  --ink-soft: #4A4844;
  --paper: #F5F4F2;
  --panel: #FFFFFF;
  --line: #DEDCD8;
  --line-soft: #EAE8E4;
  --muted: #8A8782;
  --accent: #2255DD;
  --ok: #2E7D5B;
  --danger: #C0392B;
  --line-len: 68ch;
}

[data-theme="dark"] {
  --ink: #EDECEA;
  --ink-soft: #B8B5AF;
  --paper: #161513;
  --panel: #1E1D1A;
  --line: #33312C;
  --line-soft: #262420;
  --muted: #7C7972;
  --accent: #6C93F5;
  --ok: #52A57C;
  --danger: #DB6B5A;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 15.5px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  transition: background 0.2s ease, color 0.2s ease;
}

h1, h2, h3 {
  font-family: 'Inter', sans-serif;
  font-weight: 700;
  line-height: 1.15;
  margin: 0 0 0.5em 0;
  letter-spacing: -0.02em;
  color: var(--ink);
}

h1 { font-size: clamp(2rem, 5vw, 2.75rem); }
h1 em { font-style: normal; color: var(--muted); font-weight: 700; }
h2 { font-size: 1.1rem; font-weight: 600; }
h3 { font-size: 0.95rem; font-weight: 600; }

p { margin: 0 0 1em 0; max-width: var(--line-len); color: var(--ink-soft); }

a {
  color: var(--ink);
  text-decoration: underline;
  text-decoration-color: var(--line);
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}
a:hover { color: var(--accent); text-decoration-color: var(--accent); }
a:focus-visible, button:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible {
  outline: 1.5px solid var(--accent);
  outline-offset: 2px;
}

/* ---- Layout shell ---- */
.site-header {
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--paper);
}
.site-header-inner {
  max-width: 860px;
  margin: 0 auto;
  padding: 1.3rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}
.brand {
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--ink);
  text-decoration: none;
  letter-spacing: -0.01em;
}
.brand:hover { color: var(--ink); }
.brand em { font-style: normal; color: var(--muted); font-weight: 500; }

.brand-wrap { display: flex; align-items: baseline; gap: 0.5rem; }
.brand-offshoot {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--ink-soft);
  text-decoration: none;
  padding-left: 0.55rem;
  border-left: 1px solid var(--line);
}
.brand-offshoot:hover { color: var(--ink); }

.header-right { display: flex; align-items: center; gap: 1.5rem; }

.site-nav a {
  color: var(--muted);
  text-decoration: none;
  font-size: 0.85rem;
  margin-left: 1.3rem;
}
.site-nav a:first-child { margin-left: 0; }
.site-nav a:hover { color: var(--ink); }

.theme-toggle {
  background: none;
  border: 1px solid var(--line);
  color: var(--ink-soft);
  width: 30px;
  height: 30px;
  border-radius: 50%;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  font-size: 0.9rem;
  line-height: 1;
}
.theme-toggle:hover { border-color: var(--ink); color: var(--ink); background: none; }

main {
  max-width: 860px;
  margin: 0 auto;
  padding: 3.5rem 1.5rem 5rem;
}

.site-footer {
  border-top: 1px solid var(--line);
  padding: 1.75rem 1.5rem;
  margin-top: 4rem;
}
.site-footer-inner {
  max-width: 860px;
  margin: 0 auto;
  color: var(--muted);
  font-size: 0.8rem;
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
}
.site-footer a { color: var(--muted); text-decoration-color: var(--line); margin-right: 1.1rem; }
.site-footer a:last-child { margin-right: 0; }
.site-footer a:hover { color: var(--ink); }
.footer-links { display: flex; }

/* ---- Homepage tool index ---- */
.intro { margin-bottom: 3rem; }
.intro h1 { margin-bottom: 0.5em; max-width: 16ch; }
.intro-meta {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 2rem;
  flex-wrap: wrap;
}
.intro p { color: var(--ink-soft); font-size: 1.02rem; max-width: 46ch; }
.intro-count { text-align: right; flex-shrink: 0; }
.intro-count .num {
  font-size: 2.2rem;
  font-weight: 700;
  line-height: 1;
  display: block;
  color: var(--ink);
  letter-spacing: -0.02em;
}
.intro-count .label {
  font-size: 0.75rem;
  color: var(--muted);
}

.category-label {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--ink);
  margin: 2.75rem 0 0.5rem 0;
}
.tag-filter {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 1.75rem;
}
.tag-pill {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--ink-soft);
  background: none;
  text-decoration: none;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.4rem 0.9rem;
  cursor: pointer;
}
.tag-pill:hover { color: var(--ink); border-color: var(--ink-soft); }
.tag-pill .tag-count { color: var(--muted); font-weight: 400; }
.tag-pill.active {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--paper);
}
.tag-pill.active .tag-count { color: var(--paper); opacity: 0.75; }
.tag-clear {
  font-size: 0.8rem;
  color: var(--muted);
  background: none;
  border: none;
  text-decoration: underline;
  cursor: pointer;
  padding: 0.4rem 0;
}
.tag-clear:hover { color: var(--ink); }

.search-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 1.1rem 1.3rem;
  margin-bottom: 2.5rem;
}
.search-panel label {
  font-size: 0.78rem;
  color: var(--muted);
  margin-bottom: 0.45rem;
}
.search-input-wrap { position: relative; }
.search-input-wrap input[type="text"] { padding-right: 2.6rem; }
.search-clear {
  position: absolute;
  top: 50%;
  right: 0.4rem;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: var(--muted);
  font-size: 0.85rem;
  width: 28px;
  height: 28px;
  padding: 0;
  cursor: pointer;
  border-radius: 50%;
}
.search-clear:hover { color: var(--ink); opacity: 1; background: var(--line-soft); }
.search-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 0.6rem;
  font-size: 0.78rem;
  color: var(--muted);
  min-height: 1em;
}
.search-panel .sort-control {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-bottom: 0;
  color: var(--muted);
}
.sort-control select {
  font: inherit;
  font-size: 0.78rem;
  color: var(--ink);
  background-color: var(--paper);
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 0.35rem 1.6rem 0.35rem 0.5rem;
  cursor: pointer;
}
.search-hint kbd {
  font-family: 'Courier New', monospace;
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 0.05rem 0.4rem;
  font-size: 0.75rem;
  background: var(--paper);
}
.no-results {
  text-align: center;
  color: var(--muted);
  padding: 2.5rem 0;
  border-top: 1px solid var(--line);
}

.back-to-top {
  position: fixed;
  right: 1.5rem;
  bottom: 1.5rem;
  width: 42px;
  height: 42px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--ink);
  color: var(--paper);
  border: 1px solid var(--ink);
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 2px 10px rgba(0,0,0,0.18);
  opacity: 0;
  visibility: hidden;
  transform: translateY(8px);
  transition: opacity 0.15s ease, transform 0.15s ease, visibility 0.15s;
  z-index: 15;
}
.back-to-top.show { opacity: 1; visibility: visible; transform: translateY(0); }
.back-to-top:hover { opacity: 0.85; }

.install-hint {
  position: fixed;
  left: 1rem;
  right: 1rem;
  bottom: 1rem;
  max-width: 420px;
  margin: 0 auto;
  background: var(--ink);
  color: var(--paper);
  border-radius: 10px;
  padding: 0.75rem 0.9rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.85rem;
  line-height: 1.3;
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.25);
  z-index: 60;
}
.install-hint span:first-child { flex: 1; }
.install-hint-action {
  background: var(--paper);
  color: var(--ink);
  border: none;
  border-radius: 999px;
  padding: 0.35rem 0.9rem;
  font-weight: 600;
  font-size: 0.8rem;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
}
.install-hint-dismiss {
  background: none;
  border: none;
  color: var(--paper);
  opacity: 0.7;
  cursor: pointer;
  font-size: 0.9rem;
  padding: 0.2rem;
  flex-shrink: 0;
}
.install-hint-dismiss:hover { opacity: 1; }

/* Ko-fi's floating widget is fixed-position by design (docked bottom-right,
   persists through scroll); this just guarantees it regardless of any page
   CSS, and keeps it above the back-to-top button's stacking order. */
/* Ko-fi's floating widget is fixed-position by design via its own
   stylesheet (storage.ko-fi.com). This is a self-sufficient fallback in
   case that stylesheet is blocked or slow to load (ad blockers, CSP,
   flaky network) -- without it, the widget's markup would still be
   injected but unstyled, sitting in normal document flow and scrolling
   away instead of floating. Bottom-left keeps it clear of the
   bottom-right back-to-top button. */
#kofi-widget-overlay {
  position: fixed !important;
  left: 20px !important;
  bottom: 20px !important;
  right: auto !important;
  top: auto !important;
  z-index: 9999 !important;
}

.tool-list {
  list-style: none;
  margin: 0 0 0.5rem 0;
  padding: 0;
  border-top: 1px solid var(--line);
}
.tool-list li { display: flex; align-items: center; gap: 0.2rem; border-bottom: 1px solid var(--line-soft); }
.tool-list li[hidden] { display: none; }
.tool-list a {
  display: flex;
  flex: 1;
  min-width: 0;
  justify-content: space-between;
  align-items: baseline;
  gap: 1.25rem;
  padding: 0.8rem 0.1rem;
  text-decoration: none;
  color: var(--ink);
}

.star-btn {
  flex-shrink: 0;
  width: 1.9rem;
  height: 1.9rem;
  padding: 0;
  background: none;
  border: none;
  border-radius: 6px;
  color: var(--muted);
  font-size: 1.15rem;
  line-height: 1;
  cursor: pointer;
}
.star-btn:hover { color: var(--ink-soft); background: var(--line-soft); }
.star-btn.active { color: #E5A93B; }
.star-btn.active:hover { color: #E5A93B; opacity: 0.8; }

.pinned-group { margin-bottom: 2.25rem; }
.pinned-group .category-label { margin-top: 0; }
.tool-list a:hover { color: var(--accent); }
.tool-list a:hover .tool-desc { color: var(--accent); opacity: 0.7; }
.tool-list a:hover .tool-name { text-decoration: underline; text-decoration-color: var(--accent); text-underline-offset: 3px; }
.tool-num { display: none; }
.tool-name { font-weight: 500; }
.tool-desc { color: var(--muted); font-size: 0.85rem; text-align: right; white-space: nowrap; }

@media (max-width: 620px) {
  .tool-list li { align-items: flex-start; }
  .star-btn { margin-top: 0.55rem; }
  .tool-list a { flex-direction: column; align-items: flex-start; gap: 0.15rem; }
  .tool-desc { text-align: left; white-space: normal; }
  .intro-meta { flex-direction: column; align-items: flex-start; gap: 0.75rem; }
  .intro-count { text-align: left; }
  .site-footer-inner { flex-direction: column; }
  .search-hint { display: none; }
}

/* ---- Tool page ---- */
.tool-header { margin-bottom: 2.25rem; }
.tool-kicker { display: none; }
.tool-header h1 { margin-bottom: 0.4em; font-size: clamp(1.7rem, 4.5vw, 2.2rem); max-width: none; }
.tool-header p { color: var(--ink-soft); font-size: 1rem; }
.share-btn {
  margin-top: 0.85rem;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--ink-soft);
  background: none;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.4rem 0.9rem;
  cursor: pointer;
}
.share-btn:hover { color: var(--ink); border-color: var(--ink-soft); }
.install-btn { margin-left: 0.5rem; }
.last-updated { margin-top: 0.5rem; font-size: 0.68rem; color: var(--muted); }

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 1.65rem;
  margin-bottom: 1.65rem;
}

.donate-embed {
  max-width: 420px;
  margin: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  line-height: 0;
}

label {
  display: block;
  font-size: 0.78rem;
  color: var(--muted);
  margin-bottom: 0.45rem;
  font-weight: 500;
}
label::before { content: none; }

textarea, input[type="text"], input[type="number"], input[type="date"], input[type="time"], input[type="datetime-local"], select {
  width: 100%;
  font-family: 'Inter', sans-serif;
  font-size: 0.92rem;
  padding: 0.68rem 0.85rem;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--paper);
  color: var(--ink);
  resize: vertical;
}
textarea:focus, input:focus, select:focus {
  border-color: var(--accent);
  outline: none;
}
select {
  cursor: pointer;
  background-repeat: no-repeat;
  background-position: right 0.9rem center;
  appearance: none;
  padding-right: 2.2rem;
  text-overflow: ellipsis;
}
:root select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%238A8782' d='M1 1l5 5 5-5'/%3E%3C/svg%3E");
}
[data-theme="dark"] select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%237C7972' d='M1 1l5 5 5-5'/%3E%3C/svg%3E");
}
[data-theme="dark"] input[type="date"]::-webkit-calendar-picker-indicator,
[data-theme="dark"] input[type="time"]::-webkit-calendar-picker-indicator,
[data-theme="dark"] input[type="datetime-local"]::-webkit-calendar-picker-indicator { filter: invert(1); }

.field { margin-bottom: 1.05rem; }
.field:last-child { margin-bottom: 0; }

.row { display: flex; gap: 1rem; flex-wrap: wrap; }
.row .field { flex: 1; min-width: 140px; }

button, .btn {
  font-family: 'Inter', sans-serif;
  font-weight: 600;
  font-size: 0.85rem;
  background: var(--ink);
  color: var(--paper);
  border: 1px solid var(--ink);
  padding: 0.62rem 1.25rem;
  border-radius: 6px;
  cursor: pointer;
}
button:hover { opacity: 0.82; }
button.secondary {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--line);
}
button.secondary:hover { border-color: var(--ink); opacity: 1; background: var(--line-soft); }

.btn-row { display: flex; align-items: center; gap: 0.75rem; flex-wrap: wrap; margin-top: 1rem; }

.output-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  color: var(--ink);
  border-radius: 8px;
  padding: 1.35rem 1.55rem;
  font-size: 0.9rem;
  white-space: pre-wrap;
  word-break: break-word;
  min-height: 3em;
  font-variant-numeric: tabular-nums;
}
.output-panel.empty { color: var(--muted); }

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  margin-bottom: 1.65rem;
}
.stat {
  background: var(--panel);
  padding: 0.95rem 0.9rem;
  text-align: left;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}
.stat-value {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--ink);
  display: block;
  line-height: 1.1;
  letter-spacing: -0.01em;
  word-break: break-word;
  overflow-wrap: break-word;
}
.stat-label { font-size: 0.7rem; color: var(--muted); }

.copy-feedback {
  font-size: 0.8rem;
  color: var(--ok);
  font-weight: 600;
  margin-left: 0.25rem;
  opacity: 0;
  transition: opacity 0.15s ease;
}
.copy-feedback.show { opacity: 1; }

.error-text {
  color: var(--danger);
  font-size: 0.85rem;
  margin-top: 0.75rem;
  font-weight: 500;
}

.ad-slot {
  text-align: center;
  margin: 2.1rem 0;
  overflow: hidden;
}

.related-tools {
  margin-top: 3rem;
  padding-top: 1.85rem;
  border-top: 1px solid var(--line);
}
.related-tools h2 { color: var(--ink); font-size: 1.05rem; margin-bottom: 0.6rem; }
.related-tools .tool-list li:first-child { border-top: none; }

.explainer {
  margin-top: 3rem;
  padding-top: 1.85rem;
  border-top: 1px solid var(--line);
  color: var(--ink-soft);
  font-size: 0.9rem;
}
.explainer h2 { color: var(--ink); font-size: 1.05rem; margin-bottom: 0.6rem; }
.explainer code {
  background: var(--line-soft);
  color: var(--ink);
  padding: 0.12em 0.4em;
  border-radius: 4px;
  font-size: 0.88em;
}

.disclaimer-note {
  border: 1px solid var(--line);
  border-left: 3px solid var(--ink);
  border-radius: 6px;
  padding: 0.9rem 1.1rem;
  margin-bottom: 1.65rem;
  font-size: 0.85rem;
  color: var(--ink-soft);
  background: var(--line-soft);
}
.disclaimer-note strong { color: var(--ink); }
