/* Web Tool Portal - styles.  No external resources, no hard-coded URLs. */
:root {
  color-scheme: dark;
  --bg: #0f1115;
  --bg-soft: #141821;
  --panel: #171c26;
  --panel-2: #1b212c;
  --border: #262d3a;
  --border-strong: #33404f;
  --text: #e6e8eb;
  --muted: #94a0ae;
  --muted-2: #6b7686;
  --accent: #5b9dff;
  --accent-strong: #3d84f0;
  --accent-soft: rgba(91, 157, 255, 0.14);
  --good: #46c08a;
  --warn: #e0a94a;
  --bad: #e5675f;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  --maxw: 1080px;
}

* { box-sizing: border-box; }

/* The hidden attribute must always win, even over author display rules. */
[hidden] { display: none !important; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: radial-gradient(1200px 600px at 20% -10%, #1a2030 0%, var(--bg) 55%) no-repeat;
  background-color: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

.wrap { width: 100%; max-width: var(--maxw); margin: 0 auto; padding: 0 1.25rem; }

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3 { line-height: 1.25; letter-spacing: -0.02em; }
h1 { font-size: clamp(1.6rem, 4vw, 2.3rem); margin: 0 0 .5rem; font-weight: 650; }
h2 { font-size: 1.15rem; margin: 0 0 .35rem; font-weight: 600; }

.visually-hidden {
  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: absolute; left: -999px; top: 0; background: var(--accent); color: #08101c;
  padding: .5rem .9rem; border-radius: 0 0 var(--radius-sm) 0; z-index: 100; font-weight: 600;
}
.skip-link:focus { left: 0; }

/* header ------------------------------------------------------------- */
.site-header {
  position: sticky; top: 0; z-index: 20;
  background: rgba(15, 17, 21, 0.82);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.header-inner { display: flex; align-items: center; justify-content: space-between; height: 60px; }
.brand {
  display: inline-flex; align-items: center; gap: .6rem;
  color: var(--text); font-weight: 650; letter-spacing: -0.01em;
}
.brand:hover { text-decoration: none; }
.brand-mark {
  width: 18px; height: 18px; border-radius: 5px;
  background: linear-gradient(135deg, var(--accent) 0%, #7f6bff 100%);
  box-shadow: 0 0 0 1px rgba(255,255,255,.06) inset;
}
.site-nav { display: flex; gap: 1.1rem; font-size: .95rem; }
.site-nav a { color: var(--muted); }
.site-nav a:hover { color: var(--text); text-decoration: none; }

/* main --------------------------------------------------------------- */
main.wrap { flex: 1 0 auto; padding-top: 2rem; padding-bottom: 3rem; }

.hero { margin-bottom: 1.5rem; }
.lede { color: var(--muted); margin: 0; max-width: 62ch; }
.hero-tool { margin-bottom: 1.25rem; }

.crumbs { font-size: .88rem; color: var(--muted-2); margin-bottom: .75rem; }
.crumbs a { color: var(--muted); }

/* search ------------------------------------------------------------- */
.search-row { display: flex; gap: .6rem; align-items: center; margin-bottom: 1rem; }
.search-input {
  flex: 1; min-width: 0;
  background: var(--panel); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: .8rem 1rem; font-size: 1rem; font-family: inherit;
  transition: border-color .15s, box-shadow .15s;
}
.search-input::placeholder { color: var(--muted-2); }
.search-input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

.filters { display: flex; flex-wrap: wrap; gap: .5rem; margin-bottom: 1.25rem; }
.chip {
  background: var(--panel); color: var(--muted); border: 1px solid var(--border);
  border-radius: 999px; padding: .35rem .9rem; font: inherit; font-size: .9rem; cursor: pointer;
  transition: all .15s;
}
.chip:hover { color: var(--text); border-color: var(--border-strong); }
.chip.is-active { background: var(--accent-soft); color: var(--accent); border-color: rgba(91,157,255,.45); }

/* status bar --------------------------------------------------------- */
.status-bar {
  display: flex; flex-wrap: wrap; align-items: center; gap: .55rem;
  background: var(--bg-soft); border: 1px solid var(--border); border-radius: var(--radius);
  padding: .7rem 1rem; margin-bottom: 1.5rem; font-size: .92rem; color: var(--muted);
}
.status-bar strong { color: var(--text); font-weight: 600; }
.status-bar .sep { color: var(--border-strong); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--good); display: inline-block; box-shadow: 0 0 8px rgba(70,192,138,.6); }

/* tool grid ---------------------------------------------------------- */
.tool-grid {
  display: grid; gap: 1rem;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
}
.tool-card {
  position: relative; display: flex; flex-direction: column;
  background: linear-gradient(180deg, var(--panel) 0%, var(--bg-soft) 100%);
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1.25rem; transition: border-color .18s, transform .18s, box-shadow .18s;
}
.tool-card:hover { border-color: var(--border-strong); transform: translateY(-2px); box-shadow: var(--shadow); }
.tool-icon {
  width: 40px; height: 40px; border-radius: 10px; display: grid; place-items: center;
  background: var(--accent-soft); color: var(--accent); margin-bottom: .85rem;
}
.tool-icon svg { width: 22px; height: 22px; }
.tool-name { font-size: 1.08rem; }
.tool-desc { color: var(--muted); margin: .15rem 0 .9rem; flex: 1; font-size: .95rem; }
.badge {
  align-self: flex-start; font-size: .74rem; text-transform: uppercase; letter-spacing: .06em;
  color: var(--muted); background: var(--panel-2); border: 1px solid var(--border);
  padding: .15rem .5rem; border-radius: 6px; margin-bottom: .9rem;
}
.tool-open { align-self: flex-start; }

.no-results { color: var(--muted); text-align: center; padding: 2.5rem 0; }

/* buttons ------------------------------------------------------------ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .45rem;
  border-radius: var(--radius-sm); padding: .6rem 1.1rem; font: inherit; font-weight: 600;
  font-size: .95rem; cursor: pointer; border: 1px solid transparent; transition: all .15s;
}
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--accent); color: #08101c; }
.btn-primary:hover { background: var(--accent-strong); }
.btn-primary:disabled { background: var(--panel-2); color: var(--muted-2); cursor: not-allowed; }
.btn-ghost { background: transparent; color: var(--muted); border-color: var(--border); }
.btn-ghost:hover { color: var(--text); border-color: var(--border-strong); }
.btn-donate { background: linear-gradient(135deg, #f2b34b, #e8873f); color: #241403; }
.btn-donate:hover { filter: brightness(1.06); }

/* forms / tool pages -------------------------------------------------- */
.tool-form { display: flex; flex-direction: column; gap: 1.25rem; }

.dropzone {
  display: grid; place-items: center; text-align: center; gap: .35rem;
  background: var(--bg-soft); border: 1.5px dashed var(--border-strong); border-radius: var(--radius);
  padding: 2.5rem 1.5rem; cursor: pointer; transition: border-color .18s, background .18s;
}
.dropzone:hover, .dropzone:focus-visible { border-color: var(--accent); background: var(--accent-soft); outline: none; }
.dropzone.is-dragover { border-color: var(--accent); background: var(--accent-soft); }
.dz-icon { width: 34px; height: 34px; color: var(--accent); }
.dz-title { margin: .4rem 0 0; font-weight: 600; }
.dz-hint { margin: 0; color: var(--muted-2); font-size: .88rem; }
.dz-file { margin: .6rem 0 0; color: var(--accent); font-weight: 600; word-break: break-all; }

fieldset.options { border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem 1.1rem; margin: 0; }
fieldset.options legend { padding: 0 .4rem; color: var(--muted); font-size: .9rem; }
.radio { display: flex; gap: .7rem; align-items: flex-start; padding: .55rem .2rem; cursor: pointer; }
.radio input { margin-top: .35rem; accent-color: var(--accent); }
.radio strong { display: block; font-weight: 600; }
.radio small { color: var(--muted); font-size: .88rem; line-height: 1.5; }

.quality-row { display: flex; align-items: center; gap: .75rem; flex-wrap: wrap; }
.quality-row select {
  background: var(--panel); color: var(--text); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: .5rem .7rem; font: inherit;
}
.warn { color: var(--warn); font-size: .88rem; margin: 0; width: 100%; }

.actions { display: flex; flex-wrap: wrap; gap: .6rem; }

/* progress / alerts --------------------------------------------------- */
.progress { display: flex; align-items: center; gap: .7rem; margin-top: 1.25rem; color: var(--muted); }
.spinner {
  width: 18px; height: 18px; border-radius: 50%;
  border: 2px solid var(--border-strong); border-top-color: var(--accent);
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.alert { border-radius: var(--radius); padding: .85rem 1rem; margin-top: 1.25rem; font-size: .95rem; }
.alert-error { background: rgba(229,103,95,.12); border: 1px solid rgba(229,103,95,.4); color: #ffb4ae; }

/* results ------------------------------------------------------------- */
.result {
  margin-top: 1.5rem; background: var(--panel); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1.25rem;
}
.result h2 { margin-bottom: .75rem; }
.result-grid { display: grid; gap: .75rem; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); margin-bottom: 1rem; }
.stat { background: var(--bg-soft); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: .7rem .85rem; }
.stat-label { display: block; color: var(--muted-2); font-size: .8rem; text-transform: uppercase; letter-spacing: .05em; }
.stat-value { font-size: 1.15rem; font-weight: 650; }
.stat-value.good { color: var(--good); }

/* re-arrange page list ------------------------------------------------ */
.pages-panel { margin-top: 1.5rem; }
.pages-head { margin-bottom: .75rem; }
.pages-head .muted { color: var(--muted); font-weight: 400; font-size: .95rem; }
.pages-head .hint { color: var(--muted-2); font-size: .88rem; margin: .25rem 0 0; }

.page-list { list-style: none; margin: 0 0 1.25rem; padding: 0; display: grid; gap: .6rem; }
.page-item {
  display: grid; grid-template-columns: auto 76px 1fr auto; align-items: center; gap: .85rem;
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: .6rem .8rem;
}
.page-item.is-deleted { opacity: .45; border-color: rgba(229,103,95,.5); }
.page-item.is-deleted .page-thumb { filter: grayscale(1); }
.page-index {
  min-width: 2rem; text-align: center; font-weight: 700; color: var(--accent);
  background: var(--accent-soft); border-radius: 6px; padding: .15rem .3rem; font-size: .9rem;
}
.page-thumb { width: 76px; height: 100px; object-fit: contain; background: #0b0e13; border-radius: 4px; border: 1px solid var(--border); }
.page-meta { font-size: .9rem; color: var(--muted); min-width: 0; }
.page-meta strong { color: var(--text); }
.page-actions { display: flex; gap: .3rem; }
.icon-btn {
  width: 34px; height: 34px; display: grid; place-items: center; cursor: pointer;
  background: var(--panel-2); border: 1px solid var(--border); border-radius: 7px; color: var(--muted);
  transition: all .15s;
}
.icon-btn:hover:not(:disabled) { color: var(--text); border-color: var(--border-strong); }
.icon-btn:disabled { opacity: .35; cursor: not-allowed; }
.icon-btn.danger:hover { color: #ffb4ae; border-color: rgba(229,103,95,.5); }
.icon-btn svg { width: 16px; height: 16px; }

@media (max-width: 560px) {
  .page-item { grid-template-columns: auto 60px 1fr; grid-template-areas: "idx thumb meta" ". . actions"; }
  .page-index { grid-area: idx; } .page-thumb { grid-area: thumb; width: 60px; height: 80px; }
  .page-meta { grid-area: meta; } .page-actions { grid-area: actions; }
}

/* footer -------------------------------------------------------------- */
.site-footer { flex-shrink: 0; border-top: 1px solid var(--border); margin-top: 3rem; padding: 2rem 0 2.5rem; background: var(--bg-soft); }
.donation {
  background: linear-gradient(135deg, rgba(242,179,75,.08), rgba(232,135,63,.06));
  border: 1px solid rgba(242,179,75,.28); border-radius: var(--radius);
  padding: 1.25rem 1.35rem; margin-bottom: 1.5rem;
}
.donation h2 { margin-bottom: .35rem; }
.donation p { color: var(--muted); margin: 0 0 .9rem; }
.notice { color: var(--muted-2); font-size: .85rem; margin: 0 0 .5rem; }
.footer-meta { color: var(--muted); font-size: .85rem; margin: 0; display: flex; align-items: center; gap: .45rem; }

/* captcha ------------------------------------------------------------- */
.captcha-row {
  display: flex; flex-direction: column; gap: .35rem;
  margin: 1rem 0 .25rem; min-height: 65px;
}
.captcha-note { color: var(--muted-2); font-size: .8rem; margin: 0; }
