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

:root {
  --primary-color: #4285F4;
  --bg-color: #f5f5f5;
  --surface-color: #ffffff;
  --text-primary: #202124;
  --text-secondary: #5f6368;
  --border-color: #dadce0;
  --user-bubble: #4285F4;
  --assistant-bubble: #e8f0fe;
  --shadow: 0 1px 3px rgba(0,0,0,0.12), 0 1px 2px rgba(0,0,0,0.24);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: var(--bg-color);
  color: var(--text-primary);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

/* App Container */
.app-container {
  width: 100vw;
  height: 100vh;
  display: flex;
  flex-direction: column;
  position: relative;
}

/* Tab Content */
.tab-content {
  flex: 1;
  display: none;
  flex-direction: column;
  overflow: hidden;
}

.tab-content.active {
  display: flex;
}

/* Chat Tab */
.chat-header {
  background: var(--surface-color);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: var(--shadow);
  z-index: 10;
}

.icon-btn {
  background: none;
  border: none;
  font-size: 24px;
  cursor: pointer;
  padding: 8px;
  color: var(--text-primary);
}

.passive-toggle {
  background: none;
  border: 1px solid #34a853;
  color: #34a853;
  border-radius: 12px;
  padding: 4px 10px;
  font-size: 12px;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
}

.passive-toggle.off {
  border-color: var(--border-color);
  color: var(--text-secondary);
}

.chat-header h1 {
  font-size: 18px;
  font-weight: 500;
  flex: 1;
}

.message-list {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.message {
  display: flex;
  gap: 8px;
  animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.message.user {
  flex-direction: row-reverse;
}

.message-bubble {
  max-width: 75%;
  padding: 10px 14px;
  border-radius: 18px;
  word-wrap: break-word;
  box-shadow: 0 1px 2px rgba(0,0,0,0.1);
}

.message.user .message-bubble {
  background: var(--user-bubble);
  color: white;
  border-bottom-right-radius: 4px;
}

.message.assistant .message-bubble {
  background: var(--assistant-bubble);
  color: var(--text-primary);
  border-bottom-left-radius: 4px;
}

.message-meta {
  font-size: 11px;
  color: var(--text-secondary);
  margin-top: 4px;
  display: flex;
  gap: 8px;
  align-items: center;
}

.message.user .message-meta {
  justify-content: flex-end;
}

.passive-badge {
  background: #34a853;
  color: white;
  padding: 2px 6px;
  border-radius: 10px;
  font-size: 10px;
}

/* 语音播放按钮 */
.msg-speaker-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 14px;
  padding: 2px 4px;
  margin-right: 4px;
  border-radius: 4px;
  transition: transform 0.2s, background 0.2s;
}

.msg-speaker-btn:hover {
  background: rgba(0, 0, 0, 0.1);
}

.msg-speaker-btn.playing {
  animation: speakerPulse 1s infinite;
}

@keyframes speakerPulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.2); }
}

/* Input Bar */
.input-bar {
  background: var(--surface-color);
  padding: 12px 16px;
  display: flex;
  gap: 8px;
  align-items: flex-end;
  box-shadow: 0 -1px 3px rgba(0,0,0,0.1);
}

#message-input {
  flex: 1;
  border: 1px solid var(--border-color);
  border-radius: 20px;
  padding: 10px 16px;
  font-size: 15px;
  resize: none;
  max-height: 100px;
  font-family: inherit;
}

#message-input:focus {
  outline: none;
  border-color: var(--primary-color);
}

.btn-send {
  background: var(--primary-color);
  color: white;
  border: none;
  border-radius: 20px;
  padding: 10px 20px;
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
}

.btn-send:active {
  opacity: 0.8;
}

.btn-voice {
  background: var(--surface-color);
  border: 1px solid var(--border-color);
  border-radius: 50%;
  width: 44px;
  height: 44px;
  font-size: 20px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all 0.2s;
}

.btn-voice:hover {
  background: var(--hover-color);
}

.btn-voice.listening {
  background: #ff4444;
  animation: pulse 1s infinite;
}

@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.1); }
}

.btn-send:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Mini Map (floating on chat page) */
.mini-map-container {
  position: absolute;
  bottom: 150px;
  right: 16px;
  width: 100px;
  height: 100px;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
  border: 2px solid white;
  z-index: 100;
  cursor: move;
  touch-action: none;
}

#mini-map {
  width: 100%;
  height: 100%;
}

/* Map Tab */
.full-map {
  width: 100%;
  height: 100%;
}

/* AI Bubble (floating on map page) */
.ai-bubble {
  position: absolute;
  bottom: 80px;
  left: 16px;
  right: 16px;
  background: white;
  border-radius: 16px;
  padding: 16px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  z-index: 100;
  animation: slideUp 0.3s ease;
}

@keyframes slideUp {
  from { transform: translateY(100%); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.ai-bubble.hidden {
  display: none;
}

.bubble-close {
  position: absolute;
  top: 8px;
  right: 8px;
  background: none;
  border: none;
  font-size: 24px;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 4px;
  line-height: 1;
}

.bubble-content {
  padding-right: 24px;
  font-size: 15px;
  line-height: 1.5;
}

/* Bottom Tab Bar */
.tab-bar {
  background: var(--surface-color);
  display: flex;
  border-top: 1px solid var(--border-color);
  box-shadow: 0 -1px 3px rgba(0,0,0,0.1);
}

.tab-btn {
  flex: 1;
  background: none;
  border: none;
  padding: 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  color: var(--text-secondary);
  transition: color 0.2s;
}

.tab-btn.active {
  color: var(--primary-color);
}

.tab-icon {
  font-size: 24px;
}

.tab-label {
  font-size: 12px;
}

/* Drawer */
.drawer {
  position: fixed;
  top: 0;
  left: -280px;
  width: 280px;
  height: 100vh;
  background: var(--surface-color);
  box-shadow: 2px 0 8px rgba(0,0,0,0.1);
  z-index: 1000;
  transition: left 0.3s ease;
  display: flex;
  flex-direction: column;
}

.drawer.open {
  left: 0;
}

.drawer-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0,0,0,0.5);
  z-index: 999;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.drawer-overlay.visible {
  opacity: 1;
  pointer-events: auto;
}

.drawer-header {
  padding: 20px 16px;
  border-bottom: 1px solid var(--border-color);
}

.drawer-header h2 {
  font-size: 20px;
  margin-bottom: 12px;
}

.btn-primary {
  width: 100%;
  background: var(--primary-color);
  color: white;
  border: none;
  border-radius: 8px;
  padding: 10px;
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
}

.btn-primary:active {
  opacity: 0.8;
}

.session-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px 0;
}

.session-item {
  padding: 12px 16px;
  cursor: pointer;
  border-left: 3px solid transparent;
  transition: background 0.2s;
  display: flex;
  align-items: center;
  gap: 8px;
}

.session-item-body {
  flex: 1;
  min-width: 0;
}

.session-delete-btn {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 18px;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 4px;
  line-height: 1;
  opacity: 0;
  transition: opacity 0.15s, color 0.15s;
  flex-shrink: 0;
}

.session-item:hover .session-delete-btn {
  opacity: 1;
}

.session-delete-btn:hover {
  color: #ea4335;
}

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

.session-item.active {
  background: var(--bg-color);
  border-left-color: var(--primary-color);
}

.session-item-title {
  font-size: 15px;
  font-weight: 500;
  margin-bottom: 4px;
}

.session-item-date {
  font-size: 12px;
  color: var(--text-secondary);
}

/* Loading indicator */
.loading-dots {
  display: inline-block;
}

.loading-dots::after {
  content: '...';
  animation: dots 1.5s steps(4, end) infinite;
}

@keyframes dots {
  0%, 20% { content: '.'; }
  40% { content: '..'; }
  60%, 100% { content: '...'; }
}

/* Debug Console */
#debug-console {
  position: fixed;
  top: 12px;
  right: 12px;
  background: rgba(0, 0, 0, 0.7);
  color: #00ff88;
  font-family: monospace;
  font-size: 11px;
  border-radius: 8px;
  z-index: 9999;
  backdrop-filter: blur(4px);
  min-width: 180px;
  pointer-events: auto;
  user-select: text;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  transition: opacity 0.2s, transform 0.2s;
}

/* 拖拽手柄 */
.debug-drag-handle {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 10px;
  cursor: move;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px 8px 0 0;
  background: rgba(255, 255, 255, 0.05);
}

.debug-drag-handle:hover {
  background: rgba(255, 255, 255, 0.1);
}

.debug-title {
  font-weight: bold;
  color: rgba(255, 255, 255, 0.8);
}

/* 调试内容区域 */
.debug-content {
  padding: 8px 10px;
}

.debug-content.collapsed {
  display: none;
}

.debug-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  line-height: 1.8;
}

.debug-divider {
  border-top: 1px solid rgba(255, 255, 255, 0.15);
  margin: 6px 0;
}

.debug-toggle {
  background: none;
  border: none;
  color: #00ff88;
  font-size: 12px;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 4px;
  transition: color 0.2s;
}

.debug-toggle:hover {
  color: #fff;
}

.debug-toggle.off {
  color: rgba(255, 255, 255, 0.3);
}

.debug-toggle.off {
  background: rgba(255, 255, 255, 0.2);
  color: rgba(255, 255, 255, 0.5);
}

.debug-label {
  color: rgba(255, 255, 255, 0.5);
}

/* 探索按钮 */
.debug-explore-btn {
  width: 100%;
  margin-top: 10px;
  padding: 8px 12px;
  background: linear-gradient(135deg, #34a853, #0d652d);
  color: white;
  border: none;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: opacity 0.2s, transform 0.1s;
}

.debug-explore-btn:hover {
  opacity: 0.9;
}

.debug-explore-btn:active {
  transform: scale(0.98);
}

.debug-explore-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.debug-explore-btn.loading {
  background: linear-gradient(135deg, #666, #444);
}

/* CityWalk 模拟 */
.debug-section {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid rgba(255, 255, 255, 0.15);
}

.debug-section-title {
  font-size: 12px;
  color: #00ff88;
  margin-bottom: 8px;
  font-weight: 500;
}

.citywalk-status,
.citywalk-speed,
.citywalk-direction {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}

.citywalk-direction select {
  flex: 1;
  padding: 4px 6px;
  border-radius: 4px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(0, 0, 0, 0.3);
  color: white;
  font-size: 12px;
}

#cw-speed-slider {
  width: 100%;
  height: 6px;
  -webkit-appearance: none;
  appearance: none;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 3px;
  outline: none;
  margin: 8px 0;
}

#cw-speed-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #00ff88;
  cursor: pointer;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

#cw-speed-slider::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #00ff88;
  cursor: pointer;
  border: none;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

#cw-speed-value {
  color: #00ff88;
  font-weight: 500;
  font-size: 14px;
  min-width: 35px;
}

#cw-status {
  color: #ff6b6b;
  font-weight: 500;
}

#cw-status.running {
  color: #00ff88;
}

#cw-status.paused {
  color: #ffd93d;
}

.citywalk-controls {
  display: flex;
  gap: 6px;
  margin-top: 8px;
}

.cw-btn {
  flex: 1;
  padding: 6px 10px;
  border-radius: 4px;
  border: none;
  background: rgba(255, 255, 255, 0.15);
  color: white;
  font-size: 12px;
  cursor: pointer;
}

.cw-btn:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.25);
}

.cw-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.cw-btn:first-child {
  background: #00ff88;
  color: #000;
}

/* Scrollbar styling */
::-webkit-scrollbar {
  width: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-secondary);
}
