:root {
  --bg: #1A1A1C;
  --glass: rgba(255, 255, 255, 0.03);
  --glass-border: rgba(255, 255, 255, 0.08);
  --primary: #D4804D;
  --secondary: #A66036;
  --text-primary: #EDEDED;
  --text-dim: #999999;
  --msg-bot: rgba(255, 255, 255, 0.02);
  --msg-user: rgba(212, 128, 77, 0.1);
}

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

body {
  font-family: 'Inter', sans-serif;
  background-color: var(--bg);
  color: var(--text-primary);
  height: 100vh;
  overflow: hidden;
  position: relative;
}

/* Dynamic Ambient Blobs */
.blob {
  position: absolute;
  width: 500px;
  height: 500px;
  background: var(--primary);
  border-radius: 50%;
  filter: blur(150px);
  opacity: 0.05;
  z-index: -1;
  animation: float 20s infinite ease-in-out alternate;
}
.blob-1 { top: -100px; left: -100px; background: var(--secondary); }
.blob-2 { bottom: -100px; right: -100px; background: var(--primary); animation-delay: -10s; }

@keyframes float {
  from { transform: translate(0, 0); }
  to { transform: translate(150px, 150px); }
}

.glass-panel {
  background: var(--glass);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--glass-border);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
  border-radius: 16px;
}

/* Layout */
.app-container {
  display: grid;
  grid-template-columns: 280px 1fr 340px;
  height: 100vh;
  gap: 24px;
  padding: 24px;
}

.workspace-main {
  position: relative;
  height: 100%;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

/* Sidebar */
.sidebar {
  display: flex;
  flex-direction: column;
  padding: 32px 24px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 48px;
}
.icon-brand { color: var(--primary); width: 32px; height: 32px; }
.brand h2 { font-weight: 700; font-size: 1.5rem; letter-spacing: -0.5px; }
.highlight { color: var(--primary); }

.nav-section span {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-dim);
  font-weight: 600;
  margin-bottom: 16px;
  display: block;
}

.nav-section ul { list-style: none; }
.nav-section li {
  padding: 12px 16px;
  border-radius: 8px;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  transition: all 0.2s ease;
  font-weight: 500;
}
.nav-section li.active { background: var(--msg-user); color: var(--primary); }
.nav-section li:hover { background: var(--glass); }
.nav-section li.disabled { opacity: 0.5; cursor: not-allowed; }

.connection-status { margin-top: auto; display: flex; align-items: center; gap: 12px; padding: 16px; background: rgba(0,0,0,0.2); border-radius: 12px; border: 1px solid var(--glass-border); }
.status-indicator { width: 10px; height: 10px; border-radius: 50%; background: #00ff88; box-shadow: 0 0 5px #00ff88; animation: pulse 2s infinite; }
@keyframes pulse { 0% { opacity: 1; } 50% { opacity: 0.5; } 100% { opacity: 1; } }
.status-text { display: flex; flex-direction: column; }
.status-title { font-size: 0.75rem; color: var(--text-dim); font-weight: 600; text-transform: uppercase; }
.status-detail { font-size: 0.85rem; font-weight: 500; }

/* Main Chat */
.chat-interface {
  display: flex;
  flex-direction: column;
  position: relative;
  height: 100%;
  min-height: 0;
}

/* Console Views */
.console-view {
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  gap: 16px;
  height: 100%;
  padding: 0 0 24px 0;
}

.console-header {
  padding: 16px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-weight: 600;
  color: var(--primary);
  border-bottom: 1px solid var(--glass-border);
}

.title-group {
  display: flex;
  align-items: center;
  gap: 12px;
}

.external-link-btn {
  color: var(--text-dim);
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  padding: 8px;
  border-radius: 8px;
}

.external-link-btn:hover {
  background: var(--glass);
  color: var(--primary);
  transform: translateY(-2px);
}

.console-iframe {
  flex-grow: 1;
  border: 1px solid var(--glass-border);
  border-radius: 16px;
  background: white;
  width: 100%;
  height: 100%;
  box-shadow: 0 20px 50px rgba(0,0,0,0.5);
}

.mock-console {
  flex-grow: 1;
  padding: 32px;
  font-family: 'Courier New', Courier, monospace;
}

.chat-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 24px 32px;
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 10;
}
.header-info h1 { font-size: 1.25rem; font-weight: 600; letter-spacing: -0.5px; margin-bottom: 4px; }
.header-info p { font-size: 0.85rem; color: var(--text-dim); }
.model-badge { display: flex; align-items: center; gap: 8px; background: rgba(0,0,0,0.3); padding: 8px 16px; border-radius: 20px; font-size: 0.85rem; font-weight: 600; color: var(--text-primary); border: 1px solid rgba(212, 128, 77, 0.3); }
.model-badge svg { color: var(--primary); width: 14px; height: 14px; }

.chat-history {
  flex: 1;
  padding: 120px 48px 140px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 24px;
  scrollbar-width: thin;
  scrollbar-color: var(--primary) transparent;
  min-height: 0;
  scroll-behavior: smooth;
}
.chat-history::-webkit-scrollbar { width: 6px; }
.chat-history::-webkit-scrollbar-thumb { background: var(--primary); border-radius: 6px; }

/* Messages */
.message { display: flex; gap: 16px; align-items: flex-start; max-width: 85%; transition: all 0.3s ease; }
.user-message { align-self: flex-end; flex-direction: row-reverse; }
.user-message .message-content { background: var(--msg-user); color: var(--text-primary); border: 1px solid rgba(212, 128, 77, 0.2); }
.system-message .message-content { background: var(--msg-bot); padding: 20px 24px; line-height: 1.6; font-size: 0.95rem; }

.avatar { width: 40px; height: 40px; border-radius: 12px; display: flex; align-items: center; justify-content: center; background: rgba(0,0,0,0.5); flex-shrink: 0; border: 1px solid var(--glass-border); }
.user-message .avatar { background: var(--primary); color: #1A1A1C; }
.system-message .avatar { background: rgba(255, 255, 255, 0.05); color: var(--text-primary); }
.message-content { padding: 16px 20px; border-radius: 16px; line-height: 1.5; font-size: 0.95rem; border: 1px solid var(--glass-border); }

/* Input Area */
.input-area {
  position: absolute;
  bottom: 0px;
  left: 0;
  right: 0;
  padding: 24px;
  background: linear-gradient(transparent, var(--bg) 20%);
  backdrop-filter: blur(20px);
  z-index: 10;
}

.recording-indicator { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; padding: 0 16px; color: #ff4757; font-weight: 600; font-size: 0.85rem; }
.recording-indicator .pulse { width: 8px; height: 8px; border-radius: 50%; background: #ff4757; animation: pulse 1s infinite; }

.input-wrapper { display: flex; align-items: flex-end; gap: 16px; background: rgba(0,0,0,0.4); border-radius: 16px; padding: 12px 18px; border: 1px solid var(--glass-border); transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1); }
.input-wrapper:focus-within { border-color: var(--primary); box-shadow: 0 0 15px rgba(212, 128, 77, 0.05); }

textarea {
  flex-grow: 1;
  background: transparent;
  border: none;
  color: #fff;
  font-family: inherit;
  font-size: 0.95rem;
  resize: none;
  padding: 4px 0;
  outline: none;
  max-height: 150px;
  line-height: 1.5;
}
textarea::placeholder { color: var(--text-dim); }

.icon-btn { background: transparent; border: none; cursor: pointer; color: var(--text-dim); display: flex; align-items: center; justify-content: center; width: 42px; height: 42px; border-radius: 10px; transition: all 0.2s ease; flex-shrink: 0; }
.icon-btn:hover { background: var(--glass); color: #fff; }
.audio-btn { color: var(--primary); }
.audio-btn.recording { background: #ff4757; color: white; animation: mic-pulse 1s infinite; }
.send-btn { background: var(--primary); color: var(--bg); font-weight: 700; }
.send-btn:hover { background: var(--secondary); transform: scale(1.05); }

@keyframes mic-pulse {
  0% { transform: scale(1); box-shadow: 0 0 0 0 rgba(255, 71, 87, 0.4); }
  70% { transform: scale(1.1); box-shadow: 0 0 0 10px rgba(255, 71, 87, 0); }
  100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(255, 71, 87, 0); }
}

/* Metadata Panel */
.metadata-panel {
  padding: 32px 24px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.metadata-panel h3 { font-size: 1.1rem; font-weight: 600; margin-bottom: 4px; color: var(--primary); }
.subtitle { font-size: 0.8rem; color: var(--text-dim); margin-bottom: 32px; text-transform: uppercase; letter-spacing: 0.5px; }

.steps-container {
  display: flex;
  flex-direction: column;
  gap: 16px;
  flex-grow: 1;
  overflow-y: auto;
  padding-right: 8px;
  scrollbar-width: thin;
}
.steps-container::-webkit-scrollbar { width: 4px; }
.steps-container::-webkit-scrollbar-thumb { background: var(--primary); border-radius: 4px; }

.empty-state { display: flex; flex-direction: column; align-items: center; justify-content: center; color: var(--text-dim); opacity: 0.5; height: 100%; gap: 16px; }

.log-item { background: rgba(0,0,0,0.3); border: 1px solid var(--glass-border); border-radius: 12px; padding: 16px; font-size: 0.85rem; animation: slideIn 0.3s ease forwards; }
.log-item.processing { border-color: var(--primary); }
.log-title { display: flex; align-items: center; gap: 8px; font-weight: 600; margin-bottom: 8px; color: #fff; }
.log-title svg { color: var(--primary); width: 16px; height: 16px; }
.log-detail { color: var(--text-dim); font-family: monospace; line-height: 1.4; word-break: break-word; }

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

/* ── Top Progress Bar (YouTube-style) ──────────────────────── */
#page-bar {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 3px;
  z-index: 9999;
  pointer-events: none;
}
#page-bar-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #D4804D, #ee6a50);
  opacity: 0;
  transition: width 0.2s ease, opacity 0.3s ease;
  box-shadow: 0 0 10px rgba(212,128,77,0.7), 0 0 4px rgba(238,106,80,0.5);
}
