* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }

:root {
  --bg: #16171a;
  --surface: #1e1f22;
  --surface-2: #27282c;
  --border: #303136;
  --text: #f2f2f3;
  --text-muted: #9a9ca3;
  --accent: #4f8cff;
  --accent-hover: #3d78e6;
  --success: #3ecf6a;
  --danger: #e05555;
  --radius: 10px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  display: flex;
  flex-direction: column;
}

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

button {
  font-family: inherit;
}

/* ---- Home page ---- */

.page {
  min-height: 100%;
  display: flex;
  flex-direction: column;
}

.hero {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 3rem 1.5rem 2rem;
  gap: 0.25rem;
}

.hero .mark {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  background: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 1.25rem;
  font-size: 1.5rem;
}

.hero h1 {
  font-size: 2rem;
  font-weight: 700;
  margin: 0 0 0.5rem;
  letter-spacing: -0.02em;
}

.hero p.tagline {
  color: var(--text-muted);
  margin: 0 0 1.75rem;
  font-size: 1.05rem;
  max-width: 32rem;
}

.btn {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  padding: 0.8rem 1.75rem;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease;
}
.btn:hover { background: var(--accent-hover); }
.btn:disabled { opacity: 0.6; cursor: default; }

.error-note {
  color: var(--danger);
  font-size: 0.85rem;
  margin: 0.75rem 0 0;
}

.btn-icon {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  width: 34px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.btn-icon:hover { background: var(--border); }
.btn-icon svg { width: 17px; height: 17px; }

.features {
  width: 100%;
  max-width: 52rem;
  margin: 0 auto;
  padding: 0 1.5rem 3rem;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
}

.feature {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  text-align: left;
}
.feature .icon { font-size: 1.3rem; margin-bottom: 0.5rem; display: block; }
.feature h3 {
  font-size: 0.95rem;
  margin: 0 0 0.35rem;
  font-weight: 600;
}
.feature p {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin: 0;
  line-height: 1.45;
}

.feature.volatile {
  border-color: rgba(79, 140, 255, 0.35);
  background: linear-gradient(180deg, rgba(79, 140, 255, 0.08), var(--surface));
}

@media (max-width: 700px) {
  .features { grid-template-columns: 1fr; }
}

/* ---- Footer / Islay credit ---- */

.site-footer {
  border-top: 1px solid var(--border);
  padding: 1.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
}

.islay-credit {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  text-decoration: none;
  color: var(--text-muted);
  font-size: 0.8rem;
}
.islay-credit:hover { color: var(--text); }

.islay-credit .badge {
  background: #fff;
  border-radius: 7px;
  padding: 3px 8px;
  display: inline-flex;
  align-items: center;
  line-height: 0;
}
.islay-credit .badge img { height: 16px; display: block; }

.footer-sep { color: var(--border); font-size: 0.8rem; }
.footer-link {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.8rem;
}
.footer-link:hover { color: var(--text); }

/* ---- Bin page ---- */

.bin-header {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.6rem 1rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.85rem;
  color: var(--text-muted);
  position: relative;
}
.bin-header a.home-link {
  color: var(--text-muted);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  font-size: 1.05rem;
}
.bin-header a.home-link:hover { color: var(--text); }
.bin-header .slug {
  color: var(--text);
  font-weight: 600;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}
.bin-header .actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}
.status { display: flex; align-items: center; gap: 0.3rem; }
.status::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--danger);
}
.status.connected::before { background: var(--success); }

.qr-panel {
  position: absolute;
  top: calc(100% + 8px);
  right: 1rem;
  background: #fff;
  border-radius: var(--radius);
  padding: 1rem;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.4);
  display: none;
  flex-direction: column;
  align-items: center;
  gap: 0.6rem;
  z-index: 10;
  width: 200px;
}
.qr-panel.open { display: flex; }
.qr-panel img, .qr-panel svg { width: 168px; height: 168px; }
.qr-panel .qr-hint {
  color: #55575c;
  font-size: 0.75rem;
  text-align: center;
  word-break: break-all;
}

#editor {
  flex: 1;
  width: 100%;
  border: none;
  outline: none;
  resize: none;
  background: var(--bg);
  color: var(--text);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 1rem;
  padding: 1.25rem;
  line-height: 1.5;
}
#editor::placeholder { color: var(--text-muted); }

.bin-footer {
  padding: 0.75rem 1rem;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}
.bin-footer .expiry-note {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.toast {
  position: fixed;
  bottom: 1.25rem;
  left: 50%;
  transform: translateX(-50%) translateY(8px);
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.55rem 1rem;
  border-radius: 8px;
  font-size: 0.85rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease, transform 0.15s ease;
}
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ---- Stats page ---- */

.stats-header {
  text-align: center;
  padding: 2.5rem 1.5rem 1.5rem;
}
.stats-header .home-link {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 1.5rem;
}
.stats-header h1 {
  font-size: 1.5rem;
  margin: 0.75rem 0 0.4rem;
  letter-spacing: -0.02em;
}
.stats-header p.tagline.small {
  color: var(--text-muted);
  font-size: 0.85rem;
  margin: 0 auto;
  max-width: 30rem;
}

.stats-content {
  width: 100%;
  max-width: 60rem;
  margin: 0 auto;
  padding: 0 1.5rem 3rem;
  flex: 1;
}

.loading {
  color: var(--text-muted);
  text-align: center;
  padding: 2rem 0;
}

.stats-period { margin-bottom: 2rem; }
.stats-period h2 {
  font-size: 1rem;
  font-weight: 600;
  margin: 0 0 0.75rem;
  color: var(--text-muted);
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 0.75rem;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
}
.stat-value {
  font-size: 1.6rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}
.stat-label {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 0.2rem;
}
.stat-sub {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-top: 0.4rem;
  opacity: 0.8;
}

.stats-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}
.stats-table th, .stats-table td {
  text-align: left;
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid var(--border);
}
.stats-table th {
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

@media (max-width: 500px) {
  .stats-table th:nth-child(4), .stats-table td:nth-child(4) { display: none; }
}
