:root {
  --bg: #0f172a;
  --surface: #1e293b;
  --border: #334155;
  --text: #e2e8f0;
  --muted: #94a3b8;
  --primary: #3b82f6;
  --primary-hover: #2563eb;
  --success: #22c55e;
  --error: #ef4444;
  --radius: 10px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  direction: ltr;
}

header { text-align: center; padding: 1.75rem 1rem 1rem; }
header h1 { font-size: 1.85rem; font-weight: 700; letter-spacing: -0.02em; }
.subtitle { color: var(--muted); font-size: 0.95rem; margin-top: 0.35rem; max-width: 520px; margin-left: auto; margin-right: auto; }

.ad-slot {
  margin: 0.75rem auto;
  max-width: 728px;
  min-height: 50px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.ad-leaderboard { display: none; min-height: 90px; }
.ad-mobile { display: flex; min-height: 50px; }
.ad-rect { min-height: 250px; margin-top: 1.25rem; }
.ad-native { min-height: 80px; width: 100%; max-width: 640px; }
.ad-bottom-banner { min-height: 60px; }

@media (min-width: 768px) {
  .ad-leaderboard { display: flex; }
  .ad-mobile { display: none; }
}

.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  justify-content: center;
  padding: 0.75rem 1rem;
  max-width: 980px;
  margin: 0 auto;
}

.tab {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--muted);
  padding: 0.4rem 0.75rem;
  border-radius: 999px;
  cursor: pointer;
  font-size: 0.8rem;
  transition: all 0.15s ease;
}
.tab:hover { color: var(--text); border-color: var(--primary); }
.tab.active { background: var(--primary); border-color: var(--primary); color: #fff; }

main { flex: 1; max-width: 640px; width: 100%; margin: 0 auto; padding: 1rem; }

.tool {
  display: none;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.35rem;
}
.tool.active { display: block; }
.tool h2 { font-size: 1.2rem; margin-bottom: 0.35rem; font-weight: 600; }
.tool-desc { color: var(--muted); font-size: 0.875rem; margin-bottom: 1rem; }

textarea, input[type="number"], input[type="datetime-local"], input[type="text"], select {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  padding: 0.7rem 0.9rem;
  font-size: 0.95rem;
  font-family: inherit;
  resize: vertical;
}
textarea:focus, input:focus, select:focus { outline: none; border-color: var(--primary); }

.btn {
  display: inline-block;
  background: var(--primary);
  color: #fff;
  border: none;
  padding: 0.55rem 1rem;
  border-radius: 8px;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  margin-top: 0.6rem;
  transition: background 0.15s ease;
}
.btn:hover { background: var(--primary-hover); }
.btn.secondary { background: transparent; border: 1px solid var(--border); color: var(--text); }
.btn.secondary:hover { border-color: var(--primary); color: var(--primary); }

.btn-row { display: flex; gap: 0.45rem; flex-wrap: wrap; }

.result {
  margin-top: 1rem;
  padding: 0.85rem;
  background: var(--bg);
  border-radius: 8px;
  border: 1px solid var(--border);
  min-height: 2.5rem;
  word-break: break-all;
  white-space: pre-wrap;
}
.result.code { font-family: ui-monospace, "Cascadia Code", "Source Code Pro", Menlo, monospace; font-size: 0.875rem; }
.result:empty { display: none; }

#qr-result { display: flex; justify-content: center; padding: 1rem; white-space: normal; }
#qr-result canvas, #qr-result img { max-width: 220px; border-radius: 8px; }

.field { margin-bottom: 0.75rem; }
.field label { display: block; font-size: 0.85rem; color: var(--muted); margin-bottom: 0.35rem; }

.checkboxes { display: flex; flex-wrap: wrap; gap: 0.75rem 1.25rem; margin: 0.75rem 0; }
.checkboxes label { display: flex; align-items: center; gap: 0.35rem; font-size: 0.9rem; cursor: pointer; }

input[type="range"] { width: 100%; accent-color: var(--primary); }

.status { margin-top: 0.5rem; font-size: 0.85rem; }
.status.ok { color: var(--success); }
.status.err { color: var(--error); }

.faq {
  margin-top: 1.5rem;
  padding: 1.25rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.faq h2 { font-size: 1.1rem; margin-bottom: 0.75rem; }
.faq h3 { font-size: 0.95rem; margin-top: 0.75rem; color: var(--text); }
.faq p { font-size: 0.875rem; color: var(--muted); margin-top: 0.25rem; }

footer {
  text-align: center;
  padding: 1.75rem 1rem;
  color: var(--muted);
  font-size: 0.85rem;
}
footer a { color: var(--primary); }
footer .small { font-size: 0.75rem; margin-top: 0.3rem; opacity: 0.9; }

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

@media (max-width: 480px) {
  header h1 { font-size: 1.45rem; }
  .tabs { gap: 0.25rem; }
  .tab { padding: 0.35rem 0.55rem; font-size: 0.72rem; }
}
