/* ================================
   Startup Screen
   ================================ */
.startup-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: var(--bg-primary);
  padding: 16px;
  overflow-y: auto;
}

.startup-overlay.hidden {
  display: none;
}

.startup-card {
  width: 100%;
  max-width: 480px;
  text-align: center;
  animation: dialog-in 400ms ease;
}

.startup-logo {
  margin-bottom: 16px;
}

.startup-logo-img {
  width: 220px;
  height: auto;
}

.startup-title {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.startup-subtitle {
  font-size: 1rem;
  color: var(--text-secondary);
  margin-bottom: 28px;
}

.startup-privacy {
  text-align: left;
  background-color: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px;
  margin-bottom: 20px;
}

.startup-privacy-header {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 10px;
}

.startup-privacy-header svg {
  color: var(--accent);
  flex-shrink: 0;
}

.startup-privacy-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.startup-privacy-list li {
  font-size: 0.8125rem;
  line-height: 1.5;
  color: var(--text-secondary);
  padding-left: 18px;
  position: relative;
}

.startup-privacy-list li::before {
  content: '•';
  position: absolute;
  left: 4px;
  color: var(--accent);
  font-weight: 700;
}

.startup-privacy-list li strong {
  color: var(--text-primary);
  font-weight: 600;
}

.startup-consent {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin-bottom: 20px;
  cursor: pointer;
  text-align: left;
}

.startup-consent input[type="checkbox"] {
  width: 16px;
  height: 16px;
  margin-top: 1px;
  accent-color: var(--accent);
  cursor: pointer;
  flex-shrink: 0;
}

.startup-consent span {
  font-size: 0.8125rem;
  color: var(--text-secondary);
  line-height: 1.4;
}

.startup-password {
  margin-bottom: 20px;
  text-align: left;
}

.startup-password.hidden {
  display: none;
}

.startup-password-label {
  display: block;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.startup-password-input {
  width: 100%;
  padding: 10px 14px;
  background-color: var(--bg-secondary);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-family: inherit;
  font-size: 0.9375rem;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.startup-password-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-light);
}

.startup-password-input::placeholder {
  color: var(--text-tertiary);
}

.startup-password-error {
  font-size: 0.75rem;
  color: var(--danger);
  margin-top: 6px;
  min-height: 1em;
}

.startup-submit {
  width: 100%;
  padding: 12px;
  font-size: 1rem;
  font-weight: 600;
  border-radius: var(--radius-md);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 16px;
  border: none;
  border-radius: var(--radius-md);
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-fast);
  white-space: nowrap;
  line-height: 1;
}

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

.btn-primary {
  background-color: var(--accent);
  color: var(--text-inverse);
}

.btn-primary:hover:not(:disabled) {
  background-color: var(--accent-hover);
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
}

.btn-ghost:hover:not(:disabled) {
  background-color: var(--bg-hover);
  color: var(--text-primary);
}

.btn-danger {
  background-color: var(--danger);
  color: var(--text-inverse);
}

.btn-danger:hover:not(:disabled) {
  background-color: var(--danger-hover);
}

.btn-icon {
  padding: 6px;
  border-radius: var(--radius-sm);
}

/* Select / Dropdown */
.model-select {
  appearance: none;
  background-color: var(--bg-secondary);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 6px 32px 6px 12px;
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-fast);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  max-width: 250px;
}

.model-select:hover {
  border-color: var(--accent);
}

.model-select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-light);
}

/* Model selector container */
.model-selector {
  display: flex;
  align-items: center;
  gap: 4px;
}

.model-refresh {
  opacity: 0.6;
}

.model-refresh:hover {
  opacity: 1;
}

/* Sidebar toggle (hidden on desktop) */
.sidebar-toggle {
  display: none;
}

/* ================================
   Dialog / Modal
   ================================ */
.dialog-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  z-index: 200;
  justify-content: center;
  align-items: center;
  padding: 16px;
}

.dialog-overlay.visible {
  display: flex;
}

.dialog {
  background-color: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  overflow-y: auto;
  animation: dialog-in 200ms ease;
}

@keyframes dialog-in {
  from {
    opacity: 0;
    transform: scale(0.95) translateY(10px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.dialog-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}

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

.dialog-body {
  padding: 20px;
}

.dialog-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 12px 20px;
  border-top: 1px solid var(--border);
}

/* Settings-specific */
.settings-section {
  margin-bottom: 24px;
}

.settings-section:last-child {
  margin-bottom: 0;
}

.settings-section-title {
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.settings-hint {
  font-size: 0.8125rem;
  color: var(--text-secondary);
  margin-bottom: 12px;
  line-height: 1.5;
}

.settings-hint a {
  color: var(--accent);
  text-decoration: underline;
}

.settings-field {
  margin-bottom: 12px;
}

.settings-field:last-child {
  margin-bottom: 0;
}

.settings-label {
  display: block;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 4px;
}

.settings-input {
  width: 100%;
  padding: 8px 12px;
  background-color: var(--bg-secondary);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-family: inherit;
  font-size: 0.875rem;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.settings-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-light);
}

.settings-input::placeholder {
  color: var(--text-tertiary);
}

.settings-textarea {
  width: 100%;
  padding: 10px 12px;
  background-color: var(--bg-secondary);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-family: inherit;
  font-size: 0.8125rem;
  line-height: 1.5;
  resize: vertical;
  min-height: 80px;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.settings-textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-light);
}

.settings-textarea::placeholder {
  color: var(--text-tertiary);
}

.settings-prompt-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 6px;
}

.settings-input-row {
  display: flex;
  gap: 4px;
  align-items: center;
}

.settings-input-row .settings-input {
  flex: 1;
}

.settings-success {
  color: var(--success);
  font-size: 0.8125rem;
  margin-top: 4px;
}

/* Settings status & config preview */
.settings-status {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  font-size: 0.8125rem;
  color: var(--text-secondary);
}

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  background-color: var(--bg-secondary);
  border: 1px solid var(--border);
  font-size: 0.8125rem;
}

.status-badge.status-ok {
  color: var(--success);
}

.status-badge.status-missing {
  color: var(--text-tertiary);
}

.settings-config-preview {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px;
  background-color: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}

.config-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.8125rem;
}

.config-label {
  color: var(--text-secondary);
}

.config-value {
  font-weight: 500;
  color: var(--text-primary);
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: 0.75rem;
}

.config-value.status-ok {
  color: var(--success);
}

.config-value.status-missing {
  color: var(--text-tertiary);
}

.settings-hint code {
  padding: 1px 6px;
  background-color: var(--bg-code);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: 0.8em;
}

.btn-danger-text {
  color: var(--danger);
}

.btn-danger-text:hover {
  background-color: color-mix(in srgb, var(--danger) 10%, transparent);
  color: var(--danger);
}

/* Gem dialog */
.gem-instruction-input {
  min-height: 120px;
  resize: vertical;
}

.gem-files-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 8px;
}

.gem-file-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  background-color: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.8125rem;
  color: var(--text-primary);
}

.gem-file-item svg {
  flex-shrink: 0;
  color: var(--text-tertiary);
}

.gem-file-item-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.gem-file-remove {
  padding: 2px;
  border: none;
  background: transparent;
  color: var(--text-tertiary);
  cursor: pointer;
  display: flex;
  align-items: center;
  border-radius: var(--radius-sm);
  transition: color var(--transition-fast);
}

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

/* Gem indicator in chat */
.gem-indicator {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  margin: 0 auto 12px;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--accent);
  background-color: var(--accent-light);
  border-radius: var(--radius-full);
  width: fit-content;
}

.gem-indicator svg {
  flex-shrink: 0;
}

/* Gem welcome screen */
.gem-welcome {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 60px 24px 40px;
  max-width: 480px;
  margin: 0 auto;
}

.gem-welcome-icon {
  width: 64px;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: var(--accent-light);
  color: var(--accent);
  border-radius: 50%;
  margin-bottom: 16px;
}

.gem-welcome-name {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 8px;
}

.gem-welcome-instruction {
  font-size: 0.875rem;
  color: var(--text-secondary);
  line-height: 1.6;
  margin-bottom: 16px;
  white-space: pre-line;
}

.gem-welcome-files {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: center;
}

.gem-welcome-file {
  font-size: 0.75rem;
  padding: 4px 10px;
  background-color: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  color: var(--text-secondary);
}
