/* ============================================================
   THE STEVE APP — Styles v3
   Teal on black. Mulligan. Photo backgrounds.
   ============================================================ */

:root {
  --bg-deep:      #000000;
  --bg-surface:   #0a0a0a;
  --bg-card:      #111111;
  --bg-input:     #161616;
  --bg-hover:     #1a1a1a;

  --text-primary:   #f0f0f0;
  --text-secondary: #a0a0a0;
  --text-muted:     #555555;
  --text-accent:    #2FE6D2;

  --accent:         #2FE6D2;
  --accent-glow:    rgba(47, 230, 210, 0.12);
  --accent-soft:    #1FBFB3;
  --accent-light:   #7FFBF0;

  --border:         #1e1e1e;
  --border-light:   #2a2a2a;

  --msg-user-bg:    #111111;
  --msg-steve-bg:   rgba(0,0,0,0.6);

  --font-display: 'Cormorant Garamond', 'Georgia', serif;
  --font-body:    'DM Sans', -apple-system, sans-serif;

  --radius:       12px;
  --radius-sm:    8px;
  --ease-out:     cubic-bezier(0.22, 0.61, 0.36, 1);
  --ease-spring:  cubic-bezier(0.34, 1.56, 0.64, 1);
}

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

html, body {
  height: 100%;
  background: var(--bg-deep);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

#app { height: 100%; max-width: 520px; margin: 0 auto; position: relative; }

.view { display: none; flex-direction: column; height: 100%; opacity: 0; transition: opacity 0.3s var(--ease-out); }
.view.active { display: flex; opacity: 1; }

/* ---- Dashboard ---- */
.dash-header { padding: 48px 24px 24px; text-align: center; }
.logo { font-family: var(--font-display); font-size: 3rem; font-weight: 400; font-style: italic; color: var(--text-accent); letter-spacing: 0.02em; margin-bottom: 4px; }
.tagline { font-family: var(--font-display); font-size: 1rem; font-style: italic; color: var(--text-muted); }
.dash-content { flex: 1; overflow-y: auto; padding: 12px 20px 100px; scrollbar-width: none; }
.dash-content::-webkit-scrollbar { display: none; }
.steve-grid { display: flex; flex-direction: column; gap: 12px; }

.steve-card {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 20px; cursor: pointer; transition: all 0.25s var(--ease-out); position: relative; overflow: hidden;
}
.steve-card::before { content: ''; position: absolute; top: 0; left: 0; width: 3px; height: 100%; background: var(--accent); opacity: 0; transition: opacity 0.25s var(--ease-out); }
.steve-card:hover { background: var(--bg-hover); border-color: var(--border-light); }
.steve-card:hover::before { opacity: 1; }
.steve-card-top { display: flex; justify-content: space-between; align-items: flex-start; }
.steve-card-name { font-family: var(--font-display); font-size: 1.35rem; font-weight: 500; color: var(--text-primary); margin-bottom: 4px; }
.steve-card-setting { font-size: 0.85rem; color: var(--text-secondary); margin-bottom: 8px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.steve-card-meta { font-size: 0.75rem; color: var(--text-muted); }

.btn-archive { background: none; border: none; color: var(--text-muted); cursor: pointer; padding: 4px 8px; font-size: 0.75rem; border-radius: var(--radius-sm); transition: all 0.2s; flex-shrink: 0; }
.btn-archive:hover { color: #ff6b6b; background: rgba(255, 107, 107, 0.1); }

.btn-create { display: flex; align-items: center; justify-content: center; gap: 10px; width: 100%; margin-top: 16px; padding: 18px; background: transparent; border: 1px dashed var(--border-light); border-radius: var(--radius); color: var(--text-secondary); font-family: var(--font-display); font-size: 1.05rem; font-style: italic; cursor: pointer; transition: all 0.25s var(--ease-out); }
.btn-create:hover { border-color: var(--accent-soft); color: var(--text-accent); background: var(--accent-glow); }
.btn-create-icon { font-size: 1.3rem; font-style: normal; line-height: 1; }

.empty-state { text-align: center; padding: 60px 20px; }
.empty-state-icon { font-size: 2.5rem; margin-bottom: 16px; opacity: 0.6; }
.empty-state h3 { font-family: var(--font-display); font-size: 1.4rem; font-weight: 400; font-style: italic; color: var(--text-secondary); margin-bottom: 8px; }
.empty-state p { font-size: 0.9rem; color: var(--text-muted); }

/* ---- Form ---- */
.form-header, .chat-header { display: flex; align-items: center; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--border); background: var(--bg-surface); min-height: 60px; flex-shrink: 0; }
.form-header h2, .chat-header h2 { font-family: var(--font-display); font-size: 1.2rem; font-weight: 500; color: var(--text-primary); }
.form-content { flex: 1; overflow-y: auto; padding: 24px 20px 100px; scrollbar-width: none; }
.form-content::-webkit-scrollbar { display: none; }

.form-section-label { font-family: var(--font-display); font-size: 1rem; font-weight: 500; color: var(--accent); margin-top: 28px; margin-bottom: 14px; padding-bottom: 6px; border-bottom: 1px solid var(--border); }
.form-section-label:first-child { margin-top: 0; }

.form-group { margin-bottom: 20px; }
.form-group label { display: block; font-size: 0.85rem; font-weight: 500; color: var(--text-secondary); margin-bottom: 6px; letter-spacing: 0.02em; }
.form-group input, .form-group textarea { width: 100%; padding: 12px 14px; background: var(--bg-input); border: 1px solid var(--border); border-radius: var(--radius-sm); color: var(--text-primary); font-family: var(--font-body); font-size: 0.95rem; line-height: 1.5; resize: none; transition: border-color 0.2s; }
.form-group input:focus, .form-group textarea:focus { outline: none; border-color: var(--accent-soft); }
.form-group input::placeholder, .form-group textarea::placeholder { color: var(--text-muted); }

/* Photo upload */
.photo-preview { width: 100%; height: 120px; background: var(--bg-input); border: 1px dashed var(--border-light); border-radius: var(--radius-sm); display: flex; align-items: center; justify-content: center; overflow: hidden; transition: border-color 0.2s; }
.photo-preview img { width: 100%; height: 100%; object-fit: cover; }
.photo-placeholder { color: var(--text-muted); font-size: 0.9rem; }
.btn-photo-upload { display: block; margin-top: 8px; padding: 8px 16px; background: var(--bg-input); border: 1px solid var(--border); border-radius: var(--radius-sm); color: var(--text-secondary); font-family: var(--font-body); font-size: 0.85rem; cursor: pointer; transition: all 0.2s; }
.btn-photo-upload:hover { border-color: var(--accent-soft); color: var(--text-accent); }
.photo-remove-wrap { margin-top: 6px; }
.btn-text { background: none; border: none; color: var(--text-muted); cursor: pointer; font-size: 0.8rem; padding: 2px 0; transition: color 0.2s; }
.btn-text:hover { color: #ff6b6b; }

/* Gender toggle */
.gender-toggle { display: flex; gap: 8px; }
.gender-btn { width: 52px; height: 44px; display: flex; align-items: center; justify-content: center; background: var(--bg-input); border: 1px solid var(--border); border-radius: var(--radius-sm); cursor: pointer; transition: all 0.2s; }
.gender-btn .gender-symbol { font-size: 1.3rem; color: var(--text-muted); transition: color 0.2s; line-height: 1; }
.gender-btn.active { border-color: var(--accent-soft); background: var(--accent-glow); }
.gender-btn.active .gender-symbol { color: var(--accent); }
.gender-btn:hover { border-color: var(--accent-soft); }

/* Spice slider */
.spice-slider-wrap { padding: 4px 0; }
.spice-slider { width: 100%; height: 6px; -webkit-appearance: none; appearance: none; background: transparent; cursor: pointer; margin-bottom: 12px; }
.spice-slider::-webkit-slider-runnable-track { height: 6px; background: var(--bg-input); border-radius: 3px; border: 1px solid var(--border); }
.spice-slider::-webkit-slider-thumb { -webkit-appearance: none; width: 22px; height: 22px; background: var(--accent); border-radius: 50%; margin-top: -9px; border: 2px solid var(--bg-deep); box-shadow: 0 0 8px var(--accent-glow); transition: background 0.2s; }
.spice-slider::-moz-range-track { height: 6px; background: var(--bg-input); border-radius: 3px; border: 1px solid var(--border); }
.spice-slider::-moz-range-thumb { width: 22px; height: 22px; background: var(--accent); border-radius: 50%; border: 2px solid var(--bg-deep); box-shadow: 0 0 8px var(--accent-glow); }
.spice-slider.hot::-webkit-slider-thumb { background: #ff4444; box-shadow: 0 0 12px rgba(255,68,68,0.4); }
.spice-slider.hot::-moz-range-thumb { background: #ff4444; box-shadow: 0 0 12px rgba(255,68,68,0.4); }
.spice-display { display: flex; align-items: baseline; gap: 10px; margin-bottom: 8px; }
.spice-value { font-family: var(--font-display); font-size: 1.8rem; font-weight: 600; color: var(--accent); line-height: 1; transition: color 0.3s; }
.spice-value.hot { color: #ff4444; }
.spice-label { font-size: 0.85rem; color: var(--text-muted); transition: color 0.3s; }
.spice-bar { width: 100%; height: 4px; background: var(--bg-input); border-radius: 2px; overflow: hidden; }
.spice-fill { height: 100%; border-radius: 2px; background: linear-gradient(90deg, var(--accent), var(--accent-light)); transition: width 0.3s var(--ease-out), background 0.3s; }
.spice-fill.hot { background: linear-gradient(90deg, #ff8800, #ff4444); }

/* Level 11 easter egg */
.spice-11-zone { margin-top: 12px; animation: spice11In 0.4s var(--ease-spring); }
@keyframes spice11In { from { opacity: 0; transform: translateY(-8px) scale(0.97); } to { opacity: 1; transform: translateY(0) scale(1); } }
.spice-11-msg { padding: 16px; background: rgba(255, 68, 68, 0.08); border: 1px solid rgba(255, 68, 68, 0.25); border-radius: var(--radius-sm); display: flex; align-items: flex-start; gap: 12px; }
.spice-11-icon { font-size: 1.4rem; line-height: 1.4; flex-shrink: 0; }
.spice-11-msg p { font-size: 0.9rem; color: var(--text-secondary); line-height: 1.5; margin: 0; }
.spice-11-msg strong { color: #ff4444; }
.spice-11-link { color: #ff4444; text-decoration: underline; text-underline-offset: 2px; }
.spice-11-link:hover { color: #ff6666; }

/* Toggle */
.toggle-row { display: flex; align-items: center; justify-content: space-between; padding: 12px 14px; background: var(--bg-input); border: 1px solid var(--border); border-radius: var(--radius-sm); cursor: pointer; margin-bottom: 12px; user-select: none; }
.toggle-row-label { font-size: 0.95rem; color: var(--text-primary); }
.toggle-switch { width: 44px; height: 24px; background: var(--border-light); border-radius: 12px; position: relative; transition: background 0.2s; flex-shrink: 0; }
.toggle-switch.on { background: var(--accent); }
.toggle-switch::after { content: ''; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; background: white; border-radius: 50%; transition: transform 0.2s var(--ease-out); }
.toggle-switch.on::after { transform: translateX(20px); }

.first-message-box { overflow: hidden; max-height: 0; opacity: 0; transition: max-height 0.3s var(--ease-out), opacity 0.3s var(--ease-out), margin 0.3s var(--ease-out); margin-bottom: 0; }
.first-message-box.visible { max-height: 200px; opacity: 1; margin-bottom: 20px; }

/* ---- Buttons ---- */
.btn-back { background: none; border: none; color: var(--text-secondary); font-size: 1.3rem; cursor: pointer; padding: 4px 8px; line-height: 1; transition: color 0.2s; }
.btn-back:hover { color: var(--text-primary); }
.btn-icon { background: none; border: none; color: var(--text-secondary); cursor: pointer; padding: 6px; border-radius: 50%; transition: all 0.2s; display: flex; align-items: center; }
.btn-icon:hover { color: var(--text-accent); background: var(--accent-glow); }

.btn-primary { width: 100%; padding: 14px; background: var(--accent); border: none; border-radius: var(--radius-sm); color: var(--bg-deep); font-family: var(--font-display); font-size: 1.1rem; font-weight: 600; cursor: pointer; transition: all 0.25s var(--ease-out); margin-top: 8px; }
.btn-primary:hover { filter: brightness(1.1); transform: translateY(-1px); box-shadow: 0 4px 20px var(--accent-glow); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

.btn-danger { width: 100%; padding: 12px; background: transparent; border: 1px solid #3a2020; border-radius: var(--radius-sm); color: #ff6b6b; font-family: var(--font-body); font-size: 0.9rem; cursor: pointer; transition: all 0.2s; margin-top: 24px; }
.btn-danger:hover { background: rgba(255, 107, 107, 0.08); border-color: #ff6b6b; }

/* ---- Chat ---- */
.chat-header { justify-content: space-between; }
.chat-header-info { flex: 1; min-width: 0; overflow: hidden; }
.chat-header h2 { color: var(--accent); }
.chat-setting { font-size: 0.8rem; color: var(--text-muted); font-family: var(--font-body); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block; max-width: 100%; }

/* Avatar circle in chat header */
.chat-avatar-btn { background: none; border: none; cursor: pointer; padding: 0; border-radius: 50%; transition: all 0.2s; display: flex; align-items: center; flex-shrink: 0; }
.chat-avatar-btn:hover { box-shadow: 0 0 0 2px var(--accent-glow); }
.chat-avatar { width: 36px; height: 36px; border-radius: 50%; object-fit: cover; border: 2px solid var(--border-light); transition: border-color 0.2s; }
.chat-avatar-btn:hover .chat-avatar { border-color: var(--accent-soft); }
.chat-avatar-placeholder { width: 36px; height: 36px; border-radius: 50%; border: 2px solid var(--border-light); display: flex; align-items: center; justify-content: center; color: var(--text-muted); transition: border-color 0.2s; }
.chat-avatar-btn:hover .chat-avatar-placeholder { border-color: var(--accent-soft); }

.chat-messages {
  flex: 1; overflow-y: auto; padding: 20px 16px;
  display: flex; flex-direction: column; gap: 16px;
  scrollbar-width: none;
  background-size: contain;
  background-position: top center;
  background-repeat: no-repeat;
  position: relative;
}
.chat-messages::-webkit-scrollbar { display: none; }

/* When there's a background image, add a dark overlay for readability */
.chat-messages.has-bg {
  background-attachment: fixed;
}
.chat-messages.has-bg::before {
  content: '';
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0, 0, 0, 0.65);
  pointer-events: none;
  z-index: 0;
}
.chat-messages.has-bg > * {
  position: relative;
  z-index: 1;
}

.message {
  max-width: 88%; padding: 14px 16px;
  border-radius: var(--radius); line-height: 1.65; font-size: 0.95rem;
  animation: messageIn 0.35s var(--ease-out);
}
@keyframes messageIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.message.user {
  align-self: flex-end;
  background: var(--msg-user-bg);
  border: 1px solid var(--border);
  color: var(--text-primary);
  border-bottom-right-radius: 4px;
}
.message.assistant {
  align-self: flex-start;
  background: var(--msg-steve-bg);
  color: var(--text-primary);
  border-bottom-left-radius: 4px;
}
.message.assistant em { color: var(--text-secondary); font-style: italic; }
.message.user em { color: var(--text-secondary); font-style: italic; }
.message.typing { color: var(--text-muted); font-style: italic; }

.typing-dots::after { content: ''; animation: dots 1.4s infinite; }
@keyframes dots { 0%, 20% { content: '.'; } 40% { content: '..'; } 60%, 100% { content: '...'; } }

/* ---- Mulligan Buttons ---- */
.msg-actions {
  margin-top: 8px;
  display: flex;
  gap: 8px;
}
.btn-mulligan {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 0.75rem;
  padding: 4px 10px;
  border-radius: 20px;
  cursor: pointer;
  transition: all 0.2s;
  font-family: var(--font-body);
}
.btn-mulligan:hover {
  color: var(--accent);
  border-color: var(--accent-soft);
  background: var(--accent-glow);
}
.btn-undo:hover {
  color: var(--accent-light);
  border-color: var(--accent-light);
}
.mulligan-status {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-style: italic;
  padding: 4px 0;
}

/* ---- Chat Input ---- */
.chat-input-area { padding: 12px 16px 20px; background: var(--bg-surface); border-top: 1px solid var(--border); flex-shrink: 0; }
.chat-input-wrap { display: flex; align-items: flex-end; gap: 8px; background: var(--bg-input); border: 1px solid var(--border); border-radius: var(--radius); padding: 8px 12px; transition: border-color 0.2s; }
.chat-input-wrap:focus-within { border-color: var(--accent-soft); }
#chat-input { flex: 1; background: transparent; border: none; color: var(--text-primary); font-family: var(--font-body); font-size: 0.95rem; line-height: 1.5; resize: none; max-height: 120px; padding: 4px 0; }
#chat-input:focus { outline: none; }
#chat-input::placeholder { color: var(--text-muted); }
.btn-send { background: none; border: none; color: var(--text-muted); cursor: pointer; padding: 6px; border-radius: 50%; transition: all 0.2s; display: flex; align-items: center; flex-shrink: 0; }
.btn-send:not(:disabled) { color: var(--accent); }
.btn-send:not(:disabled):hover { background: var(--accent-glow); }
.btn-send:disabled { cursor: default; }

/* ---- Profile ---- */
.profile-photo { margin-bottom: 20px; border-radius: var(--radius); overflow: hidden; }
.profile-photo img { width: 100%; max-height: 200px; object-fit: cover; display: block; }
.profile-section { margin-bottom: 20px; }
.profile-section-label { font-size: 0.75rem; font-weight: 500; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.08em; margin-bottom: 6px; }
.profile-section-content { font-size: 0.95rem; color: var(--text-secondary); line-height: 1.6; }
.profile-divider { font-family: var(--font-display); font-size: 1rem; font-weight: 500; color: var(--accent); margin-top: 24px; margin-bottom: 12px; padding-bottom: 6px; border-bottom: 1px solid var(--border); }
.profile-memories { margin-top: 24px; padding-top: 20px; border-top: 1px solid var(--border); }
.profile-memories h3 { font-family: var(--font-display); font-size: 1.1rem; font-weight: 500; color: var(--text-accent); margin-bottom: 12px; }
.memory-entry { padding: 12px 14px; background: var(--bg-input); border-radius: var(--radius-sm); margin-bottom: 8px; font-size: 0.9rem; color: var(--text-secondary); line-height: 1.5; }
.memory-entry-date { font-size: 0.75rem; color: var(--text-muted); margin-top: 6px; }

.loading { display: flex; justify-content: center; padding: 40px; }
.spinner { width: 28px; height: 28px; border: 2px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

@media (min-width: 600px) { #app { border-left: 1px solid var(--border); border-right: 1px solid var(--border); } }

/* ---- Login Gate ---- */
.login-wrap { display: flex; flex-direction: column; align-items: center; justify-content: center; height: 100%; padding: 40px 24px; text-align: center; }
.login-tagline { font-family: var(--font-display); font-size: 1rem; font-style: italic; color: var(--text-muted); margin-top: 8px; margin-bottom: 32px; }
.login-form { width: 100%; max-width: 280px; display: flex; flex-direction: column; gap: 12px; }
.login-form input { width: 100%; padding: 14px 16px; background: var(--bg-input); border: 1px solid var(--border); border-radius: var(--radius-sm); color: var(--text-primary); font-family: var(--font-body); font-size: 1rem; text-align: center; letter-spacing: 0.1em; transition: border-color 0.2s; }
.login-form input:focus { outline: none; border-color: var(--accent-soft); }
.login-form input::placeholder { color: var(--text-muted); letter-spacing: normal; }
.login-error { font-size: 0.85rem; color: #ff6b6b; margin-top: 12px; min-height: 1.2em; }
