@font-face {
  font-family: Inter;
  src: url('../fonts/Inter-Variable.woff2') format('woff2');
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

:root {
  color-scheme: light;
  --bg-page: #f8fafc;
  --bg-card: #ffffff;
  --bg-subtle: #eef3ff;
  --text-main: #0f172a;
  --text-muted: #475569;
  --primary: #1d4ed8;
  --border: #dce3ed;
  --shadow-sm: 0 3px 12px rgb(15 23 42 / 3%);
}

[data-theme='dark'] {
  color-scheme: dark;
  --bg-page: #0b1120;
  --bg-card: #141e30;
  --bg-subtle: #1e2b46;
  --text-main: #f1f5f9;
  --text-muted: #b5c2d6;
  --primary: #93b4ff;
  --border: #304059;
  --shadow-sm: 0 3px 12px rgb(0 0 0 / 12%);
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg-page); color: var(--text-main); font-family: Inter, system-ui, sans-serif; line-height: 1.55; }
h1, h2, h3, h4, p { margin: 0; }
button, input { font: inherit; }
button, a, input { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }
a { color: var(--primary); }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid var(--primary); outline-offset: 4px; }
.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; }
.skip-link { position: fixed; z-index: 10000; top: 10px; left: 10px; padding: 12px 18px; background: var(--bg-card); border: 2px solid var(--primary); border-radius: 8px; transform: translateY(-160%); }
.skip-link:focus { transform: translateY(0); }

.top-bar { max-width: 1184px; margin: 0 auto; display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 16px 24px; border-bottom: 1px solid var(--border); }
.brand-link { display: inline-flex; align-items: center; gap: 8px; color: var(--text-main); font-size: 19px; font-weight: 850; letter-spacing: -0.7px; text-decoration: none; white-space: nowrap; }
.brand-link i { color: var(--primary); }
.brand-link span { font-size: 13px; font-weight: 500; letter-spacing: 0; color: var(--text-muted); }
.top-actions { display: flex; align-items: center; gap: 16px; }
.about-link { color: var(--text-muted); font-size: 14px; font-weight: 600; text-decoration: none; }
.about-link:hover { color: var(--primary); }
.theme-toggle-btn { display: inline-grid; place-items: center; width: 44px; height: 44px; padding: 0; border: 1px solid var(--border); border-radius: 12px; color: var(--text-main); background: var(--bg-card); }
.btn-primary { display: inline-flex; justify-content: center; align-items: center; gap: 10px; min-height: 44px; padding: 10px 18px; border: 1px solid transparent; border-radius: 12px; background: #1d4ed8; color: white; text-decoration: none; font-size: 14px; font-weight: 650; }
.btn-primary:hover { background: #1e40af; }

.hero { max-width: 860px; margin: 0 auto; text-align: center; padding: 38px 24px 32px; }
.hero-eyebrow { margin-bottom: 12px; color: var(--primary); font-size: 13px; font-weight: 650; }
.hero-eyebrow span { padding: 0 6px; }
.hero h1 { font-size: clamp(28px, 3.5vw, 46px); font-weight: 800; line-height: 1.16; letter-spacing: -1.6px; }
.hero h1 span { color: var(--primary); }
.hero-description { max-width: 620px; margin: 16px auto 0; color: var(--text-muted); font-size: 16px; line-height: 1.65; }

.directory { max-width: 1184px; margin: 0 auto; padding: 0 24px; scroll-margin-top: 20px; }
.directory-heading { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-bottom: 16px; }
.directory-heading h2 { font-size: 21px; letter-spacing: -0.6px; font-weight: 750; }
.directory-heading p { color: var(--text-muted); font-size: 13px; text-align: right; overflow-wrap: anywhere; }
.directory-controls { margin-bottom: 24px; }
.search-input-wrap { position: relative; margin-bottom: 14px; }
.search-input-wrap > i { position: absolute; left: 18px; top: 50%; transform: translateY(-50%); color: var(--text-muted); pointer-events: none; }
.search-input-wrap input { display: block; width: 100%; min-height: 52px; padding: 12px 56px 12px 48px; background: var(--bg-card); border: 1px solid var(--border); border-radius: 14px; color: var(--text-main); font-size: 16px; box-shadow: var(--shadow-sm); }
.search-input-wrap input::placeholder { color: var(--text-muted); opacity: 1; }
.search-input-wrap input::-webkit-search-cancel-button { -webkit-appearance: none; }
#clear-search { position: absolute; right: 5px; top: 4px; width: 44px; height: 44px; border: 0; border-radius: 10px; background: transparent; color: var(--text-muted); }
#clear-search:hover { background: var(--bg-subtle); }
.filter-tabs { display: flex; flex-wrap: wrap; gap: 8px; }
.filter-tab { min-height: 44px; padding: 9px 16px; border: 1px solid var(--border); border-radius: 999px; color: var(--text-muted); background: var(--bg-card); font-size: 13px; font-weight: 600; }
.filter-tab:hover { color: var(--primary); border-color: var(--primary); }
.filter-tab[aria-pressed='true'] { color: white; background: #1d4ed8; border-color: #1d4ed8; }
.noscript-note { color: var(--text-muted); margin-bottom: 20px; }

.tools-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 22px; align-items: stretch; }
.tool-card { min-width: 0; display: flex; flex-direction: column; border: 1px solid var(--border); border-radius: 18px; background: var(--bg-card); overflow: hidden; box-shadow: var(--shadow-sm); transition: border-color 160ms ease, box-shadow 160ms ease; }
.tool-card:hover, .tool-card:focus-within { border-color: var(--primary); box-shadow: 0 6px 20px rgb(29 78 216 / 8%); }
.tool-card-banner { background: #f1f5f9; height: 120px; overflow: hidden; }
.tool-card-banner img { display: block; width: 100%; height: 100%; object-fit: contain; }
/* Match each artwork's bounds inside the padded 640 x 360 preview files. */
.banner-passport { --banner-ratio: 16 / 9; }
.banner-cnc { --banner-ratio: 16 / 9; }
.banner-compressor { --banner-ratio: 16 / 9; }
.banner-resume, .banner-chat { --banner-ratio: 16 / 9; }
.banner-receipt, .banner-salary, .banner-splitter, .banner-cad { --banner-ratio: 16 / 9; }
.catalog-card .tool-card-banner { width: 100%; height: auto; aspect-ratio: var(--banner-ratio, 16 / 9); border-radius: 0; flex-shrink: 0; }
.catalog-card .tool-card-banner img { object-fit: cover; }
.tool-card-content { flex: 1; display: flex; flex-direction: column; align-items: flex-start; padding: 22px; }
.tool-category-badge { color: var(--primary); font-size: 11px; font-weight: 700; letter-spacing: 0.35px; text-transform: uppercase; }
.tool-card h3 { margin: 7px 0 10px; font-size: 19px; font-weight: 750; line-height: 1.35; letter-spacing: -0.55px; }
.tool-card p { margin-bottom: 20px; color: var(--text-muted); font-size: 14px; line-height: 1.6; }
.tool-link { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 44px; width: 100%; margin-top: auto; padding: 10px 14px; border-radius: 10px; background: var(--bg-subtle); color: var(--primary); font-size: 13px; font-weight: 700; text-decoration: none; }
.tool-link:hover { background: #1d4ed8; color: white; }
.empty-state { border: 1px dashed var(--border); border-radius: 18px; background: var(--bg-card); padding: 40px 20px; text-align: center; }
.empty-state > i { color: var(--primary); font-size: 24px; margin-bottom: 14px; }
.empty-state h3 { font-size: 21px; margin-bottom: 8px; }
.empty-state p { color: var(--text-muted); margin-bottom: 20px; overflow-wrap: anywhere; }

.install-note { max-width: 1136px; margin: 36px auto 0; padding: 24px; border: 1px solid var(--border); border-radius: 16px; background: var(--bg-card); display: flex; align-items: center; justify-content: space-between; gap: 24px; }
.install-note h2 { font-size: 18px; margin-bottom: 4px; letter-spacing: -0.4px; }
.install-note p { font-size: 14px; color: var(--text-muted); }
.install-btn { display: inline-flex; align-items: center; justify-content: center; gap: 9px; min-height: 44px; flex-shrink: 0; padding: 10px 16px; background: var(--bg-card); color: var(--primary); border: 1px solid var(--border); border-radius: 12px; font-size: 14px; font-weight: 650; }
.install-btn:hover { border-color: var(--primary); background: var(--bg-subtle); }
@media (display-mode: standalone) { .install-note { display: none; } }

.main-footer { margin-top: 48px; padding: 38px 24px 24px; background: var(--bg-card); border-top: 1px solid var(--border); }
.footer-inner { max-width: 1136px; margin: 0 auto; display: grid; grid-template-columns: 1.2fr 1fr 1fr 1fr; gap: 32px; }
.footer-brand h3 { font-size: 18px; margin-bottom: 10px; letter-spacing: -0.4px; }
.footer-brand p { color: var(--text-muted); font-size: 13px; }
.footer-col h4 { font-size: 12px; font-weight: 750; letter-spacing: 0.6px; text-transform: uppercase; margin-bottom: 12px; }
.footer-col ul { list-style: none; padding: 0; margin: 0; }
.footer-col li { margin-bottom: 10px; }
.footer-col a { color: var(--text-muted); font-size: 13px; text-decoration: none; }
.footer-col a:hover { color: var(--primary); text-decoration: underline; }
.footer-bottom { max-width: 1136px; margin: 28px auto 0; padding-top: 20px; border-top: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 16px; color: var(--text-muted); font-size: 12px; }
.footer-bottom-links { display: flex; flex-wrap: wrap; gap: 16px; }
.footer-bottom-links a { color: var(--text-muted); text-decoration: none; }
.footer-bottom-links a:hover { text-decoration: underline; }

@media (max-width: 1184px) { .install-note { margin-left: 24px; margin-right: 24px; } }
@media (max-width: 900px) {
  .tools-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
  .footer-inner { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 600px) {
  .top-bar { padding: 10px 16px; gap: 8px; }
  .brand-link { font-size: 17px; gap: 6px; }
  .brand-link span, .about-link { display: none; }
  .top-actions { gap: 8px; }
  .top-actions .btn-primary { padding: 9px 12px; font-size: 12px; gap: 6px; }
  .theme-toggle-btn { width: 44px; height: 44px; }
  .hero { padding: 24px 18px; }
  .hero h1 { font-size: 28px; line-height: 1.18; letter-spacing: -1px; }
  .hero-eyebrow { font-size: 12px; margin-bottom: 10px; }
  .hero-description { margin-top: 12px; font-size: 14px; line-height: 1.6; }
  .directory { padding: 0 16px; }
  .directory-heading { margin-bottom: 12px; }
  .directory-heading h2 { font-size: 18px; }
  .directory-heading p { font-size: 12px; max-width: 45%; }
  .directory-controls { margin-bottom: 18px; }
  .search-input-wrap input { padding-left: 42px; }
  .search-input-wrap > i { left: 15px; }
  .filter-tabs { gap: 6px; }
  .filter-tab { padding: 8px 12px; font-size: 12px; }
  .tools-grid { grid-template-columns: minmax(0, 1fr); gap: 12px; }
  .tool-card { display: grid; grid-template-columns: 80px minmax(0, 1fr); align-items: start; gap: 14px; padding: 16px; border-radius: 14px; }
  .tool-card-banner { width: 80px; height: 80px; aspect-ratio: 1; border-radius: 10px; }
  .tool-card-banner img { object-fit: contain; }
  .tool-card-content { padding: 0; min-width: 0; }
  .tool-category-badge { font-size: 10px; }
  .tool-card h3 { margin: 5px 0 6px; font-size: 17px; letter-spacing: -0.4px; }
  .tool-card p { font-size: 13px; margin-bottom: 10px; line-height: 1.5; }
  .tool-link { font-size: 12px; padding: 9px 10px; }
  .install-note { margin: 24px 16px 0; padding: 20px; flex-direction: column; align-items: flex-start; gap: 16px; }
  .main-footer { margin-top: 28px; padding: 28px 16px 20px; }
  .footer-inner { gap: 24px 20px; }
  .footer-brand { grid-column: 1 / -1; }
  .footer-bottom { font-size: 11px; }
}
@media (max-width: 350px) {
  .top-actions .btn-primary i { display: none; }
  .tool-card { grid-template-columns: 60px minmax(0, 1fr); gap: 10px; padding: 12px; }
  .tool-card-banner { width: 60px; height: 60px; }
}
@media (max-width: 600px) {
  .tool-card.catalog-card { display: flex; flex-direction: column; align-items: stretch; gap: 0; padding: 0; }
  .catalog-card .tool-card-content { padding: 18px; }
  .catalog-card h3 { margin-top: 7px; font-size: 19px; }
  .catalog-card p { font-size: 14px; line-height: 1.6; margin-bottom: 16px; }
  .catalog-card .tool-link { font-size: 13px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}
