/* utf8.se, modular UTF-8 toolbox. Single global stylesheet. */

:root {
  --bg: #0e1116;
  --bg-elev: #161b22;
  --bg-elev-2: #1c2330;
  --border: #2a313c;
  --border-soft: #222831;
  --text: #e6edf3;
  --text-dim: #9aa7b4;
  --text-faint: #6b7682;
  --accent: #7c9eff;
  --accent-2: #62d6c4;
  --accent-warm: #ffb86b;
  --danger: #ff6b6b;
  --ok: #4ade80;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", "Fira Code", Menlo, Consolas, monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --radius: 12px;
  --radius-sm: 8px;
  --sidebar-w: 280px;
  --maxw: 980px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

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

button, input, textarea, select {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
}

::selection { background: rgba(124, 158, 255, 0.32); }

/* ---------- Layout ---------- */
.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 100vh;
}

.sidebar {
  background: var(--bg-elev);
  border-right: 1px solid var(--border-soft);
  padding: 22px 16px 40px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.brand {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 0 8px;
  cursor: pointer;
  user-select: none;
}
.brand .logo {
  font-family: var(--mono);
  font-weight: 700;
  font-size: 1.35rem;
  letter-spacing: -0.5px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.brand .tld { color: var(--text-faint); font-family: var(--mono); font-size: 1.1rem; }

.menu-search {
  position: relative;
}
.menu-search input {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  outline: none;
}
.menu-search input:focus { border-color: var(--accent); }

.menu { display: flex; flex-direction: column; gap: 18px; }
.menu-group-title {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--text-faint);
  padding: 0 10px;
  margin-bottom: 6px;
  font-weight: 600;
}
.menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  color: var(--text-dim);
  cursor: pointer;
  border: 1px solid transparent;
  width: 100%;
  text-align: left;
  background: none;
}
.menu-item:hover { background: var(--bg-elev-2); color: var(--text); text-decoration: none; }
.menu-item.active {
  background: var(--bg-elev-2);
  color: var(--text);
  border-color: var(--border);
}
.menu-item .mi-icon { font-size: 1.1rem; width: 1.4rem; text-align: center; flex: none; }
.menu-item .mi-title { font-size: 0.93rem; }

.sidebar-foot {
  margin-top: auto;
  padding: 0 10px;
  font-size: 0.75rem;
  color: var(--text-faint);
}
.sidebar-foot code { font-family: var(--mono); }
.sidebar-foot a { color: var(--text-faint); text-decoration: underline; }
.sidebar-foot a:hover { color: var(--accent); }

.license-text {
  font-family: var(--mono);
  font-size: 0.8rem;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
  margin: 0;
  color: var(--text-dim);
}

/* ---------- Main content ---------- */
.main {
  padding: 40px 40px 80px;
  overflow-x: hidden;
}
.view { max-width: var(--maxw); margin: 0 auto; }

.view-head { margin-bottom: 28px; }
.view-head h1 {
  margin: 0 0 6px;
  font-size: 1.9rem;
  letter-spacing: -0.5px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.view-head h1 .icon { font-size: 1.6rem; }
.view-head p { margin: 0; color: var(--text-dim); max-width: 70ch; }

/* ---------- Cards / home ---------- */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 16px;
}
.card {
  background: var(--bg-elev);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 18px;
  cursor: pointer;
  transition: border-color 0.15s, transform 0.15s, background 0.15s;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
  text-decoration: none;
  background: var(--bg-elev-2);
}
.card .card-icon { font-size: 1.7rem; }
.card h3 { margin: 0; font-size: 1.05rem; }
.card p { margin: 0; color: var(--text-dim); font-size: 0.88rem; }

.home-category { margin-bottom: 36px; }
.home-category > h2 {
  font-size: 1.05rem;
  color: var(--text-dim);
  font-weight: 600;
  margin: 0 0 14px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border-soft);
}

.hero {
  background: linear-gradient(135deg, rgba(124, 158, 255, 0.10), rgba(98, 214, 196, 0.08));
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 30px 32px;
  margin-bottom: 40px;
}
.hero h1 { margin: 0 0 8px; font-size: 2.1rem; letter-spacing: -1px; }
.hero p { margin: 0; color: var(--text-dim); max-width: 65ch; }
.hero .hero-glyphs { font-size: 1.7rem; margin-top: 14px; letter-spacing: 4px; opacity: 0.8; }

/* ---------- Generic controls ---------- */
.panel {
  background: var(--bg-elev);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 18px;
}
.panel h2 { margin: 0 0 14px; font-size: 1.05rem; }

label.field { display: block; margin-bottom: 14px; }
label.field > span.lbl {
  display: block;
  font-size: 0.82rem;
  color: var(--text-dim);
  margin-bottom: 6px;
}

textarea, input[type="text"], input[type="number"], select {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 11px 13px;
  outline: none;
  resize: vertical;
}
textarea:focus, input:focus, select:focus { border-color: var(--accent); }
textarea { min-height: 120px; font-family: var(--mono); line-height: 1.5; }
select { cursor: pointer; }

.row { display: flex; gap: 14px; flex-wrap: wrap; align-items: flex-end; }
.row > * { flex: 1; min-width: 140px; }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: var(--accent);
  color: #0c1018;
  border: none;
  border-radius: var(--radius-sm);
  padding: 10px 16px;
  font-weight: 600;
  cursor: pointer;
  transition: filter 0.15s, transform 0.05s;
}
.btn:hover { filter: brightness(1.08); }
.btn:active { transform: translateY(1px); }
.btn.secondary { background: var(--bg-elev-2); color: var(--text); border: 1px solid var(--border); }
.btn.ghost { background: transparent; color: var(--text-dim); border: 1px solid var(--border); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

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

.chip-row { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 5px 13px;
  font-size: 0.85rem;
  cursor: pointer;
  color: var(--text-dim);
  white-space: nowrap;
}
.chip:hover { color: var(--text); border-color: var(--accent); }
.chip.active { background: var(--accent); color: #0c1018; border-color: var(--accent); font-weight: 600; }

/* ---------- Stat blocks ---------- */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 12px;
}
.stat {
  background: var(--bg);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
}
.stat .stat-val { font-size: 1.5rem; font-weight: 700; font-family: var(--mono); }
.stat .stat-lbl { font-size: 0.78rem; color: var(--text-dim); margin-top: 2px; }
.stat.accent .stat-val { color: var(--accent-2); }

.notice {
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font-size: 0.9rem;
  border: 1px solid;
}
.notice.ok { background: rgba(74, 222, 128, 0.08); border-color: rgba(74, 222, 128, 0.4); color: #b6f3cd; }
.notice.err { background: rgba(255, 107, 107, 0.08); border-color: rgba(255, 107, 107, 0.4); color: #ffc4c4; }
.notice.info { background: rgba(124, 158, 255, 0.08); border-color: rgba(124, 158, 255, 0.35); color: #cfdbff; }

.mono { font-family: var(--mono); }
.dim { color: var(--text-dim); }
.faint { color: var(--text-faint); }

.output-box {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px;
  min-height: 60px;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 1.05rem;
  line-height: 1.7;
}

.copy-hint { font-size: 0.78rem; color: var(--text-faint); margin-top: 6px; }

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 0.9rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  z-index: 100;
  box-shadow: 0 8px 30px rgba(0,0,0,0.4);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- Mobile ---------- */
/* These are only used on small screens; keep them out of the desktop grid. */
.menu-toggle, .scrim { display: none; }
@media (max-width: 820px) {
  .app { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed;
    z-index: 50;
    width: var(--sidebar-w);
    transform: translateX(-100%);
    transition: transform 0.2s;
    box-shadow: 0 0 40px rgba(0,0,0,0.5);
  }
  .app.menu-open .sidebar { transform: translateX(0); }
  .main { padding: 70px 18px 60px; }
  .menu-toggle {
    display: flex;
    position: fixed;
    top: 14px;
    left: 14px;
    z-index: 60;
    background: var(--bg-elev-2);
    border: 1px solid var(--border);
    color: var(--text);
    border-radius: var(--radius-sm);
    width: 42px; height: 42px;
    align-items: center; justify-content: center;
    font-size: 1.2rem;
    cursor: pointer;
  }
  .scrim {
    display: none;
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 40;
  }
  .app.menu-open .scrim { display: block; }
}
