/* Penguin Wearing a Hat — shared stylesheet.
   Design language inherited from the homepage mockup: Manrope + DM Mono,
   asymmetric rounded cards, hard offset shadows, light/dark themes. */

:root {
  color-scheme: light dark;
  --bg: #f4f7fb;
  --surface: #ffffff;
  --surface-2: #e9eff7;
  --ink: #13233d;
  --muted: #5c6d82;
  --line: #d4dde8;
  --blue: #1769e0;
  --blue-deep: #10345e;
  --orange: #ff7d3b;
  --yellow: #ffd35b;
  --mint: #43c9a7;
  --pink: #ec5f9a;
  --peri: #6f7bf7;
  --teal: #2da0ad;
  --danger: #d64045;
  --shadow: 0 18px 50px rgba(23, 52, 91, .10);
  --radius: 18px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0a121c;
    --surface: #121e2b;
    --surface-2: #1b2a3a;
    --ink: #eef5ff;
    --muted: #a7b7ca;
    --line: #2d4156;
    --blue: #69a5ff;
    --blue-deep: #0d2a4a;
    --orange: #ff9257;
    --yellow: #f2c84b;
    --mint: #58d7b6;
    --danger: #ff7d82;
    --shadow: 0 18px 50px rgba(0, 0, 0, .28);
  }
}
:root[data-theme="dark"] {
  --bg: #0a121c;
  --surface: #121e2b;
  --surface-2: #1b2a3a;
  --ink: #eef5ff;
  --muted: #a7b7ca;
  --line: #2d4156;
  --blue: #69a5ff;
  --blue-deep: #0d2a4a;
  --orange: #ff9257;
  --yellow: #f2c84b;
  --mint: #58d7b6;
  --danger: #ff7d82;
  --shadow: 0 18px 50px rgba(0, 0, 0, .28);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-width: 320px;
  background:
    linear-gradient(90deg, color-mix(in srgb, var(--line) 28%, transparent) 1px, transparent 1px) 0 0 / 36px 36px,
    linear-gradient(color-mix(in srgb, var(--line) 28%, transparent) 1px, transparent 1px) 0 0 / 36px 36px,
    var(--bg);
  color: var(--ink);
  font-family: "Manrope", system-ui, -apple-system, sans-serif;
  line-height: 1.6;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
img { max-width: 100%; height: auto; }
:focus-visible { outline: 3px solid color-mix(in srgb, var(--blue) 55%, transparent); outline-offset: 3px; }

.page { width: min(1180px, calc(100% - 32px)); margin: 0 auto; padding: 40px 0 84px; }

/* ---------- header ---------- */
.site-header {
  position: sticky; top: 0; z-index: 40;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.header-inner {
  width: min(1180px, calc(100% - 32px)); margin: 0 auto;
  display: flex; align-items: center; gap: 20px; padding: 12px 0;
}
.brand { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); font-weight: 800; letter-spacing: -.02em; }
.brand img { width: 40px; height: 40px; border-radius: 50%; background: var(--surface-2); border: 1px solid var(--line); }
.site-nav { display: flex; gap: 4px; margin-left: auto; }
.site-nav a { padding: 8px 12px; border-radius: 10px; text-decoration: none; color: var(--muted); font-weight: 700; font-size: .9rem; }
.site-nav a:hover { color: var(--blue); background: var(--surface-2); }
.theme-toggle {
  width: 40px; height: 40px; border: 1px solid var(--line); border-radius: 50%;
  background: var(--surface); font-size: 1.05rem; line-height: 1;
  display: inline-flex; align-items: center; justify-content: center;
}
.theme-toggle:hover { border-color: var(--blue); }

/* ---------- hero ---------- */
.intro { display: grid; grid-template-columns: 1.1fr .9fr; gap: 46px; align-items: center; margin-bottom: 34px; }
.hero-mascot { justify-self: end; width: min(300px, 70%); filter: drop-shadow(0 14px 30px rgba(23,52,91,.18)); }
.eyebrow { display: inline-flex; align-items: center; gap: 9px; margin: 0 0 12px; font-size: .82rem; font-weight: 800; color: var(--blue); }
.eyebrow::before { content: ""; width: 26px; height: 3px; background: var(--orange); border-radius: 9px; }
h1 { max-width: 720px; margin: 0; font-size: clamp(2.4rem, 6vw, 4.6rem); line-height: .98; letter-spacing: -.055em; font-weight: 800; }
.intro-copy { margin: 18px 0 0; max-width: 590px; color: var(--muted); font-size: 1.05rem; line-height: 1.7; }
.search-wrap { align-self: end; }
.search-label { display: block; margin: 0 0 9px; font-size: .83rem; font-weight: 800; }
.search {
  display: flex; align-items: center; gap: 12px; padding: 8px 8px 8px 15px;
  background: var(--surface); border: 2px solid var(--ink); border-radius: 17px;
  box-shadow: 6px 6px 0 var(--yellow);
}
.search svg { flex: 0 0 auto; color: var(--muted); }
.search input { width: 100%; min-width: 0; border: 0; outline: 0; background: transparent; font-size: 1rem; }
.search kbd { border: 1px solid var(--line); border-bottom-width: 2px; padding: 4px 7px; border-radius: 7px; color: var(--muted); background: var(--surface-2); font: 500 .72rem "DM Mono", monospace; }

/* ---------- homepage sections ---------- */
.section-head { display: flex; justify-content: space-between; align-items: baseline; gap: 16px; margin: 48px 0 17px; }
.section-head h2 { margin: 0; font-size: clamp(1.45rem, 3vw, 2.1rem); letter-spacing: -.035em; }
.section-head p { margin: 0; color: var(--muted); font-size: .9rem; }

.pinned { display: grid; grid-template-columns: 1.22fr .9fr .88fr; gap: 16px; }
.tool-card { position: relative; min-height: 360px; overflow: hidden; border: 1px solid var(--line); background: var(--surface); }
.tool-card.password { padding: 24px; border-radius: 28px 7px 28px 7px; color: #fff; background: var(--blue-deep); border: 0; }
.tool-card.calc { padding: 22px; border-radius: 7px 28px 7px 28px; }
.tool-card.random { padding: 22px; border-radius: 28px 7px 28px 7px; }
.pin-num { position: absolute; right: 16px; top: 10px; opacity: .14; font: 500 3.4rem "DM Mono", monospace; }
.tool-title { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; }
.tool-title svg { color: var(--orange); }
.tool-title h3 { margin: 0; font-size: 1.16rem; letter-spacing: -.02em; }
.tool-sub { margin: -8px 0 20px; color: var(--muted); font-size: .82rem; }
.password .tool-sub { color: #c6d5e9; }
.password-output { min-height: 88px; display: flex; align-items: center; padding: 18px; background: #081c32; border: 1px solid #355779; border-radius: 14px; overflow-wrap: anywhere; font: 500 1rem/1.5 "DM Mono", monospace; }
.range-row { display: grid; grid-template-columns: 1fr auto; gap: 12px; align-items: center; margin: 18px 0 12px; }
input[type="range"] { width: 100%; accent-color: var(--orange); }
.length { min-width: 38px; padding: 5px 8px; text-align: center; background: #173b60; border-radius: 7px; font: 500 .84rem "DM Mono", monospace; }
.segmented { display: flex; flex-wrap: wrap; gap: 7px; margin: 0 0 17px; }
.segmented button { padding: 7px 10px; border: 1px solid #446585; border-radius: 9px; background: transparent; color: #cfe0f2; font-size: .76rem; font-weight: 700; }
.segmented button.active { background: #fff; color: #0d2948; border-color: #fff; }
.actions { display: flex; gap: 9px; flex-wrap: wrap; }
.primary, .secondary { border: 0; border-radius: 11px; padding: 11px 15px; font-weight: 800; }
.primary { background: var(--orange); color: #251106; }
.secondary { background: var(--surface-2); color: var(--ink); border: 1px solid var(--line); }
.password .secondary { background: #fff; color: #102d4d; border: 0; }

.calc-display { min-height: 72px; margin-bottom: 12px; padding: 13px 14px; display: flex; flex-direction: column; align-items: flex-end; justify-content: end; background: var(--surface-2); border-radius: 13px; overflow: hidden; }
.calc-expression { color: var(--muted); min-height: 1em; font: .76rem "DM Mono", monospace; }
.calc-result { max-width: 100%; overflow: hidden; text-overflow: ellipsis; font: 500 1.65rem "DM Mono", monospace; }
.keypad { display: grid; grid-template-columns: repeat(4, 1fr); gap: 7px; }
.keypad button { min-height: 45px; border: 0; border-radius: 10px; background: var(--surface-2); font-weight: 800; }
.keypad button.op { color: var(--blue); }
.keypad button.equal { color: #1d1600; background: var(--yellow); }

.random-face { padding: 22px 12px 18px; text-align: center; }
.random-result { font: 500 clamp(3.2rem, 8vw, 5.5rem)/1 "DM Mono", monospace; letter-spacing: -.08em; color: var(--blue); }
.random-note { margin-top: 8px; color: var(--muted); font-size: .78rem; }
.number-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; margin: 8px 0 13px; }
.full { width: 100%; }

.field label { display: block; margin: 0 0 5px; color: var(--muted); font-size: .74rem; font-weight: 700; }
.field input, .field select, .field textarea {
  width: 100%; border: 1px solid var(--line); border-radius: 10px;
  background: var(--surface-2); padding: 10px 11px; outline: none;
}
.field textarea { min-height: 110px; resize: vertical; }
.field input[type="color"] { height: 46px; padding: 4px; cursor: pointer; }

/* ---------- categories ---------- */
.categories { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; }
.category { position: relative; padding: 22px; border: 1px solid var(--line); border-radius: 18px 4px 18px 4px; background: var(--surface); overflow: hidden; }
.category:nth-child(3n+2) { border-radius: 4px 18px 4px 18px; }
.category::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 5px; background: var(--cat, var(--blue)); }
.category-head { display: flex; align-items: center; gap: 14px; margin-bottom: 14px; }
.category-head img { width: 56px; height: 56px; border-radius: 50%; background: var(--surface-2); border: 1px solid var(--line); flex: 0 0 auto; }
.category-head h3 { margin: 0; font-size: 1.05rem; }
.category-head .cat-count { display: block; color: var(--muted); font: .72rem "DM Mono", monospace; }
.category-head p { margin: 2px 0 0; color: var(--muted); font-size: .8rem; }
.tool-links { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.tool-link {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 12px; border: 0; border-radius: 10px; background: var(--surface-2);
  text-align: left; font-size: .84rem; font-weight: 700; color: var(--ink); text-decoration: none;
}
.tool-link:hover, .tool-link:focus-visible { outline: 2px solid var(--blue); outline-offset: 1px; }
.tool-link svg { flex: 0 0 auto; color: var(--muted); }

/* ---------- A–Z grid ---------- */
.az-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.az-card { display: block; padding: 18px; border: 1px solid var(--line); border-radius: 14px 4px 14px 4px; background: var(--surface); text-decoration: none; color: var(--ink); }
.az-card:hover { border-color: var(--blue); box-shadow: var(--shadow); }
.az-card h3 { margin: 0 0 6px; font-size: 1rem; letter-spacing: -.02em; }
.az-card p { margin: 0; color: var(--muted); font-size: .83rem; }
.az-card .az-cat { display: inline-block; margin-bottom: 8px; font: 700 .68rem "DM Mono", monospace; color: var(--blue); text-transform: uppercase; letter-spacing: .06em; }

/* ---------- FAQ ---------- */
.faq { display: grid; gap: 10px; margin-top: 8px; }
.faq details { border: 1px solid var(--line); border-radius: 12px; background: var(--surface); padding: 14px 18px; }
.faq summary { cursor: pointer; font-weight: 800; letter-spacing: -.01em; }
.faq details p { margin: 10px 0 4px; color: var(--muted); font-size: .92rem; }

/* ---------- footer ---------- */
.footer { margin-top: 46px; padding-top: 22px; border-top: 1px solid var(--line); color: var(--muted); font-size: .82rem; }
.footer-grid { display: grid; grid-template-columns: 1.4fr 1fr 1fr; gap: 28px; margin-bottom: 22px; }
.footer-brand { display: flex; gap: 12px; align-items: flex-start; }
.footer-brand img { width: 44px; height: 44px; border-radius: 50%; border: 1px solid var(--line); background: var(--surface-2); }
.footer h4 { margin: 0 0 10px; font-size: .8rem; text-transform: uppercase; letter-spacing: .08em; color: var(--ink); }
.footer ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 7px; }
.footer a { color: var(--muted); text-decoration: none; }
.footer a:hover { color: var(--blue); }
.footer-bottom { display: flex; justify-content: space-between; gap: 16px; padding-top: 16px; border-top: 1px solid var(--line); }

/* ---------- toast / misc ---------- */
.toast { position: fixed; left: 50%; bottom: 24px; z-index: 80; transform: translate(-50%, 20px); opacity: 0; pointer-events: none; padding: 10px 14px; border-radius: 10px; background: var(--ink); color: var(--bg); font-size: .82rem; font-weight: 800; transition: .2s ease; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.hidden-search { display: none !important; }
.empty { display: none; padding: 36px; border: 1px dashed var(--line); background: var(--surface); text-align: center; color: var(--muted); }
.empty.show { display: block; }

/* ---------- tool pages ---------- */
.breadcrumb { margin: 0 0 18px; font-size: .82rem; color: var(--muted); }
.breadcrumb a { color: var(--blue); text-decoration: none; }
.breadcrumb a:hover { text-decoration: underline; }
.breadcrumb span[aria-current] { color: var(--ink); font-weight: 700; }

.tool-hero { display: flex; gap: 22px; align-items: center; margin-bottom: 26px; }
.tool-hero img { width: 96px; height: 96px; border-radius: 50%; background: var(--surface-2); border: 2px solid var(--line); flex: 0 0 auto; }
.tool-hero h1 { font-size: clamp(1.9rem, 4.5vw, 3rem); }
.tool-hero .intro-copy { margin-top: 10px; font-size: 1rem; }
.tool-cat-tag { display: inline-block; margin-bottom: 10px; padding: 4px 12px; border-radius: 999px; background: color-mix(in srgb, var(--cat, var(--blue)) 18%, var(--surface)); border: 1px solid var(--cat, var(--blue)); color: var(--ink); font: 700 .72rem "DM Mono", monospace; text-transform: uppercase; letter-spacing: .06em; }

.widget { border: 1px solid var(--line); border-radius: 24px 6px 24px 6px; background: var(--surface); padding: 26px; box-shadow: var(--shadow); margin-bottom: 40px; }
.widget-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.output-box { min-height: 62px; margin-top: 14px; padding: 14px; border-radius: 11px; background: var(--surface-2); overflow-wrap: anywhere; font: 500 .95rem/1.55 "DM Mono", monospace; }
.result-big { font-size: 1.5rem; color: var(--blue); }
.hint { color: var(--muted); font-size: .79rem; line-height: 1.5; }
.widget .actions { margin-top: 14px; }

.howto { margin-bottom: 36px; }
.howto ol { margin: 12px 0 0; padding-left: 22px; display: grid; gap: 8px; color: var(--muted); }
.howto ol strong { color: var(--ink); }
.content-section h2 { font-size: 1.5rem; letter-spacing: -.03em; margin: 0 0 6px; }
.content-section > p { color: var(--muted); max-width: 70ch; }

.related { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-top: 14px; }

.palette { display: grid; grid-template-columns: repeat(5, 1fr); height: 150px; margin-top: 14px; overflow: hidden; border-radius: 14px; border: 1px solid var(--line); }
.swatch { display: flex; align-items: end; justify-content: center; padding: 8px 2px; color: #fff; text-shadow: 0 1px 3px rgba(0,0,0,.6); font: 500 .65rem "DM Mono", monospace; cursor: pointer; border: 0; }
.qr-wrap { display: flex; gap: 20px; align-items: flex-start; flex-wrap: wrap; }
#qrBox { padding: 14px; background: #fff; border: 1px solid var(--line); border-radius: 12px; min-width: 170px; min-height: 170px; display: grid; place-items: center; }
.countdown-digits { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 14px; }
.cd-cell { flex: 1 1 100px; text-align: center; padding: 16px 8px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-2); }
.cd-cell b { display: block; font: 500 2rem "DM Mono", monospace; color: var(--blue); }
.cd-cell span { font-size: .72rem; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; }

/* ---------- responsive ---------- */
@media (max-width: 930px) {
  .intro { grid-template-columns: 1fr; gap: 24px; }
  .hero-mascot { justify-self: start; width: 180px; }
  .pinned { grid-template-columns: 1fr 1fr; }
  .tool-card.password { grid-column: 1 / -1; min-height: auto; }
  .az-grid { grid-template-columns: 1fr 1fr; }
  .related { grid-template-columns: 1fr; }
  .footer-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 650px) {
  .page { width: min(100% - 20px, 1180px); padding-top: 28px; }
  .site-nav a:not(:first-child) { display: none; }
  .pinned, .categories, .az-grid { grid-template-columns: 1fr; }
  .tool-card.password, .tool-card.calc, .tool-card.random { min-height: 0; border-radius: 20px 5px 20px 5px; }
  .tool-links { grid-template-columns: 1fr; }
  .widget-grid { grid-template-columns: 1fr; }
  .palette { height: 220px; grid-template-columns: 1fr; }
  .swatch { align-items: center; justify-content: flex-start; padding-left: 14px; }
  .tool-hero { flex-direction: column; align-items: flex-start; gap: 14px; }
  .footer-grid { grid-template-columns: 1fr; }
  .footer-bottom { flex-direction: column; }
  .search kbd { display: none; }
}
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } .toast { transition: none; } }
