/* ── Design tokens (mirrors the rest of the 1settofailure.com brand) ──── */
:root {
  --color-scaffold:       #000000;
  --color-surface:        #111111;
  --color-surface-alt:    #1A1A1A;
  --color-border:         #2A2A2A;
  --color-text-primary:   #FFFFFF;
  --color-text-secondary: #AAAAAA;
  --color-action:         #FFFFFF;
  --color-on-action:      #000000;
  --color-error:          #FF8A80;

  --sidebar-width: 260px;
  --topbar-height: 52px;
}

/* ── Reset ───────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  color: var(--color-text-primary);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

html {
  background: #000000;
}

/* ── Root layout: sidebar + main ──────────────────────────────────────── */
body {
  display: flex;
  height: 100vh;
  background: transparent;
}

/* ── Chat history dropdown ───────────────────────────────────────────── */

/* ── Main wrap ────────────────────────────────────────────────────────── */
.main-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  height: 100vh;
  overflow: hidden;
}

/* ── Floating sidebar toggle ─────────────────────────────────────────── */
.btn-sidebar-float {
  position: fixed;
  top: 8px;
  left: 12px;
  z-index: 90;
  background: none;
  border: none;
  color: var(--color-text-secondary);
  cursor: pointer;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, color 0.15s;
  -webkit-tap-highlight-color: transparent;
}
.btn-sidebar-float:hover { background: var(--color-surface-alt); color: var(--color-text-primary); }
.btn-sidebar-float svg   { width: 20px; height: 20px; fill: currentColor; }

/* ── Top-center subscribe CTA ────────────────────────────────────────── */
.btn-topbar-subscribe {
  position: fixed;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 90;
  background: var(--color-primary);
  color: #fff;
  border: none;
  border-radius: 999px;
  padding: 6px 16px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: opacity 0.15s;
}
.btn-topbar-subscribe:hover { opacity: 0.85; }

/* ── Top-center upgrade CTA ───────────────────────────────────── */
/* ── Icon button (shared) ─────────────────────────────────────────────── */
.btn-icon {
  background: none;
  border: none;
  color: var(--color-text-secondary);
  cursor: pointer;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, color 0.15s;
  -webkit-tap-highlight-color: transparent;
  flex-shrink: 0;
}
.btn-icon:hover { background: var(--color-surface-alt); color: var(--color-text-primary); }
.btn-icon svg  { width: 20px; height: 20px; fill: currentColor; }

/* ── Chat area (messages) ──────────────────────────────────────────────── */
#chat-area {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  min-height: 0;
  scrollbar-width: none; /* Firefox */
}
#chat-area::-webkit-scrollbar { display: none; } /* Chrome / Safari / Edge */
/* Hidden when no messages yet */
.main-wrap.is-empty #chat-area { display: none; }

/* ── Input area: wraps empty-state + input-bar ────────────────────────── */
#input-area {
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  width: 100%;
}
/* When empty: fill remaining height and center welcome + input together */
.main-wrap.is-empty #input-area {
  flex: 1;
  justify-content: center;
}

/* ── Empty / welcome state ────────────────────────────────────────────── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 24px 24px 16px;
  text-align: center;
  gap: 10px;
}
/* Hide welcome text once chatting */
.main-wrap:not(.is-empty) .empty-state { display: none; }

.empty-logo {
  width: 56px;
  height: 56px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 4px;
}
.empty-logo svg { width: 28px; height: 28px; fill: var(--color-text-secondary); }

.empty-subtitle {
  color: var(--color-text-secondary);
  font-size: 14px;
  max-width: 380px;
}

.suggestion-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 10px;
  width: 100%;
  max-width: 800px;
}
/* Hide suggestions once a conversation is active */
.main-wrap:not(.is-empty) .suggestion-grid { display: none; }

.suggestion-btn {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  color: var(--color-text-secondary);
  border-radius: 10px;
  padding: 10px 14px;
  text-align: left;
  cursor: pointer;
  font-size: 13px;
  line-height: 1.4;
  transition: background 0.15s, border-color 0.15s;
  -webkit-tap-highlight-color: transparent;
}
.suggestion-btn:hover { background: var(--color-surface-alt); border-color: #3A3A3A; }

/* ── Message list ─────────────────────────────────────────────────────── */
.message-list {
  padding: 48px 16px 16px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  max-width: 800px;
  margin: 0 auto;
  width: 100%;
}

/* ── Individual message ───────────────────────────────────────────────── */
.message {
  display: flex;
  align-items: flex-end;
  gap: 8px;
}

.message:first-child { margin-top: 24px; }

/* User messages: push bubble to the right */
.message.user {
  flex-direction: row-reverse;
}

/* Hide avatars */
.message-avatar { display: none; }

.message-content {
  max-width: 75%;
  font-size: 15px;
  line-height: 1.7;
  word-break: break-word;
}

/* User bubble */
.message.user .message-content {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 18px 18px 4px 18px;
  padding: 10px 14px;
  white-space: pre-wrap;
}

/* Assistant: full-width, no bubble */
.message.assistant .message-content {
  max-width: 100%;
}

/* ── Markdown output ──────────────────────────────────────────────────── */
.message-content p    { margin: 0 0 10px; }
.message-content p:last-child { margin-bottom: 0; }

.message-content h1 { font-size: 19px; font-weight: 700; margin: 18px 0 8px; }
.message-content h2 { font-size: 16px; font-weight: 700; margin: 16px 0 6px; }
.message-content h3 { font-size: 14px; font-weight: 700; margin: 14px 0 4px; }

.message-content ul,
.message-content ol {
  padding-left: 22px;
  margin: 6px 0 10px;
}
.message-content li { margin: 3px 0; }

.message-content code {
  background: var(--color-surface-alt);
  border: 1px solid var(--color-border);
  border-radius: 4px;
  padding: 1px 6px;
  font-family: 'Fira Code', 'Cascadia Code', 'Consolas', monospace;
  font-size: 13px;
}

.message-content pre {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 10px;
  padding: 14px 16px;
  overflow-x: auto;
  margin: 10px 0;
}
.message-content pre code {
  background: none;
  border: none;
  padding: 0;
  font-size: 13px;
}

.message-content strong { font-weight: 700; }
.message-content em     { color: var(--color-text-secondary); font-style: italic; }

/* Streaming raw text */
.streaming-text {
  white-space: pre-wrap;
  display: block;
  word-break: break-word;
}

/* Error message */
.error-text {
  color: var(--color-error);
  font-size: 14px;
}

/* ── Typing indicator ─────────────────────────────────────────────────── */
.typing-indicator {
  display: flex;
  gap: 5px;
  align-items: center;
  padding: 6px 0;
}
.typing-indicator span {
  width: 7px;
  height: 7px;
  background: var(--color-text-secondary);
  border-radius: 50%;
  animation: bounce 1.2s infinite ease-in-out;
}
.typing-indicator span:nth-child(2) { animation-delay: 0.15s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.30s; }

@keyframes bounce {
  0%, 60%, 100% { transform: translateY(0); }
  30% { transform: translateY(-5px); }
}

/* ── Input bar ────────────────────────────────────────────────────────── */
#input-bar {
  padding: 10px 16px 16px;
  background: transparent;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.input-wrap {
  display: flex;
  align-items: center;
  gap: 4px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 999px;
  padding: 6px 6px 6px 20px;
  width: 100%;
  max-width: 800px;
  transition: border-color 0.15s;
}

.input-wrap:focus-within { border-color: #444; }

#chat-input {
  flex: 1;
  background: none;
  border: none;
  color: var(--color-text-primary);
  font-size: 15px;
  line-height: 1.5;
  resize: none;
  outline: none;
  max-height: 200px;
  overflow-y: auto;
  font-family: inherit;
  padding: 6px 0;
  align-self: center;
}
#chat-input::placeholder { color: var(--color-text-secondary); }

.btn-send {
  background: var(--color-action);
  color: var(--color-on-action);
  border: none;
  border-radius: 50%;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: opacity 0.15s, transform 0.1s;
  -webkit-tap-highlight-color: transparent;
  margin: 2px;
}
.btn-send:disabled           { opacity: 0.2; cursor: default; }
.btn-send:not(:disabled):hover  { opacity: 0.85; }
.btn-send:not(:disabled):active { transform: scale(0.93); }
.btn-send svg { width: 18px; height: 18px; fill: currentColor; }

.input-disclaimer {
  text-align: center;
  font-size: 11px;
  color: var(--color-text-secondary);
  margin-top: 8px;
  opacity: 0.55;
  max-width: 800px;
  margin-left: auto;
  margin-right: auto;
}
.input-disclaimer a {
  color: inherit;
  text-decoration: underline;
}

/* ── Settings modal ───────────────────────────────────────────────────── */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.72);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
}

.modal-box {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 16px;
  width: 100%;
  max-width: 440px;
  padding: 24px;
  margin: 20px;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}
.modal-header h2 { font-size: 17px; font-weight: 700; }

.modal-body {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.modal-body label {
  font-size: 12px;
  color: var(--color-text-secondary);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-top: 6px;
}

.modal-body input,
.modal-body select {
  background: var(--color-scaffold);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  color: var(--color-text-primary);
  font-size: 14px;
  padding: 10px 12px;
  width: 100%;
  outline: none;
  font-family: inherit;
  transition: border-color 0.15s;
}
.modal-body input:focus,
.modal-body select:focus { border-color: #555; }
.modal-body select option { background: var(--color-surface); }

.field-hint {
  font-size: 11px;
  color: var(--color-text-secondary);
  opacity: 0.7;
  margin-top: -4px;
}

.btn-primary {
  background: var(--color-action);
  color: var(--color-on-action);
  border: none;
  border-radius: 8px;
  padding: 11px 16px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s;
  margin-top: 8px;
}
.btn-primary:hover { opacity: 0.85; }

.btn-danger {
  background: none;
  border: 1px solid var(--color-error);
  color: var(--color-error);
  border-radius: 8px;
  padding: 11px 16px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}
.btn-danger:hover { background: rgba(255, 138, 128, 0.1); }

/* ── Subscribe dropdown (anchored below username button) ──────────────── */
.subscribe-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 10px;
  padding: 6px;
  min-width: 160px;
  z-index: 200;
  box-shadow: 0 8px 24px rgba(0,0,0,0.5);
  cursor: default;
}

.sdrop-item {
  display: block;
  width: 100%;
  padding: 9px 12px;
  background: none;
  border: none;
  border-radius: 6px;
  font-size: 14px;
  color: var(--color-text-primary);
  text-align: left;
  cursor: pointer;
  transition: background 0.15s;
}
.sdrop-item:hover { background: var(--color-surface-alt); }

.sdrop-item--danger { color: #e05252; }
.sdrop-item--danger:hover { background: rgba(224,82,82,0.1); }



/* ── Dropdown click-outside trap ─────────────────────────────────────── */
/* ── Toast ────────────────────────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%) translateY(12px);
  background: var(--color-surface-alt);
  border: 1px solid var(--color-border);
  color: var(--color-text-primary);
  padding: 9px 20px;
  border-radius: 20px;
  font-size: 13px;
  opacity: 0;
  transition: opacity 0.2s, transform 0.2s;
  z-index: 300;
  white-space: nowrap;
  pointer-events: none;
}
.toast.toast-visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ── Utility ──────────────────────────────────────────────────────────── */
.hidden { display: none !important; }

/* ── Auth screen ─────────────────────────────────────────────────────── */
.auth-screen {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: var(--color-scaffold);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.auth-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  text-align: center;
  max-width: 320px;
  width: 100%;
}

.auth-app-title {
  font-size: 36px;
  font-weight: 700;
  letter-spacing: -0.5px;
  margin-bottom: 4px;
}

.auth-tagline {
  color: var(--color-text-secondary);
  font-size: 14px;
  margin-bottom: 16px;
}

/* ── Top-right user area ────────────────────────────────────────────────── */
.empty-state-logo {
  width: 120px;
  height: auto;
  display: block;
  margin-bottom: 8px;
}

#topbar-user {
  position: fixed;
  top: calc(var(--topbar-height) / 2);
  transform: translateY(-50%);
  right: 12px;
  z-index: 90;
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-signin {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 16px;
  height: 36px;
  border-radius: 18px;
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  color: var(--color-text-primary);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s, border-color 0.15s;
}
.btn-signin:hover {
  background: var(--color-surface-alt);
  border-color: #3A3A3A;
}
/* ── Topbar name button (signed-in user name) ───────────────────────────── */
.btn-topbar-name {
  background: none;
  border: none;
  color: var(--color-text-primary);
  cursor: default;
  font-size: 13px;
  font-weight: 500;
  font-family: inherit;
  padding: 6px 8px;
  border-radius: 8px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 120px;
  transition: background 0.15s, color 0.15s;
}
.btn-topbar-name:hover { background: none; color: var(--color-text-primary); }
/* ── Topbar icon button (e.g. sign-in icon) ──────────────────────────────── */
.btn-topbar-icon {
  background: none;
  border: none;
  color: var(--color-text-secondary);
  cursor: pointer;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, color 0.15s;
  -webkit-tap-highlight-color: transparent;
}
.btn-topbar-icon:hover { background: var(--color-surface-alt); color: var(--color-text-primary); }
.btn-topbar-icon svg   { width: 20px; height: 20px; fill: currentColor; }

/* ── User info (top-right pill) ──────────────────────────────────────────── */
.user-info {
  position: relative;
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 4px;
}

.user-trigger {
  display: flex;
  align-items: center;
  gap: 8px;
  background: none;
  border: 1px solid transparent;
  border-radius: 20px;
  padding: 6px 10px 6px 16px;
  cursor: pointer;
  color: var(--color-text-primary);
  font-family: inherit;
  transition: background 0.15s, border-color 0.15s;
}
.user-trigger:hover {
  background: var(--color-surface-alt);
  border-color: var(--color-border);
}

#user-name-display {
  font-size: 13px;
  font-weight: 500;
  line-height: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 120px;
}

.user-chevron {
  width: 18px;
  height: 18px;
  fill: var(--color-text-secondary);
  flex-shrink: 0;
  transition: transform 0.2s;
}
.user-trigger[aria-expanded="true"] .user-chevron {
  transform: rotate(180deg);
}

/* ── User dropdown ────────────────────────────────────────────────────────── */
.user-dropdown {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  min-width: 160px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.25);
  padding: 4px;
  z-index: 200;
}
.user-dropdown.hidden { display: none; }

.dropdown-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  background: none;
  border: none;
  border-radius: 7px;
  padding: 9px 12px;
  font-size: 14px;
  font-family: inherit;
  color: var(--color-text-primary);
  cursor: pointer;
  text-align: left;
  transition: background 0.12s;
}
.dropdown-item:hover { background: var(--color-surface-alt); }
.dropdown-item svg {
  width: 18px;
  height: 18px;
  fill: var(--color-text-secondary);
  flex-shrink: 0;
}
.dropdown-item--danger { color: #e05252; }
.dropdown-item--danger svg { fill: #e05252; }
.dropdown-item--upgrade { color: var(--color-action); font-weight: 600; }
.dropdown-item--upgrade svg { fill: var(--color-action); }

.sidebar-signin { display: none !important; }

.btn-skip-auth {
  background: none;
  border: none;
  color: var(--color-text-secondary);
  font-size: 13px;
  cursor: pointer;
  text-decoration: underline;
  margin-top: 8px;
  padding: 4px;
  font-family: inherit;
}
.btn-skip-auth:hover { color: var(--color-text-primary); }

/* ── Responsive ───────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .suggestion-grid { grid-template-columns: 1fr; }
}
