/* ============================================================ */
/* DESIGN SYSTEM */
/* ============================================================ */
:root {
  --bg-main: #0a0a0a;
  --bg-surface: rgba(255, 255, 255, 0.02);
  --bg-surface-hover: rgba(255, 255, 255, 0.04);
  --bg-elevated: rgba(255, 255, 255, 0.05);
  --text-main: #e8e8ea;
  --text-secondary: rgba(255, 255, 255, 0.6);
  --text-muted: rgba(255, 255, 255, 0.35);
  --border: rgba(255, 255, 255, 0.06);
  --border-hover: rgba(255, 255, 255, 0.12);
  --color-primary: #f43f5e;
  --color-primary-soft: rgba(244, 63, 94, 0.15);
  --blob-a: rgba(244, 63, 94, 0.08);
  --blob-b: rgba(255, 255, 255, 0.02);
  --btn-bg: #f0f0f2;
  --btn-text: #0a0a0a;
  --input-bg: rgba(255, 255, 255, 0.03);
  --input-border: rgba(255, 255, 255, 0.07);
  --input-focus-bg: rgba(255, 255, 255, 0.05);
  --input-focus-border: rgba(255, 255, 255, 0.18);
  --line-accent: linear-gradient(90deg, transparent 0%, rgba(255, 255, 255, 0.15) 50%, transparent 100%);
  --radius: 10px;
  --radius-sm: 6px;
  --space-xs: 0.5rem;
  --space-sm: 0.75rem;
  --space-md: 1.25rem;
  --space-lg: 2rem;
  --space-xl: 3rem;
  --grain-opacity: 0.25;
  --grain-scale: 1;
  --color-success: #34d399;
  --color-info: #60a5fa;
  --color-warning: #fbbf24;
  --color-error: #f87171;
  --transition: 0.15s ease;
}

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

html { font-size: 14px; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Inter', 'Segoe UI', sans-serif;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  background: var(--bg-main);
  color: var(--text-main);
  min-height: 100vh;
}

/* ============================================================ */
/* BACKGROUND */
/* ============================================================ */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(ellipse at 15% 10%, var(--blob-a) 0%, transparent 50%),
    radial-gradient(ellipse at 85% 90%, var(--blob-b) 0%, transparent 50%);
}

/* ============================================================ */
/* LAYOUT */
/* ============================================================ */
.app {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  position: relative;
  z-index: 1;
}

/* ============================================================ */
/* NAV */
/* ============================================================ */
.nav {
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--space-lg);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(12px);
  background: rgba(10, 10, 10, 0.6);
  position: sticky;
  top: 0;
  z-index: 100;
}

.nav-brand {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-main);
  text-decoration: none;
  letter-spacing: -0.02em;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 2px;
}

.nav-link {
  font-size: 0.8rem;
  color: var(--text-muted);
  text-decoration: none;
  transition: color var(--transition);
  padding: 6px 10px;
  border-radius: var(--radius-sm);
}

.nav-link:hover { color: var(--text-main); }
.nav-link.active { color: var(--text-main); }

.nav-user {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-left: var(--space-md);
  padding-left: var(--space-md);
  border-left: 1px solid var(--border);
}

/* ============================================================ */
/* MAIN */
/* ============================================================ */
.main {
  flex: 1;
  padding: var(--space-lg);
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
}

/* ============================================================ */
/* BUTTONS */
/* ============================================================ */
.btn {
  font-size: 0.8rem;
  font-family: inherit;
  color: var(--text-secondary);
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 6px 14px;
  cursor: pointer;
  transition: all var(--transition);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

.btn:hover {
  color: var(--text-main);
  border-color: var(--border-hover);
  background: var(--bg-surface-hover);
}

.btn-primary {
  background: var(--btn-bg);
  color: var(--btn-text);
  border: none;
  font-weight: 600;
  padding: 7px 16px;
}

.btn-primary:hover { background: #d8d8da; color: var(--btn-text); }

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

.btn-danger {
  color: var(--color-error);
  border-color: rgba(248, 113, 113, 0.2);
}

.btn-danger:hover {
  border-color: rgba(248, 113, 113, 0.4);
  background: rgba(248, 113, 113, 0.06);
}

.btn-success {
  color: var(--color-success);
  border-color: rgba(52, 211, 153, 0.2);
}

.btn-success:hover {
  border-color: rgba(52, 211, 153, 0.4);
  background: rgba(52, 211, 153, 0.06);
}

.btn-sm {
  font-size: 0.75rem;
  padding: 4px 10px;
}

/* ============================================================ */
/* SECTION HEADERS */
/* ============================================================ */
.section-title {
  font-size: 0.95rem;
  font-weight: 600;
  margin-bottom: var(--space-md);
  letter-spacing: -0.01em;
}

/* ============================================================ */
/* CARDS */
/* ============================================================ */
.card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--space-md);
}

/* ============================================================ */
/* STATUS BAR */
/* ============================================================ */
.status-bar {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: 8px var(--space-md);
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: var(--space-lg);
  font-size: 0.8rem;
}

.status-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  display: inline-block;
}

.status-dot.ready { background: var(--color-success); }
.status-dot.published { background: var(--color-info); }

/* ============================================================ */
/* SERVER WIDGET */
/* ============================================================ */
.server-widget {
  position: fixed;
  bottom: 16px;
  left: 16px;
  z-index: 900;
}

.server-widget-btn {
  padding: 6px 14px;
  font-size: 0.7rem;
  font-family: inherit;
  font-weight: 500;
  color: var(--text-secondary);
  background: var(--bg-main);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: all var(--transition);
}

.server-widget-btn:hover {
  border-color: var(--border-hover);
  color: var(--text-main);
}

.server-widget-list {
  display: none;
  flex-direction: column;
  gap: 2px;
  position: absolute;
  bottom: 100%;
  left: 0;
  margin-bottom: 4px;
  background: var(--bg-main);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 6px;
  min-width: 160px;
}

.server-widget.open .server-widget-list { display: flex; }

.server-widget-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 10px;
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.server-widget-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}

.server-widget-dot.online { background: var(--color-success); }
.server-widget-dot.offline { background: var(--color-error); }

/* ============================================================ */
/* EMPTY STATE */
/* ============================================================ */
.empty-state {
  text-align: center;
  padding: 48px 20px;
  color: var(--text-muted);
  font-size: 0.85rem;
}

/* ============================================================ */
/* AUTH PAGE */
/* ============================================================ */
.auth-page {
  flex: 1;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}

.auth-blobs {
  position: fixed;
  inset: -50%;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(ellipse at 20% 20%, var(--blob-a) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 80%, var(--blob-b) 0%, transparent 50%);
  animation: blob-drift 12s ease-in-out infinite alternate;
}

@keyframes blob-drift {
  0% { transform: translate(-18%, -18%) rotate(0deg); }
  100% { transform: translate(18%, 18%) rotate(5deg); }
}

.auth-grain {
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  opacity: var(--grain-opacity);
  background:
    radial-gradient(ellipse at 20% 20%, var(--blob-a) 0%, transparent 100%),
    radial-gradient(ellipse at 80% 80%, var(--blob-b) 0%, transparent 100%);
  mask-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 512 512' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.7' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)'/%3E%3C/svg%3E");
  mask-size: calc(512px * var(--grain-scale));
  mask-repeat: repeat;
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 512 512' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.7' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)'/%3E%3C/svg%3E");
  -webkit-mask-size: calc(512px * var(--grain-scale));
  -webkit-mask-repeat: repeat;
}

.auth-container {
  position: relative;
  z-index: 2;
  width: 100%;
  max-width: 380px;
  padding: 40px;
}

.auth-topline {
  position: absolute;
  top: 0;
  left: 40px;
  right: 40px;
  height: 1px;
  background: var(--line-accent);
}

.auth-title {
  font-size: 1.4rem;
  font-weight: 600;
  color: var(--text-main);
  margin-bottom: 32px;
  letter-spacing: -0.02em;
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.auth-field {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.auth-label {
  font-size: 12px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.auth-input {
  width: 100%;
  padding: 12px 14px;
  font-size: 14px;
  font-family: inherit;
  background: var(--input-bg);
  border: 1px solid var(--input-border);
  border-radius: var(--radius-sm);
  color: var(--text-main);
  outline: none;
  transition: background var(--transition), border-color var(--transition);
}

.auth-input:focus {
  background: var(--input-focus-bg);
  border-color: var(--input-focus-border);
}

.auth-input::placeholder {
  color: var(--text-muted);
  opacity: 0.6;
}

.auth-btn {
  width: 100%;
  padding: 12px;
  margin-top: 4px;
  background: var(--btn-bg);
  color: var(--btn-text);
  border: none;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: opacity var(--transition);
}

.auth-btn:hover:not(:disabled) { opacity: 0.88; }
.auth-btn:disabled { opacity: 0.4; cursor: not-allowed; }

.auth-buttons {
  display: flex;
  gap: 10px;
  margin-top: 4px;
}

.auth-buttons .auth-btn { flex: 1; margin-top: 0; }

.auth-btn-google {
  padding: 12px 16px;
  background: transparent;
  color: var(--text-main);
  border: 1px solid var(--input-border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: border-color var(--transition);
}

.auth-btn-google:hover { border-color: var(--input-focus-border); }

.auth-error {
  font-size: 12px;
  color: var(--color-error);
}

.auth-divider {
  display: flex;
  align-items: center;
  margin: 24px 0 16px;
}

.auth-divider::before,
.auth-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

.auth-divider span {
  padding: 0 14px;
  font-size: 11px;
  color: var(--text-muted);
}

.auth-switch {
  text-align: center;
  font-size: 13px;
  color: var(--text-muted);
}

.auth-switch button {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
  transition: color var(--transition);
}

.auth-switch button:hover { color: var(--text-main); }

/* ============================================================ */
/* FOOTER */
/* ============================================================ */
.footer {
  padding: var(--space-md);
  text-align: center;
  font-size: 0.7rem;
  color: var(--text-muted);
}

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

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

/* ============================================================ */
/* TOAST */
/* ============================================================ */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  padding: 12px 20px;
  border-radius: var(--radius);
  font-size: 13px;
  color: var(--text-main);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  opacity: 0;
  transform: translateY(12px);
  transition: opacity 0.3s, transform 0.3s;
  z-index: 9999;
  max-width: 400px;
}
.toast.show {
  opacity: 1;
  transform: translateY(0);
}
.toast-error { border-color: #f43f5e; }
.toast-success { border-color: #22c55e; }

/* ============================================================ */
/* POPUP */
/* ============================================================ */
.popup-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  opacity: 0;
  transition: opacity 0.2s;
}
.popup-overlay.show { opacity: 1; }
.popup-box {
  background: #1a1a1a;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  min-width: 320px;
  max-width: 440px;
}
.popup-box p {
  margin: 0 0 20px;
  font-size: 14px;
  color: var(--text-main);
}
.popup-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}
