@import url('https://fonts.googleapis.com/css2?family=Share+Tech+Mono&family=VT323&display=swap');

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

:root {
  --green: #00ff41;
  --green-dark: #00cc33;
  --green-dim: #00aa2a;
  --green-glow: rgba(0, 255, 65, 0.35);
  --green-subtle: rgba(0, 255, 65, 0.08);
  --bg: #0a0a0a;
  --bg-alt: #0d0d0d;
  --muted: #33cc55;
  --text: #b0ffb0;
  --border: rgba(0, 255, 65, 0.15);
  --glass: rgba(0, 255, 65, 0.04);
  --radius: 6px;
}

html, body { height: 100%; font-family: 'Share Tech Mono', 'Courier New', monospace; background: var(--bg); color: var(--text); }

body::after { content: ''; position: fixed; inset: 0; background: repeating-linear-gradient(0deg, transparent, transparent 2px, rgba(0,0,0,0.12) 2px, rgba(0,0,0,0.12) 4px); pointer-events: none; z-index: 9998; will-change: transform; contain: strict; }
body::before { content: ''; position: fixed; inset: 0; background: radial-gradient(ellipse at center, transparent 60%, rgba(0,0,0,0.5) 100%); pointer-events: none; z-index: 9997; will-change: transform; contain: strict; }

#app { display: flex; height: 100%; overflow: hidden; }
.hidden { display: none !important; }

#sidebar-toggle { display: none; position: fixed; top: 12px; left: 12px; z-index: 1001; width: 44px; height: 44px; border-radius: var(--radius); border: 1px solid var(--border); background: var(--bg-alt); color: var(--green); font-size: 1.5rem; cursor: pointer; align-items: center; justify-content: center; font-family: 'Share Tech Mono', monospace; text-shadow: 0 0 8px var(--green-glow); transition: background 0.2s; }
#sidebar-toggle:hover { background: rgba(0,255,65,0.1); }

#sidebar {
  position: relative;
  width: 260px;
  min-width: 260px;
  flex-shrink: 0;
  background: linear-gradient(180deg, var(--bg-alt), #0b0f0b);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 16px 14px;
  gap: 12px;
  overflow-y: auto;
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  scrollbar-width: thin;
  scrollbar-color: rgba(0,255,65,0.2) transparent;
}
#sidebar::-webkit-scrollbar { width: 4px; }
#sidebar::-webkit-scrollbar-thumb { background: rgba(0,255,65,0.2); border-radius: 2px; }
#sidebar::-webkit-scrollbar-track { background: transparent; }

.sidebar-header { text-align: center; padding-bottom: 4px; }
.logo { display: flex; align-items: center; justify-content: center; gap: 10px; margin-bottom: 4px; }
.logo-icon { font-size: 1.6rem; color: var(--green); text-shadow: 0 0 8px var(--green-glow); font-family: 'VT323', monospace; }
.logo-text { font-family: 'VT323', monospace; font-size: 1.8rem; font-weight: 400; color: var(--green); text-shadow: 0 0 10px var(--green-glow), 0 0 20px rgba(0,255,65,0.15); letter-spacing: 2px; }
.tagline { font-size: 0.72rem; color: var(--muted); opacity: 0.7; margin-top: 2px; }

.sidebar-close-btn {
  display: none;
  position: absolute;
  top: 10px;
  right: 10px;
  width: 36px;
  height: 36px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--glass);
  color: var(--green);
  font-size: 1.2rem;
  cursor: pointer;
  align-items: center;
  justify-content: center;
  font-family: 'Share Tech Mono', monospace;
  z-index: 2;
  transition: background 0.2s;
}
.sidebar-close-btn:hover { background: rgba(0,255,65,0.12); }

.stats {
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: var(--green-subtle);
  border-radius: var(--radius);
  padding: 10px;
  border: 1px solid var(--border);
}
.stat-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 1px 4px;
}
.stat-label { flex: 1; font-size: 0.78rem; color: var(--muted); opacity: 0.7; text-transform: uppercase; letter-spacing: 1px; }
.stat-value { font-size: 0.82rem; font-weight: 600; color: var(--green); text-shadow: 0 0 6px var(--green-glow); text-align: right; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ── Model status notification dots ── */
.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
  margin-right: 4px;
  display: inline-block;
  background: #555;
}
.status-dot[data-state="loading"] {
  background: #f59e0b;
  box-shadow: 0 0 4px rgba(245, 158, 11, 0.6);
  animation: dotPulse 1.2s ease-in-out infinite;
}
.status-dot[data-state="ready"] {
  background: var(--green);
  box-shadow: 0 0 6px var(--green-glow);
  animation: dotReadyPop 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}
.status-dot[data-state="error"] {
  background: #ef4444;
  box-shadow: 0 0 4px rgba(239, 68, 68, 0.6);
  animation: none;
}
@keyframes dotPulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.35; transform: scale(0.65); }
}
@keyframes dotReadyPop {
  0% { transform: scale(0); opacity: 0; }
  70% { transform: scale(1.5); opacity: 1; }
  100% { transform: scale(1); opacity: 1; }
}

/* ── Toast notifications ── */
#notification-container {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 10000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}
.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  border-left-width: 3px;
  background: rgba(10, 10, 10, 0.95);
  backdrop-filter: blur(8px);
  font-family: 'Share Tech Mono', monospace;
  font-size: 0.78rem;
  color: var(--green);
  min-width: 200px;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.5), 0 0 16px rgba(0, 255, 65, 0.08);
  pointer-events: auto;
  animation: toastSlideIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}
.toast.toast-removing {
  animation: toastSlideOut 0.25s ease-in forwards;
}
.toast.success { border-left-color: var(--green); color: var(--green); }
.toast.error   { border-left-color: #ef4444;      color: #ef4444; }
.toast-icon {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.toast.success .toast-icon { background: var(--green); box-shadow: 0 0 6px var(--green-glow); }
.toast.error   .toast-icon { background: #ef4444;      box-shadow: 0 0 4px rgba(239,68,68,0.6); }
.toast-label {
  font-family: 'VT323', monospace;
  font-size: 0.65rem;
  opacity: 0.5;
  letter-spacing: 1px;
  text-transform: uppercase;
}
.toast-message { flex: 1; }
@keyframes toastSlideIn {
  from { opacity: 0; transform: translateX(40px) scale(0.95); }
  to   { opacity: 1; transform: translateX(0)    scale(1); }
}
@keyframes toastSlideOut {
  from { opacity: 1; transform: translateX(0)    scale(1); max-height: 60px; margin-bottom: 0; }
  to   { opacity: 0; transform: translateX(40px) scale(0.95); max-height: 0;  margin-bottom: -8px; }
}

#progress-wrap { background: var(--bg); border-radius: var(--radius); padding: 12px; border: 1px solid var(--border); }
#progress-label { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; font-family: 'Share Tech Mono', monospace; font-size: 0.72rem; }
#progress-label::before { content: '> loading'; color: var(--green); text-shadow: 0 0 6px var(--green-glow); }
#progress-track { height: 10px; background: rgba(0,255,65,0.06); border-radius: 2px; border: 1px solid var(--border); overflow: hidden; position: relative; }
#progress-bar { height: 100%; width: 0%; border-radius: 1px; transition: width 0.3s ease; position: relative; background: repeating-linear-gradient(-45deg, var(--green), var(--green) 4px, var(--green-dark) 4px, var(--green-dark) 8px); background-size: 200% 100%; animation: progressStripes 0.8s linear infinite; box-shadow: 0 0 12px var(--green-glow), 0 0 4px var(--green); }
#progress-text { font-size: 0.72rem; color: var(--green); text-shadow: 0 0 4px var(--green-glow); font-family: 'VT323', monospace; letter-spacing: 1px; }
@keyframes progressStripes { 0% { background-position: 0 0; } 100% { background-position: 16px 0; } }

.panel { border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 12px;
  cursor: pointer;
  font-family: 'Share Tech Mono', monospace;
  font-size: 0.78rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 1px;
  background: var(--green-subtle);
  transition: color 0.2s, background 0.2s;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}
.panel-header:hover { color: var(--green); background: rgba(0,255,65,0.08); }
.panel-header:active { background: rgba(0,255,65,0.12); }
.panel-arrow { font-size: 0.9rem; color: var(--green); }
.panel-body { padding: 8px; display: flex; flex-direction: column; gap: 6px; }
.panel-row { display: flex; gap: 6px; flex-wrap: wrap; }
.panel-btn {
  padding: 8px 10px;
  border-radius: var(--radius);
  font-size: 0.75rem;
  cursor: pointer;
  font-family: 'Share Tech Mono', monospace;
  transition: all 0.2s;
  flex: 1;
  min-height: 36px;
  -webkit-tap-highlight-color: transparent;
}
.panel-btn.green { border: 1px solid var(--border); background: var(--green-subtle); color: var(--green); }
.panel-btn.green:hover { background: rgba(0,255,65,0.15); border-color: rgba(0,255,65,0.4); }
#memory-input { flex: 1; padding: 8px; border-radius: var(--radius); border: 1px solid var(--border); background: var(--glass); color: var(--green); font-size: 0.75rem; font-family: 'Share Tech Mono', monospace; outline: none; min-height: 36px; }
#memory-input::placeholder { color: rgba(0,255,65,0.25); }
#convo-list, #memory-list { display: flex; flex-direction: column; gap: 3px; max-height: 140px; overflow-y: auto; }
#convo-list::-webkit-scrollbar, #memory-list::-webkit-scrollbar { width: 4px; }
#convo-list::-webkit-scrollbar-thumb, #memory-list::-webkit-scrollbar-thumb { background: rgba(0,255,65,0.2); border-radius: 2px; }
.panel-item { display: flex; align-items: center; padding: 5px 8px; border-radius: 3px; font-size: 0.72rem; font-family: 'Share Tech Mono', monospace; color: var(--text); background: var(--glass); border: 1px solid transparent; gap: 6px; }
.panel-item:hover { border-color: var(--border); }
.panel-item-text { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; cursor: pointer; }
.panel-item-text:hover { color: var(--green); }
.panel-item-del { cursor: pointer; color: #ff4444; font-size: 0.7rem; opacity: 0.4; flex-shrink: 0; }
.panel-item-del:hover { opacity: 1; }
.panel-empty { font-size: 0.7rem; color: var(--muted); opacity: 0.5; text-align: center; padding: 6px; }

#chat-area { flex: 1; min-width: 0; display: flex; flex-direction: column; background: var(--bg); position: relative; }
#messages { flex: 1; overflow-y: auto; padding: 24px 32px; display: flex; flex-direction: column; gap: 16px; }
#messages::-webkit-scrollbar { width: 6px; }
#messages::-webkit-scrollbar-thumb { background: rgba(0,255,65,0.2); border-radius: 3px; }
#messages::-webkit-scrollbar-track { background: transparent; }

.message { max-width: 70%; padding: 14px 18px; border-radius: var(--radius); font-size: 0.92rem; line-height: 1.55; word-wrap: break-word; overflow-wrap: break-word; }
.message.user { align-self: flex-end; background: rgba(0,255,65,0.12); color: var(--green); border: 1px solid rgba(0,255,65,0.3); border-bottom-right-radius: 2px; text-shadow: 0 0 4px var(--green-glow); }
.message.ai { align-self: flex-start; background: rgba(0,255,65,0.04); border: 1px solid var(--border); border-bottom-left-radius: 2px; }
.ai-label { display: block; font-family: 'VT323', monospace; font-size: 0.8rem; font-weight: 400; text-transform: uppercase; letter-spacing: 2px; color: var(--green); text-shadow: 0 0 8px var(--green-glow); margin-bottom: 6px; }

.streaming-content::after { content: '█'; animation: streamCursor 0.6s step-end infinite; color: var(--green); text-shadow: 0 0 8px var(--green-glow); margin-left: 2px; }
@keyframes streamCursor { 0%, 100% { opacity: 1; } 50% { opacity: 0; } }

.code-block { background: rgba(0,255,65,0.06); border: 1px solid var(--border); border-radius: var(--radius); margin: 8px 0; overflow-x: auto; position: relative; }
.code-block pre { margin: 0; padding: 12px; }
.code-block code { font-family: 'Share Tech Mono', monospace; font-size: 0.82rem; color: var(--green); line-height: 1.5; white-space: pre; }
.code-lang { position: absolute; top: 0; right: 50px; padding: 2px 8px; font-size: 0.65rem; color: var(--muted); background: rgba(0,255,65,0.08); border-bottom-left-radius: var(--radius); font-family: 'Share Tech Mono', monospace; text-transform: uppercase; letter-spacing: 1px; }
.md-inline-code { background: rgba(0,255,65,0.1); padding: 1px 5px; border-radius: 3px; font-size: 0.85em; color: var(--green); font-family: 'Share Tech Mono', monospace; }
.md-heading { color: var(--green); font-family: 'VT323', monospace; text-shadow: 0 0 6px var(--green-glow); margin: 10px 0 6px; letter-spacing: 1px; }
h3.md-heading { font-size: 1.15rem; }
h4.md-heading { font-size: 1rem; }
h5.md-heading { font-size: 0.9rem; }
.md-list { padding-left: 20px; margin: 6px 0; }
.md-list li { margin: 3px 0; }
.md-hr { border: none; border-top: 1px solid var(--border); margin: 10px 0; }
.message em { font-style: italic; color: var(--muted); }
.message strong { color: var(--green); text-shadow: 0 0 4px var(--green-glow); }

.chat-image-container { position: relative; display: inline-block; max-width: 240px; max-height: 180px; border-radius: var(--radius); overflow: hidden; cursor: pointer; margin-top: 4px; transition: transform 0.15s, box-shadow 0.15s; border: 1px solid var(--border); }
.chat-image-container:hover { transform: scale(1.03); box-shadow: 0 0 20px var(--green-glow); }
.chat-image { display: block; width: 100%; max-width: 240px; max-height: 180px; object-fit: contain; border-radius: var(--radius); }
.bounding-box { position: absolute; border: 2px solid; border-radius: 2px; pointer-events: none; }
.bounding-box-label { position: absolute; top: -18px; left: -1px; padding: 1px 5px; font-size: 0.6rem; font-weight: 600; color: #000; border-radius: 2px 2px 2px 0; white-space: nowrap; font-family: 'Share Tech Mono', monospace; }

.image-overlay { position: fixed; inset: 0; z-index: 9999; display: flex; align-items: center; justify-content: center; }
.overlay-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,0.9); backdrop-filter: blur(8px); }
.overlay-content { position: relative; z-index: 1; max-width: 90vw; max-height: 90vh; }
.overlay-close { position: absolute; top: -40px; right: 0; background: rgba(0,255,65,0.1); border: 1px solid var(--border); color: var(--green); font-size: 1.2rem; width: 36px; height: 36px; border-radius: 50%; cursor: pointer; display: flex; align-items: center; justify-content: center; }
.overlay-close:hover { background: rgba(255,0,0,0.2); border-color: rgba(255,0,0,0.4); color: #ff4444; }
.overlay-detection-container { position: relative; display: inline-block; }
.overlay-image { max-width: 85vw; max-height: 80vh; border-radius: var(--radius); object-fit: contain; display: block; box-shadow: 0 0 40px rgba(0,255,65,0.15); border: 1px solid var(--border); }
.overlay-detection-container .bounding-box { border-width: 3px; }
.overlay-detection-container .bounding-box-label { top: -22px; padding: 2px 8px; font-size: 0.75rem; }

.welcome-msg { text-align: center; padding: 48px 24px; animation: fadeSlideIn 0.5s ease-out; }
.welcome-msg .big-icon { font-size: 3rem; display: block; margin-bottom: 16px; color: var(--green); text-shadow: 0 0 12px var(--green-glow); font-family: 'VT323', monospace; }
.welcome-msg h2 { font-family: 'VT323', monospace; font-size: 1.8rem; font-weight: 400; color: var(--green); text-shadow: 0 0 10px var(--green-glow), 0 0 30px rgba(0,255,65,0.1); margin-bottom: 8px; letter-spacing: 2px; }
.welcome-msg p { color: var(--muted); font-size: 0.88rem; opacity: 0.8; }
.vision-hint { margin-top: 16px; font-size: 0.78rem; color: var(--muted); opacity: 0.6; }
.suggestions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 20px; }
.suggestion-chip { padding: 8px 16px; border-radius: var(--radius); border: 1px solid var(--border); background: var(--green-subtle); color: var(--green); font-size: 0.8rem; cursor: pointer; transition: all 0.2s; font-family: 'Share Tech Mono', monospace; }
.suggestion-chip:hover { background: rgba(0,255,65,0.15); border-color: rgba(0,255,65,0.5); text-shadow: 0 0 8px var(--green-glow); transform: translateY(-1px); }

#typing-indicator { padding: 4px 36px 10px; font-family: 'Share Tech Mono', monospace; font-size: 0; color: var(--green); text-shadow: 0 0 6px var(--green-glow); }
#typing-indicator .typing-line { display: inline; font-size: 0.8rem; line-height: 1.6; }
#typing-indicator .typing-cursor { display: inline-block; width: 7px; height: 1.05em; background: var(--green); box-shadow: 0 0 6px var(--green-glow); vertical-align: text-bottom; animation: cursorBlink 0.6s step-end infinite; margin-left: 2px; }
@keyframes cursorBlink { 0%, 100% { opacity: 1; } 50% { opacity: 0; } }
.typing-dot { display: none; }

/* ── Input bar clock ── */
#input-clock {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 0 2px;
  flex-shrink: 0;
  user-select: none;
  pointer-events: none;
}
#input-clock-time {
  font-family: 'VT323', monospace;
  font-size: 1.15rem;
  color: var(--muted);
  opacity: 0.55;
  letter-spacing: 1px;
  line-height: 1;
  transition: opacity 0.3s;
}
#input-clock:hover #input-clock-time { opacity: 0.85; }

#input-form { display: flex; gap: 10px; padding: 16px 32px 24px; background: linear-gradient(0deg, var(--bg) 60%, transparent); align-items: center; }
#image-upload-btn, #send-btn { width: 48px; height: 48px; min-width: 48px; border-radius: var(--radius); display: flex; align-items: center; justify-content: center; font-size: 1.2rem; cursor: pointer; transition: all 0.25s; }
#image-upload-btn { border: 1px solid var(--border); background: var(--glass); color: var(--text); }
#image-upload-btn:hover { background: rgba(0,255,65,0.12); border-color: rgba(0,255,65,0.4); transform: scale(1.05); }
#send-btn { border: 1px solid var(--green-dark); background: rgba(0,255,65,0.12); color: var(--green); text-shadow: 0 0 8px var(--green-glow); }
#send-btn:hover { transform: scale(1.05); background: rgba(0,255,65,0.2); box-shadow: 0 0 20px var(--green-glow); }
#send-btn:active { transform: scale(0.95); }
#user-input { flex: 1; padding: 14px 20px; border-radius: var(--radius); border: 1px solid var(--border); background: var(--glass); color: var(--green); font-size: 0.92rem; font-family: 'Share Tech Mono', monospace; outline: none; transition: all 0.25s; }
#user-input:focus { border-color: rgba(0,255,65,0.5); background: rgba(0,255,65,0.06); box-shadow: 0 0 20px rgba(0,255,65,0.1); }
#user-input::placeholder { color: rgba(0,255,65,0.25); }

#chat-area.drag-over { outline: 2px dashed var(--green); outline-offset: -4px; background: var(--green-subtle); }
#chat-area.drag-over::after { content: '> DROP IMAGE HERE_'; position: absolute; top: 50%; left: 50%; transform: translate(-50%,-50%); font-family: 'VT323', monospace; font-size: 1.4rem; color: var(--green); text-shadow: 0 0 10px var(--green-glow); background: rgba(0,0,0,0.9); padding: 16px 32px; border-radius: var(--radius); border: 1px solid var(--border); pointer-events: none; z-index: 10; letter-spacing: 2px; }

.copy-btn { position: absolute; top: 4px; right: 4px; padding: 2px 8px; border-radius: 3px; border: 1px solid var(--border); background: var(--bg); color: var(--muted); font-family: 'Share Tech Mono', monospace; font-size: 0.65rem; cursor: pointer; transition: all 0.2s; z-index: 1; }
.copy-btn:hover { color: var(--green); border-color: rgba(0,255,65,0.4); background: rgba(0,255,65,0.08); }

.msg-time { display: block; font-size: 0.62rem; color: var(--muted); opacity: 0.4; margin-top: 6px; font-family: 'Share Tech Mono', monospace; text-align: right; }
.message.ai .msg-time { text-align: left; }

#scroll-bottom-btn { position: absolute; bottom: 90px; right: 32px; width: 36px; height: 36px; border-radius: 50%; border: 1px solid var(--border); background: var(--bg-alt); color: var(--green); font-family: 'VT323', monospace; font-size: 1.2rem; cursor: pointer; display: flex; align-items: center; justify-content: center; transition: all 0.2s; z-index: 5; box-shadow: 0 2px 12px rgba(0,0,0,0.4); }
#scroll-bottom-btn:hover { background: rgba(0,255,65,0.1); border-color: rgba(0,255,65,0.4); box-shadow: 0 0 12px var(--green-glow); }

.copy-btn { position: absolute; top: 4px; right: 4px; padding: 2px 8px; border-radius: 3px; border: 1px solid var(--border); background: var(--bg); color: var(--muted); font-family: 'Share Tech Mono', monospace; font-size: 0.65rem; cursor: pointer; transition: all 0.2s; z-index: 1; }
.copy-btn:hover { color: var(--green); border-color: rgba(0,255,65,0.4); background: rgba(0,255,65,0.08); }
.msg-time { display: block; font-size: 0.62rem; color: var(--muted); opacity: 0.4; margin-top: 6px; font-family: 'Share Tech Mono', monospace; text-align: right; }
.message.ai .msg-time { text-align: left; }
#scroll-bottom-btn { position: absolute; bottom: 90px; right: 32px; width: 36px; height: 36px; border-radius: 50%; border: 1px solid var(--border); background: var(--bg-alt); color: var(--green); font-family: 'VT323', monospace; font-size: 1.2rem; cursor: pointer; display: flex; align-items: center; justify-content: center; transition: all 0.2s; z-index: 5; box-shadow: 0 2px 12px rgba(0,0,0,0.4); }
#scroll-bottom-btn:hover { background: rgba(0,255,65,0.1); border-color: rgba(0,255,65,0.4); box-shadow: 0 0 12px var(--green-glow); }

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(2px);
  z-index: 999;
  opacity: 0;
  transition: opacity 0.3s ease;
}
.sidebar-overlay.active {
  display: block;
  opacity: 1;
}

/* ── Search ── */
#search-input { flex: 1; padding: 8px; border-radius: var(--radius); border: 1px solid var(--border); background: var(--glass); color: var(--green); font-size: 0.75rem; font-family: 'Share Tech Mono', monospace; outline: none; min-height: 36px; }
#search-input::placeholder { color: rgba(0,255,65,0.25); }
#search-results { display: flex; flex-direction: column; gap: 3px; max-height: 160px; overflow-y: auto; }
#search-results::-webkit-scrollbar { width: 4px; }
#search-results::-webkit-scrollbar-thumb { background: rgba(0,255,65,0.2); border-radius: 2px; }
.search-result-item { cursor: pointer; }
.search-result-item:hover { border-color: var(--green); background: rgba(0,255,65,0.06); }
.search-result-role { font-size: 0.62rem; text-transform: uppercase; letter-spacing: 1px; color: var(--muted); opacity: 0.6; min-width: 22px; flex-shrink: 0; font-family: 'VT323', monospace; }
.search-highlight { box-shadow: inset 0 0 0 1px rgba(0,255,65,0.4); background: rgba(0,255,65,0.08) !important; }
.search-flash { animation: searchFlash 1.5s ease-out; }
@keyframes searchFlash { 0% { box-shadow: 0 0 20px var(--green-glow), inset 0 0 0 2px var(--green); } 100% { box-shadow: none; } }

/* ── Stopwatch ── */
.stopwatch-display { font-family: 'VT323', monospace; font-size: 1.8rem; text-align: center; color: var(--green); text-shadow: 0 0 8px var(--green-glow); padding: 8px 0 4px; letter-spacing: 3px; transition: text-shadow 0.3s; }
.stopwatch-display.running { text-shadow: 0 0 12px var(--green-glow), 0 0 24px rgba(0,255,65,0.2); animation: stopwatchPulse 1s ease-in-out infinite; }
@keyframes stopwatchPulse { 0%, 100% { text-shadow: 0 0 12px var(--green-glow), 0 0 24px rgba(0,255,65,0.2); } 50% { text-shadow: 0 0 16px var(--green-glow), 0 0 32px rgba(0,255,65,0.35); } }
#stopwatch-laps { display: flex; flex-direction: column; gap: 2px; max-height: 80px; overflow-y: auto; }

/* ── Conversation Rename ── */
.convo-rename-input { flex: 1; padding: 3px 6px; border-radius: 3px; border: 1px solid var(--green); background: rgba(0,255,65,0.08); color: var(--green); font-size: 0.72rem; font-family: 'Share Tech Mono', monospace; outline: none; box-shadow: 0 0 8px var(--green-glow); }

/* ── System Prompt Editor ── */
#sysprompt-input { width: 100%; padding: 8px; border-radius: var(--radius); border: 1px solid var(--border); background: var(--glass); color: var(--green); font-size: 0.72rem; font-family: 'Share Tech Mono', monospace; outline: none; resize: vertical; min-height: 60px; max-height: 160px; line-height: 1.4; }
#sysprompt-input::placeholder { color: rgba(0,255,65,0.25); }
#sysprompt-input:focus { border-color: rgba(0,255,65,0.5); background: rgba(0,255,65,0.06); box-shadow: 0 0 12px rgba(0,255,65,0.1); }

@keyframes fadeSlideIn { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: translateY(0); } }
@keyframes blink { 0%,100% { opacity: 1; } 50% { opacity: 0; } }

@media (max-width: 700px) {
  #sidebar-toggle { display: flex; }
  .sidebar-close-btn { display: flex; }
  #sidebar {
    position: fixed;
    top: 0;
    left: 0;
    height: 100%;
    height: 100dvh;
    z-index: 1000;
    transform: translateX(-100%);
    width: 85vw;
    max-width: 320px;
    box-shadow: none;
    padding: 16px 14px;
    padding-top: env(safe-area-inset-top, 16px);
    padding-bottom: env(safe-area-inset-bottom, 16px);
  }
  #sidebar.open {
    transform: translateX(0);
    box-shadow: 4px 0 30px rgba(0,0,0,0.5);
  }
  .sidebar-overlay.active { display: block; }
  .sidebar-header { padding-top: 24px; }
  .panel-header { padding: 12px 14px; font-size: 0.82rem; min-height: 44px; }
  .panel-btn { min-height: 44px; padding: 10px 12px; font-size: 0.78rem; }
  #memory-input, #search-input { min-height: 44px; padding: 10px; font-size: 0.82rem; }
  #messages { padding: 60px 16px 16px; }
  #input-form { padding: 12px 12px 16px; gap: 8px; padding-bottom: max(16px, env(safe-area-inset-bottom)); }
  .message { max-width: 88%; font-size: 0.85rem; }
  .chat-image-container, .chat-image { max-width: 180px; max-height: 130px; }
  .welcome-msg { padding: 80px 20px 40px; }
  .welcome-msg h2 { font-size: 1.4rem; }
  .suggestions { gap: 6px; }
  .suggestion-chip { font-size: 0.72rem; padding: 8px 14px; min-height: 40px; display: flex; align-items: center; }
  #image-upload-btn, #send-btn { width: 48px; height: 48px; min-width: 48px; }
  #user-input { padding: 12px 14px; font-size: 0.88rem; }
  #input-clock { display: none; }
  #scroll-bottom-btn { bottom: 80px; right: 16px; width: 36px; height: 36px; font-size: 1rem; }
  .panel-item { padding: 8px 10px; min-height: 40px; }
  .panel-item-del { padding: 6px; font-size: 0.8rem; }
  .stopwatch-display { font-size: 2.2rem; padding: 12px 0 8px; }
  #sysprompt-input { font-size: 0.78rem; min-height: 80px; }
  #convo-list, #memory-list { max-height: 200px; }
}

/* Tablet breakpoint */
@media (min-width: 701px) and (max-width: 1024px) {
  #sidebar { width: 220px; min-width: 220px; padding: 14px 12px; gap: 10px; }
  .logo-text { font-size: 1.5rem; }
  .logo-icon { font-size: 1.3rem; }
  .tagline { font-size: 0.68rem; }
  .stats { padding: 8px; }
  .stat-label { font-size: 0.72rem; }
  .stat-value { font-size: 0.76rem; max-width: 100px; }
}

/* Large desktop - wider sidebar */
@media (min-width: 1400px) {
  #sidebar { width: 300px; min-width: 300px; padding: 20px 18px; gap: 14px; }
}
