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

html,
body {
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
}

:root {
  --background: 0 0% 3.9%;
  --foreground: 0 0% 98%;
  --card: 0 0% 3.9%;
  --card-foreground: 0 0% 98%;
  --popover: 0 0% 3.9%;
  --popover-foreground: 0 0% 98%;
  --primary: 262.1 83.3% 57.8%;
  --primary-foreground: 210 20% 98%;
  --secondary: 0 0% 14.9%;
  --secondary-foreground: 0 0% 98%;
  --muted: 0 0% 14.9%;
  --muted-foreground: 0 0% 63.9%;
  --accent: 0 0% 14.9%;
  --accent-foreground: 0 0% 98%;
  --destructive: 0 62.8% 30.6%;
  --destructive-foreground: 0 0% 98%;
  --border: 0 0% 14.9%;
  --input: 0 0% 14.9%;
  --ring: 262.1 83.3% 57.8%;
  --radius: 0.75rem;

  --bg-color: hsl(var(--background));
  --surface-color: hsl(0 0% 7%);
  --surface-elevated: hsl(0 0% 10%);
  --text-primary: hsl(var(--foreground));
  --text-secondary: hsl(var(--muted-foreground));
  --primary-color: hsl(var(--primary));
  --primary-dark: hsl(262.1 83.3% 47.8%);
  --primary-hover: hsl(262.1 83.3% 52.8%);
  --border-color: hsl(var(--border));
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 10px 40px rgba(0, 0, 0, 0.5);
  --user-bubble-bg: hsl(0 0% 14.9%);
  --message-radius: 1rem;
  --input-radius: 1.5rem;
  --success-color: hsl(142 76% 36%);
  --warning-color: hsl(38 92% 50%);
  --danger-color: hsl(0 84% 60%);
}

[data-theme="light"] {
  --background: 0 0% 100%;
  --foreground: 0 0% 3.9%;
  --card: 0 0% 100%;
  --card-foreground: 0 0% 3.9%;
  --popover: 0 0% 100%;
  --popover-foreground: 0 0% 3.9%;
  --secondary: 0 0% 96.1%;
  --secondary-foreground: 0 0% 9%;
  --muted: 0 0% 96.1%;
  --muted-foreground: 0 0% 45.1%;
  --accent: 0 0% 96.1%;
  --accent-foreground: 0 0% 9%;
  --destructive: 0 84.2% 60.2%;
  --destructive-foreground: 0 0% 98%;
  --border: 0 0% 89.8%;
  --input: 0 0% 89.8%;

  --bg-color: hsl(0 0% 98%);
  --surface-color: hsl(0 0% 100%);
  --surface-elevated: hsl(0 0% 96%);
  --text-primary: hsl(0 0% 9%);
  --text-secondary: hsl(0 0% 45%);
  --border-color: hsl(0 0% 90%);
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 10px 40px rgba(0, 0, 0, 0.12);
  --user-bubble-bg: hsl(0 0% 93%);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Inter', 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  background: var(--bg-color);
  color: var(--text-primary);
  line-height: 1.6;
  position: fixed;
  width: 100%;
}

#app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}

header {
  background: var(--surface-color);
  padding: 0.875rem 1rem;
  padding-top: calc(0.875rem + env(safe-area-inset-top, 0px));
  padding-left: calc(1rem + env(safe-area-inset-left, 0px));
  padding-right: calc(1rem + env(safe-area-inset-right, 0px));
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
  z-index: 100;
  min-height: 56px;
  backdrop-filter: blur(8px);
}

.header-left {
  display: flex;
  align-items: center;
  gap: 0.875rem;
  flex: 1;
  min-width: 0;
  overflow: hidden;
}

.menu-toggle {
  background: none;
  border: none;
  padding: 0.5rem;
  cursor: pointer;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 0.5rem;
  transition: all 0.2s ease;
}

.menu-toggle:hover {
  background: var(--surface-elevated);
  color: var(--text-primary);
}

header h1 {
  font-size: 1.0625rem;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: -0.01em;
}

.brand-title {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  display: flex;
  align-items: baseline;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

@media (max-width: 380px) {
  .brand-title .brand-projects {
    display: none;
  }
}

@media (max-width: 320px) {
  .brand-title {
    font-size: 1rem;
  }
}

.brand-sens {
  color: hsl(210 100% 75%);
}

.brand-ai {
  background: linear-gradient(135deg, hsl(262 83% 58%) 0%, hsl(280 80% 70%) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.brand-projects {
  color: var(--text-secondary);
  font-weight: 400;
  margin-left: 0.35rem;
}

.header-controls {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  flex-shrink: 0;
}

.toggle-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 0.5rem;
  border: 1px solid var(--border-color);
  background: var(--surface-elevated);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s ease;
}

.user-auth-btn {
  position: relative;
  overflow: hidden;
}

.user-auth-btn .icon-user {
  transition: opacity 0.2s ease;
}

.user-auth-btn.authenticated .icon-user {
  opacity: 0;
  position: absolute;
}

.user-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  object-fit: cover;
}

.user-avatar.hidden {
  display: none;
}

.social-login-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  width: 100%;
  padding: 0.875rem 1rem;
  margin-bottom: 0.75rem;
  border-radius: 0.75rem;
  font-size: 0.9375rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  border: 1px solid var(--border-color);
}

.social-login-btn.google {
  background: white;
  color: #1f1f1f;
}

.social-login-btn.google:hover {
  background: #f8f8f8;
}

.social-login-btn.apple {
  background: #000;
  color: white;
  border-color: #000;
}

.social-login-btn.apple:hover {
  background: #333;
}

.login-error {
  margin-top: 1rem;
  padding: 0.75rem;
  background: hsla(0, 84%, 60%, 0.1);
  border: 1px solid var(--danger-color);
  border-radius: 0.5rem;
  color: var(--danger-color);
  font-size: 0.875rem;
}

.login-error.hidden {
  display: none;
}

.login-success {
  margin-top: 1rem;
  padding: 0.75rem;
  background: hsla(142, 76%, 36%, 0.1);
  border: 1px solid var(--success-color);
  border-radius: 0.5rem;
  color: var(--success-color);
  font-size: 0.875rem;
}

.login-success.hidden {
  display: none;
}

.demo-message {
  padding: 0 !important;
  background: transparent !important;
  display: flex;
  justify-content: center;
}

.demo-notice {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  padding: 1.5rem;
  background: linear-gradient(90deg, hsla(262, 83%, 58%, 0.15) 0%, hsla(280, 80%, 50%, 0.15) 100%);
  border: 1px solid hsla(262, 83%, 58%, 0.3);
  border-radius: 0.75rem;
  font-size: 0.875rem;
  color: var(--text-secondary);
  text-align: center;
  width: 75%;
  margin: 0 auto;
}

.demo-logo {
  width: 120px;
  height: 120px;
  border-radius: 1.5rem;
  box-shadow: 0 4px 20px rgba(139, 92, 246, 0.3);
  background: #1a1a2e;
  flex-shrink: 0;
}

@media (max-width: 480px) {
  .demo-logo {
    width: 100px;
    height: 100px;
  }
}

.demo-text {
  flex: 1;
}

.demo-link {
  color: var(--accent-color);
  text-decoration: underline;
  font-weight: 600;
  cursor: pointer;
}

.demo-link:hover {
  opacity: 0.8;
}

.user-dropdown-menu {
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: 0.5rem;
  min-width: 240px;
  background: var(--surface-color);
  border: 1px solid var(--border-color);
  border-radius: 0.75rem;
  box-shadow: var(--shadow-lg);
  z-index: 1000;
  overflow: hidden;
}

.user-menu-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1rem;
  border-bottom: 1px solid var(--border-color);
}

.user-menu-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
}

.user-menu-info {
  flex: 1;
  min-width: 0;
}

.user-menu-name {
  font-weight: 600;
  font-size: 0.9375rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-menu-email {
  font-size: 0.8125rem;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-menu-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  width: 100%;
  padding: 0.875rem 1rem;
  border: none;
  background: transparent;
  color: var(--text-primary);
  font-size: 0.9375rem;
  cursor: pointer;
  transition: background 0.15s ease;
}

.user-menu-item:hover {
  background: var(--surface-elevated);
}

.user-menu-item.logout-btn {
  color: var(--danger-color);
}

.toggle-btn:hover {
  background: var(--primary-color);
  color: white;
  border-color: var(--primary-color);
}

.lang-toggle .toggle-label {
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}

/* Profile Selector (Multi-Account) */
.profile-selector {
  position: relative;
}

.profile-toggle {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.375rem 0.75rem;
  min-width: 100px;
  max-width: 180px;
}

.profile-toggle .profile-name {
  font-size: 0.8125rem;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100px;
}

.profile-toggle .dropdown-arrow {
  flex-shrink: 0;
  transition: transform 0.2s ease;
}

.profile-selector.open .dropdown-arrow {
  transform: rotate(180deg);
}

.profile-dropdown {
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: 0.5rem;
  min-width: 220px;
  background: var(--surface-color);
  border: 1px solid var(--border-color);
  border-radius: 0.75rem;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
  z-index: 1000;
  overflow: hidden;
}

.profile-dropdown-header {
  padding: 0.75rem 1rem;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border-color);
}

.profile-list {
  padding: 0.5rem 0;
}

.profile-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  width: 100%;
  padding: 0.75rem 1rem;
  border: none;
  background: transparent;
  color: var(--text-primary);
  font-size: 0.875rem;
  cursor: pointer;
  transition: background 0.15s ease;
  text-align: left;
}

.profile-item:hover {
  background: var(--surface-elevated);
}

.profile-item.active {
  background: hsla(262, 83%, 58%, 0.1);
}

.profile-item .check-icon {
  width: 16px;
  flex-shrink: 0;
  color: var(--primary-color);
}

.profile-item .profile-info {
  flex: 1;
  min-width: 0;
}

.profile-item .profile-item-name {
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.profile-item .profile-item-login {
  font-size: 0.75rem;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.profile-dropdown-footer {
  padding: 0.5rem;
  border-top: 1px solid var(--border-color);
}

.manage-profiles-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  padding: 0.625rem;
  border: none;
  background: transparent;
  color: var(--primary-color);
  font-size: 0.8125rem;
  font-weight: 500;
  cursor: pointer;
  border-radius: 0.5rem;
  transition: background 0.15s ease;
}

.manage-profiles-btn:hover {
  background: hsla(262, 83%, 58%, 0.1);
}

/* Redmine Profiles Management in Settings */
.redmine-profiles-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.redmine-profile-card {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem;
  background: var(--surface-elevated);
  border: 1px solid var(--border-color);
  border-radius: 0.5rem;
}

.redmine-profile-card.selected {
  border-color: var(--primary-color);
  background: hsla(262, 83%, 58%, 0.08);
}

.profile-checkbox-wrapper {
  display: flex;
  align-items: center;
  cursor: pointer;
}

.profile-checkbox {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.profile-checkbox:checked + .profile-icon {
  box-shadow: 0 0 0 2px var(--primary-color);
}

.redmine-profile-card .profile-icon {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--primary-color);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 0.875rem;
  flex-shrink: 0;
}

.redmine-profile-card .profile-details {
  flex: 1;
  min-width: 0;
}

.redmine-profile-card .profile-card-name {
  font-weight: 500;
  font-size: 0.875rem;
}

.redmine-profile-card .profile-card-login {
  font-size: 0.8rem;
  color: var(--primary-color);
  font-weight: 500;
}

.redmine-profile-card .profile-card-email {
  font-size: 0.7rem;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.redmine-profile-card .profile-card-id {
  font-size: 0.65rem;
  color: var(--text-muted);
}

.redmine-profile-card .profile-activate-btn {
  font-size: 0.65rem;
  padding: 0.25rem 0.5rem;
  border: 1px solid var(--border-color);
  background: transparent;
  color: var(--text-secondary);
  border-radius: 0.25rem;
  cursor: pointer;
  transition: all 0.15s ease;
}

.redmine-profile-card .profile-activate-btn:hover {
  background: var(--primary-color);
  color: white;
  border-color: var(--primary-color);
}

.redmine-profile-card .profile-badge {
  font-size: 0.625rem;
  padding: 0.125rem 0.375rem;
  background: var(--primary-color);
  color: white;
  border-radius: 0.25rem;
  text-transform: uppercase;
  font-weight: 600;
}

.redmine-profile-card .profile-delete-btn {
  padding: 0.375rem;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  border-radius: 0.375rem;
  transition: all 0.15s ease;
}

.redmine-profile-card .profile-delete-btn:hover {
  background: hsla(0, 70%, 50%, 0.1);
  color: var(--danger-color);
}

/* MCP Tokens Styles */
.mcp-tokens-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.mcp-token-card {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem;
  background: var(--surface-color);
  border: 1px solid var(--border-color);
  border-radius: 0.5rem;
}

.mcp-token-card .token-info {
  flex: 1;
  min-width: 0;
}

.mcp-token-card .token-name {
  font-weight: 500;
  font-size: 0.875rem;
}

.mcp-token-card .token-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  font-size: 0.7rem;
  color: var(--text-secondary);
  margin-top: 0.25rem;
}

.mcp-token-card .token-revoke-btn {
  padding: 0.375rem;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  border-radius: 0.375rem;
  transition: all 0.15s ease;
}

.mcp-token-card .token-revoke-btn:hover {
  background: hsla(0, 70%, 50%, 0.1);
  color: var(--danger-color);
}

.add-token-form {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}

.add-token-form .profile-input {
  flex: 1;
  min-width: 150px;
}

.new-token-display {
  padding: 1rem;
  background: hsla(120, 50%, 50%, 0.1);
  border: 1px solid hsla(120, 50%, 40%, 0.3);
  border-radius: 0.5rem;
  margin-bottom: 1rem;
}

.token-value-container {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  margin: 0.5rem 0;
}

.token-value {
  flex: 1;
  padding: 0.5rem;
  background: var(--surface-color);
  border: 1px solid var(--border-color);
  border-radius: 0.25rem;
  font-family: monospace;
  font-size: 0.75rem;
  word-break: break-all;
  user-select: all;
}

.token-warning {
  color: var(--warning-color, #e67e22);
  font-size: 0.8rem;
  font-weight: 500;
  margin-top: 0.5rem;
}

.claude-config-help {
  margin-top: 1rem;
  font-size: 0.875rem;
}

.claude-config-help summary {
  cursor: pointer;
  color: var(--text-secondary);
}

.config-example {
  background: var(--surface-color);
  padding: 0.75rem;
  border-radius: 0.5rem;
  font-size: 0.75rem;
  overflow-x: auto;
  margin-top: 0.5rem;
}

.empty-tokens {
  color: var(--text-secondary);
  font-size: 0.875rem;
  text-align: center;
  padding: 1rem;
}

.add-profile-form {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 1rem;
  background: var(--surface-elevated);
  border: 1px solid var(--border-color);
  border-radius: 0.5rem;
  margin-bottom: 0.5rem;
}

.add-profile-form .profile-input {
  padding: 0.625rem 0.75rem;
  border: 1px solid var(--border-color);
  border-radius: 0.375rem;
  background: var(--surface-color);
  color: var(--text-primary);
  font-size: 0.875rem;
}

.add-profile-form .profile-input:focus {
  outline: none;
  border-color: var(--primary-color);
}

.add-profile-buttons {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.25rem;
}

.add-profile-form .profile-hint {
  font-size: 0.8125rem;
  color: var(--text-secondary);
  margin: 0.25rem 0;
  padding: 0.5rem;
  background: hsla(var(--primary-hue), 70%, 50%, 0.1);
  border-radius: 0.375rem;
  border-left: 3px solid var(--primary-color);
}

.add-profile-form .link-account-email {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem;
  background: var(--surface-color);
  border: 1px solid var(--border-color);
  border-radius: 0.375rem;
  margin-bottom: 0.25rem;
}

.add-profile-form .email-label {
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.add-profile-form .email-value {
  font-size: 0.875rem;
  color: var(--primary-color);
  font-weight: 500;
}

.manual-login-section {
  padding: 0.75rem;
  background: hsla(30, 80%, 50%, 0.1);
  border: 1px solid hsla(30, 80%, 50%, 0.3);
  border-radius: 0.375rem;
  margin-top: 0.5rem;
}

.manual-login-hint {
  font-size: 0.8125rem;
  color: hsla(30, 80%, 60%, 1);
  margin: 0 0 0.5rem;
}

.settings-description {
  font-size: 0.8125rem;
  color: var(--text-secondary);
  margin: 0.25rem 0 0.75rem;
}

.theme-toggle .icon-sun {
  display: none;
}

.theme-toggle .icon-moon {
  display: block;
}

[data-theme="light"] .theme-toggle .icon-sun {
  display: block;
}

[data-theme="light"] .theme-toggle .icon-moon {
  display: none;
}

.model-selector {
  padding: 0.5rem 1rem;
  border: 1px solid var(--border-color);
  border-radius: 0.5rem;
  background: var(--surface-color);
  color: var(--text-primary);
  cursor: pointer;
  font-size: 0.9rem;
  transition: all 0.2s ease;
}

.model-selector:hover {
  background: var(--surface-elevated);
  border-color: var(--primary-color);
}

.model-selector:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 2px hsla(262, 83%, 58%, 0.2);
}

.icon-btn {
  background: transparent;
  border: none;
  font-size: 1.375rem;
  cursor: pointer;
  padding: 0.5rem;
  border-radius: 0.5rem;
  transition: all 0.2s ease;
  color: var(--text-secondary);
}

.icon-btn:hover {
  background: var(--surface-elevated);
  color: var(--text-primary);
}

.main-container {
  display: flex;
  flex: 1;
  overflow: hidden;
  overflow-x: hidden;
  background: var(--bg-color);
}

.sidebar {
  width: 220px;
  background: var(--surface-color);
  padding: 0;
  overflow: hidden;
  transition: width 0.2s ease;
  position: relative;
  display: flex;
  flex-direction: column;
}

.sidebar.collapsed {
  width: 60px;
}

.sidebar-header {
  flex-shrink: 0;
  padding: 0.75rem;
  border-bottom: 1px solid var(--border-color);
}

.sidebar-content {
  flex: 1;
  overflow-y: auto;
  padding: 0.5rem 0.75rem;
  scrollbar-width: thin;
  scrollbar-color: var(--border-color) transparent;
}

.sidebar-content::-webkit-scrollbar {
  width: 4px;
}

.sidebar-content::-webkit-scrollbar-track {
  background: transparent;
}

.sidebar-content::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 2px;
}

.sidebar-content::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

.sidebar.collapsed .sidebar-header,
.sidebar.collapsed .sidebar-content {
  padding: 0.5rem;
}

.sidebar-toggle {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  width: 28px;
  height: 28px;
  background: var(--surface-elevated);
  border: 1px solid var(--border-color);
  border-radius: 0.375rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  transition: all 0.2s ease;
  z-index: 10;
}

.sidebar-toggle:hover {
  background: var(--primary-color);
  color: white;
  border-color: var(--primary-color);
}

.sidebar.collapsed .sidebar-toggle svg {
  transform: rotate(0deg);
}

.sidebar:not(.collapsed) .sidebar-toggle svg {
  transform: rotate(180deg);
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.25rem;
}

.sidebar-logo {
  width: 32px;
  height: 32px;
  border-radius: 0.5rem;
  object-fit: cover;
}

.sidebar-brand-text {
  font-size: 1rem;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
}

.sidebar.collapsed .sidebar-brand-text {
  display: none;
}

.sidebar.collapsed .sidebar-logo {
  width: 28px;
  height: 28px;
}

.sidebar-section {
  margin-bottom: 0.25rem;
}

.sidebar-section:first-of-type {
  margin-top: 0;
}

.sidebar-section[data-section="quick"] {
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border-color);
  margin-bottom: 0.5rem;
}

.sidebar-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 0.5rem 0.5rem;
  background: transparent;
  border: none;
  border-radius: 0.375rem;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  transition: all 0.15s ease;
  position: relative;
  z-index: 5;
  pointer-events: auto;
  /* iOS touch fixes */
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  -webkit-touch-callout: none;
  user-select: none;
  -webkit-user-select: none;
}

.sidebar-section-header:hover {
  color: var(--text-secondary);
  background: var(--surface-elevated);
}

.sidebar-section-header .section-title {
  white-space: nowrap;
  overflow: hidden;
}

.accordion-chevron {
  flex-shrink: 0;
  transition: transform 0.2s ease;
  opacity: 0.6;
}

.sidebar-section.accordion.collapsed .accordion-chevron {
  transform: rotate(-90deg);
}

.sidebar-section-items {
  overflow: hidden;
  transition: max-height 0.2s ease, opacity 0.2s ease;
  max-height: 500px;
  opacity: 1;
}

.sidebar-section.accordion.collapsed .sidebar-section-items {
  max-height: 0;
  opacity: 0;
  pointer-events: none;
}

.sidebar.collapsed .sidebar-section-header {
  display: none;
}

.sidebar.collapsed .sidebar-section.accordion .sidebar-section-items {
  max-height: 500px;
  opacity: 1;
  pointer-events: auto;
}

.sidebar.collapsed .sidebar-section[data-section="quick"] {
  border-bottom: none;
  padding-bottom: 0;
}

.sidebar-footer {
  flex-shrink: 0;
  padding: 0.5rem 0.75rem;
  border-top: 1px solid var(--border-color);
  background: var(--surface-color);
}

.sidebar.collapsed .sidebar-footer {
  padding: 0.5rem;
}


.action-btn,
.view-btn {
  width: 100%;
  padding: 0.6rem 0.5rem;
  margin-bottom: 0.25rem;
  background: transparent;
  border: none;
  border-radius: 0.5rem;
  cursor: pointer;
  text-align: left;
  font-size: 0.85rem;
  transition: all 0.15s ease;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--text-secondary);
}

.btn-icon {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
}

.btn-icon svg {
  width: 18px;
  height: 18px;
}

.action-btn:hover .btn-icon,
.view-btn:hover .btn-icon {
  color: var(--text-primary);
}

.view-btn.active .btn-icon {
  color: white;
}

.btn-label {
  white-space: nowrap;
  overflow: hidden;
  transition: opacity 0.15s, width 0.15s;
}

.sidebar.collapsed .btn-label {
  opacity: 0;
  width: 0;
  overflow: hidden;
}

.sidebar.collapsed .action-btn,
.sidebar.collapsed .view-btn {
  justify-content: center;
  padding: 0.6rem;
}

.action-btn:hover,
.view-btn:hover {
  background: var(--surface-elevated);
  color: var(--text-primary);
}

.action-btn:active,
.view-btn:active {
  transform: scale(0.98);
}

.view-btn.active {
  background: var(--primary-color);
  color: white;
}

.view-btn.active:hover {
  background: var(--primary-hover);
}

.view-btn.external-link {
  text-decoration: none;
}

.external-icon {
  font-size: 0.75rem;
  opacity: 0.6;
  margin-left: auto;
}

.sidebar.collapsed .external-icon {
  display: none;
}

.gantt-iframe-wrapper {
  position: absolute;
  top: 50px;
  left: 0;
  right: 0;
  bottom: 0;
  overflow: auto;
  background: var(--surface-color);
  display: none;
}

.gantt-iframe {
  width: 200%;
  min-width: 1800px;
  height: 100%;
  border: none;
  background: #fff;
}

.kanban-iframe-wrapper {
  position: absolute;
  top: 50px;
  left: 0;
  right: 0;
  bottom: 0;
  overflow: auto;
  background: var(--surface-color);
  display: none;
}

.kanban-iframe {
  width: 200%;
  min-width: 1800px;
  height: 100%;
  border: none;
  background: #fff;
}

.iframe-fallback {
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  padding: 2rem;
  text-align: center;
  color: var(--text-primary);
  gap: 1rem;
}

.iframe-fallback p {
  font-size: 1.1rem;
  margin: 0;
}

/* Send button states */
#sendBtn .icon-send,
#sendBtn .icon-loading,
#sendBtn .icon-stop {
  display: none;
}

#sendBtn[data-state="send"] .icon-send {
  display: block;
}

#sendBtn[data-state="loading"] .icon-loading {
  display: block;
  animation: spin 1s linear infinite;
}

#sendBtn[data-state="stop"] .icon-stop {
  display: block;
}

#sendBtn[data-state="loading"],
#sendBtn[data-state="stop"] {
  background: var(--accent-color);
}

#sendBtn[data-state="stop"]:hover {
  background: hsl(0, 70%, 50%);
}

/* Fixed send button states */
#fixedSendBtn .icon-send,
#fixedSendBtn .icon-loading,
#fixedSendBtn .icon-stop {
  display: none;
}

#fixedSendBtn[data-state="send"] .icon-send {
  display: block;
}

#fixedSendBtn[data-state="loading"] .icon-loading {
  display: block;
  animation: spin 1s linear infinite;
}

#fixedSendBtn[data-state="stop"] .icon-stop {
  display: block;
}

#fixedSendBtn[data-state="loading"],
#fixedSendBtn[data-state="stop"] {
  background: var(--accent-color);
}

#fixedSendBtn[data-state="stop"]:hover {
  background: hsl(0, 70%, 50%);
}

@keyframes spin {
  from {
    transform: rotate(0deg);
  }

  to {
    transform: rotate(360deg);
  }
}

.content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
  background: var(--bg-color);
}

.canvas-container {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--surface-color);
  overflow: hidden;
  display: none;
  z-index: 100;
}

.canvas-container.visible {
  display: flex;
  flex-direction: column;
}

#visualCanvas {
  width: 100%;
  height: 100%;
  display: block;
}

.canvas-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  pointer-events: none;
}

.canvas-header {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  padding: 0.5rem 0.75rem;
  background: var(--surface-color);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
  z-index: 10;
  gap: 0.5rem;
}

.canvas-header h3 {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-muted, var(--text-secondary));
  text-transform: uppercase;
  letter-spacing: 0.05em;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.canvas-header h3 svg {
  width: 16px;
  height: 16px;
  color: var(--text-secondary);
  flex-shrink: 0;
}

.close-canvas-btn {
  background: transparent;
  border: none;
  cursor: pointer;
  color: var(--text-secondary);
  padding: 0.5rem;
  border-radius: 0.5rem;
  transition: all 0.15s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.close-canvas-btn svg {
  width: 18px;
  height: 18px;
}

.close-canvas-btn:hover {
  background: var(--surface-elevated);
  color: var(--text-primary);
}

.chat-container {
  flex: 1;
  display: grid;
  grid-template-rows: 1fr auto;
  background: var(--bg-color);
  min-height: 0;
  overflow: hidden;
  position: relative;
  transition: width 0.25s ease, min-width 0.25s ease, opacity 0.25s ease;
}

.chat-container.collapsed {
  width: 0;
  min-width: 0;
  opacity: 0;
  overflow: hidden;
}

.chat-toggle {
  position: absolute;
  top: 0.5rem;
  left: 0.5rem;
  width: 28px;
  height: 28px;
  background: var(--surface-elevated);
  border: 1px solid var(--border-color);
  border-radius: 0.375rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  transition: all 0.2s ease;
  z-index: 10;
}

.chat-toggle:hover {
  background: var(--primary-color);
  color: white;
  border-color: var(--primary-color);
}

.chat-container.collapsed .chat-toggle {
  display: none;
}

.chat-container:not(.collapsed) .chat-toggle svg {
  transform: rotate(180deg);
}

.chat-pull-tab {
  position: absolute;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 20px;
  height: 60px;
  background: var(--surface-elevated);
  border: 1px solid var(--border-color);
  border-right: none;
  border-radius: 8px 0 0 8px;
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  transition: all 0.2s ease;
  z-index: 100;
}

.chat-pull-tab:hover {
  background: var(--primary-color);
  color: white;
  width: 24px;
}

.chat-container.collapsed ~ .chat-pull-tab,
.chat-container.collapsed + .chat-pull-tab {
  display: flex;
}

main.content:has(.chat-container.collapsed) .chat-pull-tab {
  display: flex;
}

.chat-messages {
  overflow-y: auto;
  overflow-x: hidden;
  padding: 1rem;
  padding-bottom: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  min-height: 0;
  background: var(--bg-color);
}

.chat-messages::-webkit-scrollbar {
  width: 6px;
}

.chat-messages::-webkit-scrollbar-track {
  background: transparent;
}

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

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

.message {
  display: flex;
  flex-direction: column;
  max-width: 100%;
  animation: messageSlideIn 0.3s ease-out;
  overflow: visible;
}

@keyframes messageSlideIn {
  from {
    opacity: 0;
    transform: translateY(12px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.message.user {
  align-self: flex-end;
  max-width: 80%;
}

.message.assistant {
  align-self: flex-start;
  max-width: 100%;
}

.route-indicator {
  margin-bottom: 0.25rem;
}

.route-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.125rem 0.5rem;
  border-radius: 1rem;
  font-size: 0.6875rem;
  font-weight: 500;
  letter-spacing: 0.02em;
}

.route-badge.fast {
  background: linear-gradient(135deg, rgba(251, 191, 36, 0.15), rgba(245, 158, 11, 0.15));
  color: #fbbf24;
  border: 1px solid rgba(251, 191, 36, 0.3);
}

.route-badge.ai {
  background: linear-gradient(135deg, rgba(139, 92, 246, 0.15), rgba(168, 85, 247, 0.15));
  color: #a78bfa;
  border: 1px solid rgba(139, 92, 246, 0.3);
}

/* Skill feedback badges */
.skill-feedback {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.125rem 0.5rem;
  border-radius: 1rem;
  font-size: 0.6875rem;
  font-weight: 500;
  letter-spacing: 0.02em;
}

.skill-feedback.skill-fast {
  background: linear-gradient(135deg, rgba(251, 191, 36, 0.15), rgba(245, 158, 11, 0.15));
  color: #fbbf24;
  border: 1px solid rgba(251, 191, 36, 0.3);
}

.skill-feedback.skill-analyst {
  background: linear-gradient(135deg, rgba(34, 197, 94, 0.15), rgba(22, 163, 74, 0.15));
  color: #4ade80;
  border: 1px solid rgba(34, 197, 94, 0.3);
}

.skill-feedback.skill-writer {
  background: linear-gradient(135deg, rgba(168, 85, 247, 0.15), rgba(139, 92, 246, 0.15));
  color: #c084fc;
  border: 1px solid rgba(168, 85, 247, 0.3);
}

.skill-feedback.skill-reviewer {
  background: linear-gradient(135deg, rgba(244, 114, 182, 0.15), rgba(236, 72, 153, 0.15));
  color: #f472b6;
  border: 1px solid rgba(244, 114, 182, 0.3);
}

.skill-feedback.skill-literature {
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.15), rgba(37, 99, 235, 0.15));
  color: #60a5fa;
  border: 1px solid rgba(59, 130, 246, 0.3);
}

.message.assistant.action-widget-container {
  align-self: center;
  width: 100%;
  max-width: 100%;
}

.message-content {
  background: transparent;
  padding: 0.25rem 0;
  word-wrap: break-word;
  overflow: visible;
  max-height: none;
  line-height: 1.5;
  font-size: 0.9375rem;
}

.message.user .message-content {
  background: var(--user-bubble-bg);
  color: var(--text-primary);
  padding: 0.875rem 1.125rem;
  border-radius: var(--message-radius);
  border-bottom-right-radius: 0.375rem;
  font-size: 0.9375rem;
  border: 1px solid var(--border-color);
}

.message.assistant .message-content {
  background: transparent;
  padding: 0.25rem 0;
}

.message.system.promo {
  align-self: center;
  max-width: 90%;
  margin: 1.5rem 0;
}

.message.system.promo .message-content {
  background: linear-gradient(135deg, hsla(262 83% 58% / 0.1) 0%, hsla(280 80% 70% / 0.1) 100%);
  border: 1px solid hsla(262 83% 58% / 0.3);
  border-radius: 1rem;
  padding: 0;
}

.promo-message {
  padding: 1.25rem 1.5rem;
}

.promo-logo-container {
  text-align: center;
  margin-bottom: 1rem;
}

.promo-logo {
  width: 120px;
  height: 120px;
  border-radius: 1.5rem;
  box-shadow: 0 4px 20px rgba(139, 92, 246, 0.3);
  background: #1a1a2e;
}

@media (max-width: 480px) {
  .promo-logo {
    width: 100px;
    height: 100px;
  }
}

.promo-header {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--primary-color);
  margin-bottom: 0.75rem;
  text-align: center;
}

.promo-message p {
  margin: 0.5rem 0;
  color: var(--text-primary);
  font-size: 0.95rem;
}

.promo-message ul {
  margin: 0.75rem 0;
  padding-left: 1.25rem;
}

.promo-message li {
  margin: 0.4rem 0;
  color: var(--text-secondary);
  font-size: 0.9rem;
}

.promo-message li strong {
  color: var(--text-primary);
}

.promo-email {
  text-align: center;
  margin-top: 1rem !important;
}

.promo-email a {
  display: inline-block;
  background: var(--primary-color);
  color: white !important;
  padding: 0.6rem 1.25rem;
  border-radius: 0.5rem;
  text-decoration: none;
  font-weight: 500;
  transition: all 0.2s ease;
}

.promo-email a:hover {
  background: var(--primary-hover);
  transform: translateY(-1px);
}

.message-actions {
  display: flex;
  align-items: center;
  gap: 0.125rem;
  margin-top: 0.375rem;
  opacity: 1;
}

.message-action-btn {
  background: transparent;
  border: none;
  padding: 0.25rem;
  cursor: pointer;
  color: var(--text-muted, hsl(240 5% 50%));
  border-radius: 0.25rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
  font-size: 0.875rem;
}

.message-action-btn:hover {
  color: var(--text-secondary);
}

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

.message-action-btn svg {
  width: 16px;
  height: 16px;
  stroke-width: 1.5;
}

.message-content h2 {
  font-size: 1rem;
  font-weight: 600;
  margin: 0.625rem 0 0.25rem 0;
  display: flex;
  align-items: center;
  gap: 0.375rem;
}

.message-content h2:first-child {
  margin-top: 0;
}

.message-content p {
  margin: 0.25rem 0;
}

.ics-download-btn {
  display: inline-block;
  background: var(--primary-color);
  color: white;
  padding: 0.4rem 0.8rem;
  border-radius: 0.375rem;
  text-decoration: none;
  font-size: 0.85rem;
  margin-top: 0.25rem;
  transition: all 0.2s ease;
  border: none;
  cursor: pointer;
  font-family: inherit;
}

.ics-download-btn:hover {
  background: var(--primary-hover);
  text-decoration: none;
}

.message-content p:first-child {
  margin-top: 0;
}

.message-content p:last-child {
  margin-bottom: 0;
}

.message-content ul,
.message-content ol {
  margin: 0.25rem 0;
  padding-left: 1.125rem;
}

.message-content li {
  margin: 0.125rem 0;
}

.message-content a {
  color: var(--primary-color);
  text-decoration: none;
  transition: color 0.2s ease;
}

.message-content a:hover {
  text-decoration: underline;
  color: var(--primary-hover);
}

.message-content .external-link::after {
  content: ' ↗';
  font-size: 0.85em;
}

.message-content .task-link {
  color: var(--accent-color);
  font-weight: 600;
  background: hsla(262, 83%, 58%, 0.1);
  padding: 0.1rem 0.3rem;
  border-radius: 0.25rem;
}

.message-content .task-link:hover {
  background: hsla(262, 83%, 58%, 0.2);
}

.message-content strong {
  font-weight: 600;
}

.message-content em {
  font-style: italic;
  color: var(--text-secondary);
}

.message-content pre {
  background: var(--surface-color);
  padding: 0.75rem 1rem;
  border-radius: 0.5rem;
  overflow-x: auto;
  margin: 0.5rem 0;
  border: 1px solid var(--border-color);
}

.message-content code {
  font-family: 'JetBrains Mono', 'Fira Code', 'Courier New', monospace;
  font-size: 0.9em;
  background: var(--surface-color);
  padding: 0.125rem 0.375rem;
  border-radius: 0.25rem;
}

.message-content hr,
.message-content .markdown-hr {
  border: none;
  height: 1px;
  background: var(--border-color);
  margin: 1rem 0;
}

.message-content pre code {
  background: transparent;
  padding: 0;
}

.message-content .md-table {
  width: 100%;
  border-collapse: collapse;
  margin: 0.75rem 0;
  font-size: 0.9rem;
  border: 1px solid var(--border-color);
  border-radius: 0.5rem;
  overflow: hidden;
}

.message-content .md-table th,
.message-content .md-table td {
  padding: 0.5rem 0.75rem;
  text-align: left;
  border-bottom: 1px solid var(--border-color);
}

.message-content .md-table th {
  background: var(--surface-elevated);
  font-weight: 600;
  color: var(--text-primary);
}

.message-content .md-table td {
  background: var(--surface-color);
}

.message-content .md-table tr:last-child td {
  border-bottom: none;
}

.message-content .md-table tr:hover td {
  background: var(--surface-elevated);
}

.typing-indicator {
  display: flex;
  gap: 4px;
  padding: 0.5rem;
}

.typing-indicator span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-secondary);
  animation: typing 1.4s infinite;
}

.typing-indicator span:nth-child(2) {
  animation-delay: 0.2s;
}

.typing-indicator span:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes typing {

  0%,
  60%,
  100% {
    opacity: 0.3;
  }

  30% {
    opacity: 1;
  }
}

.typing-status {
  color: var(--text-secondary);
  font-size: 0.85rem;
  margin-bottom: 0.25rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.typing-status::before {
  content: '⏳';
  animation: pulse 1s infinite;
}

.typing-timer {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-left: auto;
  font-variant-numeric: tabular-nums;
}

.typing-status.warning {
  color: var(--warning-color, #f59e0b);
}

.typing-status.warning::before {
  content: '⚠️';
}

@keyframes pulse {

  0%,
  100% {
    opacity: 0.5;
  }

  50% {
    opacity: 1;
  }
}

.streaming-cursor {
  display: inline-block;
  width: 8px;
  height: 16px;
  background: var(--primary-color);
  margin-left: 2px;
  animation: blink 0.6s infinite;
  vertical-align: text-bottom;
}

@keyframes blink {

  0%,
  50% {
    opacity: 1;
  }

  51%,
  100% {
    opacity: 0;
  }
}

.message.streaming .message-content {
  border-left: 3px solid var(--primary-color);
  padding-left: 0.75rem;
  animation: streamPulse 1.5s ease-in-out infinite;
}

@keyframes streamPulse {

  0%,
  100% {
    border-color: var(--primary-color);
  }

  50% {
    border-color: var(--primary-dark);
  }
}

.streaming-status {
  color: var(--primary-color);
  font-size: 0.8rem;
  padding: 0.25rem 0;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.streaming-status::before {
  content: '';
  width: 6px;
  height: 6px;
  background: var(--primary-color);
  border-radius: 50%;
  animation: statusPulse 1s infinite;
}

@keyframes statusPulse {

  0%,
  100% {
    transform: scale(1);
    opacity: 1;
  }

  50% {
    transform: scale(1.3);
    opacity: 0.7;
  }
}

.message.user.action-trigger .message-content {
  background: var(--user-bubble-bg);
  border: 1px solid var(--border-color);
}

.message.automation-question .message-content {
  background: linear-gradient(135deg, hsla(45 90% 50% / 0.1) 0%, var(--surface-elevated) 100%);
  border-left: 3px solid hsl(45 90% 50%);
}

.automation-header {
  font-size: 0.85rem;
  color: hsl(45 90% 50%);
  margin-bottom: 0.5rem;
}

.automation-body {
  margin-bottom: 1rem;
}

.automation-options {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.automation-option-btn {
  background: var(--surface-elevated);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  padding: 0.5rem 1rem;
  border-radius: 0.5rem;
  cursor: pointer;
  font-size: 0.875rem;
  transition: all 0.15s ease;
}

.automation-option-btn:hover {
  background: var(--primary-color);
  color: white;
  border-color: var(--primary-color);
}

.automation-input-container {
  display: flex;
  gap: 0.5rem;
  align-items: flex-end;
}

.automation-response-input {
  flex: 1;
  background: var(--surface-color);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  padding: 0.75rem;
  border-radius: 0.5rem;
  font-size: 0.875rem;
  resize: none;
  font-family: inherit;
}

.automation-response-input:focus {
  outline: none;
  border-color: var(--primary-color);
}

.automation-submit-btn {
  background: var(--primary-color);
  color: white;
  border: none;
  padding: 0.75rem 1.25rem;
  border-radius: 0.5rem;
  cursor: pointer;
  font-size: 0.875rem;
  font-weight: 500;
  transition: all 0.15s ease;
}

.automation-submit-btn:hover {
  opacity: 0.9;
}

.automation-sent {
  color: var(--success-color);
  font-size: 0.875rem;
  padding: 0.5rem 0;
}

.chat-input-container {
  padding: 0.5rem 0.75rem;
  padding-bottom: max(0.5rem, env(safe-area-inset-bottom, 0.5rem));
  padding-right: max(0.75rem, env(safe-area-inset-right, 0.75rem));
  padding-left: max(0.75rem, env(safe-area-inset-left, 0.75rem));
  background: var(--surface-color);
  border-top: 1px solid var(--border-color);
  display: flex;
  align-items: flex-end;
  flex-shrink: 0;
  -webkit-box-sizing: border-box;
  box-sizing: border-box;
}

.input-inline-btn {
  width: 32px;
  height: 32px;
  min-width: 32px;
  border-radius: 0.5rem;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
  flex-shrink: 0;
}

.input-inline-btn:hover {
  color: var(--text-primary);
  background: var(--surface-elevated);
}

.input-inline-btn:active {
  transform: scale(0.95);
}

.input-inline-btn.send {
  background: var(--primary-color);
  color: white;
}

.input-inline-btn.send:hover {
  background: var(--primary-hover);
}

.input-inline-btn.fast-mode-btn {
  transition: all 0.2s ease;
}

.input-inline-btn.fast-mode-btn.active {
  background: linear-gradient(135deg, #f59e0b, #d97706);
  color: white;
}

.input-inline-btn.fast-mode-btn.active svg {
  filter: drop-shadow(0 0 4px rgba(251, 191, 36, 0.5));
}

.input-inline-btn.fast-mode-btn:hover {
  color: #fbbf24;
}

.input-inline-btn.fast-mode-btn.active:hover {
  background: linear-gradient(135deg, #d97706, #b45309);
  color: white;
}

.ai-mode-selector {
  position: relative;
  flex-shrink: 0;
}

.ai-mode-selector select {
  appearance: none;
  -webkit-appearance: none;
  background: var(--surface-elevated);
  border: 1px solid var(--border-color);
  border-radius: 0.5rem;
  padding: 0.375rem 1.75rem 0.375rem 0.5rem;
  font-size: 0.75rem;
  color: var(--text-primary);
  cursor: pointer;
  min-width: 90px;
  transition: all 0.15s ease;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%239ca3af' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.5rem center;
}

.ai-mode-selector select:hover {
  border-color: var(--primary-color);
}

.ai-mode-selector select:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 2px rgba(139, 92, 246, 0.2);
}

.ai-mode-selector select option {
  background: var(--surface-color);
  color: var(--text-primary);
  padding: 0.5rem;
}

.skill-feedback {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.125rem 0.5rem;
  border-radius: 1rem;
  font-size: 0.6875rem;
  font-weight: 500;
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.15), rgba(99, 102, 241, 0.15));
  color: #60a5fa;
  border: 1px solid rgba(59, 130, 246, 0.3);
  margin-bottom: 0.25rem;
}

.skill-feedback.skill-fast {
  background: linear-gradient(135deg, rgba(251, 191, 36, 0.15), rgba(245, 158, 11, 0.15));
  color: #fbbf24;
  border: 1px solid rgba(251, 191, 36, 0.3);
}

.skill-feedback.skill-analyst {
  background: linear-gradient(135deg, rgba(34, 197, 94, 0.15), rgba(22, 163, 74, 0.15));
  color: #4ade80;
  border: 1px solid rgba(34, 197, 94, 0.3);
}

.skill-feedback.skill-writer {
  background: linear-gradient(135deg, rgba(168, 85, 247, 0.15), rgba(139, 92, 246, 0.15));
  color: #c084fc;
  border: 1px solid rgba(168, 85, 247, 0.3);
}

.skill-feedback.skill-reviewer {
  background: linear-gradient(135deg, rgba(236, 72, 153, 0.15), rgba(219, 39, 119, 0.15));
  color: #f472b6;
  border: 1px solid rgba(236, 72, 153, 0.3);
}

.skill-feedback.skill-literature {
  background: linear-gradient(135deg, rgba(14, 165, 233, 0.15), rgba(2, 132, 199, 0.15));
  color: #38bdf8;
  border: 1px solid rgba(14, 165, 233, 0.3);
}

@media (max-width: 480px) {
  .ai-mode-selector select {
    min-width: 70px;
    font-size: 0.6875rem;
    padding: 0.25rem 1.5rem 0.25rem 0.375rem;
  }
}

.input-inline-actions {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  flex-shrink: 0;
}

.input-action-btn {
  width: 40px;
  height: 40px;
  border-radius: 0.75rem;
  border: 1px solid var(--border-color);
  background: var(--surface-elevated);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: var(--text-secondary);
  transition: all 0.2s ease;
  font-size: 1.25rem;
}

.input-action-btn:hover {
  background: var(--primary-color);
  color: white;
  border-color: var(--primary-color);
}

.input-wrapper {
  flex: 1 1 auto;
  min-width: 0;
  background: var(--surface-elevated);
  border: 1px solid var(--border-color);
  border-radius: var(--input-radius);
  padding: 0.25rem 0.375rem;
  display: flex;
  align-items: flex-end;
  gap: 0.25rem;
  transition: all 0.2s ease;
}

.input-wrapper:focus-within {
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px hsla(262 83% 58% / 0.15);
}

.input-wrapper.has-attachment {
  flex-direction: column;
  align-items: stretch;
}

.input-wrapper.has-attachment #chatInput {
  max-height: 48px;
  overflow-y: auto;
}

#chatInput {
  flex: 1 1 auto;
  min-width: 0;
  padding: 0.375rem 0.5rem;
  border: none;
  background: transparent;
  font-family: inherit;
  font-size: 1rem;
  color: var(--text-primary);
  resize: none;
  outline: none;
  line-height: 1.5;
  min-height: 32px;
  max-height: 200px;
  overflow-y: hidden;
  transition: height 0.1s ease;
}

#chatInput::placeholder {
  color: var(--text-secondary);
  font-size: 0.9375rem;
}

#voiceBtn.recording {
  background: var(--danger-color) !important;
  color: white !important;
  border-color: var(--danger-color) !important;
  animation: pulse-recording 1.5s infinite;
}

#voiceBtn.hidden {
  display: none;
}

.attachment-preview {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  background: var(--surface-color);
  border-radius: 0.5rem;
  margin-bottom: 0.25rem;
  font-size: 0.875rem;
  width: 100%;
  border: 1px solid var(--border-color);
}

.attachment-icon {
  font-size: 1.25rem;
}

.attachment-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text-primary);
}

.attachment-remove {
  width: 20px;
  height: 20px;
  border: none;
  background: var(--text-secondary);
  color: white;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  line-height: 1;
  transition: background 0.2s ease;
}

.attachment-remove:hover {
  background: var(--danger-color);
}

.message-attachment {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem;
  background: var(--surface-color);
  border-radius: 0.5rem;
  margin-bottom: 0.5rem;
  font-size: 0.85rem;
  border: 1px solid var(--border-color);
}

.message-attachment.clickable {
  cursor: pointer;
  transition: all 0.2s ease;
}

.message-attachment.clickable:hover {
  background: var(--surface-elevated);
  border-color: var(--primary-color);
}

.message-attachment.clickable:active {
  transform: scale(0.98);
}

.attachment-open-hint {
  color: var(--primary-color);
  font-size: 0.9rem;
  margin-left: auto;
  opacity: 0.7;
}

.attachment-thumbnail {
  max-width: 120px;
  max-height: 80px;
  border-radius: 0.25rem;
  object-fit: cover;
}

.attachment-file-icon {
  font-size: 1.25rem;
}

@keyframes pulse-recording {

  0%,
  100% {
    transform: scale(1);
  }

  50% {
    transform: scale(1.1);
  }
}

.send-btn {
  width: 40px;
  height: 40px;
  border-radius: 0.75rem;
  background: var(--primary-color);
  color: white;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all 0.2s ease;
}

.send-btn:hover {
  background: var(--primary-hover);
  transform: scale(1.05);
}

.send-btn:active {
  transform: scale(0.95);
}

.send-btn:disabled {
  background: var(--border-color);
  color: var(--text-secondary);
  cursor: not-allowed;
  transform: none;
}

.send-btn svg {
  margin-left: 2px;
}

.modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: hsla(0 0% 0% / 0.8);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal.hidden {
  display: none;
}

.modal-content {
  background: var(--surface-color);
  border-radius: 1rem;
  width: 90%;
  max-width: 500px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border-color);
}

.modal-header {
  padding: 1.5rem;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-shrink: 0;
}

.modal-header h2 {
  font-size: 1.25rem;
  color: var(--text-primary);
}

.close-btn {
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--text-secondary);
  transition: color 0.2s ease;
}

.close-btn:hover {
  color: var(--text-primary);
}

.modal-body {
  padding: 1.5rem;
  overflow-y: auto;
  flex: 1;
}

.modal-body::-webkit-scrollbar {
  width: 6px;
}

.modal-body::-webkit-scrollbar-track {
  background: transparent;
}

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

.modal-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: flex-end;
  gap: 1rem;
  flex-shrink: 0;
  background: var(--surface-color);
}

.delegate-ai-modal-content {
  max-width: 520px;
}

.delegate-role-select {
  width: 100%;
  padding: 0.75rem;
  border-radius: 0.5rem;
  border: 1px solid var(--border-color);
  background: var(--surface-elevated);
  color: var(--text-primary);
  font-size: 0.95rem;
  cursor: pointer;
}

.delegate-role-select:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px hsla(var(--primary-hue) 70% 50% / 0.2);
}

.delegate-textarea {
  width: 100%;
  padding: 0.75rem;
  border-radius: 0.5rem;
  border: 1px solid var(--border-color);
  background: var(--surface-elevated);
  color: var(--text-primary);
  font-size: 0.95rem;
  resize: vertical;
  min-height: 100px;
  font-family: inherit;
}

.delegate-textarea:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px hsla(var(--primary-hue) 70% 50% / 0.2);
}

.delegate-drop-zone {
  border: 2px dashed var(--border-color);
  border-radius: 0.5rem;
  padding: 1rem;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s ease;
}

.delegate-drop-zone:hover,
.delegate-drop-zone.dragover {
  border-color: var(--primary-color);
  background: hsla(var(--primary-hue) 70% 50% / 0.05);
}

.drop-zone-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  color: var(--text-secondary);
}

.drop-zone-placeholder svg {
  opacity: 0.5;
}

.delegate-file-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.delegate-file-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.375rem 0.75rem;
  background: var(--surface-elevated);
  border-radius: 0.375rem;
  font-size: 0.85rem;
}

.delegate-file-item .remove-file {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 0;
  line-height: 1;
}

.delegate-file-item .remove-file:hover {
  color: var(--danger-color);
}

.delegate-task-input {
  width: 100%;
  padding: 0.75rem;
  border-radius: 0.5rem;
  border: 1px solid var(--border-color);
  background: var(--surface-elevated);
  color: var(--text-primary);
  font-size: 0.95rem;
}

.delegate-task-input:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px hsla(var(--primary-hue) 70% 50% / 0.2);
}

.action-btn.primary-action {
  background: transparent;
  color: var(--text-secondary);
  border-radius: 0.5rem;
}

.action-btn.primary-action:hover {
  background: var(--surface-elevated);
  color: var(--text-primary);
}

.action-btn.primary-action .btn-icon,
.action-btn.primary-action:hover .btn-icon {
  color: inherit;
}

.action-btn.primary-action .btn-label {
  color: inherit;
}


.form-group {
  margin-bottom: 1.5rem;
}

.form-group label {
  display: block;
  margin-bottom: 0.5rem;
  font-weight: 500;
  color: var(--text-primary);
  font-size: 0.9rem;
}

.form-group input[type="text"],
.form-group input[type="password"],
.form-group input[type="number"],
.form-group select {
  width: 100%;
  padding: 0.75rem;
  border: 1px solid var(--border-color);
  border-radius: 0.5rem;
  font-size: 0.95rem;
  background: var(--surface-elevated);
  color: var(--text-primary);
  transition: all 0.2s ease;
}

.form-group input[type="text"]:focus,
.form-group input[type="password"]:focus,
.form-group input[type="number"]:focus,
.form-group select:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px hsla(262 83% 58% / 0.15);
}

.form-group input[type="checkbox"] {
  margin-right: 0.5rem;
  accent-color: var(--primary-color);
}

.form-group small {
  color: var(--text-secondary) !important;
  display: block;
  margin-top: 0.375rem;
}

.form-group a {
  color: var(--primary-color);
}

.form-group hr {
  border: none;
  border-top: 1px solid var(--border-color);
  margin: 1.5rem 0;
}

.mb-2 {
  margin-bottom: 8px;
}

.settings-divider {
  margin: 1.5rem 0;
  border: none;
  border-top: 1px solid var(--border-color);
}

.user-profile-row {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
  align-items: center;
}

.user-profile-row .profile-login {
  flex: 1;
  min-width: 0;
}

.user-profile-row .profile-apikey {
  flex: 1.5;
  min-width: 0;
}

.user-profile-row .profile-remove-btn {
  background: transparent;
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  width: 32px;
  height: 32px;
  border-radius: 0.375rem;
  cursor: pointer;
  font-size: 1.2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.user-profile-row .profile-remove-btn:hover {
  background: var(--danger-color, #ef4444);
  border-color: var(--danger-color, #ef4444);
  color: white;
}

.user-profile-row:only-child .profile-remove-btn {
  visibility: hidden;
}

#addProfileBtn {
  margin-top: 0.5rem;
  margin-bottom: 0.5rem;
}

.btn-small {
  padding: 0.375rem 0.75rem;
  font-size: 0.85rem;
}

.slider-row {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-top: 0.5rem;
}

.slider-emoji {
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.slider-input {
  flex: 1;
  height: 8px;
  accent-color: var(--primary-color);
}

.slider-value {
  font-weight: 600;
  min-width: 24px;
  text-align: center;
  color: var(--text-primary);
}

.slider-labels {
  display: flex;
  justify-content: space-between;
  margin-top: 0.25rem;
}

.btn-row {
  display: flex;
  gap: 0.5rem;
}

.btn-row button {
  flex: 1;
}

.settings-collapsible {
  margin-bottom: 1rem;
}

.settings-collapsible summary {
  font-weight: 500;
  cursor: pointer;
  padding: 0.5rem 0;
  color: var(--text-primary);
  list-style: none;
}

.settings-collapsible summary::-webkit-details-marker {
  display: none;
}

.settings-collapsible summary::before {
  content: "▶ ";
  font-size: 0.75rem;
  margin-right: 0.5rem;
}

.settings-collapsible[open] summary::before {
  content: "▼ ";
}

.collapsible-content {
  padding: 0.75rem 0;
}

.settings-grid {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 0.75rem;
}

.settings-field {
  flex: 1;
  min-width: 100px;
}

.field-label {
  font-size: 0.85rem;
  color: var(--text-secondary);
  display: block;
  margin-bottom: 0.25rem;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
  color: var(--text-primary);
}

.premium-box {
  background: var(--surface-elevated);
  padding: 0.75rem;
  border-radius: 8px;
  margin-top: 0.5rem;
  border: 1px solid var(--border-color);
}

.premium-options {
  margin-left: 1.5rem;
  margin-top: 0.5rem;
}

.piper-status {
  margin-top: 0.75rem;
  padding: 0.5rem;
  background: var(--surface);
  border-radius: 6px;
}

.piper-status .progress-bar {
  height: 6px;
  background: var(--border-color);
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 0.5rem;
}

.piper-status .progress-fill {
  height: 100%;
  background: var(--primary);
  transition: width 0.3s ease;
}

.piper-status span {
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.version-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-top: 0.5rem;
}

.version-badge {
  font-family: monospace;
  background: var(--surface-elevated);
  color: var(--text-primary);
  padding: 0.5rem 0.75rem;
  border-radius: 4px;
  border: 1px solid var(--border-color);
}

.prompts-modal-content {
  max-width: 600px;
  height: 80vh;
  max-height: 700px;
  display: flex;
  flex-direction: column;
}

.prompts-tabs {
  display: flex;
  border-bottom: 1px solid var(--border-color);
  padding: 0 1rem;
  background: var(--surface-color);
  flex-shrink: 0;
}

.prompts-tab {
  flex: 1;
  padding: 0.875rem 0.5rem;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-secondary);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.prompts-tab:hover {
  color: var(--text-primary);
  background: var(--surface-elevated);
}

.prompts-tab.active {
  color: var(--primary-color);
  border-bottom-color: var(--primary-color);
}

.prompts-body {
  padding: 1rem;
  flex: 1;
  overflow-y: auto;
}

.prompts-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.prompt-item {
  padding: 1rem;
  background: var(--surface-elevated);
  border: 1px solid var(--border-color);
  border-radius: 0.75rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

.prompt-item:hover {
  border-color: var(--primary-color);
  background: hsla(262 83% 58% / 0.05);
  transform: translateY(-1px);
}

.prompt-item:active {
  transform: translateY(0);
}

.prompt-item-title {
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 0.5rem;
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.prompt-item-title::before {
  content: "💡";
  font-size: 0.875rem;
}

.prompt-item-description {
  color: var(--text-secondary);
  font-size: 0.8rem;
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

@media (max-width: 768px) {
  .prompts-modal-content {
    width: 100%;
    height: 100%;
    max-height: 100%;
    border-radius: 0;
  }

  .prompts-tab {
    padding: 1rem 0.25rem;
    font-size: 0.8rem;
  }

  .prompt-item {
    padding: 0.875rem;
  }
}

.hidden {
  display: none !important;
}

.btn-primary {
  padding: 0.75rem 1.5rem;
  background: var(--primary-color);
  color: white;
  border: none;
  border-radius: 0.5rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

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

.btn-secondary {
  padding: 0.75rem 1.5rem;
  background: var(--surface-elevated);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  border-radius: 0.5rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

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

.install-prompt {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--surface-color);
  padding: 1rem 1.5rem;
  border-radius: 1rem;
  box-shadow: var(--shadow-lg);
  display: flex;
  gap: 1rem;
  align-items: center;
  z-index: 1000;
  border: 1px solid var(--border-color);
}

.install-prompt.hidden {
  display: none;
}

.update-banner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  background: var(--surface-color);
  border-bottom: 1px solid var(--border-color);
  color: var(--text-primary);
  padding: 0.5rem 1rem;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.75rem;
  z-index: 2000;
  font-size: 0.85rem;
}

.update-banner.hidden {
  display: none;
}

.update-banner > svg {
  color: var(--primary-color);
  flex-shrink: 0;
}

.update-banner .btn-small {
  padding: 0.375rem 0.75rem;
  font-size: 0.8rem;
  background: var(--primary-color);
  color: white;
  border: none;
  border-radius: 0.5rem;
  cursor: pointer;
  font-weight: 500;
  transition: all 0.15s ease;
}

.update-banner .btn-small:hover {
  background: var(--primary-hover);
}

.update-banner .dismiss-btn {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 0.375rem;
  border-radius: 0.375rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
}

.update-banner .dismiss-btn:hover {
  background: var(--surface-elevated);
  color: var(--text-primary);
}

.menu-toggle {
  display: none;
  background: transparent;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  padding: 0.5rem;
}

.sidebar-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: hsla(0 0% 0% / 0.6);
  backdrop-filter: blur(2px);
  z-index: 199;
}

.sidebar-overlay.active {
  display: block;
}

.sidebar-pull-tab {
  display: none;
  position: fixed;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 12px;
  height: 48px;
  background: var(--primary-color);
  border-radius: 0 6px 6px 0;
  z-index: 198;
  cursor: pointer;
  align-items: center;
  justify-content: center;
  opacity: 0.3;
  transition: opacity 0.2s, width 0.2s;
  -webkit-tap-highlight-color: transparent;
}

.sidebar-pull-tab:hover,
.sidebar-pull-tab:active {
  opacity: 0.6;
  width: 16px;
}

.sidebar-pull-tab svg {
  color: white;
}

.message-action-btn.tts-btn {
  transition: all 0.2s;
}

.message-action-btn.tts-btn.speaking {
  color: var(--primary-color);
  animation: tts-pulse 1s infinite;
}

.message-action-btn.tts-btn.loading {
  opacity: 0.7;
  animation: tts-loading 0.8s infinite;
}

@keyframes tts-loading {

  0%,
  100% {
    opacity: 0.5;
  }

  50% {
    opacity: 1;
  }
}

@keyframes tts-pulse {

  0%,
  100% {
    transform: scale(1);
  }

  50% {
    transform: scale(1.15);
  }
}

@media (hover: none) {
  .message-actions {
    opacity: 1;
  }
}

@media (max-width: 768px) {
  .menu-toggle {
    display: block;
  }

  .sidebar-pull-tab {
    display: flex;
  }

  .sidebar.open~.sidebar-pull-tab,
  .sidebar-pull-tab.hidden {
    display: none;
  }

  header {
    padding: 0.75rem 1rem;
  }

  header h1 {
    font-size: 1.2rem;
  }

  .sidebar {
    position: fixed;
    left: -280px;
    top: 0;
    bottom: 0;
    width: 280px !important;
    z-index: 200;
    transition: left 0.3s ease;
    box-shadow: var(--shadow-lg);
    padding: 1rem !important;
  }

  .sidebar.open {
    left: 0;
  }

  .sidebar.collapsed,
  .sidebar:not(.collapsed) {
    width: 280px !important;
    padding: 1rem !important;
  }

  .sidebar .btn-label,
  .sidebar.collapsed .btn-label {
    opacity: 1 !important;
    width: auto !important;
  }

  .sidebar .sidebar-section-title,
  .sidebar.collapsed .sidebar-section-title {
    opacity: 1 !important;
    height: auto !important;
    margin-bottom: 0.5rem !important;
  }

  .sidebar .sidebar-brand-text,
  .sidebar.collapsed .sidebar-brand-text {
    display: inline !important;
  }

  .sidebar-toggle {
    display: none !important;
  }

  .sidebar .sidebar-section-header,
  .sidebar.collapsed .sidebar-section-header {
    display: flex !important;
  }

  .sidebar .sidebar-section[data-section="quick"],
  .sidebar.collapsed .sidebar-section[data-section="quick"] {
    padding-bottom: 0.5rem !important;
    border-bottom: 1px solid var(--border-color) !important;
    margin-bottom: 0.5rem !important;
  }

  .sidebar .action-btn,
  .sidebar .view-btn,
  .sidebar.collapsed .action-btn,
  .sidebar.collapsed .view-btn {
    justify-content: flex-start !important;
    padding: 0.75rem !important;
  }

  .main-container {
    flex-direction: column;
  }

  .content {
    height: calc(100vh - 60px);
    height: calc(100dvh - 60px);
  }

  .chat-messages {
    padding: 1rem;
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  .message {
    overflow: visible;
    flex-shrink: 0;
  }

  .message-content {
    overflow: visible;
    max-height: none;
  }

  .chat-input-container {
    padding: 0.375rem 0.5rem;
    padding-bottom: max(0.375rem, env(safe-area-inset-bottom, 0.375rem));
    padding-right: max(0.5rem, env(safe-area-inset-right, 0.5rem));
    padding-left: max(0.5rem, env(safe-area-inset-left, 0.5rem));
  }

  .input-inline-btn {
    width: 28px;
    height: 28px;
    min-width: 28px;
  }

  .input-inline-btn svg {
    width: 16px;
    height: 16px;
  }

  .input-wrapper {
    padding: 0.25rem 0.25rem;
  }

  #chatInput {
    font-size: 16px;
    min-height: 28px;
  }

  .message {
    max-width: 90%;
  }

  .message.user {
    max-width: 90%;
  }

  .model-selector {
    padding: 0.4rem 0.5rem;
    font-size: 0.8rem;
    max-width: 100px;
  }

  .modal-content {
    width: 95%;
    max-height: 90vh;
    overflow-y: auto;
  }

  .install-prompt {
    bottom: 80px;
    width: 90%;
    left: 5%;
    transform: none;
  }

  .canvas-header {
    padding: 0.5rem 0.75rem;
  }

  .canvas-header h3 {
    font-size: 0.8rem;
  }
}

@media (max-width: 480px) {
  header h1 {
    font-size: 1rem;
  }

  .chat-messages {
    padding: 0.75rem;
    gap: 0.75rem;
  }

  .message-content {
    padding: 0.6rem 0.8rem;
    font-size: 0.95rem;
  }
}

.canvas-container.calendar-active .canvas-header,
.canvas-container.kanban-active .canvas-header,
.canvas-container.statistics-active .canvas-header,
.canvas-container.eisenhower-active .canvas-header {
  display: none;
}

/* FullCalendar Customization */
.full-calendar-container {
  padding: 1rem;
  background: var(--surface-color);
  color: var(--text-primary);
  height: 100%;
  display: flex;
  flex-direction: column;
}

:root {
  --fc-page-bg-color: var(--surface-color);
  --fc-neutral-bg-color: var(--surface-elevated);
  --fc-neutral-text-color: var(--text-secondary);
  --fc-border-color: var(--border-color);
  --fc-button-text-color: #fff;
  --fc-button-bg-color: var(--primary-color);
  --fc-button-border-color: var(--primary-color);
  --fc-button-hover-bg-color: var(--primary-hover);
  --fc-button-hover-border-color: var(--primary-hover);
  --fc-button-active-bg-color: var(--primary-dark);
  --fc-button-active-border-color: var(--primary-dark);
  --fc-event-bg-color: var(--primary-color);
  --fc-event-border-color: var(--primary-color);
  --fc-today-bg-color: hsla(262, 83%, 58%, 0.05);
  --fc-now-indicator-color: var(--accent-color);
}

.fc {
  font-family: inherit;
}

.fc-toolbar-title {
  font-size: 1.25rem !important;
  font-weight: 600;
}

.fc-col-header-cell {
  background-color: var(--surface-elevated);
  padding: 8px 0 !important;
}

.fc-daygrid-day-number {
  color: var(--text-primary);
}

/* Today's date highlighting */
.fc .fc-daygrid-day.fc-day-today {
  background-color: hsla(262, 83%, 58%, 0.12) !important;
}

.fc .fc-daygrid-day.fc-day-today .fc-daygrid-day-number {
  background: var(--primary-color);
  color: white;
  border-radius: 50%;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
}

.fc-col-header-cell-cushion {
  color: var(--text-secondary);
  text-transform: uppercase;
  font-size: 0.75rem;
  letter-spacing: 0.05em;
}

.fc-list-event:hover td {
  background-color: var(--surface-elevated) !important;
}

.fc-popover {
  background-color: var(--surface-elevated) !important;
  border-color: var(--border-color) !important;
}

.fc-popover-header {
  background-color: var(--surface-color) !important;
  color: var(--text-primary) !important;
}

.fc-popover-body {
  color: var(--text-primary) !important;
}

/* Mobile Tweaks */
@media (max-width: 768px) {
  .fc-toolbar {
    flex-direction: column;
    gap: 0.5rem;
  }

  .fc-toolbar-title {
    font-size: 1rem !important;
  }
}

.fup-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 1rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border-color);
}

.fup-btn {
  background: var(--surface-color);
  border: 1px solid var(--primary-color);
  color: var(--primary-color);
  padding: 0.4rem 0.75rem;
  border-radius: 1rem;
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.fup-btn:hover {
  background: var(--primary-color);
  color: white;
  transform: translateY(-1px);
}

.fup-btn:active {
  transform: translateY(0);
}

@media (max-width: 768px) {
  .fup-suggestions {
    gap: 0.4rem;
  }

  .fup-btn {
    font-size: 0.8rem;
    padding: 0.35rem 0.6rem;
  }
}

select {
  appearance: none;
  background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%239ca3af' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  background-size: 1rem;
  padding-right: 2.5rem;
}

select option {
  background: var(--surface-color);
  color: var(--text-primary);
}

select optgroup {
  background: var(--surface-elevated);
  color: var(--text-secondary);
  font-weight: 600;
}

::-webkit-input-placeholder {
  color: var(--text-secondary);
}

::-moz-placeholder {
  color: var(--text-secondary);
}

:-ms-input-placeholder {
  color: var(--text-secondary);
}

::selection {
  background: hsla(262 83% 58% / 0.3);
  color: var(--text-primary);
}

:focus-visible {
  outline: 2px solid var(--primary-color);
  outline-offset: 2px;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--primary-color);
  outline-offset: 2px;
}

/* Welcome Intro Styles */
.welcome-intro {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 2rem 1rem;
  gap: 1.5rem;
  max-width: 600px;
  margin: 0 auto;
}

/* Wider welcome intro for two-column layout */
body.right-chat-layout .welcome-intro {
  max-width: 800px;
}

.welcome-logo {
  width: 120px;
  height: 120px;
  border-radius: 1.5rem;
  overflow: hidden;
  box-shadow: 0 4px 20px rgba(139, 92, 246, 0.3);
  background: #1a1a2e;
}

.welcome-logo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

[data-theme="light"] .welcome-logo {
  background: #1a1a2e;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
}

.welcome-description {
  font-size: 1rem;
  line-height: 1.6;
  color: var(--text-secondary);
  max-width: 360px;
}

.welcome-prompts {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.75rem;
  width: 100%;
  max-width: 500px;
}

/* Wider prompts grid for two-column layout */
body.right-chat-layout .welcome-prompts {
  max-width: 700px;
  grid-template-columns: repeat(4, 1fr);
}

.welcome-prompts-loading {
  grid-column: span 2;
  text-align: center;
  color: var(--text-secondary);
  font-size: 0.875rem;
  padding: 1rem;
}

.welcome-prompt-btn {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  background: var(--surface-elevated);
  border: 1px solid var(--border-color);
  border-radius: 0.75rem;
  color: var(--text-primary);
  font-size: 0.875rem;
  cursor: pointer;
  transition: all 0.2s ease;
  text-align: left;
}

.welcome-prompt-btn:hover {
  background: var(--surface-color);
  border-color: var(--primary-color);
  transform: translateY(-1px);
}

.welcome-prompt-btn:active {
  transform: translateY(0);
}

.welcome-prompt-btn .prompt-icon {
  font-size: 1.25rem;
  flex-shrink: 0;
}

.welcome-prompt-btn .prompt-title {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Responsive welcome prompts for right-chat-layout */
@media (max-width: 1024px) {
  body.right-chat-layout .welcome-prompts {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 767px) {
  body.right-chat-layout .welcome-intro {
    max-width: 100%;
    padding: 1.5rem 1rem;
  }
  
  body.right-chat-layout .welcome-prompts {
    max-width: 100%;
    grid-template-columns: repeat(2, 1fr);
  }
  
  body.right-chat-layout .welcome-description {
    max-width: 100%;
  }
}

@media (max-width: 480px) {
  .welcome-intro,
  body.right-chat-layout .welcome-intro {
    padding: 1.5rem 0.75rem;
    max-width: 100%;
  }

  .welcome-logo {
    width: 100px;
    height: 100px;
  }

  .welcome-description,
  body.right-chat-layout .welcome-description {
    font-size: 0.9rem;
    max-width: 100%;
  }

  .welcome-prompts,
  body.right-chat-layout .welcome-prompts {
    grid-template-columns: 1fr;
    max-width: 100%;
  }

  .welcome-prompts-loading {
    grid-column: span 1;
  }
  
  .welcome-prompt-btn {
    padding: 0.625rem 0.75rem;
    font-size: 0.8125rem;
  }
}

/* Eisenhower Matrix View */
.eisenhower-view {
  display: flex;
  flex-direction: column;
  height: 100%;
  padding: 0;
  background: var(--bg-color);
  overflow: hidden;
}

.eisenhower-view .view-header {
  flex-shrink: 0;
}

.eisenhower-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 0.75rem;
  overflow: hidden;
  min-height: 0;
}

.eisenhower-header {
  flex-shrink: 0;
  margin-bottom: 1rem;
  text-align: center;
}

.eisenhower-title {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0;
}

.eisenhower-grid {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr 1fr;
  gap: 0.75rem;
  min-height: 0;
  overflow: hidden;
}

.eisenhower-quadrant {
  display: flex;
  flex-direction: column;
  background: var(--surface-color);
  border-radius: 0.75rem;
  border: 1px solid var(--border-color);
  overflow: hidden;
}

.eisenhower-quadrant.q1 {
  border-top: 3px solid #ef4444;
}

.eisenhower-quadrant.q2 {
  border-top: 3px solid #3b82f6;
}

.eisenhower-quadrant.q3 {
  border-top: 3px solid #f59e0b;
}

.eisenhower-quadrant.q4 {
  border-top: 3px solid #6b7280;
}

.quadrant-header {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem;
  background: var(--surface-elevated);
  border-bottom: 1px solid var(--border-color);
}

.quadrant-icon {
  font-size: 1.25rem;
}

.quadrant-labels {
  display: flex;
  flex-direction: column;
  gap: 0.125rem;
}

.quadrant-title {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-primary);
}

.quadrant-subtitle {
  font-size: 0.7rem;
  color: var(--text-secondary);
}

.quadrant-tasks {
  flex: 1;
  overflow-y: auto;
  padding: 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
}

.eisenhower-task {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem 0.75rem;
  background: var(--surface-elevated);
  border-radius: 0.5rem;
  cursor: pointer;
  transition: all 0.15s ease;
  border: 1px solid transparent;
}

.eisenhower-task:hover {
  background: var(--primary-color);
  color: white;
  border-color: var(--primary-color);
}

.eisenhower-task:hover .task-due {
  color: rgba(255, 255, 255, 0.8);
}

.task-subject {
  font-size: 0.8rem;
  color: var(--text-primary);
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.task-due {
  font-size: 0.7rem;
  color: var(--text-secondary);
  flex-shrink: 0;
}

.task-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
}

.delegate-task-btn {
  background: transparent;
  border: none;
  cursor: pointer;
  font-size: 0.9rem;
  padding: 0.25rem;
  border-radius: 0.25rem;
  transition: all 0.15s ease;
  opacity: 0.6;
}

.delegate-task-btn:hover {
  opacity: 1;
  background: var(--primary-color);
  transform: scale(1.1);
}

.delegate-task-btn.working {
  opacity: 1;
  animation: spin 2s linear infinite;
}

@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.eisenhower-task.automation-active {
  border-left: 3px solid var(--primary-color);
  background: rgba(99, 102, 241, 0.1);
}

.eisenhower-task:hover .delegate-task-btn {
  opacity: 1;
}

.empty-quadrant,
.loading-tasks,
.error-tasks {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.error-tasks {
  color: var(--danger-color);
}

/* Quadrant count badge and expand icon */
.quadrant-count {
  margin-left: auto;
  background: var(--primary-color);
  color: white;
  font-size: 0.7rem;
  font-weight: 600;
  padding: 0.125rem 0.5rem;
  border-radius: 1rem;
  min-width: 1.25rem;
  text-align: center;
}

.quadrant-count:empty {
  display: none;
}

.quadrant-expand {
  display: none;
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-left: 0.5rem;
  transition: transform 0.2s ease;
}

@media (max-width: 768px) {
  .eisenhower-grid {
    grid-template-columns: 1fr;
    grid-template-rows: auto;
    gap: 0.5rem;
    overflow-y: auto;
  }

  .eisenhower-title {
    font-size: 1.25rem;
  }

  .eisenhower-quadrant {
    transition: all 0.3s ease;
  }

  .eisenhower-quadrant .quadrant-tasks {
    max-height: 0;
    overflow: hidden;
    padding: 0 0.5rem;
    transition: max-height 0.3s ease, padding 0.3s ease;
  }

  .eisenhower-quadrant.expanded .quadrant-tasks {
    max-height: 50vh;
    overflow-y: auto;
    padding: 0.5rem;
  }

  .quadrant-header {
    cursor: pointer;
  }

  .quadrant-expand {
    display: block;
  }

  .eisenhower-quadrant.expanded .quadrant-expand {
    transform: rotate(180deg);
  }

  .quadrant-title {
    font-size: 0.75rem;
  }
}


/* ==========================================
   UNIFIED VIEW HEADER
   ========================================== */
.view-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.875rem 1rem;
  border-bottom: 1px solid var(--border-color);
  background: var(--surface-color);
  flex-shrink: 0;
  gap: 0.75rem;
}

.view-header-left {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.view-header-right {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.view-close-btn {
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--text-secondary);
  padding: 0.25rem 0.5rem;
  line-height: 1;
  border-radius: 0.375rem;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.view-close-btn:hover {
  background: var(--surface-elevated);
  color: var(--text-primary);
}

.view-header-title {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.view-header-btn {
  border: 1px solid var(--border-color);
  border-radius: 0.5rem;
  padding: 0.5rem 0.875rem;
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 500;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  gap: 0.35rem;
  background: var(--surface-color);
  color: var(--text-primary);
}

.view-header-btn:hover {
  background: var(--surface-elevated);
  border-color: var(--primary-color);
}

.view-header-btn.primary {
  background: var(--primary-color);
  color: white;
  border-color: var(--primary-color);
}

.view-header-btn.primary:hover {
  background: hsl(262, 83%, 50%);
}

.view-header-btn.success {
  background: var(--success-color, #22c55e);
  color: white;
  border-color: var(--success-color, #22c55e);
}

.view-header-btn.success:hover {
  background: var(--success-hover, #16a34a);
}

@media (max-width: 600px) {
  .view-header {
    flex-wrap: wrap;
    padding: 0.75rem;
  }

  .view-header-right {
    width: 100%;
    justify-content: flex-start;
  }

  .view-header-btn {
    padding: 0.4rem 0.6rem;
    font-size: 0.8rem;
  }
}

/* Calendar Actions Header - now uses unified view-header */
.calendar-actions-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.875rem 1rem;
  border-bottom: 1px solid var(--border-color);
  background: var(--surface-color);
  flex-shrink: 0;
  gap: 0.75rem;
}

.cal-actions-left {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.cal-actions-right {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.cal-close-btn {
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--text-secondary);
  padding: 0.25rem 0.5rem;
  line-height: 1;
  border-radius: 0.375rem;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.cal-close-btn:hover {
  background: var(--surface-elevated);
  color: var(--text-primary);
}

.cal-header-title {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.cal-sync-btn,
.cal-sprint-close-btn,
.cal-subscribe-btn {
  border: 1px solid var(--border-color);
  border-radius: 0.5rem;
  padding: 0.5rem 0.875rem;
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 500;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  gap: 0.35rem;
  background: var(--surface-color);
  color: var(--text-primary);
}

.cal-sync-btn:hover,
.cal-sprint-close-btn:hover,
.cal-subscribe-btn:hover {
  background: var(--surface-elevated);
  border-color: var(--primary-color);
}

@media (max-width: 600px) {
  .calendar-actions-bar {
    flex-wrap: wrap;
    padding: 0.75rem;
  }
  
  .cal-actions-right {
    width: 100%;
    justify-content: flex-start;
  }
  
  .cal-sync-btn,
  .cal-sprint-close-btn,
  .cal-subscribe-btn {
    padding: 0.4rem 0.6rem;
    font-size: 0.8rem;
  }
}

.cal-subscribe-btn {
  background: transparent;
  color: var(--primary-color);
  border: 1px solid var(--primary-color);
}

.cal-subscribe-btn:hover {
  background: hsla(262, 83%, 58%, 0.1);
}

@media (max-width: 600px) {
  .calendar-actions-bar {
    flex-wrap: wrap;
    padding: 0.75rem;
  }

  .cal-actions-right {
    width: 100%;
    justify-content: flex-start;
    flex-wrap: wrap;
  }
}

/* Action Widget Styles */
.action-widget-container {
  margin-bottom: 1rem;
}

.action-widget {
  background: var(--surface-elevated);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 1rem;
  max-width: 400px;
  margin: 0 auto;
}

.action-widget-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 0.5rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border-color);
}

.action-widget-description {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-bottom: 1rem;
  line-height: 1.4;
}

.action-widget-form {
  display: flex;
  flex-direction: column;
  gap: 0.875rem;
}

.action-widget-field {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.action-widget-field label {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-secondary);
}

.action-widget-field label .required {
  color: var(--danger-color);
}

.action-widget-input {
  padding: 0.625rem 0.75rem;
  font-size: 0.875rem;
  background: var(--surface-color);
  border: 1px solid var(--border-color);
  border-radius: calc(var(--radius) - 4px);
  color: var(--text-primary);
  transition: border-color 0.2s, box-shadow 0.2s;
  font-family: inherit;
}

.action-widget-input:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 2px hsla(262, 83%, 58%, 0.2);
}

.action-widget-input::placeholder {
  color: var(--text-secondary);
  opacity: 0.7;
}

textarea.action-widget-input {
  resize: vertical;
  min-height: 60px;
}

select.action-widget-input {
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%239ca3af' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  padding-right: 2rem;
}

.action-widget-buttons {
  display: flex;
  gap: 0.5rem;
  justify-content: flex-end;
  margin-top: 0.5rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border-color);
}

.action-widget-btn {
  padding: 0.5rem 1rem;
  font-size: 0.8rem;
  font-weight: 500;
  border-radius: calc(var(--radius) - 4px);
  cursor: pointer;
  transition: all 0.2s;
  border: none;
}

.action-widget-btn.cancel {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border-color);
}

.action-widget-btn.cancel:hover {
  background: var(--surface-color);
  color: var(--text-primary);
}

.action-widget-btn.submit {
  background: var(--primary-color);
  color: white;
}

.action-widget-btn.submit:hover {
  background: var(--primary-hover);
}

@media (max-width: 600px) {
  .action-widget {
    max-width: 100%;
  }

  .action-widget-buttons {
    flex-direction: column-reverse;
  }

  .action-widget-btn {
    width: 100%;
    justify-content: center;
  }
}

/* Statistics View Styles */
.statistics-view {
  padding: 0;
  max-width: 1200px;
  margin: 0 auto;
  height: 100%;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.statistics-view .view-header {
  flex-shrink: 0;
}

.stats-loading,
.stats-content,
.stats-error {
  padding: 1.5rem;
}

.stats-header h2 {
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 1.5rem;
}

.stats-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 3rem;
  color: var(--text-secondary);
}

.stats-loading .loading-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--border-color);
  border-top-color: var(--primary-color);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin-bottom: 1rem;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.stats-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 1rem;
  margin-bottom: 2rem;
}

.stat-card {
  background: var(--surface-elevated);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 1.25rem;
  text-align: center;
}

.stat-value {
  font-size: 2rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.2;
}

.stat-label {
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-top: 0.25rem;
}

.stat-label.danger {
  color: var(--danger-color);
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 1rem;
}

.project-stat-card {
  background: var(--surface-elevated);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 1rem;
}

.project-stat-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border-color);
}

.project-stat-header h4 {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 55%;
}

.project-stat-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.report-link {
  text-decoration: none;
  font-size: 1rem;
  opacity: 0.6;
  transition: opacity 0.2s, transform 0.2s;
}

.report-link:hover {
  opacity: 1;
  transform: scale(1.15);
}

.health-badge {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
}

.health-badge.good {
  background: hsla(142, 76%, 36%, 0.2);
  color: var(--success-color);
}

.health-badge.warning {
  background: hsla(38, 92%, 50%, 0.2);
  color: var(--warning-color);
}

.health-badge.danger {
  background: hsla(0, 84%, 60%, 0.2);
  color: var(--danger-color);
}

.project-stat-metrics {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.5rem;
  text-align: center;
}

.metric {
  display: flex;
  flex-direction: column;
}

.metric-value {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text-primary);
}

.metric-label {
  font-size: 0.7rem;
  color: var(--text-secondary);
}

.metric.danger .metric-value {
  color: var(--danger-color);
}

.project-budget-bar {
  margin-top: 1rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border-color);
}

.budget-label {
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin-bottom: 0.5rem;
}

.budget-track {
  height: 6px;
  background: var(--surface-color);
  border-radius: 3px;
  overflow: hidden;
}

.budget-fill {
  height: 100%;
  background: var(--success-color);
  border-radius: 3px;
  transition: width 0.3s ease;
}

.budget-fill.warning {
  background: var(--warning-color);
}

.budget-fill.over {
  background: var(--danger-color);
}

.stats-error {
  text-align: center;
  padding: 3rem;
  color: var(--text-secondary);
}

.no-data {
  text-align: center;
  color: var(--text-secondary);
  padding: 2rem;
}

@media (max-width: 600px) {
  .statistics-view {
    padding: 1rem;
  }

  .stats-summary {
    grid-template-columns: repeat(2, 1fr);
  }

  .project-stat-metrics {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
  }
}
/* Availability Required Modal */
.availability-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  backdrop-filter: blur(4px);
}

.availability-modal {
  background: var(--surface-elevated, #1a1a1a);
  border-radius: 12px;
  max-width: 420px;
  width: 90%;
  padding: 1.5rem;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
  border: 1px solid var(--border-color, #333);
}

.availability-modal-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.availability-modal-icon {
  font-size: 1.5rem;
}

.availability-modal-header h3 {
  margin: 0;
  font-size: 1.25rem;
  color: var(--text-primary, #fff);
}

.availability-modal-body {
  margin-bottom: 1.5rem;
}

.availability-modal-body p {
  margin: 0;
  color: var(--text-secondary, #aaa);
  line-height: 1.6;
}

.availability-modal-body strong {
  color: var(--warning-color, #f59e0b);
}

.availability-modal-actions {
  display: flex;
  gap: 0.75rem;
  justify-content: flex-end;
}

.availability-modal-close {
  padding: 0.5rem 1rem;
  border: 1px solid var(--border-color, #444);
  background: transparent;
  color: var(--text-secondary, #aaa);
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s;
}

.availability-modal-close:hover {
  background: var(--surface-color, #222);
  color: var(--text-primary, #fff);
}

.availability-modal-settings {
  padding: 0.5rem 1rem;
  background: var(--primary-color, #3b82f6);
  color: white;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 500;
  transition: all 0.2s;
}

.availability-modal-settings:hover {
  background: var(--primary-hover, #2563eb);
}

/* ==========================================
   KANBAN BOARD STYLES
   ========================================== */

.kanban-view {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  background: var(--bg-color);
  padding: 0;
}

.kanban-view .view-header {
  flex-shrink: 0;
}

.kanban-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 1rem;
  overflow: visible;
}

.kanban-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 0.5rem 1rem;
  flex-wrap: wrap;
  gap: 0.75rem;
  overflow: visible;
  z-index: 10;
}

.kanban-header h2 {
  color: var(--text-primary);
  font-size: 1.25rem;
  margin: 0;
}

.kanban-controls {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  flex-wrap: wrap;
  overflow: visible;
}

.kanban-search {
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  background: var(--surface-color);
  color: var(--text-primary);
  font-size: 0.875rem;
  min-width: 180px;
}

.kanban-search:focus {
  outline: none;
  border-color: var(--primary-color);
}

.kanban-profile-select {
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  background: var(--surface-color);
  color: var(--text-primary);
  font-size: 0.875rem;
  min-width: 150px;
  cursor: pointer;
}

.kanban-profile-select:focus {
  outline: none;
  border-color: var(--primary-color);
}

.kanban-filter {
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  background: var(--surface-color);
  color: var(--text-primary);
  font-size: 0.875rem;
  max-width: 200px;
}

.kanban-refresh-btn {
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  background: var(--surface-color);
  color: var(--text-primary);
  cursor: pointer;
  transition: all 0.2s;
}

.kanban-refresh-btn:hover {
  background: var(--surface-elevated);
  border-color: var(--primary-color);
}

.kanban-multiselect {
  position: relative;
}

.kanban-multiselect-btn {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  background: var(--surface-color);
  color: var(--text-primary);
  font-size: 0.875rem;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

.kanban-multiselect-btn:hover {
  border-color: var(--primary-color);
}

.kanban-multiselect.open .kanban-multiselect-btn {
  border-color: var(--primary-color);
  background: var(--surface-elevated);
}

.filter-count {
  color: var(--primary-color);
  font-weight: 600;
  font-size: 0.75rem;
}

.filter-arrow {
  font-size: 0.625rem;
  color: var(--text-secondary);
  transition: transform 0.2s;
}

.kanban-multiselect.open .filter-arrow {
  transform: rotate(180deg);
}

.kanban-multiselect-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  min-width: 200px;
  max-height: 280px;
  overflow-y: auto;
  background: var(--surface-elevated);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
  z-index: 100;
  padding: 0.5rem;
}

.kanban-multiselect.open .kanban-multiselect-dropdown {
  display: block;
}

.kanban-filter-option {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.875rem;
  color: var(--text-primary);
  transition: background 0.15s;
}

.kanban-filter-option:hover {
  background: var(--surface-color);
}

.kanban-filter-option input[type="checkbox"] {
  accent-color: var(--primary-color);
  width: 16px;
  height: 16px;
  cursor: pointer;
}

.priority-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.no-options {
  color: var(--text-secondary);
  font-size: 0.875rem;
  padding: 0.5rem;
}

.kanban-loading,
.kanban-error {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 1;
  gap: 1rem;
  color: var(--text-secondary);
  padding: 1rem;
}

.kanban-error button {
  padding: 0.5rem 1rem;
  background: var(--primary-color);
  color: white;
  border: none;
  border-radius: 6px;
  cursor: pointer;
}

.kanban-board {
  display: flex;
  gap: 1rem;
  flex: 1;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 1rem;
  padding-bottom: 0.5rem;
  -webkit-overflow-scrolling: touch;
}

.kanban-column {
  min-width: 280px;
  max-width: 320px;
  flex: 1;
  display: flex;
  flex-direction: column;
  background: var(--surface-color);
  border-radius: 8px;
  overflow: hidden;
}

.kanban-column-header {
  padding: 0.75rem 1rem;
  background: var(--surface-elevated);
  border-top: 3px solid #6b7280;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.kanban-column-title {
  font-weight: 600;
  color: var(--text-primary);
  font-size: 0.875rem;
}

.kanban-column-count {
  background: var(--border-color);
  color: var(--text-secondary);
  padding: 0.125rem 0.5rem;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 500;
}

.kanban-column-cards {
  flex: 1;
  overflow-y: auto;
  padding: 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  min-height: 100px;
}

.kanban-card {
  background: var(--surface-elevated);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  padding: 0.75rem;
  cursor: grab;
  transition: all 0.2s;
  user-select: none;
}

.kanban-card:hover {
  border-color: var(--primary-color);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.kanban-card:active {
  cursor: grabbing;
}

.kanban-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
}

.kanban-card-id {
  font-size: 0.75rem;
  color: var(--primary-color);
  font-family: monospace;
  text-decoration: none;
  cursor: pointer;
}

.kanban-card-id:hover {
  text-decoration: underline;
  color: var(--primary-hover);
}

.kanban-card-priority {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.kanban-card-title {
  font-size: 0.875rem;
  color: var(--text-primary);
  line-height: 1.4;
  margin-bottom: 0.5rem;
  word-break: break-word;
}

.kanban-card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.kanban-card-project {
  background: var(--border-color);
  padding: 0.125rem 0.5rem;
  border-radius: 4px;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.kanban-card-assignee {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.kanban-card-due {
  margin-top: 0.5rem;
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.kanban-card-due.overdue {
  color: var(--danger-color);
  font-weight: 500;
}

/* Drag and drop states */
.kanban-card-ghost {
  opacity: 0.4;
  background: var(--primary-color);
}

.kanban-card-chosen {
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
  transform: rotate(2deg);
}

.kanban-card-drag {
  opacity: 1;
}

.kanban-card-saving {
  opacity: 0.7;
  pointer-events: none;
  position: relative;
}

.kanban-card-saving::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 16px;
  height: 16px;
  margin: -8px 0 0 -8px;
  border: 2px solid var(--primary-color);
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.kanban-card-error {
  border-color: var(--danger-color) !important;
  background: rgba(239, 68, 68, 0.1) !important;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Mobile responsive */
@media (max-width: 768px) {
  .kanban-view {
    padding: 0.5rem;
  }

  .kanban-header {
    padding: 0 0 0.75rem;
  }

  .kanban-header h2 {
    font-size: 1rem;
  }

  .kanban-controls {
    width: 100%;
  }

  .kanban-search {
    flex: 1;
    min-width: 120px;
  }

  .kanban-filter {
    flex: 1;
    max-width: none;
  }

  /* Responsive multi-select filters */
  .kanban-view .view-header-right {
    flex-wrap: wrap;
    gap: 0.375rem;
  }

  .kanban-multiselect-btn {
    padding: 0.375rem 0.5rem;
    font-size: 0.75rem;
  }

  .kanban-multiselect-btn .filter-arrow {
    display: none;
  }

  .kanban-board {
    gap: 0.75rem;
  }

  .kanban-column {
    min-width: 260px;
  }

  .kanban-card {
    padding: 0.625rem;
  }

  .kanban-card-title {
    font-size: 0.8125rem;
  }
}

/* Touch-friendly drag on mobile */
@media (pointer: coarse) {
  .kanban-card {
    touch-action: none;
    padding: 1rem 0.75rem;
  }
}

/* Kanban Toast Notifications */
.kanban-toast {
  position: fixed;
  bottom: 100px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: var(--surface-elevated);
  color: var(--text-primary);
  padding: 0.75rem 1.25rem;
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
  z-index: 10000;
  opacity: 0;
  transition: all 0.3s ease;
  pointer-events: none;
  border: 1px solid var(--border-color);
}

.kanban-toast-show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.kanban-toast-error {
  border-color: var(--danger-color);
  background: rgba(239, 68, 68, 0.15);
}

.kanban-toast-success {
  border-color: var(--success-color);
  background: rgba(34, 197, 94, 0.15);
}

/* Kanban Offline Indicator */
.kanban-offline-indicator {
  background: var(--warning-color);
  color: #000;
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 500;
}

/* Kanban Card Queued State (offline) */
.kanban-card-queued {
  border-left: 3px solid var(--warning-color);
  position: relative;
}

.kanban-card-queued::before {
  content: '📴';
  position: absolute;
  top: 4px;
  right: 4px;
  font-size: 0.625rem;
}

/* ===========================================
   MOBILE-FIRST AI-FIRST LAYOUT v2.3.86
   =========================================== */

/* Base Layout - Mobile First */
body.mobile-first-layout {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  overflow: hidden;
}

body.mobile-first-layout #app {
  display: flex;
  flex-direction: column;
  height: 100%;
}

body.mobile-first-layout .main-container {
  display: flex;
  flex: 1;
  min-height: 0;
  position: relative;
}

/* Sidebar - Mobile First (uses existing collapsed class pattern) */
body.mobile-first-layout .sidebar {
  width: 260px;
  min-width: 260px;
  background: var(--surface-color);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  transition: width 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 100;
  overflow: hidden;
}

body.mobile-first-layout .sidebar.collapsed {
  width: 60px;
  min-width: 60px;
}

body.mobile-first-layout .sidebar .sidebar-header {
  padding: 0.75rem;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  border-bottom: 1px solid var(--border-color);
  min-height: 56px;
}

body.mobile-first-layout .sidebar.collapsed .sidebar-header {
  justify-content: center;
  padding: 0.5rem;
}

body.mobile-first-layout .sidebar .sidebar-brand-text {
  display: block;
}

body.mobile-first-layout .sidebar.collapsed .sidebar-brand-text {
  display: none;
}

body.mobile-first-layout .sidebar .sidebar-logo {
  width: 32px;
  height: 32px;
}

body.mobile-first-layout .sidebar .btn-label {
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

body.mobile-first-layout .sidebar.collapsed .btn-label {
  display: none;
}

body.mobile-first-layout .sidebar .action-btn,
body.mobile-first-layout .sidebar .view-btn {
  justify-content: flex-start;
  padding: 0.5rem 0.75rem;
}

body.mobile-first-layout .sidebar.collapsed .action-btn,
body.mobile-first-layout .sidebar.collapsed .view-btn {
  justify-content: center;
  padding: 0.625rem;
}

body.mobile-first-layout .sidebar .sidebar-section-header {
  justify-content: space-between;
  padding: 0.5rem 0.5rem;
}

body.mobile-first-layout .sidebar.collapsed .sidebar-section-header {
  justify-content: center;
  padding: 0.375rem;
}

body.mobile-first-layout .sidebar .section-title,
body.mobile-first-layout .sidebar .accordion-chevron {
  display: block;
}

body.mobile-first-layout .sidebar.collapsed .section-title,
body.mobile-first-layout .sidebar.collapsed .accordion-chevron {
  display: none;
}

body.mobile-first-layout .sidebar-toggle {
  display: flex;
}

/* Content Area - Flex grow */
body.mobile-first-layout .content {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  position: relative;
  overflow: hidden;
}

/* Canvas Container */
body.mobile-first-layout .canvas-container {
  flex: 1;
  min-height: 0;
  display: none;
}

body.mobile-first-layout .canvas-container.visible {
  display: flex;
  flex-direction: column;
}

/* Chat Fixed at Bottom */
body.mobile-first-layout .chat-container {
  position: fixed;
  bottom: 0;
  left: 260px;
  right: 0;
  max-height: 60vh;
  background: var(--bg-color);
  border-top: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  z-index: 50;
  transition: left 0.25s cubic-bezier(0.4, 0, 0.2, 1), max-height 0.25s ease;
}

body.mobile-first-layout:has(.sidebar.collapsed) .chat-container {
  left: 60px;
}

body.mobile-first-layout .chat-container .chat-messages {
  flex: 1;
  min-height: 100px;
  max-height: calc(60vh - 80px);
  overflow-y: auto;
}

body.mobile-first-layout .chat-container .chat-input-container {
  flex-shrink: 0;
  padding: 0.75rem;
  background: var(--surface-color);
  border-top: 1px solid var(--border-color);
}

body.mobile-first-layout .chat-container.minimized {
  max-height: 60px;
}

body.mobile-first-layout .chat-container.minimized .chat-messages {
  display: none;
}

/* Chat Toggle for minimize */
body.mobile-first-layout .chat-toggle {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  left: auto;
}

/* Adjust content padding for fixed chat */
body.mobile-first-layout .content {
  padding-bottom: 140px;
}

body.mobile-first-layout .canvas-container.visible ~ .chat-container {
  max-height: 200px;
}

/* Desktop: Sidebar expanded by default - inherits base rules */
@media (min-width: 769px) {
  body.mobile-first-layout .sidebar-toggle {
    display: flex;
  }
}

/* Tablet: Sidebar collapsed by default (60px) */
@media (max-width: 768px) {
  body.mobile-first-layout .sidebar {
    width: 60px;
    min-width: 60px;
  }
  
  body.mobile-first-layout .sidebar .btn-label,
  body.mobile-first-layout .sidebar .sidebar-brand-text,
  body.mobile-first-layout .sidebar .section-title,
  body.mobile-first-layout .sidebar .accordion-chevron {
    display: none;
  }
  
  body.mobile-first-layout .sidebar .action-btn,
  body.mobile-first-layout .sidebar .view-btn {
    justify-content: center;
    padding: 0.625rem;
  }
  
  body.mobile-first-layout .sidebar .sidebar-section-header {
    justify-content: center;
    padding: 0.375rem;
  }
  
  body.mobile-first-layout .sidebar-toggle {
    display: none;
  }
  
  body.mobile-first-layout .chat-container {
    left: 60px;
  }
  
  body.mobile-first-layout .content {
    padding-bottom: 120px;
  }
}

/* Mobile Portrait: Full overlay sidebar (drawer mode) */
@media (max-width: 480px) {
  body.mobile-first-layout .sidebar {
    position: fixed;
    left: -280px;
    top: 0;
    bottom: 0;
    width: 280px;
    min-width: 280px;
    z-index: 200;
    transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  }
  
  body.mobile-first-layout .sidebar.open {
    left: 0;
  }
  
  body.mobile-first-layout .sidebar .btn-label,
  body.mobile-first-layout .sidebar .sidebar-brand-text,
  body.mobile-first-layout .sidebar .section-title,
  body.mobile-first-layout .sidebar .accordion-chevron {
    display: block;
  }
  
  body.mobile-first-layout .sidebar .action-btn,
  body.mobile-first-layout .sidebar .view-btn {
    justify-content: flex-start;
    padding: 0.5rem 0.75rem;
  }
  
  body.mobile-first-layout .sidebar .sidebar-section-header {
    justify-content: space-between;
    padding: 0.5rem 0.5rem;
  }
  
  body.mobile-first-layout .sidebar-overlay.active {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 199;
  }
  
  body.mobile-first-layout .chat-container {
    left: 0;
    right: 0;
  }
  
  body.mobile-first-layout .chat-container .chat-messages {
    max-height: calc(50vh - 80px);
  }
}

/* ============================================
   TWO-COLUMN LAYOUT (v2.3.93)
   Sidebar on left, chat panel fills remaining space
   Fixed input bar always visible at bottom
   ============================================ */

body.right-chat-layout {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

body.right-chat-layout .main-container {
  flex: 1;
  display: flex;
  flex-direction: row;
  min-height: 0;
  overflow: hidden;
}

/* Sidebar stays on left */
body.right-chat-layout .sidebar {
  flex-shrink: 0;
  height: 100%;
  z-index: 100;
}

/* Content area fills remaining space - full width */
body.right-chat-layout .content {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  width: 100%;
  max-width: none;
  position: relative;
  overflow: hidden;
  height: calc(100vh - 56px); /* Full height minus header only - input bar floats on top */
}

/* Canvas container - hidden by default, shown when visible */
body.right-chat-layout .canvas-container {
  display: none;
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 150;
  background: var(--surface-color);
}

body.right-chat-layout .canvas-container.visible {
  display: flex !important;
  flex-direction: column;
}

/* Hide pull tab - not needed in two-column layout */
body.right-chat-layout .chat-pull-tab {
  display: none !important;
}

/* Chat panel fills remaining space within content - full width */
body.right-chat-layout .chat-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: var(--bg-color);
  min-height: 0;
  width: 100%;
  max-width: none;
  overflow: hidden;
  /* Remove fixed positioning - use flex layout */
  position: static;
  border-left: none;
}

body.right-chat-layout .chat-container .chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 1rem 2rem;
  padding-bottom: 120px; /* Space for fixed input bar */
  min-height: 0;
  width: 100%;
  max-width: none;
}

/* Hide the input container inside chat - we use fixed input bar instead */
body.right-chat-layout .chat-container .chat-input-container {
  display: none !important;
}

/* Hide chat toggle button - not needed in two-column layout */
body.right-chat-layout .chat-toggle {
  display: none !important;
}

/* FIXED INPUT BAR - floating centered at bottom */
body.right-chat-layout .fixed-chat-input {
  position: fixed;
  bottom: 1rem;
  max-width: 800px;
  background: color-mix(in srgb, var(--surface-color) 90%, transparent);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border-color);
  border-radius: 1rem;
  padding: 0.75rem 1rem;
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
  transition: left 0.25s ease, right 0.25s ease, width 0.25s ease;
}

/* Adjust position for collapsed sidebar - center in available space */
body.right-chat-layout:has(.sidebar.collapsed) .fixed-chat-input {
  left: calc(60px + 1rem);
  right: 1rem;
  width: calc(100% - 60px - 2rem);
  transform: none;
  margin-left: auto;
  margin-right: auto;
}

/* Adjust position for expanded sidebar - center in available space */
body.right-chat-layout:has(.sidebar:not(.collapsed)) .fixed-chat-input {
  left: calc(260px + 1rem);
  right: 1rem;
  width: calc(100% - 260px - 2rem);
  transform: none;
  margin-left: auto;
  margin-right: auto;
}

/* Input row - text input with send button */
body.right-chat-layout .fixed-chat-input .input-row {
  display: flex;
  align-items: flex-end;
  gap: 0.5rem;
}

body.right-chat-layout .fixed-chat-input textarea {
  flex: 1;
  min-height: 40px;
  max-height: 120px;
  padding: 0.625rem 1rem;
  border: 1px solid var(--border-color);
  border-radius: 1.25rem;
  background: var(--bg-color);
  color: var(--text-primary);
  font-size: 0.9375rem;
  resize: none;
  outline: none;
  transition: border-color 0.15s ease;
}

body.right-chat-layout .fixed-chat-input textarea:focus {
  border-color: var(--primary-color);
}

body.right-chat-layout .fixed-chat-input .send-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--primary-color);
  border: none;
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s ease;
}

body.right-chat-layout .fixed-chat-input .send-btn:hover {
  background: var(--primary-hover);
}

/* Actions row - half-height row with icons */
body.right-chat-layout .fixed-chat-input .actions-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

body.right-chat-layout .fixed-chat-input .action-btn-small {
  padding: 0.375rem 0.625rem;
  background: var(--surface-elevated);
  border: 1px solid var(--border-color);
  border-radius: 0.5rem;
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.25rem;
  font-size: 0.75rem;
  transition: all 0.15s ease;
}

body.right-chat-layout .fixed-chat-input .action-btn-small:hover {
  background: var(--primary-color);
  color: white;
  border-color: var(--primary-color);
}

body.right-chat-layout .fixed-chat-input .action-btn-small svg {
  width: 14px;
  height: 14px;
}

/* AI Mode selector in actions row */
body.right-chat-layout .fixed-chat-input .ai-mode-selector {
  display: flex;
  align-items: center;
}

body.right-chat-layout .fixed-chat-input .ai-mode-selector select {
  padding: 0.375rem 0.5rem;
  font-size: 0.75rem;
  border-radius: 0.5rem;
  background: var(--surface-elevated);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  cursor: pointer;
}

/* Context indicator */
body.right-chat-layout .fixed-chat-input .context-indicator {
  margin-left: auto;
  font-size: 0.6875rem;
  color: var(--text-tertiary);
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

body.right-chat-layout .fixed-chat-input .context-indicator .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--success-color);
}


/* Desktop: Two-column layout - chat fills remaining space */
@media (min-width: 769px) {
  body.right-chat-layout .chat-container {
    width: 100%;
    max-width: none;
  }
  
  body.right-chat-layout .content {
    margin-right: 0;
  }
}

/* Intermediate screens: 768px-1024px - ensure proper spacing */
@media (min-width: 481px) and (max-width: 1024px) {
  body.right-chat-layout .chat-container .chat-messages {
    padding-bottom: 140px;
  }
}

/* Mobile & Tablet (below 768px): Sidebar as overlay drawer */
@media (max-width: 767px) {
  body.right-chat-layout .sidebar {
    position: fixed;
    left: -280px;
    width: 280px;
    z-index: 200;
    transition: left 0.3s ease;
  }
  
  body.right-chat-layout .sidebar.open {
    left: 0;
  }
  
  /* Hide labels by default */
  body.right-chat-layout .sidebar .btn-label,
  body.right-chat-layout .sidebar .sidebar-brand-text,
  body.right-chat-layout .sidebar .section-title {
    display: none;
  }
  
  /* Show labels when sidebar is open */
  body.right-chat-layout .sidebar.open .btn-label,
  body.right-chat-layout .sidebar.open .sidebar-brand-text,
  body.right-chat-layout .sidebar.open .section-title {
    display: inline !important;
  }
  
  body.right-chat-layout .sidebar.open .action-btn,
  body.right-chat-layout .sidebar.open .view-btn {
    justify-content: flex-start;
    padding: 0.5rem 0.75rem;
  }
  
  body.right-chat-layout .chat-container {
    width: 100%;
    max-width: 100%;
  }
  
  /* Input bar: full width centered */
  body.right-chat-layout .fixed-chat-input,
  body.right-chat-layout:has(.sidebar.collapsed) .fixed-chat-input,
  body.right-chat-layout:has(.sidebar:not(.collapsed)) .fixed-chat-input {
    left: 0.5rem !important;
    right: 0.5rem !important;
    width: auto !important;
    max-width: none !important;
    transform: none !important;
    padding: 0.5rem;
    margin-left: 0 !important;
    margin-right: 0 !important;
  }
  
  /* Stack input row and actions row vertically */
  body.right-chat-layout .fixed-chat-input .input-row {
    margin-bottom: 0.25rem;
  }
  
  body.right-chat-layout .fixed-chat-input .actions-row {
    padding-top: 0.25rem;
    border-top: 1px solid var(--border-color);
    overflow-x: auto;
    flex-wrap: nowrap;
    -webkit-overflow-scrolling: touch;
  }
  
  body.right-chat-layout .fixed-chat-input .action-btn-small {
    flex-shrink: 0;
  }
  
  /* Adjust content padding */
  body.right-chat-layout .content {
    padding-bottom: 110px;
  }
}
