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

:root {
  --bg:        #0f1117;
  --surface:   #161b27;
  --surface2:  #1e2535;
  --border:    #2a3248;
  --accent:    #00d4ff;
  --accent-dim:#0099bb;
  --user-bg:   #1a2744;
  --wanda-bg:  #161b27;
  --text:      #dde3f0;
  --text-dim:  #7a8aa8;
  --red:       #ff4d6d;
  --green:     #00e5a0;
  --radius:    10px;
  --font:      'Segoe UI', system-ui, -apple-system, sans-serif;
  --mono:      'Cascadia Code', 'Fira Code', 'Consolas', monospace;
}

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.6;
  overflow: hidden;
}

/* ─── Layout ─── */
#app {
  display: flex;
  flex-direction: column;
  height: 100vh;
}

/* ─── Header ─── */
#header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  z-index: 10;
}

#header-left { display: flex; align-items: center; gap: 12px; }

#logo {
  width: 36px; height: 36px;
  background: linear-gradient(135deg, var(--accent), #7c3aed);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 18px; color: #fff;
  flex-shrink: 0;
}

#title-block { display: flex; flex-direction: column; }
#title-name {
  font-size: 13px; font-weight: 700; letter-spacing: 3px;
  color: var(--accent); line-height: 1;
}
#title-sub { font-size: 10px; color: var(--text-dim); letter-spacing: 1px; }

#header-right { display: flex; align-items: center; gap: 8px; }

/* ─── Buttons ─── */
.btn-icon {
  display: flex; align-items: center; gap: 6px;
  background: var(--surface2); border: 1px solid var(--border);
  color: var(--text-dim); border-radius: var(--radius);
  padding: 6px 10px; cursor: pointer;
  font-size: 12px; transition: all 0.15s;
}
.btn-icon:hover { border-color: var(--accent); color: var(--accent); }
.btn-icon.active {
  background: rgba(0, 212, 255, 0.12);
  border-color: var(--accent); color: var(--accent);
}
.btn-icon.live {
  background: rgba(255, 77, 109, 0.12);
  border-color: var(--red); color: var(--red);
  animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}

/* ─── Screen preview ─── */
#screen-preview-wrap {
  position: fixed;
  bottom: 90px; right: 16px;
  width: 240px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  z-index: 100;
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
}
#screen-video { width: 100%; display: block; }
#screen-badge {
  position: absolute; top: 6px; left: 6px;
  background: var(--red); color: #fff;
  font-size: 9px; font-weight: 700; letter-spacing: 1px;
  padding: 2px 6px; border-radius: 4px;
}

/* ─── Messages ─── */
#messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  scroll-behavior: smooth;
}

#messages::-webkit-scrollbar { width: 4px; }
#messages::-webkit-scrollbar-track { background: transparent; }
#messages::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

.msg {
  display: flex;
  flex-direction: column;
  max-width: 820px;
  width: 100%;
}
.msg.user { align-self: flex-end; align-items: flex-end; }
.msg.wanda { align-self: flex-start; align-items: flex-start; }

.msg-label {
  font-size: 10px; font-weight: 600; letter-spacing: 1.5px;
  color: var(--text-dim); margin-bottom: 4px;
  text-transform: uppercase;
}
.msg.user .msg-label { color: var(--accent-dim); }
.msg.wanda .msg-label { color: #7c3aed; }

.msg-bubble {
  padding: 12px 16px;
  border-radius: var(--radius);
  line-height: 1.65;
  max-width: 100%;
  word-break: break-word;
}
.msg.user .msg-bubble {
  background: var(--user-bg);
  border: 1px solid #2a3e6a;
  border-bottom-right-radius: 2px;
}
.msg.wanda .msg-bubble {
  background: var(--wanda-bg);
  border: 1px solid var(--border);
  border-bottom-left-radius: 2px;
}

/* Attached image inside bubble */
.msg-bubble img.attached-img {
  display: block;
  max-width: 300px; max-height: 200px;
  border-radius: 6px;
  margin-bottom: 8px;
  object-fit: cover;
  border: 1px solid var(--border);
}

/* ─── Markdown rendering ─── */
.msg-bubble h1, .msg-bubble h2, .msg-bubble h3 {
  color: var(--accent); margin: 12px 0 6px; font-size: 1em;
}
.msg-bubble p { margin: 6px 0; }
.msg-bubble ul, .msg-bubble ol { padding-left: 20px; margin: 6px 0; }
.msg-bubble li { margin: 3px 0; }
.msg-bubble strong { color: #fff; }
.msg-bubble em { color: var(--text-dim); }
.msg-bubble code {
  font-family: var(--mono);
  background: #0d1117;
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 12px;
  color: #79c0ff;
}
.msg-bubble pre {
  background: #0d1117;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  overflow-x: auto;
  margin: 10px 0;
}
.msg-bubble pre code {
  background: none;
  padding: 0;
  font-size: 12.5px;
  color: inherit;
}
.msg-bubble blockquote {
  border-left: 3px solid var(--accent);
  padding-left: 12px;
  color: var(--text-dim);
  margin: 8px 0;
}
.msg-bubble hr { border: none; border-top: 1px solid var(--border); margin: 12px 0; }

/* ─── Typing indicator ─── */
.typing-dots { display: flex; gap: 4px; padding: 4px 0; }
.typing-dots span {
  width: 6px; height: 6px;
  background: var(--text-dim); border-radius: 50%;
  animation: dot-bounce 1.2s ease-in-out infinite;
}
.typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-dots span:nth-child(3) { animation-delay: 0.4s; }

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

/* ─── Attachment preview bar ─── */
#attachment-preview {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 16px;
  background: var(--surface);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}
#attachment-img {
  height: 48px; width: auto;
  border-radius: 6px;
  border: 1px solid var(--border);
  object-fit: cover;
}
#btn-remove-attachment {
  background: none; border: none; color: var(--text-dim);
  cursor: pointer; font-size: 16px; padding: 4px;
}
#btn-remove-attachment:hover { color: var(--red); }

/* ─── Input bar ─── */
#input-bar {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 12px 16px;
  background: var(--surface);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

#btn-attach {
  cursor: pointer; flex-shrink: 0;
}

#msg-input {
  flex: 1;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  padding: 10px 14px;
  resize: none;
  outline: none;
  max-height: 160px;
  overflow-y: auto;
  transition: border-color 0.15s;
  line-height: 1.5;
}
#msg-input:focus { border-color: var(--accent); }
#msg-input::placeholder { color: var(--text-dim); }

#btn-send {
  width: 38px; height: 38px; flex-shrink: 0;
  background: var(--accent);
  border: none; border-radius: var(--radius);
  color: #000; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.15s, transform 0.1s;
}
#btn-send:hover { background: #33ddff; }
#btn-send:active { transform: scale(0.95); }
#btn-send:disabled { background: var(--surface2); color: var(--text-dim); cursor: not-allowed; }

/* ─── Utilities ─── */
.hidden { display: none !important; }

/* ─── Welcome message ─── */
#welcome {
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  flex: 1; gap: 12px; color: var(--text-dim); text-align: center;
  padding: 40px;
}
#welcome .w-logo {
  width: 64px; height: 64px;
  background: linear-gradient(135deg, var(--accent), #7c3aed);
  border-radius: 16px;
  display: flex; align-items: center; justify-content: center;
  font-size: 36px; font-weight: 800; color: #fff;
  margin-bottom: 8px;
}
#welcome h2 { color: var(--text); font-size: 20px; }
#welcome p { font-size: 13px; max-width: 400px; }
#welcome .hints { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 8px; }
#welcome .hint {
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: 20px; padding: 6px 14px;
  font-size: 12px; cursor: pointer; transition: border-color 0.15s;
}
#welcome .hint:hover { border-color: var(--accent); color: var(--accent); }

/* ─── Screen indicator in input bar ─── */
#screen-status {
  font-size: 11px; color: var(--red);
  display: flex; align-items: center; gap: 4px;
  padding: 4px 8px;
  background: rgba(255,77,109,0.08);
  border: 1px solid rgba(255,77,109,0.25);
  border-radius: 6px;
  flex-shrink: 0;
}
#screen-status .dot {
  width: 6px; height: 6px; background: var(--red);
  border-radius: 50%; animation: pulse 1.5s ease-in-out infinite;
}

/* ─── YouTube pill ─── */
#yt-pill {
  display: flex; align-items: center; gap: 8px;
  margin: 0 16px 4px;
  padding: 6px 12px;
  background: rgba(255, 0, 0, 0.08);
  border: 1px solid rgba(255, 80, 80, 0.3);
  border-radius: 8px;
  color: #ff6b6b;
  font-size: 12px;
  flex-shrink: 0;
}

/* ─── Memory button badge ─── */
#btn-memory.has-data { border-color: var(--accent); color: var(--accent); }
#memory-count { font-size: 11px; opacity: 0.7; }

/* ─── Memory overlay ─── */
#memory-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 200;
}

/* ─── Memory panel ─── */
#memory-panel {
  position: fixed; top: 0; right: 0; bottom: 0;
  width: 380px;
  background: var(--surface);
  border-left: 1px solid var(--border);
  z-index: 201;
  display: flex; flex-direction: column;
  overflow: hidden;
  box-shadow: -8px 0 32px rgba(0,0,0,0.4);
}
#memory-panel.hidden { display: none !important; }

#memory-panel-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  font-size: 13px; font-weight: 600;
  color: var(--accent);
  flex-shrink: 0;
}

#memory-list {
  flex: 1; overflow-y: auto;
  padding: 12px;
  display: flex; flex-direction: column; gap: 10px;
}
#memory-list::-webkit-scrollbar { width: 4px; }
#memory-list::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

.memory-empty {
  color: var(--text-dim); font-size: 12px;
  text-align: center; padding: 32px 16px; line-height: 1.7;
}

.memory-entry {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
}
.memory-topic {
  font-size: 12px; font-weight: 700;
  color: var(--accent); margin-bottom: 5px;
  text-transform: uppercase; letter-spacing: 0.5px;
}
.memory-content {
  font-size: 12px; color: var(--text);
  line-height: 1.6; margin-bottom: 8px;
}
.memory-meta {
  display: flex; align-items: center; gap: 8px;
  font-size: 10px; color: var(--text-dim);
}
.memory-meta span { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.btn-delete-memory {
  background: none; border: none; color: var(--text-dim);
  cursor: pointer; font-size: 12px; padding: 2px 4px;
  flex-shrink: 0;
}
.btn-delete-memory:hover { color: var(--red); }

/* ─── Typing custom text ─── */
.typing-custom {
  color: var(--text-dim); font-size: 13px;
  animation: blink 1.4s ease-in-out infinite;
}
@keyframes blink { 0%, 100% { opacity: 1; } 50% { opacity: 0.4; } }

/* ─── Screen context overlay ─── */
#screen-context-overlay {
  position: absolute; bottom: 0; left: 0; right: 0;
  background: rgba(0,0,0,0.75);
  color: #a0c4ff;
  font-size: 10px; line-height: 1.4;
  padding: 5px 8px;
  max-height: 56px; overflow: hidden;
  text-overflow: ellipsis;
  backdrop-filter: blur(2px);
}
#screen-context-overlay:empty { display: none; }

/* ─── Memory panel tabs ─── */
#memory-tabs {
  display: flex; gap: 4px;
}
.mem-tab {
  background: none; border: 1px solid var(--border);
  color: var(--text-dim); border-radius: 6px;
  padding: 4px 12px; font-size: 12px; cursor: pointer;
  transition: all 0.15s;
}
.mem-tab.active, .mem-tab:hover {
  border-color: var(--accent); color: var(--accent);
  background: rgba(0,212,255,0.08);
}

/* ─── Tab content ─── */
.tab-content {
  flex: 1; overflow-y: auto; display: flex; flex-direction: column;
}
.tab-content::-webkit-scrollbar { width: 4px; }
.tab-content::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

/* ─── Project form ─── */
#project-form {
  display: flex; flex-direction: column; gap: 8px;
  padding: 12px 12px 0;
  border-bottom: 1px solid var(--border);
  padding-bottom: 12px;
  flex-shrink: 0;
}
#project-form input, #project-form textarea {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--font);
  font-size: 12px;
  padding: 7px 10px;
  outline: none;
  resize: none;
  transition: border-color 0.15s;
}
#project-form input:focus, #project-form textarea:focus { border-color: var(--accent); }
#project-form input::placeholder, #project-form textarea::placeholder { color: var(--text-dim); }

.btn-primary {
  background: var(--accent); border: none;
  color: #000; border-radius: var(--radius);
  padding: 7px 14px; font-size: 12px; font-weight: 600;
  cursor: pointer; transition: background 0.15s;
}
.btn-primary:hover { background: #33ddff; }

/* ─── Project list ─── */
#project-list {
  padding: 12px;
  display: flex; flex-direction: column; gap: 10px;
  flex: 1;
}

.project-entry {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius);
  padding: 12px;
}
.project-name {
  font-size: 13px; font-weight: 700; color: var(--text);
  margin-bottom: 6px;
}
.project-meta-line {
  font-size: 11px; color: var(--text-dim); margin-bottom: 3px;
}
.project-notes {
  margin: 6px 0 6px 14px; padding: 0;
  font-size: 11px; color: var(--text-dim); line-height: 1.6;
}
.project-notes li { margin-bottom: 2px; }

/* ─── Memory list (inside tab) ─── */
#memory-list {
  flex: 1; padding: 12px;
  display: flex; flex-direction: column; gap: 10px;
}

/* ─── Show Wanda button ─── */
.btn-show-wanda {
  display: inline-flex; align-items: center; gap: 6px;
  margin-top: 8px;
  background: rgba(0, 212, 255, 0.1);
  border: 1px solid var(--accent);
  color: var(--accent);
  border-radius: 20px;
  padding: 6px 14px;
  font-size: 12px; font-family: var(--font);
  cursor: pointer; transition: all 0.15s;
}
.btn-show-wanda:hover {
  background: rgba(0, 212, 255, 0.2);
  transform: translateY(-1px);
}
.btn-show-wanda:disabled {
  opacity: 0.5; cursor: not-allowed; transform: none;
}

/* ─── Session kickoff message ─── */
.kickoff-msg .msg-bubble {
  border-color: var(--accent);
  background: rgba(0, 212, 255, 0.05);
}
.kickoff-chips {
  display: flex; flex-wrap: wrap; gap: 6px;
  margin-top: 10px;
}
.kickoff-chip {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 20px;
  color: var(--text-dim);
  font-size: 12px; padding: 5px 12px;
  cursor: pointer; transition: all 0.15s;
  font-family: var(--font);
}
.kickoff-chip:hover {
  border-color: var(--accent); color: var(--accent);
  background: rgba(0,212,255,0.08);
}

/* ─── Error / Review paste panel ─── */
#paste-panel {
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 12px 16px;
  display: flex; flex-direction: column; gap: 8px;
  flex-shrink: 0;
}
#paste-panel-header {
  display: flex; align-items: center; justify-content: space-between;
}
#paste-panel-title {
  font-size: 12px; font-weight: 700;
  color: var(--accent); letter-spacing: 0.5px;
}
#btn-close-paste {
  background: none; border: none; color: var(--text-dim);
  cursor: pointer; font-size: 14px; padding: 2px 6px;
}
#btn-close-paste:hover { color: var(--red); }
#paste-input {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--mono);
  font-size: 12px;
  padding: 10px 12px;
  resize: vertical;
  outline: none;
  min-height: 80px;
  transition: border-color 0.15s;
}
#paste-input:focus { border-color: var(--accent); }
#paste-input::placeholder { color: var(--text-dim); font-family: var(--font); }

/* ─── Screen action chips ─── */
#screen-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 8px 16px;
  background: var(--surface);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}
.screen-chip {
  background: rgba(0, 212, 255, 0.08);
  border: 1px solid rgba(0, 212, 255, 0.3);
  border-radius: 20px;
  color: var(--accent);
  font-size: 12px; font-family: var(--font);
  padding: 5px 12px;
  cursor: pointer; transition: all 0.15s;
}
.screen-chip:hover {
  background: rgba(0, 212, 255, 0.18);
  border-color: var(--accent);
}

/* ─── Screen proactive suggestions ─── */
#screen-suggestions {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 6px 8px;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(4px);
}
#screen-suggestions:empty { display: none; }
.suggest-chip {
  background: rgba(0, 212, 255, 0.1);
  border: 1px solid rgba(0, 212, 255, 0.25);
  border-radius: 6px;
  color: var(--accent);
  font-size: 10px; font-family: var(--font);
  padding: 4px 8px;
  cursor: pointer; text-align: left;
  transition: all 0.15s; line-height: 1.4;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.suggest-chip:hover {
  background: rgba(0, 212, 255, 0.2);
  border-color: var(--accent);
}

/* ─── Settings tab ─── */
#settings-form {
  padding: 16px;
  display: flex; flex-direction: column; gap: 14px;
}
.setting-row {
  display: flex; flex-direction: column; gap: 6px;
}
.setting-label {
  font-size: 11px; font-weight: 700;
  color: var(--accent); letter-spacing: 0.5px; text-transform: uppercase;
}
.setting-hint {
  font-size: 10px; color: var(--text-dim); line-height: 1.5;
}
#settings-form input {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--font);
  font-size: 13px;
  padding: 8px 12px;
  outline: none;
  transition: border-color 0.15s;
}
#settings-form input:focus { border-color: var(--accent); }
#settings-form input::placeholder { color: var(--text-dim); }

/* ─── Hip file pill ─── */
#hip-pill {
  display: flex; align-items: center; gap: 8px;
  margin: 0 16px 4px;
  padding: 6px 12px;
  background: rgba(124, 58, 237, 0.08);
  border: 1px solid rgba(124, 58, 237, 0.3);
  border-radius: 8px;
  color: #a78bfa;
  font-size: 12px;
  flex-shrink: 0;
}
#btn-remove-hip {
  background: none; border: none; color: #a78bfa;
  cursor: pointer; font-size: 14px; padding: 0 2px;
  margin-left: auto; opacity: 0.6;
}
#btn-remove-hip:hover { opacity: 1; color: var(--red); }

/* ─── Scenes tab ─── */
#scene-list {
  padding: 12px;
  display: flex; flex-direction: column; gap: 10px;
  flex: 1; overflow-y: auto;
}
#scene-list::-webkit-scrollbar { width: 4px; }
#scene-list::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

.scene-entry {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-left: 3px solid #7c3aed;
  border-radius: var(--radius);
  padding: 12px;
}
.scene-filename {
  font-size: 13px; font-weight: 700;
  color: #a78bfa; margin-bottom: 8px;
}
.scene-summary {
  font-family: var(--mono);
  font-size: 10px; color: var(--text-dim);
  line-height: 1.6; margin-bottom: 8px;
  white-space: pre-wrap; overflow-x: auto;
  background: rgba(0,0,0,0.2);
  padding: 6px 8px; border-radius: 4px;
}

