:root {
  --primary: #0e2233;
  --primary-dark: #0a1723;
  --primary-light: #2b4152;
  --secondary: #0e6a62;
  --secondary-dark: #0b4f49;
  --primary-rgb: 14, 34, 51;
  --secondary-rgb: 14, 106, 98;
  --info-rgb: 36, 104, 242;

  --font-sans: "Manrope", "Inter", "Helvetica Neue", Arial, sans-serif;
  --font-mono: "Space Mono", "SFMono-Regular", Consolas, "Liberation Mono", monospace;

  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-7: 32px;
  --space-8: 40px;

  --text-xs: 12px;
  --text-sm: 14px;
  --text-md: 16px;
  --text-lg: 18px;
  --text-xl: 22px;
  --text-2xl: 28px;
  
  --success: #0e6a62;
  --warning: #d97706;
  --error: #dc2626;
  --info: #2468f2;
  
  --bg-primary: #ffffff;
  --bg-secondary: #f7f4ef;
  --bg-tertiary: #eef2f6;
  --bg-overlay: rgba(0, 0, 0, 0.5);
  
  --text-primary: #0e2233;
  --text-secondary: #4b5a66;
  --text-tertiary: #6b7782;
  --text-inverse: #ffffff;
  
  --border: #d6dee6;
  --border-light: #eef2f6;
  --border-dark: #c7d2dc;
  
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow: 0 4px 6px rgba(0, 0, 0, 0.07);
  --shadow-md: 0 10px 15px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 20px 25px rgba(0, 0, 0, 0.15);
  
  --radius: 12px;
  --radius-sm: 8px;
  --radius-lg: 16px;
  --radius-full: 9999px;
  
  --nav-height: 60px;
  --header-height: 56px;
  
  --transition: 200ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: 300ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* Dark Theme */
.dark-theme {
  --bg-primary: #101a24;
  --bg-secondary: #0b1219;
  --bg-tertiary: #16212c;
  --bg-overlay: rgba(0, 0, 0, 0.7);

  --text-primary: #f1f5f9;
  --text-secondary: #b6c2cc;
  --text-tertiary: #82909c;
  --text-inverse: #ffffff;

  --border: #223243;
  --border-light: #16212c;
  --border-dark: #2d3f52;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow: 0 4px 6px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 10px 15px rgba(0, 0, 0, 0.5);
  --shadow-lg: 0 20px 25px rgba(0, 0, 0, 0.6);
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

body {
  margin: 0;
  padding: 0;
  font-family: var(--font-sans);
  font-size: var(--text-md);
  line-height: 1.5;
  color: var(--text-primary);
  background: var(--bg-secondary);
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  transition: background-color var(--transition), color var(--transition);
}

.hidden {
  display: none !important;
}

.visually-hidden-input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
  width: 1px;
  height: 1px;
}

.loading-indicator {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-4);
  border-radius: var(--radius);
  background: var(--bg-primary);
  border: 1px dashed var(--border);
  color: var(--text-secondary);
  font-size: var(--text-sm);
  justify-content: center;
}

.loading-spinner {
  width: 16px;
  height: 16px;
  border: 2px solid var(--border);
  border-top-color: var(--primary);
  border-radius: var(--radius-full);
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

button {
  font-family: inherit;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
}

input, textarea, select {
  font-family: inherit;
  font-size: 16px;
}

/* Auth Section */
.auth-section {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background:
    radial-gradient(640px 420px at 95% 10%, rgba(var(--info-rgb), 0.14), transparent 70%),
    radial-gradient(560px 360px at 4% 30%, rgba(var(--secondary-rgb), 0.12), transparent 72%),
    var(--bg-secondary);
}

.dark-theme .auth-section {
  background:
    radial-gradient(620px 420px at 90% 8%, rgba(var(--info-rgb), 0.2), transparent 72%),
    radial-gradient(560px 360px at 10% 18%, rgba(var(--secondary-rgb), 0.16), transparent 72%),
    var(--bg-secondary);
}

.auth-container {
  width: 100%;
  max-width: 400px;
}

.auth-header {
  text-align: center;
  margin-bottom: 32px;
  color: var(--text-primary);
}

.auth-logo {
  width: 200px;
  height: 64px;
  margin: 0 auto 16px;
  display: flex;
  align-items: center;
  justify-content: center;

}

.auth-logo img {
  width: 300px;
  height: 300px;
  object-fit: contain;
}

.auth-header h1 {
  margin: 0 0 8px;
  font-size: 28px;
  font-weight: 700;
}

.auth-header p {
  margin: 0;
  color: var(--text-secondary);
  font-size: 15px;
}

.auth-card {
  background: var(--bg-primary);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  padding: 24px;
  box-shadow: 0 18px 36px rgba(var(--primary-rgb), 0.12);
}

.dark-theme .auth-card {
  border-color: var(--border-dark);
  box-shadow: 0 20px 42px rgba(0, 0, 0, 0.45);
}

.auth-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 24px;
  background: var(--bg-secondary);
  padding: 4px;
  border-radius: var(--radius-sm);
}

.auth-tab {
  flex: 1;
  padding: 10px;
  border: none;
  background: transparent;
  border-radius: var(--radius-sm);
  font-weight: 500;
  color: var(--text-secondary);
  transition: var(--transition);
}

.auth-tab.active {
  background: var(--bg-primary);
  color: var(--text-primary);
  box-shadow: var(--shadow-sm);
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.form-group label {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
}

.form-helper {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 4px;
  display: block;
}

.form-helper a {
  color: var(--primary);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.form-helper a:focus-visible {
  outline: 2px solid rgba(var(--primary-rgb), 0.4);
  outline-offset: 2px;
  border-radius: 2px;
}

.model-typeahead-status {
  min-height: 1.1em;
}

.model-typeahead-status--error {
  color: var(--error);
}

.approval-toggle-inline {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
}

.approval-role-list {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.approval-role-option {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  background: var(--bg-secondary);
  font-size: 13px;
  color: var(--text-primary);
}

.approval-role-option input {
  accent-color: var(--primary);
}

/* Marketing / SEO Sections */
.seo-hero {
  background: var(--bg-primary);
  padding: 80px 24px 40px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 32px;
  align-items: center;
  border-bottom: 1px solid var(--border);
}

.seo-hero__content {
  max-width: 640px;
}

.seo-hero__eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 14px;
  font-weight: 600;
  color: var(--secondary);
  margin: 0 0 12px;
}

.seo-hero__lede {
  font-size: 18px;
  margin: 16px 0;
  color: var(--text-secondary);
}

.seo-hero__list {
  list-style: disc;
  padding-left: 18px;
  margin: 0 0 24px;
  color: var(--text-secondary);
}

.seo-hero__list li + li {
  margin-top: 10px;
}

.seo-hero__cta {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
}

.seo-hero__link {
  text-decoration: none;
  display: inline-flex;
  align-items: center;
}

.seo-hero__metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 16px;
}

.seo-hero__metrics article {
  background: var(--bg-secondary);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow-sm);
}

.metric {
  font-size: 36px;
  font-weight: 700;
  margin: 0;
}

.caption {
  margin: 8px 0 0;
  color: var(--text-secondary);
}

.seo-proof {
  background: var(--bg-secondary);
  padding: 40px 24px;
}

.seo-proof__grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 20px;
}

.seo-proof__grid article {
  background: var(--bg-primary);
  padding: 20px;
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

.seo-feature-grid {
  padding: 40px 24px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 20px;
  background: var(--bg-primary);
}

.feature-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  background: var(--bg-secondary);
  box-shadow: var(--shadow-sm);
}

.seo-faq {
  padding: 40px 24px 60px;
  background: var(--bg-secondary);
  border-top: 1px solid var(--border);
}

.seo-faq h2 {
  margin-top: 0;
}

.seo-faq details {
  background: var(--bg-primary);
  border-radius: var(--radius);
  padding: 16px 20px;
  margin-bottom: 12px;
  border: 1px solid var(--border);
}

.seo-faq summary {
  cursor: pointer;
  font-weight: 600;
}

.seo-faq p {
  margin: 12px 0 0;
  color: var(--text-secondary);
}

body.app-active #seo-hero,
body.app-active #seo-proof,
body.app-active #features,
body.app-active #faq {
  display: none;
}

@media (max-width: 768px) {
  .seo-hero {
    padding: 60px 16px 24px;
  }

  .seo-hero__cta {
    flex-direction: column;
    align-items: stretch;
  }
}

.form-group input,
.form-group select,
.form-group textarea {
  padding: 12px 16px;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-primary);
  color: var(--text-primary);
  transition: var(--transition);
  outline: none;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(var(--info-rgb), 0.15);
}

.form-group input[aria-invalid="true"],
.form-group select[aria-invalid="true"],
.form-group textarea[aria-invalid="true"] {
  border-color: var(--error);
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.15);
}

.dark-theme .form-group input:focus,
.dark-theme .form-group select:focus,
.dark-theme .form-group textarea:focus {
  box-shadow: 0 0 0 3px rgba(var(--info-rgb), 0.25);
}

.form-group textarea {
  resize: vertical;
  min-height: 100px;
}

.input-error {
  border-color: var(--error) !important;
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.15);
}

.btn-primary {
  padding: 14px 24px;
  border: none;
  border-radius: var(--radius-sm);
  background: var(--primary);
  color: var(--text-inverse);
  font-weight: 600;
  font-size: 15px;
  transition: var(--transition);
  box-shadow: var(--shadow-sm);
}

.auth-form .btn-primary {
  width: 100%;
}

.btn-rollback {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(239, 68, 68, 0.35);
  background: rgba(239, 68, 68, 0.12);
  color: #b91c1c;
  font-weight: 600;
  font-size: 13px;
  transition: var(--transition);
}

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

.btn-rollback:hover {
  border-color: rgba(239, 68, 68, 0.6);
  background: rgba(239, 68, 68, 0.18);
}

.btn-rollback.confirming {
  border-color: rgba(239, 68, 68, 0.9);
  background: rgba(239, 68, 68, 0.28);
}

.btn-rollback:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.btn-primary:active {
  transform: scale(0.98);
  box-shadow: none;
}

.btn-secondary {
  padding: 12px 20px;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-primary);
  color: var(--text-primary);
  font-weight: 500;
  font-size: 14px;
  transition: var(--transition);
}

.btn-secondary:active {
  transform: scale(0.98);
}

.auth-passkey-button {
  width: 100%;
  margin-top: 12px;
}

.btn-danger {
  padding: 14px 24px;
  border: none;
  border-radius: var(--radius-sm);
  background: var(--error);
  color: var(--text-inverse);
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  transition: var(--transition);
}

.btn-danger svg {
  width: 20px;
  height: 20px;
}

.error-message {
  font-size: 13px;
  color: var(--error);
  margin: 0;
  min-height: 18px;
}

.auth-hint {
  font-size: 13px;
  color: var(--text-tertiary);
  margin: 12px 0 0;
  text-align: center;
}

.auth-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 20px 0;
  color: var(--text-tertiary);
  font-size: 13px;
}

.auth-divider::before,
.auth-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

.btn-oauth {
  width: 100%;
  padding: 12px;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-primary);
  color: var(--text-primary);
  font-weight: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: var(--transition);
}

.btn-oauth svg {
  width: 20px;
  height: 20px;
}

.btn-oauth:active {
  transform: scale(0.98);
}

/* Main App Layout */
.app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  min-height: 0;
}

.view {
  display: none;
  flex-direction: column;
  flex: 1;
  overflow: hidden;
  padding-bottom: calc(var(--nav-height) + env(safe-area-inset-bottom, 0px));
  min-height: 0;
}

.view.active {
  display: flex;
}

.view-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  background: var(--bg-primary);
  border-bottom: 1px solid var(--border);
  min-height: var(--header-height);
}

.view-header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.view-logo {
  width: 45px;
  height: 45px;
  object-fit: contain;
}

.view-header h1 {
  margin: 0;
  font-size: 24px;
  font-weight: 700;
}

.btn-icon {
  width: 40px;
  height: 40px;
  padding: 0;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}

.btn-icon:active {
  background: var(--bg-secondary);
}

.btn-icon svg {
  width: 24px;
  height: 24px;
}

/* Projects View */
.projects-container {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.projects-list {
  padding: 12px;
  display: grid;
  gap: 12px;
}

.project-card {
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.project-card:active {
  transform: scale(0.98);
  box-shadow: var(--shadow);
}

.project-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.project-card h3 {
  margin: 0;
  font-size: 17px;
  font-weight: 600;
  color: var(--text-primary);
}

.project-card-badge {
  padding: 4px 8px;
  border-radius: 4px;
  background: var(--bg-secondary);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--text-secondary);
}

.project-card-badge.owner,
.member-role-badge.owner {
  background: rgba(var(--info-rgb), 0.16);
  color: #1d4ed8;
}

.project-card-badge.admin,
.member-role-badge.admin {
  background: rgba(var(--secondary-rgb), 0.16);
  color: var(--secondary-dark);
}

.project-card-badge.member,
.member-role-badge.member {
  background: var(--bg-secondary);
  color: var(--text-secondary);
}

.project-card-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  font-size: 13px;
  color: var(--text-secondary);
}

.project-framework-badge {
  padding: 2px 8px;
  border-radius: 9999px;
  background: rgba(var(--info-rgb), 0.12);
  color: #1e3a8a;
  font-size: 11px;
  font-weight: 600;
}

.project-card-meta svg {
  width: 14px;
  height: 14px;
}

.project-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 8px;
  border-top: 1px solid var(--border-light);
  font-size: 12px;
  color: var(--text-tertiary);
}

.quick-join {
  padding: 20px;
  background: var(--bg-primary);
  border-top: 1px solid var(--border);
}

.input-with-button {
  display: flex;
  gap: 8px;
}

.input-with-button input {
  flex: 1;
}

/* Chat View */
#view-chat {
  min-height: 0;
}

.chat-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: var(--bg-primary);
  border-bottom: 1px solid var(--border);
  min-height: var(--header-height);
  flex-shrink: 0;
}

.chat-logo {
  width: 28px;
  height: 28px;
  object-fit: contain;
  flex-shrink: 0;
}

.chat-header-info {
  flex: 1;
  min-width: 0;
}

.chat-header-info h2 {
  margin: 0;
  font-size: 17px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-header-info p {
  margin: 0;
  font-size: 13px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.settings-usage-panel {
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-secondary);
}

.usage-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.usage-item {
  min-width: 0;
}

.usage-item strong {
  display: block;
  font-size: 14px;
  line-height: 1.2;
  color: var(--text-primary);
}

.usage-label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--text-tertiary);
}

.usage-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 8px;
  font-size: 13px;
  color: var(--text-secondary);
}

.usage-empty,
.usage-note {
  margin: 0;
  font-size: 13px;
  color: var(--text-secondary);
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 0;
}

.chat-placeholder {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  color: var(--text-tertiary);
  text-align: center;
  padding: 40px 20px;
}

.chat-placeholder svg {
  width: 48px;
  height: 48px;
  opacity: 0.5;
}

.chat-placeholder p {
  margin: 0;
  font-size: 16px;
  font-weight: 500;
  color: var(--text-secondary);
}

.chat-placeholder span {
  font-size: 14px;
}

.message {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-width: 85%;
  animation: messageSlide 0.2s ease-out;
  margin-bottom: 4px;
}

@keyframes messageSlide {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.user-message {
  align-self: flex-end;
  align-items: flex-end;
}

.assistant-message {
  align-self: flex-start;
  align-items: flex-start;
}

.message-bubble {
  padding: 12px 16px;
  border-radius: var(--radius);
  word-wrap: break-word;
  word-break: break-word;
  white-space: pre-wrap;
  line-height: 1.5;
  font-size: 15px;
  min-height: 20px;
}

.user-message .message-bubble {
  background: var(--primary);
  color: var(--text-inverse);
  border-bottom-right-radius: 4px;
}

.assistant-message .message-bubble {
  background: var(--bg-primary);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
}

.assistant-message.message--error .message-bubble {
  background: #fef2f2;
  border-color: #fecaca;
  color: #991b1b;
}

.dark-theme .assistant-message.message--error .message-bubble {
  background: #450a0a;
  border-color: #7f1d1d;
  color: #fca5a5;
}

.assistant-message.message--status .message-bubble {
  background: rgba(var(--info-rgb), 0.08);
  border-color: rgba(var(--info-rgb), 0.35);
  color: #1d4ed8;
}

.dark-theme .assistant-message.message--status .message-bubble {
  background: rgba(var(--info-rgb), 0.2);
  border-color: rgba(var(--info-rgb), 0.45);
  color: #bfdbfe;
}

.message-deployment {
  padding: 0 4px;
  margin-top: 2px;
}

.assistant-message .message-deployment .deployment-chip {
  font-size: 10px;
}

.message-time {
  font-size: 11px;
  color: var(--text-tertiary);
  padding: 0 4px;
  margin-top: 2px;
}

.chat-history-notice {
  margin: 12px 0;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  font-size: 12px;
  text-align: center;
}

.typing-indicator {
  display: none;
  align-items: center;
  gap: 8px;
  padding: 16px 20px;
  font-size: 14px;
  color: var(--text-secondary);
  flex-shrink: 0;
}

.typing-indicator.visible {
  display: flex;
}

.typing-dots {
  display: flex;
  gap: 4px;
}

.typing-dots span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-tertiary);
  animation: typing 1.4s infinite;
}

.typing-dots span:nth-child(2) {
  animation-delay: 0.2s;
}

.typing-dots span:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes typing {
  0%, 60%, 100% {
    opacity: 0.3;
    transform: scale(0.8);
  }
  30% {
    opacity: 1;
    transform: scale(1);
  }
}

.chat-toolbar {
  display: flex;
  gap: 8px;
  padding: 12px 16px;
  background: var(--bg-primary);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.toolbar-pages {
  flex: 1;
}

.toolbar-pages select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-primary);
  color: var(--text-primary);
  font-size: 14px;
}

.toolbar-actions {
  display: flex;
  gap: 8px;
}

.btn-tool {
  width: 40px;
  height: 40px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-primary);
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}

.btn-tool:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-tool:not(:disabled):active {
  background: var(--bg-secondary);
  transform: scale(0.95);
}

.btn-tool svg {
  width: 20px;
  height: 20px;
}

.new-page-panel {
  display: none;
  padding: 16px;
  background: var(--bg-secondary);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.new-page-panel.visible {
  display: block;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.form-actions {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

.form-actions button {
  flex: 1;
}

.chat-attachments {
  padding: 0 16px;
  flex-shrink: 0;
}

.chat-attachments.drag-over,
.chat-input-container.drag-over {
  outline: 1px dashed var(--primary);
  outline-offset: -6px;
  background: rgba(var(--info-rgb), 0.08);
}

.attachment-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.attachment-list.hidden {
  display: none;
}

.upload-dir-selector {
  margin-top: 12px;
  padding: 12px;
  background: var(--bg-secondary);
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.upload-dir-selector label {
  font-size: 0.9em;
  font-weight: 500;
  color: var(--text-primary);
}

.upload-dir-selector select {
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg-primary);
  color: var(--text-primary);
  font-size: 0.9em;
  cursor: pointer;
  transition: border-color 0.2s ease;
}

.upload-dir-selector select:hover {
  border-color: var(--primary);
}

.upload-dir-selector select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(var(--info-rgb), 0.15);
}

.attachment-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.attachment-info {
  flex: 1;
  min-width: 0;
}

.attachment-name {
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.attachment-meta {
  font-size: 12px;
  color: var(--text-secondary);
}

.attachment-remove {
  padding: 6px 12px;
  border: none;
  border-radius: 4px;
  background: var(--error);
  color: var(--text-inverse);
  font-size: 12px;
  font-weight: 500;
}

.command-hint {
  padding: 8px 16px;
  font-size: 13px;
  color: var(--text-secondary);
  min-height: 20px;
  flex-shrink: 0;
}

.command-hint.command-hint--error {
  color: var(--error);
}

.chat-input-container {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 12px 16px;
  background: var(--bg-primary);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.btn-attachment {
  width: 40px;
  height: 40px;
  padding: 0;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition);
  position: relative;
}

.btn-attachment input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.btn-attachment:active {
  background: var(--bg-secondary);
}

.btn-attachment svg {
  width: 22px;
  height: 22px;
}

.btn-attachment.is-disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.chat-input-form {
  flex: 1;
  display: flex;
  align-items: flex-end;
  gap: 8px;
}

.chat-input-form textarea {
  flex: 1;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-primary);
  color: var(--text-primary);
  resize: none;
  min-height: 56px;
  max-height: 120px;
  outline: none;
  transition: var(--transition);
  line-height: 1.5;
}

.chat-input-form textarea:focus {
  border-color: var(--primary);
}

.btn-send {
  width: 40px;
  height: 40px;
  padding: 0;
  border: none;
  border-radius: var(--radius-sm);
  background: var(--primary);
  color: var(--text-inverse);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}

.btn-send:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-send:not(:disabled):active {
  transform: scale(0.95);
}

.btn-send svg {
  width: 20px;
  height: 20px;
}

/* Settings View */
.settings-container {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.settings-section h3 {
  margin: 0 0 16px;
  font-size: 15px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
}

.settings-section h3.settings-section-heading {
  margin: 0;
}

.settings-section-toggle {
  width: 100%;
  border: none;
  background: transparent;
  padding: 0 0 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  text-align: left;
  color: inherit;
  font: inherit;
  letter-spacing: inherit;
  text-transform: inherit;
  cursor: pointer;
}

.settings-section-toggle:focus-visible {
  outline: 2px solid rgba(var(--primary-rgb), 0.45);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

.settings-section-toggle__label {
  flex: 1;
}

.settings-section-toggle__icon {
  font-size: 12px;
  color: var(--text-tertiary);
  transition: transform 0.2s ease;
}

.settings-section--collapsed .settings-section-toggle {
  padding-bottom: 0;
}

.settings-section--collapsed .settings-section-toggle__icon {
  transform: rotate(-90deg);
}

.settings-section-content {
  display: block;
}

.profile-card {
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 16px;
}

.profile-avatar {
  width: 56px;
  height: 56px;
  border-radius: var(--radius-full);
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-inverse);
  flex-shrink: 0;
}

.profile-avatar svg {
  width: 28px;
  height: 28px;
}

.profile-info {
  flex: 1;
  min-width: 0;
}

.profile-email {
  margin: 0 0 4px;
  font-size: 16px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.profile-since {
  font-size: 13px;
  color: var(--text-secondary);
}

.project-settings {
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}

.project-folders {
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}

.commit-history {
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  max-height: 360px;
  overflow-y: auto;
}

.commit-history-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.commit-history-controls select {
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-primary);
  color: var(--text-primary);
  font-size: 13px;
}

.commit-history-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.commit-entry {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  background: var(--bg-secondary);
}

.commit-entry__meta {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.commit-entry__title {
  font-weight: 600;
  font-size: 14px;
  color: var(--text-primary);
}

.commit-entry__desc {
  font-size: 13px;
  color: var(--text-secondary);
}

.commit-entry__sub {
  font-size: 12px;
  color: var(--text-tertiary);
}

.project-approval-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 9999px;
  background: rgba(245, 158, 11, 0.18);
  color: #9a3412;
  font-size: 11px;
  font-weight: 700;
}

.commit-entry__deploy {
  margin-top: 2px;
}

.deployment-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 8px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.01em;
  line-height: 1;
  white-space: nowrap;
}

.deployment-chip--building {
  background: rgba(245, 158, 11, 0.14);
  border-color: rgba(245, 158, 11, 0.4);
  color: #92400e;
}

.deployment-chip--success {
  background: rgba(34, 197, 94, 0.14);
  border-color: rgba(34, 197, 94, 0.4);
  color: #166534;
}

.deployment-chip--failed {
  background: rgba(239, 68, 68, 0.12);
  border-color: rgba(239, 68, 68, 0.35);
  color: #991b1b;
}

.deployment-chip--neutral {
  background: var(--bg-primary);
  border-color: var(--border);
  color: var(--text-secondary);
}

.deployment-chip__spinner {
  width: 10px;
  height: 10px;
  border-width: 2px;
}

.deployment-chip__icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  line-height: 1;
}

.deployment-chip__message {
  display: inline-block;
  margin-left: 8px;
  font-size: 12px;
  color: var(--text-secondary);
  vertical-align: middle;
  white-space: normal;
  word-break: break-word;
  text-align: right;
}

.commit-entry__actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: flex-end;
}

.commit-entry__link {
  font-size: 12px;
  color: var(--primary);
  text-decoration: none;
}

.commit-entry__link:hover {
  text-decoration: underline;
}

.commit-entry__rollback {
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(239, 68, 68, 0.4);
  background: rgba(239, 68, 68, 0.08);
  color: #b91c1c;
  font-size: 12px;
  font-weight: 600;
}

.commit-entry__rollback.confirming {
  border-color: rgba(239, 68, 68, 0.9);
  background: rgba(239, 68, 68, 0.22);
}

.commit-entry__rollback:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.folder-settings {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.folder-subsection {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  background: var(--bg-secondary);
}

.folder-subsection-header {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.folder-subsection-title {
  margin: 0;
  font-size: 14px;
  color: var(--text-primary);
}

.folder-warning {
  margin: 0;
  padding: 10px 12px;
  background: rgba(245, 158, 11, 0.12);
  border: 1px solid rgba(245, 158, 11, 0.35);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 13px;
}

.folder-summary {
  font-size: 13px;
  color: var(--text-secondary);
}

.folder-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.folder-actions--end {
  justify-content: flex-end;
}

.folder-list {
  max-height: 260px;
  overflow-y: auto;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  padding: 8px;
  display: grid;
  gap: 6px;
}

.folder-group-label {
  margin: 2px 4px 0;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.folder-option {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition);
}

.folder-option:hover {
  background: var(--bg-secondary);
}

.folder-option input {
  accent-color: var(--primary);
}

.folder-option span {
  font-size: 13px;
  color: var(--text-primary);
  word-break: break-word;
}

.folder-option--scoped {
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.folder-option-path {
  flex: 1;
  font-size: 13px;
  color: var(--text-primary);
  word-break: break-word;
}

.folder-scope-select {
  min-width: 132px;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  padding: 4px 8px;
  font-size: 12px;
  color: var(--text-primary);
  background: var(--bg-primary);
}

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

.settings-empty {
  margin: 0;
  color: var(--text-secondary);
  text-align: center;
  padding: 20px;
}

.approval-settings-readonly,
.approval-settings-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.approval-role-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.approval-group-title {
  margin: 0;
  font-size: 13px;
  color: var(--text-secondary);
}

.change-requests {
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
}

.change-requests-empty {
  color: var(--text-secondary);
  font-size: 14px;
}

.change-requests-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 10px;
}

.change-requests-header-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.change-requests-header-actions .btn-secondary {
  padding: 6px 10px;
  border-width: 1px;
  font-size: 12px;
}

.change-requests-filter-toggle.is-active {
  border-color: rgba(var(--primary-rgb), 0.45);
  color: var(--primary);
  background: rgba(var(--primary-rgb), 0.1);
}

.change-requests-filters-panel {
  margin-bottom: 10px;
  padding: 8px;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  background: var(--bg-secondary);
}

.change-requests-filters {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  margin-bottom: 0;
}

.change-requests-filters label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
  color: var(--text-secondary);
}

.change-requests-filters input,
.change-requests-filters select {
  padding: 7px;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  background: var(--bg-secondary);
  color: var(--text-primary);
}

.change-requests-filter-actions {
  display: flex;
  align-items: flex-end;
}

.change-requests-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 520px;
  overflow-y: auto;
  padding-right: 2px;
}

.change-request-row {
  width: 100%;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  background: var(--bg-secondary);
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.change-request-row__header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
}

.change-request-row__title {
  margin: 0;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.35;
}

.change-request-row__meta {
  margin: 0;
  font-size: 11px;
  color: var(--text-secondary);
  line-height: 1.35;
}

.change-request-row__message {
  margin: 0;
  padding: 7px 8px;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  background: var(--bg-primary);
  color: var(--text-primary);
  font-size: 12px;
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-word;
}

.change-request-row__reviewer-note {
  margin: 0;
  font-size: 11px;
  color: var(--text-secondary);
}

.change-request-row__error {
  margin: 0;
  font-size: 11px;
  color: var(--error);
}

.change-request-row__actions {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.change-request-row__review-input {
  width: 100%;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  padding: 7px 8px;
  background: var(--bg-primary);
  color: var(--text-primary);
  font-size: 12px;
}

.change-request-row__action-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.change-request-action.btn-secondary {
  padding: 6px 10px;
  border-width: 1px;
  font-size: 12px;
}

.change-request-action--approve.btn-secondary {
  border-color: rgba(34, 197, 94, 0.35);
  color: #166534;
  background: rgba(34, 197, 94, 0.1);
}

.change-request-action.btn-secondary:disabled {
  opacity: 0.65;
  cursor: not-allowed;
}

.change-request-status {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  padding: 2px 7px;
  border-radius: 9999px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.change-request-status--open {
  background: rgba(245, 158, 11, 0.18);
  color: #9a3412;
}

.change-request-status--approved {
  background: rgba(34, 197, 94, 0.18);
  color: #166534;
}

.change-request-status--rejected,
.change-request-status--cancelled {
  background: rgba(239, 68, 68, 0.14);
  color: #991b1b;
}

.project-settings-info {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.settings-info-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid var(--border-light);
}

.settings-info-item:last-child {
  border-bottom: none;
}

.settings-info-label {
  font-size: 14px;
  color: var(--text-secondary);
}

.settings-info-value {
  font-size: 14px;
  font-weight: 500;
  text-align: right;
}

.settings-info-value--deployment {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 4px;
  max-width: 62%;
}

.settings-list {
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.setting-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px;
  border-bottom: 1px solid var(--border-light);
}

.setting-item:last-child {
  border-bottom: none;
}

.setting-item--stacked {
  align-items: stretch;
  flex-direction: column;
  gap: 12px;
}

.setting-item--stacked .btn-secondary {
  width: 100%;
}

.setting-info {
  flex: 1;
}

.setting-label {
  display: block;
  font-size: 15px;
  font-weight: 500;
  margin-bottom: 2px;
}

.setting-desc {
  display: block;
  font-size: 13px;
  color: var(--text-secondary);
}

.setting-control {
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-primary);
  color: var(--text-primary);
  font-size: 14px;
}

.toggle {
  position: relative;
  display: inline-block;
  width: 48px;
  height: 28px;
  flex-shrink: 0;
}

.toggle input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--border);
  border-radius: var(--radius-full);
  transition: var(--transition);
}

.toggle-slider::before {
  position: absolute;
  content: '';
  height: 20px;
  width: 20px;
  left: 4px;
  bottom: 4px;
  background: white;
  border-radius: 50%;
  transition: var(--transition);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.toggle input:checked + .toggle-slider {
  background: var(--primary);
}

.toggle input:checked + .toggle-slider::before {
  transform: translateX(20px);
}

.dark-theme .toggle-slider::before {
  background: #e5e5e5;
}

.about-info {
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  font-size: 14px;
  line-height: 1.8;
}

.about-info p {
  margin: 0;
}

.about-footer {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border-light);
  color: var(--text-secondary);
}

.settings-actions {
  padding-top: 16px;
}

/* Bottom Navigation */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--nav-height);
  background: var(--bg-primary);
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-around;
  padding: 0 env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  z-index: 100;
}

.nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  border: none;
  background: transparent;
  color: var(--text-tertiary);
  font-size: 11px;
  font-weight: 500;
  transition: var(--transition);
  padding: 8px;
}

.nav-item svg {
  width: 24px;
  height: 24px;
  transition: var(--transition);
}

.nav-item.active {
  color: var(--info);
  background: rgba(var(--info-rgb), 0.12);
  border-radius: var(--radius-sm);
}

.nav-item.active svg {
  transform: scale(1.1);
}

/* Modals */
.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--bg-overlay);
  z-index: 1000;
  align-items: flex-end;
  animation: fadeIn 0.2s ease-out;
}

.modal.active {
  display: flex;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.modal-content {
  width: 100%;
  max-height: 90vh;
  background: var(--bg-primary);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  overflow-y: auto;
  animation: slideUp 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes slideUp {
  from {
    transform: translateY(100%);
  }
  to {
    transform: translateY(0);
  }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--bg-primary);
  z-index: 1;
}

.modal-header h2,
.modal-header h3 {
  margin: 0;
  font-size: 20px;
  font-weight: 700;
}

.btn-close {
  width: 32px;
  height: 32px;
  padding: 0;
  border: none;
  border-radius: var(--radius-sm);
  background: var(--bg-secondary);
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}

.btn-close:active {
  transform: scale(0.95);
}

.btn-close svg {
  width: 20px;
  height: 20px;
}

.modal form {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.modal-actions {
  display: flex;
  gap: 12px;
}

.modal-actions button {
  flex: 1;
}

.modal-actions-inline {
  margin-top: -4px;
}

.modal-description {
  margin: 0 0 16px;
  color: var(--text-secondary);
  font-size: 14px;
  line-height: 1.5;
}

.members-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.members-loading,
.members-empty {
  padding: 16px;
  border-radius: var(--radius);
  background: var(--bg-secondary);
  color: var(--text-secondary);
  font-size: 14px;
  text-align: center;
}

.member-row {
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

@media (min-width: 768px) {
  .member-row {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
  }
}

.member-info {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.member-email {
  font-weight: 600;
  color: var(--text-primary);
}

.member-role-badge {
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
}

.member-self-tag {
  font-size: 12px;
  font-weight: 600;
  color: var(--primary);
}

.member-actions {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.member-role-control {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  color: var(--text-secondary);
}

.member-role-control select {
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-primary);
  color: var(--text-primary);
  font-size: 14px;
}

.member-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.member-action-button {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-primary);
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
  padding: 8px 12px;
  transition: var(--transition);
  flex: none;
}

.member-action-button:hover {
  background: var(--bg-secondary);
}

.member-action-button.danger {
  border-color: rgba(239, 68, 68, 0.4);
  color: #ef4444;
}

.member-action-button.danger:hover {
  background: rgba(239, 68, 68, 0.08);
}

.modal-menu {
  max-height: 80vh;
}

.menu-header {
  padding: 20px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--bg-primary);
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.menu-section {
  padding: 20px;
  border-bottom: 1px solid var(--border-light);
}

.menu-section:last-child {
  border-bottom: none;
}

.menu-section h4 {
  margin: 0 0 12px;
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
}

.menu-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid var(--border-light);
}

.menu-item:last-child {
  border-bottom: none;
}

.menu-item-share-code {
  gap: 12px;
}

.share-code-controls {
  display: flex;
  align-items: center;
  gap: 12px;
}

.menu-label {
  font-size: 14px;
  color: var(--text-secondary);
}

.menu-value {
  font-size: 14px;
  font-weight: 500;
}

.menu-status-inline {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.menu-status-inline .loading-spinner {
  width: 12px;
  height: 12px;
  border-width: 2px;
}

.menu-status-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 12px;
  height: 12px;
  font-size: 11px;
  line-height: 1;
}

.menu-status-icon--success {
  color: #15803d;
}

.menu-status-icon--failed {
  color: #b91c1c;
}

.share-code-badge {
  padding: 6px 12px;
  background: var(--primary);
  color: var(--text-inverse);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  font-family: 'Courier New', monospace;
}

.share-code-copy-button {
  border: 1px solid var(--border);
  background: var(--bg-primary);
  color: var(--text-primary);
  border-radius: var(--radius-sm);
  padding: 6px 12px;
  font-size: 13px;
  font-weight: 500;
  transition: var(--transition);
}

.share-code-copy-button:active {
  background: var(--bg-secondary);
  transform: scale(0.98);
}

.share-code-copy-button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.menu-button {
  width: 100%;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-primary);
  color: var(--text-primary);
  font-size: 15px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
  transition: var(--transition);
  text-align: left;
}

.menu-button:last-child {
  margin-bottom: 0;
}

.menu-button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.menu-button:not(:disabled):active {
  background: var(--bg-secondary);
  transform: scale(0.98);
}

.menu-button svg {
  width: 20px;
  height: 20px;
  color: var(--text-secondary);
}

.menu-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-primary);
  color: var(--text-primary);
  text-decoration: none;
  font-size: 15px;
  font-weight: 500;
  margin-bottom: 8px;
  transition: var(--transition);
}

.menu-link:last-child {
  margin-bottom: 0;
}

.menu-link:active {
  background: var(--bg-secondary);
  transform: scale(0.98);
}

.menu-link svg {
  width: 20px;
  height: 20px;
  color: var(--text-secondary);
}

/* Toast Notifications */
.toast-container {
  position: fixed;
  top: 16px;
  left: 16px;
  right: 16px;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: 12px;
  pointer-events: auto;
  opacity: 0;
  transform: translateY(12px);
  transition: opacity var(--transition), transform var(--transition);
}

.toast--visible {
  opacity: 1;
  transform: translateY(0);
}

.toast--hide {
  opacity: 0;
  transform: translateY(-8px);
}

.toast-icon {
  width: 24px;
  height: 24px;
  flex-shrink: 0;
}

.toast-content {
  flex: 1;
}

.toast-title {
  font-size: 14px;
  font-weight: 600;
  margin: 0 0 2px;
}

.toast-message {
  font-size: 13px;
  color: var(--text-secondary);
  margin: 0;
}

.toast-action {
  align-self: center;
  border: 1px solid var(--border);
  background: var(--bg-secondary);
  color: var(--text-primary);
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
}

.toast-action:hover {
  border-color: var(--border-dark);
}

.toast-action:active {
  transform: translateY(1px);
}

.toast.success {
  border-color: var(--success);
}

.toast.success .toast-icon {
  color: var(--success);
}

.toast.error {
  border-color: var(--error);
}

.toast.error .toast-icon {
  color: var(--error);
}

.toast.info {
  border-color: var(--info);
}

.toast.info .toast-icon {
  color: var(--info);
}

.dark-theme .toast {
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.8);
}

/* Help Modal */
.modal-help {
  max-height: 85vh;
}

.help-content {
  padding: 20px;
  overflow-y: auto;
}

.help-section {
  margin-bottom: 24px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border-light);
}

.help-section:last-child {
  border-bottom: none;
  margin-bottom: 0;
}

.help-section h3 {
  margin: 0 0 12px;
  font-size: 17px;
  font-weight: 600;
  color: var(--text-primary);
}

.help-section ol,
.help-section ul {
  margin: 0;
  padding-left: 24px;
  color: var(--text-secondary);
}

.help-section li {
  margin-bottom: 8px;
  line-height: 1.6;
}

.help-section li strong {
  color: var(--text-primary);
  font-weight: 600;
}

.help-section p {
  margin: 0;
  line-height: 1.6;
  color: var(--text-secondary);
}

.help-section .btn-primary {
  margin-top: 12px;
}

/* Onboarding Tour */
.tour-panel {
  position: fixed;
  left: auto;
  right: 16px;
  transform: none;
  width: min(380px, calc(100vw - 20px));
  top: calc(env(safe-area-inset-top, 0px) + 92px);
  bottom: auto;
  z-index: 3000;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  max-height: min(66vh, 520px);
  overflow: hidden;
  opacity: 0.98;
  touch-action: pan-y;
}

.tour-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border-light);
  cursor: grab;
  user-select: none;
  touch-action: none;
}

.tour-panel-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.tour-drag-hint {
  font-size: 11px;
  color: var(--text-tertiary);
  font-weight: 500;
}

.tour-role {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  background: rgba(var(--info-rgb), 0.14);
  color: #1d4ed8;
}

.tour-step-count {
  font-size: 12px;
  color: var(--text-secondary);
  font-weight: 500;
}

.tour-progress {
  position: relative;
  height: 3px;
  background: var(--bg-tertiary);
  border-bottom: 1px solid var(--border-light);
}

.tour-progress-fill {
  display: block;
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--info), var(--secondary));
  transition: width var(--transition-slow);
}

.tour-panel-body {
  padding: 14px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.tour-intro {
  margin: 0;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  background: rgba(var(--info-rgb), 0.06);
  border: 1px solid rgba(var(--info-rgb), 0.12);
  color: var(--text-primary);
  font-size: 13px;
  line-height: 1.45;
}

.tour-loading,
.tour-empty {
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-secondary);
  color: var(--text-secondary);
  padding: 10px 12px;
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.tour-mobile-story {
  display: none;
}

.tour-mobile-context {
  margin: 0;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, rgba(var(--info-rgb), 0.12), rgba(var(--secondary-rgb), 0.1));
  border: 1px solid rgba(var(--info-rgb), 0.2);
  color: var(--text-primary);
  font-size: 12px;
  font-weight: 600;
  line-height: 1.45;
}

.tour-mobile-dots {
  display: flex;
  align-items: center;
  flex-wrap: nowrap;
  gap: 6px;
  overflow-x: auto;
  scrollbar-width: none;
}

.tour-mobile-dots::-webkit-scrollbar {
  display: none;
}

.tour-mobile-dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: rgba(var(--info-rgb), 0.25);
  flex: 0 0 auto;
}

.tour-mobile-dot--active {
  width: 24px;
  background: linear-gradient(90deg, var(--info), var(--secondary));
}

.tour-mobile-dot--done {
  background: rgba(var(--info-rgb), 0.55);
}

.tour-step-label {
  margin: 0;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-tertiary);
}

.tour-step-title {
  margin: 0;
  font-size: 18px;
  line-height: 1.3;
  color: var(--text-primary);
}

.tour-step-description,
.tour-step-hint {
  margin: 0;
  font-size: 14px;
  line-height: 1.5;
}

.tour-step-hint {
  font-size: 13px;
  color: var(--text-secondary);
  background: var(--bg-secondary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
}

.tour-panel-actions {
  display: flex;
  gap: 10px;
  padding: 10px 12px;
  border-top: 1px solid var(--border-light);
}

.tour-panel-actions .btn-primary,
.tour-panel-actions .btn-secondary {
  padding: 8px 10px;
  font-size: 13px;
}

.tour-panel--dragging .tour-panel-header {
  cursor: grabbing;
}

.tour-highlight {
  position: relative !important;
  z-index: 3200 !important;
  border-radius: var(--radius-sm);
  box-shadow:
    0 0 0 3px rgba(var(--info-rgb), 0.45),
    0 0 0 9px rgba(var(--info-rgb), 0.12),
    var(--shadow-md);
  animation: tourPulse 1.8s ease-in-out infinite;
}

@keyframes tourPulse {
  0% {
    box-shadow:
      0 0 0 3px rgba(var(--info-rgb), 0.45),
      0 0 0 9px rgba(var(--info-rgb), 0.12),
      var(--shadow-md);
  }
  50% {
    box-shadow:
      0 0 0 3px rgba(var(--info-rgb), 0.55),
      0 0 0 12px rgba(var(--info-rgb), 0.07),
      var(--shadow-md);
  }
  100% {
    box-shadow:
      0 0 0 3px rgba(var(--info-rgb), 0.45),
      0 0 0 9px rgba(var(--info-rgb), 0.12),
      var(--shadow-md);
  }
}

@media (prefers-reduced-motion: reduce) {
  .tour-highlight {
    animation: none;
  }
}

@media (max-width: 640px) {
  .chat-header {
    padding: 12px;
  }

  .usage-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .modal-actions-inline {
    flex-wrap: wrap;
  }

  .chat-messages {
    padding: 12px;
  }

  .message {
    max-width: 100%;
  }

  .chat-input-container {
    padding: 12px calc(12px + env(safe-area-inset-right, 0px)) calc(12px + env(safe-area-inset-bottom, 0px)) calc(12px + env(safe-area-inset-left, 0px));
  }

  .tour-panel {
    right: 8px;
    left: 8px;
    top: auto;
    bottom: calc(var(--nav-height) + env(safe-area-inset-bottom, 0px) + 10px);
    width: calc(100vw - 16px);
    height: auto;
    max-height: min(52vh, 420px);
    border-radius: 18px;
    border: 1px solid var(--border);
    box-shadow: 0 20px 40px rgba(16, 26, 36, 0.28);
    opacity: 0.99;
    z-index: 3000;
  }

  .tour-panel.tour-panel--mobile-top {
    top: calc(env(safe-area-inset-top, 0px) + 52px);
    bottom: auto;
  }

  .tour-panel.tour-panel--mobile-bottom {
    top: auto;
    bottom: calc(var(--nav-height) + env(safe-area-inset-bottom, 0px) + 10px);
  }

  .tour-panel-header {
    cursor: default;
    touch-action: auto;
    padding: calc(11px + env(safe-area-inset-top, 0px)) 14px 12px;
    background: linear-gradient(140deg, rgba(var(--info-rgb), 0.15), rgba(var(--secondary-rgb), 0.12));
    border-bottom: 1px solid rgba(var(--info-rgb), 0.18);
  }

  .tour-panel-meta {
    width: 100%;
    justify-content: space-between;
    gap: 8px;
  }

  .tour-role {
    padding: 4px 9px;
    font-size: 10px;
  }

  .tour-step-count {
    padding: 4px 8px;
    border-radius: 999px;
    background: rgba(var(--info-rgb), 0.1);
    font-size: 11px;
    color: var(--text-primary);
    font-weight: 600;
  }

  .tour-progress {
    height: 4px;
  }

  .tour-drag-hint {
    display: none;
  }

  .tour-panel-body {
    padding: 14px;
    gap: 12px;
    overflow-y: auto;
  }

  .tour-intro,
  .tour-step-label {
    display: none;
  }

  .tour-mobile-story {
    display: grid;
    gap: 8px;
  }

  .tour-intro {
    font-size: 12px;
    line-height: 1.45;
  }

  .tour-step-title {
    font-size: 19px;
    line-height: 1.32;
  }

  .tour-step-description,
  .tour-step-hint {
    font-size: 14px;
    line-height: 1.55;
  }

  .tour-step-hint {
    padding: 11px;
  }

  .tour-panel-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    padding: 10px 14px calc(12px + env(safe-area-inset-bottom, 0px));
    background: var(--bg-primary);
    border-top: 1px solid var(--border-light);
    position: static;
  }

  .tour-panel-actions .btn-primary,
  .tour-panel-actions .btn-secondary {
    width: 100%;
  }

  #tour-next {
    grid-column: 1 / -1;
    order: -1;
  }

  #tour-retry {
    grid-column: 1 / -1;
    order: 3;
  }

  .change-requests-header {
    flex-direction: column;
    align-items: stretch;
  }

  .change-requests-header-actions {
    width: 100%;
  }

  .change-requests-header-actions .btn-secondary {
    flex: 1 1 calc(50% - 3px);
  }

  .change-requests-filters {
    grid-template-columns: 1fr;
  }

  .change-requests-list {
    max-height: none;
  }

  .change-request-row__header {
    flex-direction: column;
    gap: 6px;
  }

  .change-request-row__action-buttons {
    flex-direction: column;
  }

  .change-request-action.btn-secondary {
    width: 100%;
  }
}

/* Responsive */
@media (min-width: 768px) {
  .auth-section {
    padding: 40px;
  }
  
  .view {
    max-width: 600px;
    margin: 0 auto;
    width: 100%;
  }
  
  .projects-list {
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  }
  
  .toast-container {
    left: auto;
    right: 16px;
    max-width: 400px;
  }

  .tour-panel {
    right: 20px;
    top: calc(env(safe-area-inset-top, 0px) + 90px);
    width: min(360px, calc(100vw - 56px));
  }
}
