/* SnugTools — warm minimal theme */
:root {
  --bg: #faf6f0;            /* warm cream */
  --bg-soft: #f3ece2;       /* slightly deeper cream for panels */
  --panel: #ffffff;
  --panel-2: #fbf7f1;
  --border: #e6dccb;
  --border-strong: #d8c9b3;
  --text: #2a2520;          /* near-black warm */
  --text-dim: #6b6258;
  --text-mute: #756b5f;     /* AA contrast on cream bg */
  --accent: #c26b4a;        /* terracotta — decorative use */
  --accent-2: #a85a3c;      /* hover state */
  --accent-solid: #a85a3c;  /* button bg with white text (AA contrast) */
  --accent-soft: rgba(194, 107, 74, 0.10);
  --accent-tint: rgba(194, 107, 74, 0.16);
  --shadow-sm: 0 1px 2px rgba(60, 45, 30, 0.05);
  --shadow: 0 4px 16px rgba(60, 45, 30, 0.07);
  --shadow-lg: 0 10px 30px rgba(60, 45, 30, 0.09);
  --radius: 16px;
  --radius-sm: 10px;
  --radius-xs: 7px;
  --maxw: 820px;
  --font-head: "Fraunces", Georgia, "Times New Roman", serif;
  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  font-size: 16px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  /* fine-grain noise overlay for tactile depth */
  background-image: url("noise.svg");
  background-repeat: repeat;
  background-size: 160px 160px;
  background-attachment: fixed;
}

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

h1, h2, h3 { font-family: var(--font-head); font-weight: 600; letter-spacing: -0.01em; }

/* ---------- Header / nav ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(250, 246, 240, 0.85);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.nav {
  max-width: 1080px;
  margin: 0 auto;
  padding: 16px 22px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}
.brand {
  font-family: var(--font-head);
  font-weight: 600;
  font-size: 22px;
  letter-spacing: -0.01em;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 10px;
}
.brand .mark {
  width: 24px; height: 24px;
  background: var(--accent);
  border-radius: 8px;
  transform: rotate(45deg);
  flex: none;
}
.nav-links { display: flex; gap: 24px; align-items: center; }
.nav-links a { color: var(--text-dim); font-size: 15px; font-weight: 500; }
.nav-links a:hover { color: var(--accent); }

/* ---------- Footer ---------- */
.site-footer {
  margin-top: auto;
  border-top: 1px solid var(--border);
  background: var(--bg);
  padding: 28px 22px;
  text-align: center;
  color: var(--text-mute);
  font-size: 14px;
}
.site-footer a { color: var(--text-dim); }
.site-footer a:hover { color: var(--accent); }
.site-footer .foot-links { margin-bottom: 8px; display: flex; gap: 20px; justify-content: center; flex-wrap: wrap; }

/* ---------- Homepage hero ---------- */
.hero {
  position: relative;
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 70px 22px 90px;
  overflow: hidden;
}
.hero-blob {
  position: absolute;
  top: 50%;
  left: 50%;
  width: min(560px, 92vw);
  height: auto;
  transform: translate(-50%, -54%);
  z-index: 0;
  pointer-events: none;
}
.hero-inner { position: relative; z-index: 2; max-width: 820px; }
.hero h1 {
  font-size: clamp(38px, 7vw, 68px);
  line-height: 1.04;
  font-weight: 600;
  margin: 0 0 18px;
  letter-spacing: -0.02em;
  color: var(--text);
}
.hero h1 .accent { color: var(--accent); font-style: italic; }
.hero p.sub {
  font-size: clamp(17px, 2.4vw, 21px);
  color: var(--text-dim);
  margin: 0 auto 34px;
  max-width: 580px;
  font-weight: 400;
}
.cta {
  display: inline-block;
  background: var(--accent-solid);
  color: #fff;
  font-weight: 600;
  padding: 15px 34px;
  border-radius: 999px;
  font-size: 16px;
  box-shadow: var(--shadow);
  transition: transform 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
}
.cta:hover { background: var(--accent-2); color: #fff; transform: translateY(-2px); box-shadow: var(--shadow-lg); }

/* ---------- Tools list (homepage) ---------- */
.tools-section {
  max-width: 980px;
  margin: 0 auto;
  padding: 0 22px 90px;
}
.tools-section h2 {
  font-size: 30px;
  font-weight: 600;
  margin: 0 0 8px;
  text-align: center;
}
.tools-section .sec-sub {
  text-align: center;
  color: var(--text-dim);
  margin: 0 auto 40px;
  font-size: 16px;
  max-width: 620px;
}
.tools-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 20px;
}
.tool-card {
  display: block;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 26px 24px;
  color: var(--text);
  box-shadow: var(--shadow-sm);
  transition: border-color 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
}
.tool-card:hover {
  border-color: var(--border-strong);
  transform: translateY(-3px);
  box-shadow: var(--shadow);
}
.tool-card .tc-icon {
  width: 42px; height: 42px;
  border-radius: 12px;
  background: var(--accent-soft);
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 16px;
  color: var(--accent);
}
.tool-card h3 { margin: 0 0 7px; font-size: 20px; font-weight: 600; }
.tool-card p { margin: 0; color: var(--text-dim); font-size: 14px; line-height: 1.55; }

/* ---------- Tool page layout ---------- */
.tool-page { flex: 1; background: transparent; }
.tool-wrap {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 40px 22px 70px;
  width: 100%;
}
.tool-wrap-narrow { max-width: 720px; }
.panel-spacious { padding: 32px; }
.tool-wrap h1 {
  font-size: clamp(28px, 4.5vw, 38px);
  font-weight: 600;
  margin: 0 0 12px;
  letter-spacing: -0.02em;
}
.tool-intro {
  color: var(--text-dim);
  font-size: 16px;
  margin: 0 0 28px;
  max-width: 620px;
}
.tool-intro code {
  background: var(--accent-soft);
  color: var(--accent-solid);
  padding: 1px 6px;
  border-radius: 5px;
  font-size: 14px;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}

/* ad slots */
.ad-slot {
  margin: 24px 0;
  min-height: 90px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--panel-2);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-sm);
  color: var(--text-mute);
  font-size: 13px;
  text-align: center;
}
.ad-slot.top { margin-top: 0; }
.ad-slot.bottom { margin-bottom: 0; }

/* tool UI shell */
.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 26px;
  box-shadow: var(--shadow);
}
.field { margin-bottom: 18px; }
.field:last-child { margin-bottom: 0; }
.field-mt { margin-top: 20px; }
.field-mt-lg { margin-top: 24px; }
label {
  display: block;
  font-size: 14px;
  color: var(--text-dim);
  margin-bottom: 8px;
  font-weight: 500;
}
.label-mb { display: block; margin-bottom: 10px; font-size: 14px; color: var(--text-dim); font-weight: 500; }
textarea, input[type="text"], input[type="number"], input[type="date"], input[type="datetime-local"], select {
  width: 100%;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px; /* 16px prevents iOS auto-zoom on focus */
  padding: 13px 15px;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
/* custom select arrow — consistent across browsers, no native OS styling */
select {
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8' fill='none'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%236b6258' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 38px;
  cursor: pointer;
}
select::-ms-expand { display: none; }
textarea { resize: vertical; min-height: 170px; line-height: 1.55; }
textarea:focus, input:focus, select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-tint);
}
.btn {
  background: var(--accent-solid);
  color: #fff;
  border: none;
  border-radius: 999px;
  padding: 12px 24px;
  font-family: var(--font);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: background 0.15s ease, transform 0.1s ease, box-shadow 0.15s ease;
}
.btn:hover { background: var(--accent-2); box-shadow: var(--shadow); }
.btn:active { transform: translateY(1px); }
.btn.ghost {
  background: transparent;
  color: var(--text-dim);
  border: 1px solid var(--border-strong);
  box-shadow: none;
}
.btn.ghost:hover { color: var(--accent-solid); border-color: var(--accent-solid); background: var(--accent-soft); }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; }
.btn-row-mt { margin-top: 12px; }

/* stats grid (word counter, age calculator) */
.stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-top: 20px;
}
.stat {
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 16px 12px;
  text-align: center;
  min-width: 0;
}
.stat .num {
  font-family: var(--font-head);
  font-size: clamp(16px, 3vw, 22px);
  font-weight: 600;
  color: var(--accent);
  line-height: 1.2;
  overflow-wrap: break-word;
  word-break: break-word;
}
.stat .lbl {
  font-size: 11px;
  color: var(--text-mute);
  margin-top: 6px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  line-height: 1.3;
}
@media (min-width: 640px) {
  .stats { gap: 14px; }
  .stat { padding: 18px 14px; }
  .stat .num { font-size: 22px; }
  .stat .lbl { font-size: 12px; }
}

/* options (password gen / case / uuid) */
.options { display: flex; flex-wrap: wrap; gap: 14px 24px; align-items: center; }
.opt {
  display: flex; align-items: center; gap: 6px;
  font-size: 15px; color: var(--text-dim); cursor: pointer;
}
.opt input[type="number"] { width: 92px; }
.check {
  display: flex; align-items: center; gap: 9px;
  font-size: 15px; color: var(--text-dim); cursor: pointer;
}
.check input { width: auto; accent-color: var(--accent); }
.range-row { display: flex; align-items: center; gap: 14px; }
.range-row input[type="range"] { accent-color: var(--accent); flex: 1; }
.range-row .len-val {
  font-family: var(--font-head);
  font-weight: 600; color: var(--accent); min-width: 34px; text-align: right; font-size: 18px;
}

.output-box {
  margin-top: 20px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 18px;
  font-size: 16px;
  word-break: break-all;
  min-height: 60px;
  max-height: 400px;
  overflow-y: auto;
  display: flex;
  align-items: center;
  box-shadow: inset 0 1px 2px rgba(60, 45, 30, 0.03);
}
.output-box .placeholder { color: var(--text-mute); }
.strength { margin-top: 14px; height: 7px; border-radius: 999px; background: var(--border); overflow: hidden; }
.strength .bar { height: 100%; width: 0; background: var(--accent); transition: width 0.2s ease, background 0.2s ease; }
.strength-label { font-size: 13px; color: var(--text-mute); margin-top: 8px; }

.case-buttons { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.case-buttons .btn { padding: 12px 18px; white-space: normal; overflow-wrap: break-word; }

/* responsive */
@media (max-width: 600px) {
  .nav { padding: 14px 18px; }
  .nav-links { gap: 18px; }
  .tool-wrap { padding: 30px 18px 60px; }
  .panel { padding: 20px; }
  .hero { padding: 50px 18px 70px; }
}

/* ---------- Help tooltip (?) ---------- */
.help-tip {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.help-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 17px; height: 17px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent-solid);
  font-size: 11px;
  font-weight: 700;
  font-family: var(--font);
  cursor: help;
  border: none;
  padding: 0;
  line-height: 1;
  flex: none;
  transition: background 0.15s ease;
}
.help-badge:hover, .help-badge:focus { background: var(--accent-tint); }
.help-text {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  width: max-content;
  max-width: min(260px, calc(100vw - 32px));
  background: var(--text);
  color: var(--bg);
  font-size: 13px;
  font-weight: 400;
  line-height: 1.5;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.15s ease, visibility 0.15s ease;
  z-index: 50;
  text-align: left;
  white-space: normal;
}
.help-text::after {
  content: "";
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 6px solid transparent;
  border-top-color: var(--text);
}
.help-text strong { color: var(--accent-solid); font-weight: 600; }
.help-tip:hover .help-text,
.help-tip:focus-within .help-text {
  opacity: 1;
  visibility: visible;
}
/* JS adds .flip-right when tooltip is shifted left to prevent right-edge overflow */
.help-text.flip-right::after {
  left: auto;
  right: 12px;
  transform: none;
}
/* JS adds .flip-left when tooltip is shifted right to prevent left-edge overflow */
.help-text.flip-left::after {
  left: 12px;
  transform: none;
}

/* ---------- Toast (copy confirmation) ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translate(-50%, 20px);
  background: var(--text);
  color: var(--bg);
  font-size: 14px;
  font-weight: 500;
  padding: 12px 20px 12px 16px;
  border-radius: 999px;
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: 9px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 100;
  max-width: calc(100vw - 32px);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast .check-icon {
  width: 18px; height: 18px;
  flex: none;
  color: var(--accent);
  background: var(--bg);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
}
.toast .check-icon svg { width: 11px; height: 11px; }

/* utility */
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); border: 0; }

/* ---------- Percentage calculator ---------- */
.sub-calc h3 {
  font-family: var(--font-head);
  font-weight: 600;
  font-size: 20px;
  margin: 0 0 16px;
  color: var(--text);
}
.sub-calc .field { margin-bottom: 14px; }
.calc-divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 26px 0;
}
.result {
  margin-top: 18px;
  background: var(--accent-soft);
  border: 1px solid var(--accent-tint);
  border-radius: var(--radius-sm);
  padding: 16px 18px;
  font-size: 17px;
  font-weight: 500;
  color: var(--text);
  min-height: 52px;
  display: flex;
  align-items: center;
  line-height: 1.4;
  word-break: break-word;
  overflow-wrap: break-word;
}
.result.is-empty { color: var(--text-mute); font-weight: 400; background: var(--bg-soft); border-color: var(--border); }
.result strong { font-family: var(--font-head); font-weight: 600; color: var(--accent-solid); }

/* ---------- Hint text (age calculator) ---------- */
.hint { font-size: 13px; color: var(--text-mute); font-weight: 400; }

/* ---------- UUID generator ---------- */
.uuid-list { display: flex; flex-direction: column; gap: 8px; }
.uuid-row {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
}
.uuid-row code {
  flex: 1;
  word-break: break-all;
  font-family: var(--font);
  font-size: 14px;
  color: var(--text);
}
.uuid-row .copy-btn {
  flex: none;
  background: transparent;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 4px 12px;
  font-size: 13px;
  color: var(--text-dim);
  cursor: pointer;
  transition: all 0.15s ease;
}
.uuid-row .copy-btn:hover { color: var(--accent-solid); border-color: var(--accent-solid); }

/* ---------- HEX/RGB converter ---------- */
.swatch-wrap { margin-top: 20px; }
.swatch {
  width: 100%;
  height: 80px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  transition: background 0.15s ease;
  box-shadow: var(--shadow-sm);
}
.swatch-label {
  text-align: center;
  margin-top: 10px;
  font-family: var(--font-head);
  font-size: 18px;
  color: var(--text);
}
.rgb-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 10px;
}

/* ---------- Unix timestamp converter ---------- */
.live-ts {
  text-align: center;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 18px;
}
.live-ts-label {
  font-size: 12px;
  color: var(--text-mute);
  text-transform: uppercase;
  letter-spacing: 0.6px;
  margin-bottom: 6px;
}
.live-ts-num {
  font-family: var(--font-head);
  font-size: clamp(24px, 6vw, 32px);
  font-weight: 600;
  color: var(--accent);
  word-break: break-all;
}
.live-ts-date {
  font-size: 14px;
  color: var(--text-dim);
  margin-top: 6px;
}

/* ---------- QR code generator ---------- */
.qr-output {
  margin-top: 20px;
  text-align: center;
}
.qr-output img {
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  max-width: 100%;
  height: auto;
}

/* ---------- Placeholder text (shared) ---------- */
.placeholder { color: var(--text-mute); }
