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

:root {
  --bg: #0a0a0a;
  --surface: #111111;
  --surface2: #161616;
  --border: #1e1e1e;
  --accent: #ff4c6a;
  --accent2: #ff8c42;
  --ok: #3ecf8e;
  --skip: #aaaaaa;
  --text: #ffffff;
  --muted: #e4e4e4;
  --font-display: 'Bebas Neue', sans-serif;
  --font-body: 'DM Sans', sans-serif;
  --font-mono: 'DM Mono', monospace;
}

html,
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  min-height: 100vh;
  overflow-x: hidden;
  overflow-wrap: anywhere;
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)' opacity='0.04'/%3E%3C/svg%3E");
  pointer-events: none;
  z-index: 999;
  opacity: 0.4;
}

/* ── Header ── */
.header {
  border-bottom: 1px solid var(--border);
  padding: 20px 48px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  position: sticky;
  top: 0;
  background: rgba(10, 10, 10, 0.95);
  backdrop-filter: blur(12px);
  z-index: 100;
}

.nav-toggle {
  display: none;
  background: transparent;
  border: none;
  color: var(--text);
  font-size: 24px;
  cursor: pointer;
  padding: 4px;
  line-height: 1;
}

.header-logo {
  font-family: var(--font-display);
  font-size: 22px;
  letter-spacing: 2px;
  color: var(--text);
}

.header-logo span {
  color: var(--accent);
}

.header-user {
  display: flex;
  align-items: center;
  gap: 20px;
  font-size: 13px;
  color: var(--muted);
}

.header-user strong {
  color: var(--text);
}

.btn-logout {
  font-size: 11px;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--muted);
  text-decoration: none;
  border: 1px solid var(--border);
  padding: 6px 14px;
  transition: all 0.2s;
}

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

/* ── Main layout ── */
.main {
  max-width: 1440px;
  margin: 40px auto;
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 40px;
  padding: 0 24px;
  min-height: calc(100vh - 400px);
}

.main.full-width {
  max-width: 1440px;
  grid-template-columns: 1fr;
}

/* ── Scanner panel ── */
.scanner-panel {
  position: relative;
  min-width: 0;
}

.panel-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  margin-bottom: 24px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border);
}

.panel-title {
  font-family: var(--font-display);
  font-size: 32px;
  line-height: 1;
}

.panel-title span {
  color: var(--accent);
}

.panel-meta {
  font-size: 12px;
  color: var(--muted);
  letter-spacing: 1px;
  text-align: right;
  line-height: 1.8;
  white-space: normal;
}

/* ── Progress bar ── */
.progress-wrap {
  margin-bottom: 24px;
}

.progress-info {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 8px;
  font-family: var(--font-mono);
}

.progress-bar {
  height: 2px;
  background: var(--border);
  position: relative;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent2));
  width: 0%;
  transition: width 0.4s ease;
  position: relative;
}

.progress-fill::after {
  content: '';
  position: absolute;
  right: 0;
  top: -2px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent2);
  box-shadow: 0 0 8px var(--accent2);
}

/* ── Log ── */
.log {
  background: var(--surface);
  border: 1px solid var(--border);
  height: 520px;
  overflow-y: auto;
  overflow-x: hidden;
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.6;
  padding: 20px;
  scroll-behavior: smooth;
  position: relative;
}

.log::-webkit-scrollbar {
  width: 4px;
}

.log::-webkit-scrollbar-track {
  background: transparent;
}

.log::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 2px;
}

.log-entry {
  display: flex;
  gap: 12px;
  padding: 4px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.02);
  animation: fade-in 0.2s ease;
}

@keyframes fade-in {
  from {
    opacity: 0;
    transform: translateX(-4px);
  }

  to {
    opacity: 1;
    transform: translateX(0);
  }
}

.log-idx {
  color: var(--muted);
  min-width: 52px;
  text-align: right;
  flex-shrink: 0;
  white-space: nowrap;
}

.log-tag {
  min-width: 52px;
  flex-shrink: 0;
  font-weight: 500;
  text-align: center;
}

.log-name {
  color: var(--text);
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: normal;
  overflow-wrap: break-word;
}

.log-date {
  color: var(--muted);
  flex-shrink: 0;
}

.tag-ok {
  color: var(--ok);
}

.tag-inact {
  color: var(--accent);
}

.tag-skip {
  color: var(--skip);
}

.tag-info {
  color: var(--accent2);
}

/* ── Scan button ── */
.btn-scan {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  margin-top: 20px;
  padding: 16px;
  background: var(--accent);
  color: #fff;
  border: none;
  cursor: pointer;
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 2px;
  text-transform: uppercase;
  transition: all 0.2s;
}

.btn-scan:hover:not(:disabled) {
  background: #ff2d4f;
  box-shadow: 0 8px 32px rgba(255, 76, 106, 0.25);
  transform: translateY(-1px);
}

.btn-scan:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

/* ── Spinner ── */
.spinner {
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  display: none;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ── Right sidebar ── */
.sidebar {
  position: sticky;
  top: 100px;
}

.stats-card {
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 28px;
  margin-bottom: 16px;
  position: relative;
}

.stats-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--accent), var(--accent2));
}

.stats-title {
  font-size: 10px;
  letter-spacing: 3px;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 20px;
}

.stat-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}

.stat-item:last-child {
  border-bottom: none;
}

.stat-item-label {
  color: #e4e4e4;
}

.stat-item-value {
  font-family: var(--font-mono);
  font-size: 15px;
  font-weight: 500;
}

.val-total {
  color: var(--text);
}

.val-ok {
  color: var(--ok);
}

.val-inact {
  color: var(--accent);
}

.val-skip {
  color: var(--muted);
}

/* ── Inactive list ── */
.inactive-card {
  background: var(--surface2);
  border: 1px solid var(--border);
  padding: 20px;
}

.inactive-title {
  font-family: var(--font-display);
  font-size: 18px;
  margin-bottom: 2px;
}

.inactive-subtitle {
  font-size: 10px;
  color: var(--muted);
  letter-spacing: 1px;
  margin-bottom: 16px;
}

.inactive-list {
  max-height: 150px;
  overflow-y: auto;
}

.inactive-list::-webkit-scrollbar {
  width: 3px;
}

.inactive-list::-webkit-scrollbar-thumb {
  background: var(--border);
}

.inactive-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  animation: fade-in 0.3s ease;
}

.inactive-item:last-child {
  border-bottom: none;
}

.inactive-name {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--accent);
}

.inactive-meta {
  font-size: 11px;
  color: var(--muted);
}

.inactive-empty {
  font-size: 12px;
  color: var(--muted);
  font-style: italic;
  padding: 12px 0;
}

/* ── Done banner ── */
.done-banner {
  display: none;
  margin-top: 20px;
  padding: 16px 20px;
  background: rgba(62, 207, 142, 0.08);
  border: 1px solid rgba(62, 207, 142, 0.2);
  font-size: 13px;
  color: var(--ok);
  letter-spacing: 1px;
  overflow-wrap: break-word;
  word-break: break-all;
}

/* ── Responsive ── */
@media (max-width: 900px) {
  .main {
    grid-template-columns: minmax(0, 1fr);
    padding: 24px;
    gap: 24px;
    width: 100%;
  }

  .sidebar {
    position: static;
    display: block;
    width: 100%;
  }
}

@media (max-width: 768px) {
  .main {
    padding: 16px;
  }

  .header {
    padding: 16px 20px;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    box-sizing: border-box;
  }

  .nav-toggle {
    display: block;
  }

  .header-user {
    display: none;
    width: 100%;
    flex-direction: column;
    align-items: flex-start;
    padding-top: 16px;
    margin-top: 16px;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    gap: 8px;
  }

  .header-user.is-active {
    display: flex;
  }

  .h-dot {
    display: none;
  }

  .h-user,
  .h-stats {
    display: block;
    width: 100%;
    font-size: 13px;
    line-height: 1.5;
  }

  .btn-logout {
    margin-top: 8px;
    width: 100%;
    text-align: center;
    padding: 12px;
  }
}

@keyframes fade-in {
  from {
    opacity: 0;
    transform: translateY(4px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ── Connect Prompt (Step 2) ── */
.connect-prompt {
  animation: fade-in 0.4s ease;
  display: flex;
  flex-direction: column;
  padding: 40px;
  text-align: center;
  background: rgba(255, 255, 255, 0.02);
  border: 1px dashed var(--border);
  align-items: center;
  gap: 16px;
}

.btn-connect {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  background: #36465d !important;
  color: #fff !important;
  text-decoration: none;
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 2px;
  text-transform: uppercase;
  padding: 16px 32px;
  border: none;
  cursor: pointer;
  transition: all 0.2s ease;
  display: inline-flex;
  width: auto;
}

.btn-connect:hover {
  background: #46566d !important;
  transform: translateY(-1px);
}

.tumblr-icon {
  width: 18px;
  height: 18px;
  fill: #fff;
}