:root {
  --bg: #0b111e;
  --bg-surface: #131b2e;
  --bg-elev: #1a243d;
  --bg-input: #0e1628;
  --text: #f0f4fc;
  --text-muted: #8e9bb5;
  --line: #24314f;
  --line-light: #34446b;
  --brand: #3b82f6;
  --brand-light: #60a5fa;
  --accent: #06b6d4;
  --warn: #f59e0b;
  --bad: #ef4444;
  --good: #10b981;
  --radius-lg: 16px;
  --radius-md: 10px;
  --radius-sm: 6px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; padding: 0; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

.app-container {
  display: flex;
  flex-direction: column;
  height: 100vh;
  max-width: 960px;
  margin: 0 auto;
  background: var(--bg);
}

/* Header */
.top-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 18px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--line);
  z-index: 10;
}
.brand-group {
  display: flex;
  align-items: center;
  gap: 12px;
}
.selltime-mark {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 750;
  font-size: 1.05rem;
  letter-spacing: -0.02em;
  color: var(--text);
  text-decoration: none;
}
.selltime-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--brand-light);
  box-shadow: 0 0 10px var(--brand);
}
.site-divider {
  width: 1px;
  height: 20px;
  background: var(--line);
}
.site-identity {
  display: flex;
  align-items: center;
  gap: 8px;
}
.site-logo {
  width: 24px;
  height: 24px;
  border-radius: 6px;
  object-fit: cover;
}
.site-title {
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--text);
}
.user-menu {
  display: flex;
  align-items: center;
  gap: 10px;
}
.user-badge {
  font-size: 0.8rem;
  color: var(--text-muted);
}
.btn-logout {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--text-muted);
  border-radius: var(--radius-sm);
  padding: 5px 10px;
  font-size: 0.8rem;
  cursor: pointer;
}
.btn-logout:hover {
  background: var(--bg-elev);
  color: var(--text);
}

/* Main Area Layout */
.main-layout {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

/* Work Log Bar (Collapsible) */
.worklog-bar {
  background: var(--bg-surface);
  border-bottom: 1px solid var(--line);
  padding: 8px 18px;
  font-size: 0.85rem;
}
.worklog-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  user-select: none;
}
.worklog-summary {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  color: var(--text-muted);
}
.worklog-items {
  margin-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 150px;
  overflow-y: auto;
}
.worklog-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-elev);
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
}
.badge-status {
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
  text-decoration: none;
}
.badge-in-progress { background: rgba(245, 158, 11, 0.2); color: var(--warn); border: 1px solid rgba(245, 158, 11, 0.4); }
.badge-preview { background: rgba(16, 185, 129, 0.2); color: var(--good); border: 1px solid rgba(16, 185, 129, 0.4); }
.badge-live { background: rgba(100, 116, 139, 0.2); color: #cbd5e1; border: 1px solid rgba(100, 116, 139, 0.4); }

/* Chat History */
.chat-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.msg {
  display: flex;
  flex-direction: column;
  max-width: 82%;
  padding: 12px 16px;
  border-radius: var(--radius-lg);
  line-height: 1.45;
  font-size: 0.93rem;
  word-break: break-word;
}
.msg.user {
  align-self: flex-end;
  background: var(--brand);
  color: #ffffff;
  border-bottom-right-radius: 4px;
}
.msg.assistant {
  align-self: flex-start;
  background: var(--bg-surface);
  border: 1px solid var(--line);
  color: var(--text);
  border-bottom-left-radius: 4px;
}
.msg.system {
  align-self: center;
  max-width: 90%;
  background: var(--bg-elev);
  color: var(--text-muted);
  font-size: 0.85rem;
  text-align: center;
  border-radius: var(--radius-sm);
  padding: 6px 14px;
}

/* Composer & Actions */
.composer-dock {
  padding: 12px 18px 18px;
  background: var(--bg-surface);
  border-top: 1px solid var(--line);
}
.upload-queue-container {
  margin-bottom: 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.queue-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-input);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  font-size: 0.8rem;
}
.progress-bar-bg {
  width: 120px;
  height: 6px;
  background: var(--line);
  border-radius: 3px;
  overflow: hidden;
}
.progress-bar-fill {
  height: 100%;
  background: var(--brand-light);
  width: 0%;
  transition: width 0.2s ease;
}

.composer-bar {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  background: var(--bg-input);
  border: 1px solid var(--line);
  border-radius: 24px;
  padding: 6px 12px;
}
.composer-bar:focus-within {
  border-color: var(--brand);
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}
.chat-textarea {
  flex: 1;
  background: transparent;
  border: 0;
  outline: 0;
  color: var(--text);
  font: inherit;
  font-size: 0.95rem;
  resize: none;
  max-height: 160px;
  padding: 8px 4px;
  min-height: 24px;
}
.action-icon-btn {
  background: transparent;
  border: 0;
  color: var(--text-muted);
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s ease;
}
.action-icon-btn:hover {
  background: var(--bg-elev);
  color: var(--text);
}
.btn-mic.recording {
  background: var(--warn) !important;
  color: #101524 !important;
  animation: pulse-mic 1.5s infinite;
}
@keyframes pulse-mic {
  0% { box-shadow: 0 0 0 0 rgba(245, 158, 11, 0.6); }
  70% { box-shadow: 0 0 0 10px rgba(245, 158, 11, 0); }
  100% { box-shadow: 0 0 0 0 rgba(245, 158, 11, 0); }
}
.btn-send {
  background: var(--brand);
  color: #ffffff;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 0;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.btn-send:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* Modals & Dialogs */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 100;
}
.modal-card {
  background: var(--bg-surface);
  border: 1px solid var(--line-light);
  border-radius: var(--radius-lg);
  max-width: 480px;
  width: 100%;
  padding: 20px;
  box-shadow: 0 20px 40px rgba(0,0,0,0.5);
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.modal-header h3 {
  margin: 0;
  font-size: 1.1rem;
}
.modal-body {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.option-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px;
  background: var(--bg-elev);
  border-radius: var(--radius-md);
  border: 1px solid var(--line);
  cursor: pointer;
}
.option-row.selected {
  border-color: var(--brand);
  background: rgba(59, 130, 246, 0.1);
}
.form-input {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 10px 12px;
  font: inherit;
}
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 20px;
}
.btn-primary {
  background: var(--brand);
  color: #fff;
  border: 0;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  cursor: pointer;
}
.btn-secondary {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--line);
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  cursor: pointer;
}

/* Login Card */
.login-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100vh;
  padding: 20px;
}
.login-card {
  background: var(--bg-surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 28px;
  max-width: 400px;
  width: 100%;
  box-shadow: 0 20px 40px rgba(0,0,0,0.4);
}
