/* ====== Reset & Base ====== */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --nav-height: 60px;
  --bg-dark: #0a0a1a;
  --card-bg: rgba(255, 255, 255, 0.06);
  --card-border: rgba(255, 255, 255, 0.1);
  --text-primary: #f0f0f5;
  --text-secondary: rgba(255, 255, 255, 0.7);
  --accent: #6c63ff;
  --accent-glow: rgba(108, 99, 255, 0.3);
  --gradient-1: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  --danger: #ff4757;
  --success: #2ed573;
  --radius: 16px;
  --radius-sm: 10px;
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg-dark);
  color: var(--text-primary);
  overflow-x: hidden;
  min-height: 100vh;
}

/* ====== Navigation ====== */
.top-nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1000;
  background: rgba(10, 10, 26, 0.85);
  backdrop-filter: blur(20px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  height: var(--nav-height);
}

.nav-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 24px;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.logo {
  font-size: 1.25rem;
  font-weight: 700;
  background: var(--gradient-1);
  background-clip: text;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.nav-links {
  display: flex;
  gap: 8px;
}

.nav-btn {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--text-secondary);
  padding: 8px 20px;
  border-radius: 20px;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.9rem;
  transition: all 0.3s ease;
}

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

.nav-btn.active {
  background: var(--gradient-1);
  border-color: transparent;
  color: #fff;
  font-weight: 600;
}

/* ====== Pages ====== */
.page {
  display: none;
  min-height: 100vh;
  padding-top: var(--nav-height);
}

.page.active {
  display: block;
}

/* ====== Visitor Page - Canvas Sky ====== */
#sky-canvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  z-index: 0;
}

.visitor-overlay {
  position: relative;
  z-index: 1;
  pointer-events: none;
}

.visitor-overlay * {
  pointer-events: auto;
}

/* Hero Section */
.hero-text {
  text-align: center;
  padding: 100px 20px 60px;
  min-height: 80vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.hero-text h1 {
  font-size: clamp(2.5rem, 6vw, 5rem);
  font-weight: 700;
  margin-bottom: 16px;
  background: linear-gradient(135deg, #f093fb 0%, #f5576c 50%, #ffecd2 100%);
  background-clip: text;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.subtitle {
  font-size: clamp(1.1rem, 2.5vw, 1.6rem);
  color: var(--text-secondary);
  font-weight: 300;
  margin-bottom: 24px;
}

.hint {
  font-size: 0.95rem;
  color: rgba(255, 255, 255, 0.4);
  animation: bounce 2s infinite;
}

@keyframes bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(8px); }
}

.fade-in {
  opacity: 0;
  transform: translateY(20px);
  animation: fadeIn 0.8s ease forwards;
}

.fade-in.delay-1 { animation-delay: 0.3s; }
.fade-in.delay-2 { animation-delay: 0.6s; }

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

/* Scroll Content - Message Cards */
.scroll-content {
  max-width: 700px;
  margin: 0 auto;
  padding: 0 20px 100px;
}

.message-card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  padding: 40px;
  margin-bottom: 40px;
  backdrop-filter: blur(10px);
  opacity: 0;
  transform: translateY(60px);
  transition: all 0.8s cubic-bezier(0.16, 1, 0.3, 1);
}

.message-card.visible {
  opacity: 1;
  transform: translateY(0);
}

.message-card:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.2);
  transform: translateY(-4px);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.chapter {
  border-left: 3px solid var(--accent);
  position: relative;
}

.chapter-label {
  position: absolute;
  top: -10px;
  left: 24px;
  background: var(--accent);
  color: #fff;
  padding: 2px 14px;
  border-radius: 10px;
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 1px;
}

.card-icon {
  font-size: 2.8rem;
  margin-bottom: 12px;
}

.message-card h2 {
  font-size: 1.65rem;
  margin-bottom: 10px;
  font-weight: 600;
}

.message-card > p {
  color: var(--text-secondary);
  line-height: 1.8;
  font-size: 1.1rem;
  margin-bottom: 6px;
}

.card-detail {
  color: var(--text-secondary);
  line-height: 1.9;
  font-size: 0.95rem;
  opacity: 0.75;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.final-card {
  text-align: center;
  background: linear-gradient(135deg, rgba(108, 99, 255, 0.15), rgba(118, 75, 162, 0.15));
  border-color: var(--accent);
}

.final-text {
  font-size: 1.3rem !important;
  color: var(--text-primary) !important;
  font-weight: 400;
  margin-bottom: 8px;
}

.final-sub {
  color: var(--text-secondary) !important;
  font-size: 1rem !important;
  font-weight: 300;
  opacity: 0.7;
}

/* Scroll Progress Bar */
.scroll-progress {
  position: fixed;
  top: var(--nav-height);
  left: 0;
  width: 100%;
  height: 3px;
  z-index: 100;
  background: rgba(255, 255, 255, 0.05);
}

.scroll-progress-bar {
  height: 100%;
  width: 0%;
  background: var(--gradient-1);
  transition: width 0.1s linear;
  border-radius: 0 2px 2px 0;
}

/* ====== Admin Page ====== */
.admin-container {
  max-width: 800px;
  margin: 0 auto;
  padding: 40px 20px;
  min-height: calc(100vh - var(--nav-height));
  display: flex;
  flex-direction: column;
}

.admin-header {
  text-align: center;
  margin-bottom: 40px;
}

.admin-header h2 {
  font-size: 2rem;
  font-weight: 700;
  margin-bottom: 8px;
}

.admin-sub {
  color: var(--text-secondary);
}

/* Password Gate */
.auth-gate {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

.auth-box {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  padding: 48px;
  text-align: center;
  max-width: 420px;
  width: 100%;
}

.lock-icon {
  font-size: 3rem;
  margin-bottom: 16px;
}

.auth-box h3 {
  font-size: 1.3rem;
  margin-bottom: 24px;
  font-weight: 500;
}

.input-group {
  display: flex;
  gap: 8px;
}

.input-group input {
  flex: 1;
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--card-border);
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 1rem;
  outline: none;
  transition: border 0.3s;
}

.input-group input:focus {
  border-color: var(--accent);
}

.btn-primary {
  padding: 14px 28px;
  border-radius: var(--radius-sm);
  border: none;
  background: var(--gradient-1);
  color: #fff;
  font-weight: 600;
  font-family: inherit;
  font-size: 1rem;
  cursor: pointer;
  transition: all 0.3s;
  white-space: nowrap;
}

.btn-primary:hover {
  opacity: 0.9;
  transform: translateY(-1px);
  box-shadow: 0 8px 24px var(--accent-glow);
}

.error-msg {
  color: var(--danger);
  margin-top: 12px;
  font-size: 0.9rem;
  min-height: 1.4em;
}

/* Chat Interface */
.chat-interface {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.chat-interface.hidden {
  display: none;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px 0;
  display: flex;
  flex-direction: column;
  gap: 20px;
  max-height: calc(100vh - 300px);
}

.message {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  max-width: 85%;
}

.message.user {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.msg-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--card-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  flex-shrink: 0;
}

.msg-content {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-sm);
  padding: 14px 18px;
  line-height: 1.6;
  font-size: 0.95rem;
  word-wrap: break-word;
}

.message.bot .msg-content {
  border-top-left-radius: 4px;
}

.message.user .msg-content {
  background: var(--accent);
  border-color: var(--accent);
  border-top-right-radius: 4px;
  color: #fff;
}

/* Chat Input */
.chat-input-area {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  padding: 16px;
  margin-top: auto;
}

.model-selector {
  margin-bottom: 12px;
}

.model-selector select {
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--card-border);
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.9rem;
  cursor: pointer;
  outline: none;
  width: 100%;
}

.model-selector select:focus {
  border-color: var(--accent);
}

.input-row {
  display: flex;
  gap: 8px;
}

.input-row textarea {
  flex: 1;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--card-border);
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.95rem;
  resize: none;
  outline: none;
  line-height: 1.5;
  max-height: 120px;
}

.input-row textarea:focus {
  border-color: var(--accent);
}

.btn-send {
  padding: 12px 24px;
  border-radius: var(--radius-sm);
  border: none;
  background: var(--gradient-1);
  color: #fff;
  font-weight: 600;
  font-family: inherit;
  font-size: 0.95rem;
  cursor: pointer;
  transition: all 0.3s;
}

.btn-send:hover {
  opacity: 0.9;
  transform: translateY(-1px);
}

.btn-send:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
}

.api-status {
  margin-top: 10px;
  font-size: 0.8rem;
  color: var(--success);
  text-align: right;
}

.api-status.error {
  color: var(--danger);
}

/* Typing indicator */
.typing-indicator {
  display: flex;
  gap: 4px;
  padding: 4px 0;
}

.typing-indicator span {
  width: 8px;
  height: 8px;
  background: var(--text-secondary);
  border-radius: 50%;
  animation: typing 1.4s infinite ease-in-out;
}

.typing-indicator span:nth-child(2) { animation-delay: 0.2s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typing {
  0%, 60%, 100% { opacity: 0.3; transform: scale(0.8); }
  30% { opacity: 1; transform: scale(1); }
}

/* ====== Scrollbar ====== */
::-webkit-scrollbar {
  width: 6px;
}

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

::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.2);
}

/* ====== Responsive ====== */
@media (max-width: 600px) {
  .auth-box {
    padding: 32px 20px;
  }

  .message-card {
    padding: 28px;
  }

  .hero-text {
    padding: 80px 16px 40px;
    min-height: 70vh;
  }

  .chat-messages {
    max-height: calc(100vh - 320px);
  }
}