:root {
  --bg: #fbf7f5;
  --surface: #ffffff;
  --surface-2: #f4eeec;
  --text: #1c1a1c;
  --muted: #6b6570;
  --border: #e7ddd9;
  --love: #e6394a;
  --love-dark: #c02638;
  --hate: #2b2140;
  --accent: #6c4bd8;
  --ok: #1c9d6b;
  --shadow: 0 1px 2px rgba(0, 0, 0, .05), 0 8px 24px rgba(60, 30, 30, .07);
  --radius: 14px;
  --maxw: 1080px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #16131a;
    --surface: #201c28;
    --surface-2: #2a2533;
    --text: #f3eef7;
    --muted: #a79fb2;
    --border: #332c3f;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 10px 30px rgba(0, 0, 0, .35);
  }
}

* { 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;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; }
h1, h2, h3 { line-height: 1.2; letter-spacing: -0.02em; }

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

/* Header */
.site-header {
  position: sticky; top: 0; z-index: 50;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(180%) blur(10px);
  border-bottom: 1px solid var(--border);
}
.site-header::after {
  content: ""; position: fixed; inset: 62px 0 0; background: rgba(18, 13, 24, .32);
  opacity: 0; pointer-events: none; transition: opacity .16s ease; z-index: 1;
}
.site-header:has(.mega-menu[open])::after { opacity: 1; pointer-events: auto; }
.site-header .wrap { display: flex; align-items: center; justify-content: space-between; height: 62px; }
.header-inner { position: relative; z-index: 2; }
.brand { display: flex; align-items: center; gap: 9px; font-weight: 800; font-size: 1.12rem; color: var(--text); }
.brand:hover { text-decoration: none; }
.brand .love { color: var(--love); }
.brand .hate { color: var(--muted); }
.brand-mark {
  width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center;
  background: linear-gradient(140deg, var(--love), var(--accent)); color: #fff; font-size: 15px;
}
.footer-brand { font-size: 1rem; margin-bottom: 8px; }
.footer-mark { width: 24px; height: 24px; font-size: 12px; }
.footer-copyright { margin-top: 10px; }
.centered-prose, .not-found { text-align: center; }
.not-found { padding: 60px 0; }
.nav-links { display: flex; gap: 18px; align-items: center; }
.nav-links > a { color: var(--muted); font-weight: 650; font-size: .93rem; }
.nav-links a:hover { color: var(--text); text-decoration: none; }
.mega-menu { position: static; }
.mega-menu summary {
  display: flex; align-items: center; gap: 6px; cursor: pointer; list-style: none;
  color: var(--text); font-weight: 750; font-size: .93rem; padding: 8px 11px;
  border: 1px solid var(--border); border-radius: 9px; background: var(--surface);
}
.mega-menu summary::-webkit-details-marker { display: none; }
.mega-menu summary span { font-size: 1rem; transition: transform .15s ease; }
.mega-menu[open] summary { border-color: var(--accent); }
.mega-menu[open] summary span { transform: rotate(180deg); }
.mega-menu summary:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--accent) 70%, white);
  outline-offset: 3px;
}
.mega-panel {
  position: fixed; top: 70px; left: 50%; transform: translateX(-50%);
  width: min(1040px, calc(100vw - 32px)); max-height: calc(100vh - 86px); overflow: auto;
  background: color-mix(in srgb, var(--surface) 97%, transparent); border: 1px solid var(--border);
  border-radius: 16px; box-shadow: 0 24px 70px rgba(24, 16, 30, .2); padding: 20px;
  overscroll-behavior: contain;
  z-index: 3;
}
.mega-heading { display: flex; justify-content: space-between; align-items: center; gap: 20px; padding-bottom: 16px; border-bottom: 1px solid var(--border); }
.mega-heading > div { display: flex; flex-direction: column; }
.mega-heading strong { font-size: 1.05rem; }
.mega-heading span { color: var(--muted); font-size: .82rem; }
.mega-search { width: min(320px, 42vw); }
.mega-search input {
  width: 100%; border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px;
  background: var(--surface-2); color: var(--text); font: inherit;
}
.mega-search input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.mega-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 22px 24px; padding-top: 18px; }
.mega-group h2 { font-size: .78rem; text-transform: uppercase; letter-spacing: .09em; margin: 0 0 7px; }
.mega-group h2 a { color: var(--love); }
.mega-tool { display: flex; align-items: center; gap: 8px; min-height: 29px; color: var(--text); font-size: .86rem; border-radius: 7px; padding: 3px 5px; }
.mega-tool:hover { background: var(--surface-2); }
.mega-icon {
  width: 27px; height: 27px; display: grid; place-items: center; flex: 0 0 27px;
  border-radius: 8px; background: color-mix(in srgb, var(--accent) 13%, var(--surface-2));
  font-size: .86rem;
}
.mega-group[data-group="organize"] .mega-icon { background: color-mix(in srgb, #ff4d5e 17%, var(--surface-2)); }
.mega-group[data-group="edit"] .mega-icon { background: color-mix(in srgb, #7c4dff 17%, var(--surface-2)); }
.mega-group[data-group="optimize"] .mega-icon { background: color-mix(in srgb, #16a36a 17%, var(--surface-2)); }
.mega-group[data-group="convert"] .mega-icon { background: color-mix(in srgb, #ff7a00 17%, var(--surface-2)); }
.mega-group[data-group="security"] .mega-icon { background: color-mix(in srgb, #e80046 17%, var(--surface-2)); }
.mega-group[data-group="image"] .mega-icon { background: color-mix(in srgb, #0b82f6 17%, var(--surface-2)); }
.mega-group[data-group="intelligence"] .mega-icon { background: color-mix(in srgb, #5837e8 17%, var(--surface-2)); }
.mega-empty { text-align: center; color: var(--muted); padding: 28px 0 10px; margin: 0; }
.visually-hidden {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}
@media (max-width: 800px) {
  .popular-link { display: none; }
  .mega-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (min-width: 801px) and (max-width: 1000px) { .mega-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
@media (max-width: 540px) {
  .site-header .wrap { padding: 0 12px; }
  .brand { font-size: 1rem; }
  .brand-mark { width: 28px; height: 28px; }
  .nav-links { gap: 8px; }
  .nav-links > a { display: none; }
  .mega-menu summary { padding: 7px 10px; }
  .mega-panel { top: 66px; width: calc(100vw - 20px); padding: 15px; max-height: calc(100vh - 76px); }
  .mega-heading { align-items: stretch; flex-direction: column; gap: 10px; }
  .mega-search { width: 100%; }
  .mega-grid { grid-template-columns: 1fr; gap: 18px; }
}

/* Hero */
.hero { text-align: center; padding: 70px 0 40px; }
.hero h1 { font-size: clamp(2rem, 5vw, 3.3rem); margin: 0 0 16px; }
.hero h1 .love { color: var(--love); }
.hero p.lead { font-size: 1.15rem; color: var(--muted); max-width: 620px; margin: 0 auto 22px; }
.badges { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-top: 8px; }
.badge {
  background: var(--surface); border: 1px solid var(--border); border-radius: 999px;
  padding: 6px 14px; font-size: .85rem; font-weight: 600; color: var(--muted);
  box-shadow: var(--shadow);
}
.badge b { color: var(--text); }

.tool-finder {
  display: flex; align-items: center; justify-content: space-between; gap: 24px;
  margin: 12px 0 4px; padding: 18px 20px; border: 1px solid var(--border);
  border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow);
}
.tool-finder h2 { font-size: 1.05rem; margin: 0 0 2px; }
.tool-finder p { color: var(--muted); font-size: .85rem; margin: 0; }
.home-search { width: min(440px, 50%); }
.home-search input {
  width: 100%; padding: 12px 14px 12px 42px; border: 1px solid var(--border); border-radius: 11px;
  background: var(--surface-2) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18' viewBox='0 0 24 24' fill='none' stroke='%236b6570' stroke-width='2'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='m20 20-3.5-3.5'/%3E%3C/svg%3E") no-repeat 14px center;
  color: var(--text); font: inherit;
}
.home-search input:focus { outline: 3px solid color-mix(in srgb, var(--accent) 70%, white); outline-offset: 2px; }
.home-empty { text-align: center; color: var(--muted); padding: 38px 16px 8px; }
@media (max-width: 640px) {
  .hero { padding-top: 48px; }
  .tool-finder { align-items: stretch; flex-direction: column; gap: 12px; }
  .home-search { width: 100%; }
}

/* Tool grid */
.section-title { font-size: 1.4rem; margin: 40px 0 4px; }
.section-sub { color: var(--muted); margin: 0 0 20px; }
.grid {
  display: grid; gap: 14px;
  grid-template-columns: repeat(auto-fill, minmax(215px, 1fr));
}
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px; box-shadow: var(--shadow); transition: transform .12s ease, border-color .12s ease;
  display: block; color: var(--text);
}
.card:hover { transform: translateY(-3px); border-color: var(--love); text-decoration: none; }
.card .icon { font-size: 1.7rem; }
.card h3 { margin: 8px 0 4px; font-size: 1.05rem; }
.card p { margin: 0; color: var(--muted); font-size: .9rem; }
.card .group-tag { font-size: .72rem; text-transform: uppercase; letter-spacing: .08em; color: var(--love); font-weight: 700; }

/* Tool page */
.tool-head { text-align: center; padding: 44px 0 10px; }
.tool-head .icon { font-size: 3rem; }
.tool-head h1 { font-size: clamp(1.8rem, 4vw, 2.6rem); margin: 10px 0 8px; }
.tool-head p { color: var(--muted); max-width: 560px; margin: 0 auto; }

.panel {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 24px; margin: 24px 0;
}

.dropzone {
  border: 2px dashed var(--border); border-radius: var(--radius);
  padding: 46px 20px; text-align: center; cursor: pointer;
  transition: border-color .15s ease, background .15s ease; background: var(--surface-2);
}
.dropzone.drag { border-color: var(--love); background: color-mix(in srgb, var(--love) 8%, var(--surface)); }
.dropzone:focus-visible, .btn:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--accent) 70%, white);
  outline-offset: 3px;
}
.dropzone strong { display: block; font-size: 1.05rem; margin-bottom: 4px; }
.dropzone span { color: var(--muted); font-size: .9rem; }

.filelist { list-style: none; margin: 18px 0 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.filelist li {
  display: flex; align-items: center; gap: 10px; background: var(--surface-2);
  border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; font-size: .92rem;
}
.filelist li .fname { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.filelist li .fsize { color: var(--muted); font-size: .82rem; }
.filelist li .drag-handle { cursor: grab; color: var(--muted); }
.filelist li button.remove {
  background: none; border: none; color: var(--muted); cursor: pointer; font-size: 1.1rem; line-height: 1;
}
.filelist li button.remove:hover { color: var(--love); }
.filelist li.dragging { opacity: .4; }

.options { display: grid; gap: 16px; margin-top: 20px; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.field label { display: block; font-weight: 600; font-size: .9rem; margin-bottom: 6px; }
.field input[type=text], .field input[type=number], .field select {
  width: 100%; padding: 9px 11px; border: 1px solid var(--border); border-radius: 9px;
  background: var(--surface); color: var(--text); font: inherit; font-size: .92rem;
}
.field input[type=range] { width: 100%; }
.field textarea {
  width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: 9px;
  background: var(--surface); color: var(--text); font: inherit; font-size: .92rem;
  resize: vertical; min-height: 90px;
}
.field .hint { color: var(--muted); font-size: .8rem; margin-top: 4px; }
.field.checkbox { display: flex; align-items: center; gap: 8px; }
.field.checkbox label { margin: 0; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  background: var(--love); color: #fff; border: none; border-radius: 10px;
  padding: 13px 26px; font: inherit; font-weight: 700; font-size: 1rem; cursor: pointer;
  transition: background .12s ease, transform .12s ease;
}
.btn:hover { background: var(--love-dark); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.block { width: 100%; margin-top: 22px; }
.btn.ghost { background: var(--surface-2); color: var(--text); border: 1px solid var(--border); }
.btn.ghost:hover { background: var(--border); }

.progress { margin-top: 20px; }
.progress .bar { height: 8px; background: var(--surface-2); border-radius: 999px; overflow: hidden; }
.progress .bar i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--love), var(--accent)); transition: width .2s ease; }
.progress .label { text-align: center; color: var(--muted); font-size: .88rem; margin-top: 8px; }

.result { text-align: center; padding: 30px 20px; }
.result .big { font-size: 2.4rem; }
.result h3 { margin: 10px 0 6px; }
.result p { color: var(--muted); margin: 0 0 18px; }

.alert { background: color-mix(in srgb, var(--love) 12%, var(--surface)); border: 1px solid var(--love); color: var(--love-dark); border-radius: 10px; padding: 12px 14px; font-size: .9rem; margin-top: 16px; }
@media (prefers-color-scheme: dark) { .alert { color: #ffb3ba; } }

/* thumbnails (organize) */
.thumbs { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 14px; margin-top: 20px; }
.thumb {
  position: relative; border: 1px solid var(--border); border-radius: 10px; overflow: hidden;
  background: var(--surface-2); cursor: grab;
}
.thumb canvas { display: block; width: 100%; height: auto; background: #fff; }
.thumb .pageno { position: absolute; left: 6px; bottom: 6px; background: rgba(0,0,0,.65); color: #fff; font-size: .72rem; padding: 2px 6px; border-radius: 6px; }
.thumb .ctrls { position: absolute; top: 6px; right: 6px; display: flex; gap: 4px; }
.thumb .ctrls button { border: none; background: rgba(0,0,0,.65); color: #fff; width: 24px; height: 24px; border-radius: 6px; cursor: pointer; font-size: .8rem; line-height: 1; }
.thumb .ctrls button:hover { background: var(--love); }
.thumb.dragging { opacity: .35; }
.thumb.removed { display: none; }

/* content sections */
.prose { max-width: 720px; margin: 30px auto; }
.prose h2 { font-size: 1.3rem; margin-top: 28px; }
.faq details { border-bottom: 1px solid var(--border); padding: 14px 0; }
.faq summary { font-weight: 600; cursor: pointer; }
.faq p { color: var(--muted); margin: 10px 0 0; }

.related { margin: 40px 0; }
.related .grid { grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); }

/* footer */
.site-footer { border-top: 1px solid var(--border); margin-top: 60px; padding: 34px 0; color: var(--muted); font-size: .88rem; }
.site-footer .wrap { display: flex; justify-content: space-between; gap: 20px; flex-wrap: wrap; }
.site-footer a { color: var(--muted); }
.site-footer .cols { display: flex; gap: 40px; flex-wrap: wrap; }
.site-footer .cols div { display: flex; flex-direction: column; gap: 6px; }
.site-footer .cols b { color: var(--text); margin-bottom: 2px; }

/* preview (image tools) */
.preview-mount { margin-top: 20px; text-align: center; }
.preview-mount canvas, .preview-mount img {
  max-width: 100%; max-height: 460px; border: 1px solid var(--border);
  border-radius: 10px; background: #fff; box-shadow: var(--shadow);
}
.preview-mount .hint { margin-top: 8px; }

.result-text {
  text-align: left; white-space: pre-wrap; word-break: break-word;
  max-height: 320px; overflow: auto; background: var(--surface-2);
  border: 1px solid var(--border); border-radius: 10px; padding: 14px;
  font: 12.5px/1.5 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  margin: 0 0 18px;
}

.hidden { display: none !important; }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
}
