/* BrainyWorks — design system.
   Single stylesheet, no framework, no external fonts. Light and dark are both
   first-class: every colour is a variable, and the toggle stamps data-theme on <html>. */

:root {
  --bg:            #f6f7fb;
  --surface:       #ffffff;
  --surface-2:     #f0f2f7;
  --border:        #e2e6ef;
  --border-strong: #cbd3e1;
  --text:          #10141f;
  --text-muted:    #5b6478;
  --text-faint:    #8a93a6;

  --brand:         #4f46e5;
  --brand-hover:   #4338ca;
  --brand-soft:    #eef0fe;
  --brand-text:    #ffffff;

  --security:      #dc2626;
  --security-soft: #fef2f2;
  --organise:      #2563eb;
  --organise-soft: #eff6ff;
  --optimise:      #059669;
  --optimise-soft: #ecfdf5;
  --convert:       #d97706;
  --convert-soft:  #fffbeb;

  --danger:        #dc2626;
  --danger-soft:   #fef2f2;
  --success:       #16a34a;
  --success-soft:  #f0fdf4;

  --radius:    14px;
  --radius-sm: 9px;
  --shadow:    0 1px 2px rgba(16,20,31,.06), 0 8px 24px rgba(16,20,31,.06);
  --shadow-lg: 0 2px 4px rgba(16,20,31,.06), 0 18px 44px rgba(16,20,31,.12);
  --wrap: 1140px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root[data-theme="auto"] {
    --bg: #0d1017; --surface: #151a24; --surface-2: #1b2130;
    --border: #262d3d; --border-strong: #37405480;
    --text: #eef1f7; --text-muted: #9aa4b8; --text-faint: #6f7994;
    --brand: #7c7ff2; --brand-hover: #9497f5; --brand-soft: #1e2138; --brand-text: #0d1017;
    --security-soft: #2a1417; --organise-soft: #141d30; --optimise-soft: #10241c; --convert-soft: #2a1f0f;
    --danger-soft: #2a1417; --success-soft: #10241c;
    --shadow: 0 1px 2px rgba(0,0,0,.4), 0 8px 24px rgba(0,0,0,.3);
    --shadow-lg: 0 2px 4px rgba(0,0,0,.4), 0 18px 44px rgba(0,0,0,.45);
  }
}
:root[data-theme="dark"] {
  --bg: #0d1017; --surface: #151a24; --surface-2: #1b2130;
  --border: #262d3d; --border-strong: #374054;
  --text: #eef1f7; --text-muted: #9aa4b8; --text-faint: #6f7994;
  --brand: #7c7ff2; --brand-hover: #9497f5; --brand-soft: #1e2138; --brand-text: #0d1017;
  --security-soft: #2a1417; --organise-soft: #141d30; --optimise-soft: #10241c; --convert-soft: #2a1f0f;
  --danger-soft: #2a1417; --success-soft: #10241c;
  --shadow: 0 1px 2px rgba(0,0,0,.4), 0 8px 24px rgba(0,0,0,.3);
  --shadow-lg: 0 2px 4px rgba(0,0,0,.4), 0 18px 44px rgba(0,0,0,.45);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font-family: var(--font); font-size: 16px; line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { line-height: 1.22; margin: 0 0 .5em; letter-spacing: -.02em; }
h1 { font-size: clamp(1.9rem, 4.5vw, 3rem); font-weight: 750; }
h2 { font-size: clamp(1.35rem, 2.6vw, 1.9rem); font-weight: 700; }
h3 { font-size: 1.12rem; font-weight: 650; }
p { margin: 0 0 1rem; }
.muted { color: var(--text-muted); }
.small { font-size: .875rem; }
.wrap { max-width: var(--wrap); margin: 0 auto; padding: 0 20px; }
.skip {
  position: absolute; left: -9999px; top: 0; background: var(--brand);
  color: var(--brand-text); padding: 10px 16px; z-index: 100; border-radius: 0 0 8px 0;
}
.skip:focus { left: 0; }
svg.ico, svg.brand-mark, svg.chev {
  width: 20px; height: 20px; fill: none; stroke: currentColor;
  stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; flex: none;
}

/* ---------- header ---------- */
.site-header {
  position: sticky; top: 0; z-index: 50; background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: saturate(180%) blur(12px); border-bottom: 1px solid var(--border);
}
.header-inner { display: flex; align-items: center; justify-content: space-between; height: 62px; gap: 16px; }
.brand { display: inline-flex; align-items: center; gap: 9px; font-weight: 700; font-size: 1.06rem; color: var(--text); }
.brand:hover { text-decoration: none; }
.brand-mark { width: 26px; height: 26px; color: var(--brand); }
.site-nav { display: flex; align-items: center; gap: 4px; }
.nav-link {
  display: inline-flex; align-items: center; gap: 5px; padding: 8px 12px;
  border-radius: var(--radius-sm); color: var(--text-muted); font-weight: 550;
  font-size: .93rem; background: none; border: 0; cursor: pointer; font-family: inherit;
}
.nav-link:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.chev { width: 15px; height: 15px; stroke-width: 2.4; transition: transform .18s; }
.dropdown { position: relative; }
.dropdown.open .chev { transform: rotate(180deg); }
.dropdown-menu {
  position: absolute; right: 0; top: calc(100% + 8px); min-width: 560px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow-lg); padding: 14px; display: none;
  grid-template-columns: repeat(2, 1fr); gap: 6px 18px;
}
.dropdown.open .dropdown-menu { display: grid; }
.dropdown-heading {
  font-size: .7rem; text-transform: uppercase; letter-spacing: .09em;
  color: var(--text-faint); font-weight: 700; margin: 8px 8px 4px;
}
.dropdown-item {
  display: flex; align-items: center; gap: 10px; padding: 8px 9px;
  border-radius: var(--radius-sm); color: var(--text); font-size: .9rem;
}
.dropdown-item:hover { background: var(--surface-2); text-decoration: none; }
.dropdown-item .ico { width: 17px; height: 17px; color: var(--text-muted); }
.theme-toggle {
  display: inline-flex; align-items: center; justify-content: center; width: 38px; height: 38px;
  border-radius: var(--radius-sm); border: 1px solid var(--border); background: var(--surface);
  color: var(--text-muted); cursor: pointer; margin-left: 6px;
}
.theme-toggle:hover { color: var(--text); border-color: var(--border-strong); }
.theme-toggle .moon { display: none; }
:root[data-theme="dark"] .theme-toggle .sun { display: none; }
:root[data-theme="dark"] .theme-toggle .moon { display: block; }
@media (prefers-color-scheme: dark) {
  :root[data-theme="auto"] .theme-toggle .sun { display: none; }
  :root[data-theme="auto"] .theme-toggle .moon { display: block; }
}

/* ---------- hero ---------- */
.hero { padding: 68px 0 44px; text-align: center; }
.hero .eyebrow {
  display: inline-flex; align-items: center; gap: 7px; padding: 5px 13px; border-radius: 999px;
  background: var(--brand-soft); color: var(--brand); font-size: .8rem; font-weight: 650;
  margin-bottom: 18px; border: 1px solid color-mix(in srgb, var(--brand) 22%, transparent);
}
.hero p.lead { font-size: 1.12rem; color: var(--text-muted); max-width: 640px; margin: 0 auto 22px; }
.hero-badges { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.badge {
  display: inline-flex; align-items: center; gap: 6px; padding: 6px 13px; border-radius: 999px;
  background: var(--surface); border: 1px solid var(--border); font-size: .84rem; color: var(--text-muted);
}
.badge .ico { width: 15px; height: 15px; color: var(--success); }

/* ---------- tool grid ---------- */
.section { padding: 30px 0 12px; }
.section-head { display: flex; align-items: baseline; gap: 12px; margin-bottom: 18px; }
.section-head h2 { margin: 0; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(266px, 1fr)); gap: 16px; }
.tool-card {
  display: flex; flex-direction: column; gap: 9px; padding: 20px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  color: var(--text); transition: transform .15s ease, box-shadow .15s ease, border-color .15s;
}
.tool-card:hover {
  text-decoration: none; transform: translateY(-3px);
  box-shadow: var(--shadow-lg); border-color: var(--border-strong);
}
.tool-icon {
  width: 42px; height: 42px; border-radius: 11px; display: grid; place-items: center;
  background: var(--brand-soft); color: var(--brand);
}
.tool-icon .ico { width: 21px; height: 21px; }
.tool-card[data-cat="Security"] .tool-icon { background: var(--security-soft); color: var(--security); }
.tool-card[data-cat="Organise"] .tool-icon { background: var(--organise-soft); color: var(--organise); }
.tool-card[data-cat="Optimise"] .tool-icon { background: var(--optimise-soft); color: var(--optimise); }
.tool-card[data-cat="Convert"] .tool-icon  { background: var(--convert-soft);  color: var(--convert); }
.tool-card h3 { margin: 0; font-size: 1.02rem; }
.tool-card p { margin: 0; font-size: .89rem; color: var(--text-muted); }
.tag {
  align-self: flex-start; font-size: .68rem; font-weight: 700; letter-spacing: .07em;
  text-transform: uppercase; padding: 3px 8px; border-radius: 5px;
  background: var(--security-soft); color: var(--security);
}

/* ---------- tool page ---------- */
.tool-hero { padding: 34px 0 18px; display: flex; gap: 18px; align-items: flex-start; }
.tool-hero .tool-icon { width: 52px; height: 52px; border-radius: 13px; }
.tool-hero .tool-icon .ico { width: 26px; height: 26px; }
.tool-hero h1 { font-size: clamp(1.6rem, 3.4vw, 2.15rem); margin-bottom: 6px; }
.tool-hero p { margin: 0; color: var(--text-muted); max-width: 720px; }
.tool-layout { display: grid; grid-template-columns: minmax(0, 1fr) 330px; gap: 22px; padding-bottom: 56px; }
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 22px; }
.panel + .panel { margin-top: 16px; }
.panel h3 { margin-top: 0; }

.dropzone {
  border: 2px dashed var(--border-strong); border-radius: var(--radius); padding: 42px 20px;
  text-align: center; cursor: pointer; background: var(--surface-2);
  transition: border-color .15s, background .15s; position: relative;
}
.dropzone:hover, .dropzone.dragover { border-color: var(--brand); background: var(--brand-soft); }
.dropzone .ico { width: 34px; height: 34px; color: var(--brand); margin-bottom: 8px; }
.dropzone strong { display: block; font-size: 1.02rem; }
.dropzone input[type=file] { display: none; }

.filelist { list-style: none; margin: 16px 0 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.filelist li {
  display: flex; align-items: center; gap: 11px; padding: 10px 13px;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm);
  font-size: .89rem;
}
.filelist .fname { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.filelist .fsize { color: var(--text-faint); font-size: .82rem; flex: none; }
.filelist button {
  border: 0; background: none; color: var(--text-faint); cursor: pointer; padding: 3px;
  display: grid; place-items: center; border-radius: 5px;
}
.filelist button:hover { color: var(--danger); background: var(--danger-soft); }
.filelist .drag { cursor: grab; color: var(--text-faint); }
.filelist li.dragging { opacity: .45; }

.field { margin-bottom: 15px; }
.field label { display: block; font-weight: 600; font-size: .88rem; margin-bottom: 5px; }
.field .hint { font-size: .8rem; color: var(--text-faint); margin-top: 4px; }
.field input[type=text], .field input[type=number], .field select {
  width: 100%; padding: 9px 11px; border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text);
  font-family: inherit; font-size: .92rem;
}
.field input:focus, .field select:focus { outline: 2px solid var(--brand); outline-offset: 1px; border-color: var(--brand); }
.field.check { display: flex; align-items: flex-start; gap: 9px; }
.field.check input { margin-top: 3px; width: 16px; height: 16px; accent-color: var(--brand); }
.field.check label { font-weight: 500; margin: 0; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 12px 20px; border-radius: var(--radius-sm); border: 1px solid transparent;
  background: var(--brand); color: var(--brand-text); font-weight: 650; font-size: .95rem;
  cursor: pointer; font-family: inherit; width: 100%;
}
.btn:hover:not(:disabled) { background: var(--brand-hover); text-decoration: none; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.secondary { background: var(--surface); color: var(--text); border-color: var(--border-strong); }
.btn.secondary:hover:not(:disabled) { background: var(--surface-2); }
.btn.success { background: var(--success); color: #fff; }

.spinner {
  width: 16px; height: 16px; border: 2px solid currentColor; border-right-color: transparent;
  border-radius: 50%; animation: spin .7s linear infinite; display: none;
}
.is-busy .spinner { display: block; }
@keyframes spin { to { transform: rotate(360deg); } }

.alert { padding: 13px 16px; border-radius: var(--radius-sm); font-size: .9rem; margin-top: 16px; }
.alert.error { background: var(--danger-soft); color: var(--danger); border: 1px solid color-mix(in srgb, var(--danger) 30%, transparent); }
.alert.ok { background: var(--success-soft); color: var(--success); border: 1px solid color-mix(in srgb, var(--success) 30%, transparent); }

.result { margin-top: 18px; display: none; }
.result.show { display: block; }
.result-card {
  border: 1px solid var(--border); border-radius: var(--radius); padding: 20px;
  background: var(--surface-2); text-align: center;
}
.result-card .ico { width: 36px; height: 36px; color: var(--success); margin-bottom: 6px; }
.report-frame {
  border: 1px solid var(--border); border-radius: var(--radius); padding: 4px;
  background: #fff; overflow-x: auto; margin-top: 14px;
}
.sidebar .panel { position: sticky; top: 80px; }
.steps { list-style: none; margin: 0; padding: 0; counter-reset: s; }
.steps li { counter-increment: s; padding-left: 34px; position: relative; margin-bottom: 12px; font-size: .89rem; color: var(--text-muted); }
.steps li::before {
  content: counter(s); position: absolute; left: 0; top: -1px; width: 23px; height: 23px;
  border-radius: 50%; background: var(--brand-soft); color: var(--brand);
  display: grid; place-items: center; font-size: .76rem; font-weight: 700;
}
.privacy-note {
  display: flex; gap: 11px; padding: 14px; border-radius: var(--radius-sm);
  background: var(--success-soft); border: 1px solid color-mix(in srgb, var(--success) 26%, transparent);
  font-size: .85rem; color: var(--text); margin-top: 16px;
}
.privacy-note .ico { color: var(--success); width: 18px; height: 18px; }

/* ---------- prose ---------- */
.prose { max-width: 760px; padding: 34px 0 60px; }
.prose h2 { margin-top: 2em; }
.prose ul { padding-left: 1.2em; }
.prose li { margin-bottom: .45em; }
.prose code {
  font-family: var(--mono); font-size: .87em; background: var(--surface-2);
  padding: 2px 6px; border-radius: 5px; border: 1px solid var(--border);
}
.prose table { width: 100%; border-collapse: collapse; margin: 1.2em 0; font-size: .9rem; }
.prose th, .prose td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--border); }
.prose th { font-weight: 650; color: var(--text-muted); font-size: .82rem; text-transform: uppercase; letter-spacing: .05em; }

/* ---------- footer ---------- */
.site-footer { border-top: 1px solid var(--border); background: var(--surface); margin-top: 40px; }
.footer-inner {
  display: grid; grid-template-columns: 1.6fr repeat(auto-fit, minmax(130px, 1fr));
  gap: 28px; padding-top: 40px; padding-bottom: 28px;
}
.footer-heading { font-size: .78rem; text-transform: uppercase; letter-spacing: .08em; color: var(--text-faint); font-weight: 700; margin-bottom: 10px; }
.footer-col ul { list-style: none; margin: 0; padding: 0; }
.footer-col li { margin-bottom: 7px; }
.footer-col a { color: var(--text-muted); font-size: .89rem; }
.footer-col a:hover { color: var(--brand); }
.footer-brand p { margin-top: 10px; max-width: 280px; }
.footer-bottom {
  display: flex; justify-content: space-between; flex-wrap: wrap; gap: 10px;
  padding-top: 16px; padding-bottom: 26px; border-top: 1px solid var(--border);
}
.footer-bottom p { margin: 0; }

@media (max-width: 900px) {
  .tool-layout { grid-template-columns: 1fr; }
  .sidebar .panel { position: static; }
  .dropdown-menu { min-width: 0; width: calc(100vw - 40px); right: -8px; grid-template-columns: 1fr; max-height: 70vh; overflow-y: auto; }
}
@media (max-width: 620px) {
  .hero { padding: 44px 0 30px; }
  .site-nav .nav-link[href="/about"] { display: none; }
  .tool-hero { flex-direction: column; gap: 12px; }
  .footer-inner { grid-template-columns: 1fr 1fr; }
}
