/* useforfree — shared styles */

:root {
  --bg: #f6f6f3;
  --surface: #ffffff;
  --text: #1c1c1e;
  --muted: #5d6066;
  --border: #e1e1dc;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --accent-text: #ffffff;
  --accent-soft: #e8eefc;
  --ok: #17784a;
  --ok-bg: #e5f4ec;
  --warn: #8a5600;
  --warn-bg: #fdf2dc;
  --err: #b42318;
  --err-bg: #fdebe9;
  --info: #3d4654;
  --info-bg: #eef0f4;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(0, 0, 0, .05), 0 4px 12px rgba(0, 0, 0, .04);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --max: 960px;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111113;
    --surface: #1b1b1f;
    --text: #ececee;
    --muted: #a1a1aa;
    --border: #2d2d33;
    --accent: #6d9bff;
    --accent-hover: #8fb2ff;
    --accent-text: #0a1020;
    --accent-soft: #1d2843;
    --ok: #5fd39a;
    --ok-bg: #11291c;
    --warn: #f2c46b;
    --warn-bg: #2c2411;
    --err: #ff8a80;
    --err-bg: #2e1614;
    --info: #c4cad4;
    --info-bg: #23262c;
    --shadow: none;
  }
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.6 var(--font);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

main { flex: 1; }

img, video, canvas { max-width: 100%; display: block; }

a { color: var(--accent); }
a:hover { color: var(--accent-hover); }

h1, h2, h3 { line-height: 1.25; margin: 0 0 .5em; }
h1 { font-size: clamp(1.6rem, 4vw, 2.2rem); }
h2 { font-size: 1.3rem; margin-top: 1.6em; }
h3 { font-size: 1.05rem; }
p { margin: 0 0 1em; }

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

/* Header & footer */

.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.site-header .wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 56px;
}
.logo {
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--text);
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 8px;
}
.logo img { width: 26px; height: 26px; }
.site-nav a {
  color: var(--muted);
  text-decoration: none;
  font-size: .95rem;
}
.site-nav a:hover { color: var(--text); }

.site-footer {
  margin-top: 48px;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: .9rem;
}
.site-footer .wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 20px;
  padding-top: 20px;
  padding-bottom: 28px;
}
.site-footer a { color: var(--muted); }
.site-footer a:hover { color: var(--text); }

/* Page intro */

.page-head { padding: 28px 0 8px; }
.page-head p { color: var(--muted); font-size: 1.05rem; max-width: 640px; }

.breadcrumb {
  font-size: .9rem;
  margin-bottom: 8px;
}
.breadcrumb a { color: var(--muted); text-decoration: none; }
.breadcrumb a:hover { color: var(--text); }

/* Tool area */

.tool {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
}

.tool-grid {
  display: grid;
  gap: 20px;
}
@media (min-width: 760px) {
  .tool-grid.two { grid-template-columns: 1fr 1fr; }
}

.panel h2 { margin-top: 0; font-size: 1.15rem; }

.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin: 12px 0;
}

label { font-size: .9rem; color: var(--muted); }

select,
input[type="text"],
input[type="number"],
input[type="password"] {
  font: inherit;
  font-size: .95rem;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  width: 100%;
  min-width: 0;
}

.checkbox {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
}

/* Buttons */

.btn {
  font: inherit;
  font-size: .95rem;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 42px;
  padding: 8px 16px;
  border-radius: 8px;
  border: 1px solid transparent;
  background: var(--accent);
  color: var(--accent-text);
  cursor: pointer;
  text-decoration: none;
}
.btn:hover { background: var(--accent-hover); color: var(--accent-text); }
.btn.secondary {
  background: transparent;
  color: var(--text);
  border-color: var(--border);
}
.btn.secondary:hover { background: var(--accent-soft); }
.btn:disabled, .btn[aria-disabled="true"] {
  opacity: .45;
  cursor: not-allowed;
  pointer-events: none;
}
.btn:focus-visible, select:focus-visible, input:focus-visible, a:focus-visible, summary:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

/* Status messages */

.status {
  font-size: .95rem;
  border-radius: 8px;
  padding: 10px 12px;
  margin: 12px 0;
  background: var(--info-bg);
  color: var(--info);
}
.status:empty { display: none; }
.status-ok { background: var(--ok-bg); color: var(--ok); }
.status-warn { background: var(--warn-bg); color: var(--warn); }
.status-error { background: var(--err-bg); color: var(--err); }

/* Media */

.screen {
  position: relative;
  aspect-ratio: 16 / 9;
  background: #000;
  border-radius: 10px;
  overflow: hidden;
}
.screen video {
  width: 100%;
  height: 100%;
  object-fit: contain;
}
.screen .placeholder {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: #9a9aa2;
  font-size: .95rem;
  text-align: center;
  padding: 16px;
}
.mirrored { transform: scaleX(-1); }

.meta {
  font: .85rem/1.5 var(--mono);
  color: var(--muted);
  margin: 8px 0 0;
  min-height: 1.3em;
}

.meter {
  position: relative;
  height: 16px;
  border-radius: 8px;
  overflow: hidden;
  background: linear-gradient(90deg, #22a06b 0%, #22a06b 60%, #e2b203 80%, #e5484d 100%);
}
.meter-mask {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 100%;
  background: var(--info-bg);
}

.wave {
  width: 100%;
  height: 120px;
  margin-top: 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
}

audio { width: 100%; margin-top: 12px; }

.snapshot { margin-top: 12px; }
.snapshot img { border-radius: 10px; margin-bottom: 8px; }

/* Content below the tool */

.content { max-width: 720px; }
.content ol, .content ul { padding-left: 1.3em; margin: 0 0 1em; }
.content li { margin-bottom: .35em; }

.faq details {
  border-bottom: 1px solid var(--border);
  padding: 12px 0;
}
.faq summary {
  cursor: pointer;
  font-weight: 600;
}
.faq details p { margin: 8px 0 0; color: var(--muted); }

.related ul {
  list-style: none;
  padding: 0;
  margin: 0 0 1em;
  display: grid;
  gap: 8px;
}

/* Tool cards (homepage) */

.cards {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  margin-bottom: 8px;
}
.card {
  display: block;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px 18px;
  color: var(--text);
  text-decoration: none;
  transition: border-color .15s, transform .15s;
}
.card:hover {
  border-color: var(--accent);
  color: var(--text);
  transform: translateY(-1px);
}
.card .icon { font-size: 1.6rem; line-height: 1; }
.card h3 { margin: 10px 0 4px; }
.card p { margin: 0; color: var(--muted); font-size: .92rem; }

.category h2 { font-size: 1.1rem; color: var(--muted); font-weight: 600; }

/* Toast */

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  background: var(--text);
  color: var(--bg);
  padding: 10px 16px;
  border-radius: 8px;
  font-size: .95rem;
  z-index: 100;
  max-width: calc(100% - 32px);
}

/* Screen info panel */

.screen-info,
.tool-section {
  border-top: 1px solid var(--border);
  margin-top: 20px;
  padding-top: 20px;
}
.info-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 10px;
  margin: 12px 0 0;
}
.info-grid div {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 12px;
}
.info-grid dt { font-size: .8rem; color: var(--muted); }
.info-grid dd { margin: 0; font: 600 1rem/1.4 var(--mono); overflow-wrap: anywhere; }

/* What is my IP */

.ip-hero { text-align: center; padding: 8px 0; }
.ip-hero .controls { justify-content: center; }
.ip-big {
  font: 700 clamp(1.5rem, 6vw, 2.6rem)/1.25 var(--mono);
  overflow-wrap: anywhere;
  margin: 6px 0;
}
.ip-sub { color: var(--muted); min-height: 1.6em; }
.badge {
  display: inline-block;
  font: 600 .75rem/1 var(--font);
  background: var(--accent-soft);
  color: var(--accent);
  border-radius: 999px;
  padding: 4px 8px;
  vertical-align: middle;
}
.badge:empty { display: none; }
.ua { overflow-wrap: anywhere; }
.map iframe {
  display: block;
  width: 100%;
  height: 320px;
  border: 1px solid var(--border);
  border-radius: 10px;
  margin-top: 12px;
}

/* File drop zone (PDF tools) */

.dropzone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 180px;
  padding: 24px 16px;
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--text);
  text-align: center;
  cursor: pointer;
  transition: border-color .15s, background .15s;
}
.dropzone:hover,
.dropzone.dragover,
.dropzone:focus-within {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.dropzone.busy { opacity: .6; cursor: progress; }
.dropzone-icon { font-size: 2.2rem; line-height: 1; }
.dropzone-title { font-weight: 600; font-size: 1.05rem; }

.password-form .controls input { flex: 1 1 200px; width: auto; }

/* PDF tools: file lists, page thumbnails, options */

.btn.small { min-height: 34px; padding: 4px 12px; font-size: .88rem; }

.icon-btn {
  font: inherit;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
}
.icon-btn:hover { background: var(--accent-soft); }

.list-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 16px;
}
.list-head .controls { margin: 0; }

.file-list {
  list-style: none;
  padding: 0;
  margin: 8px 0;
  display: grid;
  gap: 8px;
}
.file-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  cursor: grab;
}
.file-row.dragging { opacity: .5; }
.file-row.has-error { border-color: var(--err); background: var(--err-bg); }
.file-meta { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.file-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-actions { display: flex; gap: 4px; flex: none; }

.thumb-frame {
  display: block;
  aspect-ratio: 1 / 1.414;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 4px;
  overflow: hidden;
}
.thumb-frame canvas { width: 100%; height: 100%; display: block; }
.thumb-frame.small { width: 44px; flex: none; }

.thumbs {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(104px, 1fr));
  gap: 10px;
  margin: 16px 0 0;
  max-height: 560px;
  overflow-y: auto;
  padding: 4px;
}
.thumb {
  font: inherit;
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 4px;
  padding: 6px;
  border: 2px solid transparent;
  border-radius: 10px;
  background: none;
  color: var(--text);
  cursor: pointer;
}
.thumb:hover { background: var(--accent-soft); }
.thumb-label { font-size: .8rem; color: var(--muted); text-align: center; }
.thumb[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); }
.thumb[aria-pressed="true"]::after {
  content: "✓";
  position: absolute;
  top: 10px;
  right: 10px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: .8rem;
  font-weight: 700;
  background: var(--accent);
  color: var(--accent-text);
}
.thumbs.delete-mode .thumb[aria-pressed="true"] { border-color: var(--err); background: var(--err-bg); }
.thumbs.delete-mode .thumb[aria-pressed="true"]::after { content: "✕"; background: var(--err); color: #fff; }
.thumbs.delete-mode .thumb[aria-pressed="true"] .thumb-frame { opacity: .35; }
.thumbs.locked .thumb { cursor: default; }
.thumbs.locked .thumb:hover { background: none; }

.options { display: grid; gap: 14px; margin-top: 12px; }
.option > label,
.option > legend { display: block; margin-bottom: 4px; }
fieldset.option { border: 0; padding: 0; margin: 0; min-width: 0; }
.option input[type="text"] + input,
.option select + input { margin-top: 8px; }
.radio-row { display: flex; flex-wrap: wrap; gap: 8px 18px; }
.radio-row label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text);
  font-size: .95rem;
  cursor: pointer;
}
input[type="radio"], input[type="checkbox"], input[type="range"] { accent-color: var(--accent); }
input[type="range"] { width: 100%; }
input[type="color"] {
  width: 48px;
  height: 40px;
  flex: none;
  padding: 2px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  cursor: pointer;
}
.controls.tight { margin: 0; flex-wrap: nowrap; }
.controls.tight input[type="text"] { flex: 1; }

.wm-layout { display: grid; gap: 20px; }
@media (min-width: 760px) {
  .wm-layout { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-items: start; }
}
.preview-stage { position: relative; max-width: 420px; margin: 12px auto 0; }
.preview-stage .overlay {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}
.preview-note { text-align: center; }

/* Pixel-test swatches and full-screen overlay */

.swatch {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  border: 1px solid var(--border);
  padding: 0;
  cursor: pointer;
}
.swatch:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

#overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: #000;
  cursor: pointer;
}
#overlay canvas { width: 100%; height: 100%; display: block; }
#overlay-hint,
#overlay-label {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  font: 14px/1.4 var(--font);
  color: rgba(255, 255, 255, .55);
  mix-blend-mode: difference;
  background: transparent;
  padding: 6px 12px;
  pointer-events: none;
  text-align: center;
  transition: opacity .4s;
}
#overlay-hint { bottom: 24px; }
#overlay-label { top: 24px; text-transform: capitalize; }
#overlay.hide-hint #overlay-hint { opacity: 0; }

.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
