/* =========================================================================
   Handy Toolkit - shared design system (base.css)
   Linked by the hub and every tool page.
   ========================================================================= */

:root {
  --bg: #f5f7fb;
  --card: #ffffff;
  --primary: #4f46e5;
  --primary-dark: #4338ca;
  --primary-soft: #eef1ff;
  --text: #1b2233;
  --muted: #6b7280;
  --border: #e4e8f0;
  --good: #16a34a;
  --warn: #d97706;
  --bad: #dc2626;
  --radius: 14px;
  --shadow: 0 10px 30px rgba(20, 30, 66, 0.08);
  --shadow-lg: 0 16px 40px rgba(79, 70, 229, 0.16);
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
  color: var(--text);
  background:
    radial-gradient(1200px 500px at 100% -10%, #e9ecff 0, transparent 60%),
    radial-gradient(1000px 500px at -10% 0, #e6fbff 0, transparent 55%),
    var(--bg);
  display: flex;
  flex-direction: column;
  line-height: 1.5;
}

a { color: var(--primary); }

/* ---------- Header ---------- */
.site-header {
  text-align: center;
  padding: 26px 20px 6px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--text);
}

.brand-mark {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--primary), #7c73ff);
  color: #fff;
  font-weight: 800;
  font-size: 1.25rem;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow);
}

.brand-name {
  font-size: 1.45rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.site-tagline {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 0.92rem;
}

/* ---------- Layout ---------- */
.container {
  flex: 1;
  width: 100%;
  max-width: 560px;
  margin: 0 auto;
  padding: 18px 20px 40px;
}

.container.wide { max-width: 900px; }

/* ---------- Back link ---------- */
.back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 4px 0 14px;
  color: var(--primary);
  text-decoration: none;
  font-weight: 600;
  font-size: 0.9rem;
}
.back-link:hover { text-decoration: underline; }

/* ---------- Card ---------- */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 24px;
  box-shadow: var(--shadow);
}
.card + .card { margin-top: 16px; }

.tool-heading {
  margin: 0 0 6px;
  font-size: 1.35rem;
  font-weight: 800;
  letter-spacing: -0.01em;
}
.tool-sub {
  margin: 0 0 20px;
  color: var(--muted);
  font-size: 0.9rem;
}

/* ---------- Fields ---------- */
.field { margin-bottom: 18px; }
.field:last-child { margin-bottom: 0; }

label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 7px;
}

input[type="number"],
input[type="text"],
input[type="url"],
input[type="date"],
input[type="datetime-local"],
input[type="time"],
input[type="search"],
select,
textarea {
  width: 100%;
  padding: 13px 14px;
  font-size: 1.02rem;
  font-family: inherit;
  color: var(--text);
  border: 1.5px solid var(--border);
  border-radius: 10px;
  background: #fff;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

textarea { resize: vertical; min-height: 120px; line-height: 1.45; }

input:focus, select:focus, textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.14);
}

.input-group {
  display: flex;
  align-items: center;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  transition: border-color 0.15s, box-shadow 0.15s;
  background: #fff;
}
.input-group:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.14);
}
.input-prefix, .input-suffix {
  padding: 0 14px;
  font-size: 1rem;
  font-weight: 600;
  color: var(--muted);
  background: #fafbfe;
  align-self: stretch;
  display: flex;
  align-items: center;
  white-space: nowrap;
}
.input-group input {
  flex: 1;
  border: none;
  outline: none;
  padding: 13px 14px;
  font-size: 1.05rem;
  font-family: inherit;
  color: var(--text);
  width: 100%;
  background: transparent;
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: none;
  cursor: pointer;
  font-family: inherit;
  font-size: 1rem;
  font-weight: 700;
  padding: 13px 18px;
  border-radius: 11px;
  background: var(--primary);
  color: #fff;
  transition: background 0.15s, transform 0.08s, box-shadow 0.15s;
  box-shadow: 0 6px 16px rgba(79, 70, 229, 0.28);
}
.btn:hover { background: var(--primary-dark); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; box-shadow: none; }
.btn.full { width: 100%; }
.btn.ghost {
  background: #fff;
  color: var(--primary);
  border: 1.5px solid var(--border);
  box-shadow: none;
}
.btn.ghost:hover { border-color: var(--primary); background: var(--primary-soft); }
.btn.small { padding: 8px 12px; font-size: 0.85rem; }

.btn-row { display: flex; gap: 10px; flex-wrap: wrap; }

/* ---------- Mode toggle ---------- */
.mode-toggle {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  gap: 4px;
  background: var(--primary-soft);
  padding: 4px;
  border-radius: 12px;
  margin-bottom: 20px;
}
.mode-btn {
  border: none;
  background: transparent;
  padding: 10px;
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--muted);
  border-radius: 9px;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.15s;
}
.mode-btn.active {
  background: #fff;
  color: var(--primary);
  box-shadow: 0 1px 3px rgba(20, 30, 66, 0.12);
}

/* ---------- Presets ---------- */
.presets { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.preset {
  flex: 1;
  min-width: 56px;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
  padding: 7px 0;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.15s;
}
.preset:hover { border-color: var(--primary); color: var(--primary); }
.preset.active { background: var(--primary); border-color: var(--primary); color: #fff; }

/* ---------- Results ---------- */
.results {
  margin-top: 22px;
  border-top: 1px solid var(--border);
  padding-top: 12px;
}
.result-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 9px 0;
}
.result-label { font-size: 0.95rem; color: var(--muted); }
.result-label em { font-style: normal; opacity: 0.7; }
.result-value {
  font-size: 1.05rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  text-align: right;
}
.result-row.total {
  margin-top: 8px;
  padding: 14px 16px;
  background: var(--primary-soft);
  border-radius: 10px;
}
.result-row.total .result-label { color: var(--text); font-weight: 600; }
.result-row.total .result-value { font-size: 1.4rem; color: var(--primary); }
.result-value.good { color: var(--good); }
.result-value.warn { color: var(--warn); }
.result-value.bad { color: var(--bad); }

.hint {
  margin: 16px 0 0;
  font-size: 0.82rem;
  color: var(--muted);
}
.hint.note {
  background: #fff8e6;
  border: 1px solid #fce8b2;
  color: #7a5a12;
  padding: 10px 12px;
  border-radius: 10px;
}

/* ---------- Grid helpers ---------- */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 460px) { .grid-2 { grid-template-columns: 1fr; } }

/* ---------- Footer ---------- */
.site-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  max-width: 560px;
  width: 100%;
  margin: 0 auto;
  padding: 16px 24px 28px;
  font-size: 0.82rem;
  color: var(--muted);
}
.site-footer.wide { max-width: 900px; }
.visitors strong { color: var(--text); }

/* ---------- Utilities ---------- */
.hidden { display: none !important; }
.mono { font-family: "SFMono-Regular", ui-monospace, Consolas, "Liberation Mono", monospace; }
.center { text-align: center; }
.muted { color: var(--muted); }
.pill {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--primary-soft);
  color: var(--primary);
  font-size: 0.78rem;
  font-weight: 700;
}