/* ===== Toolwio design tokens ===== */
:root {
  --color-bg: #fafafa;
  --color-surface: #ffffff;
  --color-text: #17181a;
  --color-text-muted: #6b6b6b;
  --color-border: #e7e7e7;

  --color-primary: #2546d1;
  --color-primary-dark: #1c37a8;
  --color-accent: #2546d1;

  /* Category tints used for tool icons on the homepage grid */
  --cat-text-bg: rgba(52, 82, 235, 0.09);
  --cat-text-fg: #3452eb;
  --cat-calc-bg: rgba(181, 118, 47, 0.12);
  --cat-calc-fg: #a5691f;
  --cat-image-bg: rgba(31, 122, 110, 0.11);
  --cat-image-fg: #1f7a6e;
  --cat-pdf-bg: rgba(180, 60, 60, 0.1);
  --cat-pdf-fg: #a63d3d;
  --cat-audio-bg: rgba(147, 76, 202, 0.1);
  --cat-audio-fg: #7d3fae;

  --radius: 14px;
  --radius-sm: 8px;

  --font-heading: "Archivo", system-ui, sans-serif;
  --font-body: "Work Sans", system-ui, -apple-system, sans-serif;

  --shadow-sm: 0 1px 2px rgba(23, 24, 26, 0.06);
  --wrap-width: 1120px;
}

* {
  box-sizing: border-box;
}

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

body {
  background: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-body);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

h1, h2, h3, h4 {
  font-family: var(--font-heading);
  color: var(--color-text);
  line-height: 1.2;
  margin: 0 0 0.5em;
}

a {
  color: var(--color-primary);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

p {
  margin: 0 0 1em;
  color: var(--color-text-muted);
}

.wrap {
  width: 100%;
  max-width: var(--wrap-width);
  margin: 0 auto;
  padding: 0 20px;
}

.skip-link {
  position: absolute;
  left: -999px;
  top: 0;
  background: var(--color-primary);
  color: #fff;
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  z-index: 100;
}

.skip-link:focus {
  left: 12px;
  top: 12px;
}

/* ===== Header ===== */
.site-header {
  border-bottom: 1px solid var(--color-border);
  background: var(--color-surface);
  position: sticky;
  top: 0;
  z-index: 10;
}

.site-header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding-top: 14px;
  padding-bottom: 14px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 9px;
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 1.2rem;
  color: var(--color-text);
  flex-shrink: 0;
}

.logo:hover {
  text-decoration: none;
}

.logo-mark {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  color: var(--color-primary);
}

.logo-mark svg {
  width: 23px;
  height: 23px;
}

.header-search {
  flex: 1;
  max-width: 420px;
}

.header-search input,
.hero-search input {
  width: 100%;
  padding: 10px 16px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-bg);
  font-family: var(--font-body);
  font-size: 0.95rem;
  color: var(--color-text);
}

.header-search input:focus,
.hero-search input:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(37, 70, 209, 0.14);
}

/* ===== Hero ===== */
.hero {
  padding: 64px 0 40px;
  text-align: center;
}

.hero h1 {
  font-size: clamp(2rem, 4vw, 2.75rem);
  margin-bottom: 0.4em;
}

.hero-sub {
  font-size: 1.1rem;
  max-width: 560px;
  margin: 0 auto 28px;
}

.hero-search {
  max-width: 520px;
  margin: 0 auto;
}

.hero-search input {
  padding: 14px 20px;
  border-radius: var(--radius);
  font-size: 1rem;
  box-shadow: var(--shadow-sm);
}

.trust-line {
  margin: 20px 0 0;
  font-size: 0.85rem;
  color: var(--color-text-muted);
  letter-spacing: 0.01em;
}

/* ===== Ad slots ===== */
.ad-slot {
  max-width: var(--wrap-width);
  margin: 24px auto;
  padding: 18px;
  border: 1px dashed var(--color-border);
  border-radius: var(--radius-sm);
  color: var(--color-text-muted);
  font-size: 0.8rem;
  text-align: center;
  background: rgba(23, 24, 26, 0.02);
}

/* ===== Tool grid ===== */
.tool-grid-section {
  padding: 20px 0 56px;
}

.section-title {
  font-size: 1.4rem;
  margin-bottom: 20px;
}

.tool-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 16px;
}

.tool-card {
  display: flex;
  align-items: flex-start;
  gap: 13px;
  padding: 18px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  color: var(--color-text);
  transition: border-color 0.15s ease, transform 0.15s ease;
}

.tool-card:hover {
  border-color: var(--color-primary);
  text-decoration: none;
  transform: translateY(-2px);
}

.tool-card-icon {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.tool-card-icon svg {
  width: 22px;
  height: 22px;
}

.tool-card-icon.icon-text {
  background: var(--cat-text-bg);
  color: var(--cat-text-fg);
}

.tool-card-icon.icon-calc {
  background: var(--cat-calc-bg);
  color: var(--cat-calc-fg);
}

.tool-card-icon.icon-image {
  background: var(--cat-image-bg);
  color: var(--cat-image-fg);
}

.tool-card-icon.icon-pdf {
  background: var(--cat-pdf-bg);
  color: var(--cat-pdf-fg);
}

.tool-card-icon.icon-audio {
  background: var(--cat-audio-bg);
  color: var(--cat-audio-fg);
}

.tool-card-body {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.tool-card-name {
  font-family: var(--font-heading);
  font-weight: 600;
}

.tool-card-desc {
  font-size: 0.85rem;
  color: var(--color-text-muted);
}

.tool-card.is-hidden {
  display: none;
}

.empty-state {
  padding: 40px;
  text-align: center;
  border: 1px dashed var(--color-border);
  border-radius: var(--radius);
  color: var(--color-text-muted);
}

/* ===== Generic page section (error page, future static pages) ===== */
.page-section {
  padding: 48px 0;
}

/* ===== Individual tool pages (shared pattern) ===== */
.tool-page {
  max-width: 760px;
  padding-top: 40px;
  padding-bottom: 8px;
}

.tool-page h1 {
  font-size: clamp(1.75rem, 3.5vw, 2.25rem);
}

.tool-intro {
  font-size: 1rem;
  margin-bottom: 28px;
}

.tool-textarea {
  width: 100%;
  padding: 16px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  background: var(--color-surface);
  font-family: var(--font-body);
  font-size: 1rem;
  color: var(--color-text);
  resize: vertical;
  box-shadow: var(--shadow-sm);
}

.tool-textarea:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(37, 70, 209, 0.14);
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 14px;
  margin-top: 20px;
}

.stat-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 20px 12px;
  border-radius: var(--radius);
  background: #f1f1ef;
  border: 1px solid #e7e7e3;
  text-align: center;
}

.stat-box-accent {
  background: rgba(37, 70, 209, 0.09);
  border-color: rgba(37, 70, 209, 0.22);
}

.stat-value {
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 1.9rem;
  color: var(--color-text);
}

.stat-box-accent .stat-value {
  color: var(--color-primary);
}

.stat-label {
  font-size: 0.8rem;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.tool-article {
  padding-top: 8px;
  padding-bottom: 40px;
}

.tool-article h2 {
  font-size: 1.2rem;
}

/* ===== Tool forms (calculators etc.) ===== */
.tool-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-top: 8px;
}

.form-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-row label {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--color-text);
}

.form-row-subtract label {
  color: var(--color-primary-dark);
}

.form-input {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-surface);
  font-family: var(--font-body);
  font-size: 1rem;
  color: var(--color-text);
}

.form-input:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(37, 70, 209, 0.14);
}

/* ===== Prominent result box (calculators) ===== */
.result-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  margin-top: 28px;
  padding: 28px 20px;
  border-radius: var(--radius);
  background: rgba(37, 70, 209, 0.08);
  border: 1px solid rgba(37, 70, 209, 0.2);
  text-align: center;
}

.result-box.is-zero {
  background: #f1f1ef;
  border-color: var(--color-border);
}

.result-label {
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--color-text-muted);
}

.result-value {
  font-family: var(--font-heading);
  font-weight: 800;
  font-size: 2.4rem;
  color: var(--color-primary);
}

.result-box.is-zero .result-value {
  color: var(--color-text-muted);
}

.result-sub {
  font-size: 0.85rem;
  color: var(--color-text-muted);
}

/* ===== Buttons (tool actions) ===== */
.btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 16px;
}

.btn {
  padding: 10px 18px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-surface);
  color: var(--color-text);
  font-family: var(--font-body);
  font-weight: 500;
  font-size: 0.9rem;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.btn:hover {
  border-color: var(--color-primary);
  background: rgba(37, 70, 209, 0.05);
}

.btn-primary {
  background: var(--color-primary);
  border-color: var(--color-primary);
  color: #fff;
}

.btn-primary:hover {
  background: var(--color-primary-dark);
  border-color: var(--color-primary-dark);
}

.btn-accent {
  background: rgba(37, 70, 209, 0.1);
  border-color: rgba(37, 70, 209, 0.25);
  color: var(--color-primary);
}

.btn-accent:hover {
  background: rgba(37, 70, 209, 0.16);
  border-color: var(--color-primary);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-feedback {
  min-height: 1.2em;
  margin-top: 10px;
  font-size: 0.85rem;
  color: var(--color-primary-dark);
}

.btn-feedback.is-error {
  color: #b3261e;
}

/* ===== Currency converter ===== */
.currency-row {
  display: flex;
  align-items: flex-end;
  gap: 10px;
}

.currency-row .form-row {
  flex: 1;
  min-width: 0;
}

.currency-swap {
  flex-shrink: 0;
  width: 42px;
  height: 42px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.currency-swap svg {
  width: 18px;
  height: 18px;
}

@media (max-width: 480px) {
  .currency-row {
    flex-wrap: wrap;
  }

  .currency-row .form-row {
    flex-basis: 100%;
  }

  .currency-swap {
    align-self: center;
  }
}

/* ===== Contact form ===== */
.hp-field {
  position: absolute;
  left: -9999px;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

.field-error {
  display: block;
  margin-top: 4px;
  font-size: 0.8rem;
  color: #b3261e;
}

/* ===== Hash generator ===== */
.hash-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 16px;
}

.hash-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-surface);
}

.hash-label {
  flex-shrink: 0;
  width: 72px;
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 0.85rem;
  color: var(--color-text-muted);
}

.hash-value {
  flex: 1;
  min-width: 0;
  overflow-x: auto;
  white-space: nowrap;
  font-family: ui-monospace, "SF Mono", "Cascadia Code", Consolas, monospace;
  font-size: 0.85rem;
  color: var(--color-text);
}

.hash-copy {
  flex-shrink: 0;
  padding: 6px 12px;
  font-size: 0.8rem;
}

/* ===== Markdown previewer ===== */
.tool-page-wide {
  max-width: 1040px;
}

.markdown-split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  align-items: stretch;
}

.markdown-split .tool-textarea {
  height: 100%;
  min-height: 420px;
}

.markdown-preview {
  min-height: 420px;
  padding: 16px 20px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  background: var(--color-surface);
  overflow-y: auto;
  line-height: 1.6;
}

.markdown-preview h1,
.markdown-preview h2,
.markdown-preview h3 {
  font-family: var(--font-heading);
}

.markdown-preview :first-child {
  margin-top: 0;
}

.markdown-preview pre {
  background: var(--color-bg);
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  overflow-x: auto;
}

.markdown-preview code {
  font-family: ui-monospace, "SF Mono", "Cascadia Code", Consolas, monospace;
  font-size: 0.9em;
}

.markdown-empty {
  color: var(--color-text-muted);
}

@media (max-width: 760px) {
  .markdown-split {
    grid-template-columns: 1fr;
  }
}

/* ===== Sub-calculators (percentage calculator, etc.) ===== */
.sub-calc {
  padding: 24px 0;
  border-top: 1px solid var(--color-border);
}

.sub-calc:first-of-type {
  border-top: none;
  padding-top: 8px;
}

.sub-calc-title {
  font-size: 1.1rem;
  margin-bottom: 14px;
}

.sub-calc .tool-form {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
  margin-top: 0;
}

.sub-calc .result-box {
  margin-top: 16px;
  padding: 18px 20px;
}

.sub-calc .result-value {
  font-size: 1.9rem;
}

/* ===== Password generator ===== */
.password-output {
  display: flex;
  gap: 10px;
  margin-top: 8px;
}

.password-output-field {
  flex: 1;
  min-width: 0;
  padding: 14px 16px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-surface);
  font-family: ui-monospace, "SF Mono", "Cascadia Code", Consolas, monospace;
  font-size: 1.1rem;
  color: var(--color-text);
}

.checkbox-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 10px;
  margin-top: 4px;
}

.checkbox-row label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.9rem;
  color: var(--color-text);
}

/* ===== QR preview ===== */
.qr-preview {
  display: flex;
  justify-content: center;
  padding: 24px;
  margin-top: 16px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  background: var(--color-surface);
}

.qr-preview canvas,
.qr-preview img {
  max-width: 100%;
  height: auto;
}

/* ===== File list (merge PDF, etc.) ===== */
.file-list {
  list-style: none;
  margin: 16px 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.file-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-surface);
}

.file-item-name {
  flex: 1;
  font-size: 0.9rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-item-size {
  font-size: 0.8rem;
  color: var(--color-text-muted);
  flex-shrink: 0;
}

.file-item-actions {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}

.file-item-btn {
  width: 28px;
  height: 28px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-surface);
  color: var(--color-text);
  cursor: pointer;
  font-size: 0.85rem;
  line-height: 1;
}

.file-item-btn:hover:not(:disabled) {
  border-color: var(--color-primary);
  color: var(--color-primary);
}

.file-item-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

/* ===== Range slider (image compressor quality, etc.) ===== */
.form-range {
  width: 100%;
  accent-color: var(--color-primary);
}

/* ===== Image compressor preview ===== */
.compress-preview {
  margin-top: 24px;
}

.compress-thumb {
  display: block;
  max-width: 100%;
  max-height: 320px;
  margin: 0 auto 20px;
  border-radius: var(--radius);
  border: 1px solid var(--color-border);
  object-fit: contain;
  background: var(--color-bg);
}

/* ===== Footer ===== */
.site-footer {
  margin-top: auto;
  border-top: 1px solid var(--color-border);
  background: var(--color-surface);
  padding: 32px 0 0;
}

.site-footer-inner {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 20px;
  padding-bottom: 24px;
}

.footer-brand-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-heading);
  font-weight: 700;
}

.footer-brand .logo-mark {
  color: var(--color-text);
}

.footer-brand p {
  font-family: var(--font-body);
  font-weight: 400;
  font-size: 0.85rem;
  margin-top: 6px;
}

.footer-links {
  display: flex;
  gap: 16px;
  font-size: 0.9rem;
}

.footer-bottom {
  border-top: 1px solid var(--color-border);
  padding: 16px 20px;
  font-size: 0.8rem;
  color: var(--color-text-muted);
  text-align: center;
}

@media (max-width: 640px) {
  .header-search {
    max-width: none;
  }

  .hero {
    padding: 40px 0 28px;
  }
}
