/* ============================================================
   Tools site — shared structural styles.
   Every tool page loads this file. It defines layout/behavior
   (header, nav, buttons, modals, toasts, auth widget) as CSS
   custom properties + structural rules, NOT a fixed color scheme.

   Each tool overrides the --variables below (in its own <style>,
   after this file loads) to get its own look while keeping the
   same structural behavior everywhere. See the bottom of this
   file for the toned-down defaults used by the Tools landing page.
   ============================================================ */

:root {
  /* ---- Overridable per tool ---- */
  --bg: #0b0d12;
  --bg-elev: #141824;
  --bg-elev-2: #1b2030;
  --text: #e7e9ee;
  --text-dim: #9aa3b2;
  --accent: #5b8cff;
  --accent-text: #ffffff;
  --border: #262b3a;
  --danger: #e2545a;
  --success: #3ecf8e;
  --radius: 10px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --max-width: 1080px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- Header / nav (structure shared everywhere) ---------- */
.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 24px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-elev);
  flex-wrap: wrap;
}
.site-header .brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 17px;
  color: var(--text);
}
.site-header .brand:hover { text-decoration: none; }
.site-header .brand .mark { font-size: 20px; line-height: 1; }
.site-header nav.crumbs {
  font-size: 13px;
  color: var(--text-dim);
}

/* ---------- Buttons (shared pattern, themeable color) ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  padding: 9px 16px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg-elev-2);
  color: var(--text);
  cursor: pointer;
  transition: filter 0.15s ease, opacity 0.15s ease;
}
.btn:hover { filter: brightness(1.12); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn.primary { background: var(--accent); color: var(--accent-text); border-color: transparent; }
.btn.danger { background: var(--danger); color: #fff; border-color: transparent; }
.btn.small { padding: 6px 11px; font-size: 13px; }
.btn.ghost { background: transparent; }
.btn.link { background: none; border: none; color: var(--accent); padding: 0; text-decoration: underline; font-weight: 500; }

/* ---------- Form fields (shared) ---------- */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field label { font-size: 13px; color: var(--text-dim); font-weight: 600; }
.field input, .field select {
  font-family: inherit;
  font-size: 14px;
  padding: 9px 11px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
}
.field input:focus, .field select:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.field .error { color: var(--danger); font-size: 12.5px; }
.field .hint { color: var(--text-dim); font-size: 12.5px; }

/* ---------- Modal (shared across all tools) ---------- */
#modalRoot:empty { display: none; }
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.6);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  z-index: 1000;
}
.modal {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 24px;
  max-width: 420px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
}
.modal h2 { margin: 0 0 4px; font-size: 18px; }
.modal .sub { color: var(--text-dim); font-size: 13.5px; margin: 0 0 18px; }
.modal .actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 18px; }
.modal .switch-mode { margin-top: 14px; font-size: 13px; color: var(--text-dim); text-align: center; }

/* ---------- Toast (shared) ---------- */
#toastRoot {
  position: fixed; bottom: 20px; right: 20px;
  display: flex; flex-direction: column; gap: 8px;
  z-index: 1100;
}
.toast {
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 13.5px;
  color: var(--text);
  box-shadow: 0 4px 16px rgba(0,0,0,0.3);
  animation: toast-in 0.15s ease;
}
.toast.success { border-color: var(--success); }
.toast.error { border-color: var(--danger); }
@keyframes toast-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }

/* ---------- Auth widget (shared, lives in the header) ---------- */
.auth-widget { display: flex; align-items: center; gap: 10px; font-size: 13.5px; }
.auth-widget .who { color: var(--text-dim); }
.auth-widget .who strong { color: var(--text); }

/* ---------- Layout helpers ---------- */
.page-wrap { max-width: var(--max-width); margin: 0 auto; padding: 32px 24px 64px; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); }

@media (max-width: 560px) {
  .site-header { padding: 12px 16px; }
  .page-wrap { padding: 20px 16px 48px; }
}
