/* ── RESET & BASE ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #f7f7f5;
  --surface: #ffffff;
  --border: #e8e6e1;
  --text: #1a1a1a;
  --text-muted: #888880;
  --text-light: #b0aea8;
  --accent: #e85d04;
  --accent-light: #fff2eb;
  --accent-dark: #c44d00;
  --sidebar-w: 240px;
  --topbar-h: 56px;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
}

body {
  font-family: 'DM Sans', sans-serif;
  background: var(--bg);
  color: var(--text);
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ── TOPBAR ── */
.topbar {
  height: var(--topbar-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px 0 0;
  flex-shrink: 0;
  z-index: 20;
}

.topbar-left {
  display: flex;
  align-items: center;
  width: var(--sidebar-w);
  padding: 0 20px;
  border-right: 1px solid var(--border);
  height: 100%;
  gap: 10px;
  flex-shrink: 0;
}

.hamburger {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
  color: var(--text);
  margin-right: 4px;
}

.logo-mark {
  width: 28px;
  height: 28px;
  background: var(--text);
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.logo-text {
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -0.3px;
  color: var(--text);
  white-space: nowrap;
}

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

.topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.credits-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--accent-light);
  border: 1px solid #ffd4b3;
  border-radius: 20px;
  padding: 4px 12px;
  font-size: 13px;
  font-weight: 500;
  color: var(--accent-dark);
}

.credits-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  flex-shrink: 0;
}

.btn-signin {
  background: var(--text);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s;
  white-space: nowrap;
}

.btn-signin:hover { background: var(--accent); }

.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  flex-shrink: 0;
}

/* ── LAYOUT ── */
.layout {
  display: flex;
  flex: 1;
  overflow: hidden;
  position: relative;
}

/* ── SIDEBAR ── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  flex-shrink: 0;
  padding: 16px 0 0;
  transition: transform 0.25s ease;
  z-index: 15;
}

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.3);
  z-index: 14;
}

.nav-section { padding: 0 12px; margin-bottom: 4px; }

.nav-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-light);
  padding: 8px 8px 4px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 8px;
  font-size: 13.5px;
  font-weight: 400;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.12s;
  text-decoration: none;
  position: relative;
}

.nav-item:hover { background: var(--bg); color: var(--text); }

.nav-item.active {
  background: var(--accent-light);
  color: var(--accent-dark);
  font-weight: 500;
}

.nav-item.active .nav-icon { color: var(--accent); opacity: 1; }

.nav-icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  opacity: 0.7;
}

.badge-soon {
  margin-left: auto;
  font-size: 10px;
  font-weight: 500;
  background: var(--border);
  color: var(--text-light);
  border-radius: 4px;
  padding: 2px 6px;
}

.badge-live {
  margin-left: auto;
  font-size: 10px;
  font-weight: 600;
  background: #e8f5e8;
  color: #2d7a2d;
  border-radius: 4px;
  padding: 2px 6px;
}

.nav-divider {
  height: 1px;
  background: var(--border);
  margin: 8px 12px;
}

.ext-icon { margin-left: auto; opacity: 0.4; }

.sidebar-spacer { flex: 1; }

/* ── FOOTER (inside sidebar) ── */
.sidebar-footer {
  padding: 12px 20px 16px;
  border-top: 1px solid var(--border);
  margin-top: 8px;
}

.sidebar-footer p {
  font-size: 11px;
  color: var(--text-light);
  line-height: 1.6;
}

.sidebar-footer a {
  color: var(--text-light);
  text-decoration: none;
}

.sidebar-footer a:hover { color: var(--accent); }

/* ── MAIN CONTENT ── */
.main {
  flex: 1;
  overflow-y: auto;
  padding: 40px 48px;
}

/* ── WELCOME ── */
.welcome-header { margin-bottom: 36px; }

.welcome-header h1 {
  font-size: 26px;
  font-weight: 600;
  letter-spacing: -0.5px;
}

.welcome-header p {
  font-size: 14px;
  color: var(--text-muted);
  margin-top: 4px;
}

/* ── FEATURE SECTIONS ── */
.feature-section { margin-bottom: 40px; }

.feature-section-title {
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -0.3px;
  margin-bottom: 6px;
}

.feature-section-sub {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 20px;
}

.feature-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 14px;
}

.feature-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  cursor: pointer;
  transition: all 0.15s;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.feature-card:hover:not(.disabled) {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-light);
}

.feature-card.disabled { opacity: 0.55; cursor: default; }

.card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
}

.card-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: var(--bg);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
}

.feature-card.live .card-icon {
  background: var(--accent-light);
  border-color: #ffd4b3;
}

.card-status {
  font-size: 11px;
  font-weight: 600;
  border-radius: 5px;
  padding: 3px 8px;
}

.status-live { background: #e8f5e8; color: #2d7a2d; }
.status-soon { background: var(--border); color: var(--text-muted); }

.card-name {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.2px;
}

.card-desc {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.5;
}

.card-cta {
  font-size: 13px;
  font-weight: 500;
  color: var(--accent);
  margin-top: 4px;
}

.card-cta-muted {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-light);
  margin-top: 4px;
}

/* ── CHAT VIEW ── */
.chat-view {
  display: none;
  flex-direction: column;
  flex: 1;
  overflow: hidden;
}

.chat-view.active { display: flex; }

.chat-header {
  padding: 20px 32px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.chat-header h2 { font-size: 16px; font-weight: 600; }

.chat-header p {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 2px;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 28px 32px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.chat-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  gap: 8px;
  color: var(--text-muted);
  text-align: center;
}

.chat-empty-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  background: var(--accent-light);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 4px;
}

.chat-empty h3 { font-size: 15px; font-weight: 500; color: var(--text); }
.chat-empty p { font-size: 13px; }

.msg-row { display: flex; gap: 12px; }
.msg-row.user { flex-direction: row-reverse; }

.msg-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 600;
}

.msg-avatar.kren {
  background: var(--accent-light);
  color: var(--accent);
  border: 1px solid #ffd4b3;
}

.msg-avatar.user-av { background: var(--text); color: #fff; }

.msg-bubble {
  max-width: 520px;
  padding: 12px 16px;
  border-radius: 12px;
  font-size: 14px;
  line-height: 1.6;
}

.msg-row.user .msg-bubble {
  background: var(--text);
  color: #fff;
  border-radius: 12px 4px 12px 12px;
}

.msg-row.kren .msg-bubble {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px 12px 12px 12px;
}

.msg-en-toggle {
  font-size: 11.5px;
  color: var(--text-muted);
  margin-top: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 4px;
}

.msg-en-toggle:hover { color: var(--accent); }

.msg-en-text {
  display: none;
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
  padding: 8px 10px;
  background: var(--bg);
  border-radius: 6px;
  font-family: 'DM Mono', monospace;
  line-height: 1.5;
}

.msg-en-text.visible { display: block; }

/* ── CHAT INPUT ── */
.chat-input-area {
  padding: 12px 32px 20px;
  flex-shrink: 0;
}

.no-credits-bar {
  display: none;
  background: #fff5f0;
  border: 1px solid #ffd4b3;
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 13px;
  color: var(--accent-dark);
  margin-bottom: 10px;
  align-items: center;
  gap: 8px;
}

.no-credits-bar a { color: var(--accent); font-weight: 500; }

.chat-input-wrap {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: 12px;
  padding: 10px 10px 10px 16px;
  transition: border-color 0.15s;
}

.chat-input-wrap:focus-within { border-color: var(--accent); }

.chat-input {
  flex: 1;
  border: none;
  outline: none;
  font-family: inherit;
  font-size: 14px;
  background: transparent;
  resize: none;
  max-height: 120px;
  line-height: 1.5;
  color: var(--text);
}

.chat-input::placeholder { color: var(--text-light); }

.char-count {
  font-size: 11px;
  color: var(--text-light);
  font-family: 'DM Mono', monospace;
  align-self: flex-end;
  padding-bottom: 2px;
  white-space: nowrap;
}

.char-count.warn { color: var(--accent); }

.send-btn {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: var(--text);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s;
}

.send-btn:hover { background: var(--accent); }
.send-btn:disabled { background: var(--border); cursor: default; }

/* ── TYPING INDICATOR ── */
.typing-indicator {
  display: none;
  gap: 4px;
  align-items: center;
  padding: 12px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px 12px 12px 12px;
  width: fit-content;
}

.typing-indicator.visible { display: flex; }

.typing-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-muted);
  animation: bounce 1.2s infinite;
}

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

@keyframes bounce {
  0%, 80%, 100% { transform: translateY(0); opacity: 0.4; }
  40% { transform: translateY(-6px); opacity: 1; }
}

/* ── AUTH MODAL ── */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.3);
  backdrop-filter: blur(4px);
  z-index: 100;
  align-items: center;
  justify-content: center;
}

.modal-overlay.active { display: flex; }

.modal {
  background: var(--surface);
  border-radius: 16px;
  padding: 36px;
  width: 380px;
  max-width: 92vw;
  box-shadow: 0 20px 60px rgba(0,0,0,0.15);
  position: relative;
}

.modal-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 24px;
}

.modal h2 {
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -0.4px;
  margin-bottom: 6px;
}

.modal p {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 24px;
}

.form-field { margin-bottom: 14px; }

.form-field label {
  display: block;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.form-field input {
  width: 100%;
  padding: 10px 12px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-family: inherit;
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
  outline: none;
  transition: border-color 0.15s;
}

.form-field input:focus { border-color: var(--accent); background: #fff; }

.btn-primary {
  width: 100%;
  padding: 11px;
  background: var(--text);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  margin-top: 4px;
  transition: background 0.15s;
}

.btn-primary:hover { background: var(--accent); }

.modal-switch {
  text-align: center;
  margin-top: 16px;
  font-size: 13px;
  color: var(--text-muted);
}

.modal-switch a {
  color: var(--accent);
  text-decoration: none;
  font-weight: 500;
  cursor: pointer;
}

.modal-close {
  position: absolute;
  top: 14px;
  right: 16px;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 22px;
  line-height: 1;
}

.modal-error {
  font-size: 12.5px;
  color: #c0392b;
  margin-top: 8px;
  text-align: center;
  min-height: 18px;
}

/* ── COMING SOON MODAL ── */
.coming-soon-modal {
  background: var(--surface);
  border-radius: 16px;
  padding: 36px;
  width: 320px;
  max-width: 92vw;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0,0,0,0.15);
}

.coming-soon-icon {
  width: 56px;
  height: 56px;
  border-radius: 14px;
  background: var(--accent-light);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 16px;
}

.coming-soon-modal h2 {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 8px;
}

.coming-soon-modal p {
  font-size: 13.5px;
  color: var(--text-muted);
  line-height: 1.6;
}

.btn-close-modal {
  margin-top: 20px;
  padding: 9px 24px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
}

.btn-close-modal:hover { background: var(--border); }

/* ── SCROLLBAR ── */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

/* ── MOBILE ── */
@media (max-width: 768px) {
  .topbar-left {
    width: auto;
    border-right: none;
    padding: 0 12px;
  }

  .hamburger { display: flex; }

  .sidebar {
    position: fixed;
    top: var(--topbar-h);
    left: 0;
    bottom: 0;
    width: 260px;
    transform: translateX(-100%);
    box-shadow: 4px 0 20px rgba(0,0,0,0.1);
  }

  .sidebar.open { transform: translateX(0); }

  .sidebar-overlay.active { display: block; }

  .main { padding: 24px 20px; }

  .chat-header { padding: 16px 20px 12px; }
  .chat-messages { padding: 20px 16px; }
  .chat-input-area { padding: 10px 16px 16px; }

  .feature-cards { grid-template-columns: 1fr; }

  .credits-badge span:last-child { display: none; }
}
