:root {
  --bg: #08080a;
  --surface: #0f0f13;
  --surface-2: #15151c;
  --border: #20202b;
  --border-hover: #343448;
  --text: #ededf5;
  --muted: #84849c;
  --dim: #55556b;
  --accent: #22c55e;
  --accent-bg: #14532d;
  --warn: #f59e0b;
  --danger: #ef4444;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --sans: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}

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

html, body {
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

body {
  display: flex;
  flex-direction: column;
}

/* Topbar */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(10, 10, 14, 0.88);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}

.topbar-inner {
  max-width: 960px;
  margin: 0 auto;
  padding: 0 20px;
  height: 56px;
  display: flex;
  align-items: center;
  gap: 20px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  font-weight: 700;
  font-size: 14px;
  color: var(--text);
  text-decoration: none;
  letter-spacing: -0.01em;
  white-space: nowrap;
}

.brand-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 10px rgba(34, 197, 94, 0.65);
}

.nav {
  display: flex;
  align-items: center;
  gap: 4px;
  overflow-x: auto;
}

.nav-btn {
  background: transparent;
  border: none;
  color: var(--muted);
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  padding: 8px 12px;
  border-radius: 8px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: color 0.15s, background 0.15s;
  white-space: nowrap;
}

.nav-btn:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.04);
}

.nav-btn.active {
  color: var(--text);
  background: var(--surface-2);
}

.pill-count {
  font-size: 11px;
  padding: 1px 6px;
  border-radius: 999px;
  background: #232332;
  color: #b8b8d0;
  font-variant-numeric: tabular-nums;
}

.status-chip {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 5px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--warn);
}

.status-chip.online .status-dot {
  background: var(--accent);
  box-shadow: 0 0 8px rgba(34, 197, 94, 0.6);
}

.status-chip.offline .status-dot {
  background: var(--danger);
}

/* Main Layout */
.container {
  flex: 1;
  width: 100%;
  max-width: 780px;
  margin: 0 auto;
  padding: 44px 20px 64px;
}

.tab-panel[hidden] {
  display: none;
}

.hero {
  text-align: center;
  margin-bottom: 30px;
}

.hero h1 {
  font-size: clamp(26px, 4.5vw, 36px);
  font-weight: 800;
  letter-spacing: -0.03em;
  margin-bottom: 8px;
}

.hero-sub {
  color: var(--muted);
  font-size: 13px;
}

.section-head {
  margin-bottom: 20px;
}

.section-head h2 {
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 4px;
}

.row-between {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
}

/* Cards & Forms */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 20px;
  margin-bottom: 16px;
}

.field-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.field-label, .result-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  color: var(--dim);
  text-transform: uppercase;
}

.field-actions {
  display: flex;
  gap: 10px;
}

.text-btn {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 12px;
  cursor: pointer;
  padding: 2px 4px;
}

.text-btn:hover {
  color: var(--text);
}

.input-wrap {
  margin-bottom: 12px;
}

input[type="url"],
.search-input {
  width: 100%;
  background: #0a0a0e;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 13px 14px;
  color: var(--text);
  font-family: var(--mono);
  font-size: 13px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.search-input {
  margin-top: 12px;
  font-family: var(--sans);
}

input[type="url"]:focus,
.search-input:focus {
  border-color: #3d3d56;
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.05);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 18px;
  border-radius: 10px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  border: 1px solid transparent;
  transition: background 0.15s, border-color 0.15s, transform 0.1s, opacity 0.15s;
  white-space: nowrap;
}

.btn:active {
  transform: scale(0.99);
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn-full {
  width: 100%;
}

.btn-primary {
  background: #f4f4f7;
  color: #09090b;
}

.btn-primary:hover:not(:disabled) {
  background: #ffffff;
}

.btn-light {
  background: #f4f4f7;
  color: #09090b;
}

.btn-light:hover {
  background: #ffffff;
}

.btn-secondary {
  background: var(--surface-2);
  color: var(--text);
  border-color: var(--border);
}

.btn-secondary:hover {
  background: #1d1d27;
  border-color: var(--border-hover);
}

.btn-ghost {
  background: transparent;
  color: var(--muted);
  border-color: var(--border);
}

.btn-ghost:hover {
  color: var(--text);
  border-color: var(--border-hover);
}

.btn:focus-visible,
.nav-btn:focus-visible,
.text-btn:focus-visible {
  outline: 2px solid #7dd3fc;
  outline-offset: 2px;
}

/* Result & Error */
.result-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}

.result-badges {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.tag {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(34, 197, 94, 0.12);
  color: #4ade80;
  border: 1px solid rgba(34, 197, 94, 0.28);
}

.tag-warn {
  background: rgba(245, 158, 11, 0.14);
  color: #fbbf24;
  border-color: rgba(245, 158, 11, 0.3);
}

.tag-expired {
  background: rgba(239, 68, 68, 0.14);
  color: #f87171;
  border-color: rgba(239, 68, 68, 0.3);
}

.tag-script {
  background: rgba(139, 92, 246, 0.14);
  color: #c4b5fd;
  border-color: rgba(139, 92, 246, 0.3);
}

.meta-time {
  font-size: 12px;
  color: var(--dim);
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
}

.hash-bar-track {
  height: 3px;
  border-radius: 99px;
  background: #1a1a24;
  overflow: hidden;
  margin-bottom: 12px;
}

.hash-bar-fill {
  height: 100%;
  width: 100%;
  background: var(--accent);
  transition: width 0.15s linear, background 0.25s ease;
}

.result-box {
  background: #0a0a0e;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 13px 14px;
  font-family: var(--mono);
  font-size: 12.5px;
  line-height: 1.55;
  color: #e4e4ef;
  word-break: break-all;
  white-space: pre-wrap;
  max-height: 240px;
  overflow-y: auto;
  user-select: all;
  margin-bottom: 14px;
}

.action-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.error-card {
  border-color: rgba(239, 68, 68, 0.35);
}

.error-label {
  color: #f87171;
}

.error-text {
  color: #fca5a5;
  font-size: 13px;
  margin-bottom: 14px;
  line-height: 1.5;
}

/* Feature grid */
.quick-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 12px;
  margin-top: 24px;
}

.mini-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
}

.mini-title {
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 6px;
}

.mini-desc {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.5;
}

/* Supported platforms grid */
.platforms-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 12px;
}

.platform-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
}

.platform-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
}

.platform-name {
  font-weight: 600;
  font-size: 13.5px;
}

.domain-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.domain-chip {
  font-family: var(--mono);
  font-size: 11px;
  padding: 2px 7px;
  border-radius: 6px;
  background: #0a0a0e;
  border: 1px solid #1d1d28;
  color: #a6a6be;
}

/* Userscript tab */
.us-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 16px;
}

.us-title {
  font-size: 15px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}

.us-btns {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.steps-list {
  padding-left: 18px;
  color: var(--muted);
  font-size: 13px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.steps-list strong {
  color: var(--text);
}

/* History */
.history-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.history-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.history-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 11px;
  color: var(--dim);
}

.history-src {
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.history-res {
  font-family: var(--mono);
  font-size: 12px;
  color: #7dd3fc;
  word-break: break-all;
}

.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--dim);
  border: 1px dashed var(--border);
  border-radius: 12px;
}

/* Footer */
.footer {
  border-top: 1px solid var(--border);
  padding: 18px 20px;
  font-size: 12px;
  color: var(--dim);
}

.footer-inner {
  max-width: 960px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.footer-links {
  display: flex;
  gap: 16px;
}

.footer-links a {
  color: var(--muted);
  text-decoration: none;
}

.footer-links a:hover {
  color: var(--text);
}

@media (max-width: 600px) {
  .status-chip { display: none; }
  .container { padding: 28px 14px 48px; }
}
