

.chat-templates-landing {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: var(--space-8) var(--space-6);
  overflow-y: auto;
  background: var(--color-bg);
}

.chat-templates-header {
  text-align: left;
  margin-bottom: var(--space-8);
}

.chat-templates-avatar {
  width: 64px;
  height: 64px;
  border-radius: var(--radius-full);
  object-fit: cover;
  margin-bottom: var(--space-4);
  box-shadow: var(--shadow-sm);
}

.chat-templates-title {
  font-size: var(--font-size-xl);
  font-weight: 600;
  color: var(--color-text-primary);
  margin: 0 0 var(--space-1) 0;
  font-family: var(--font-family);
}

.chat-templates-subtitle {
  font-size: var(--font-size-sm);
  font-weight: 400;
  color: var(--color-text-secondary, #646e78);
  margin: 0;
  font-family: var(--font-family);
}

.chat-templates-section {
  width: 100%;
  max-width: 560px;
  margin-top: var(--space-6);
}

.chat-templates-label {
  font-size: var(--font-size-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--color-text-secondary, #646e78);
  margin-bottom: var(--space-3);
  font-family: var(--font-family);
}

.chat-templates-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-3);
}

.chat-template-card {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  padding: var(--space-4) var(--space-4);
  background: var(--color-card);
  border: none;
  border-radius: var(--radius-lg);
  cursor: pointer;
  transition: box-shadow var(--transition), transform var(--transition);
  min-height: 44px;
  font-family: var(--font-family);
  text-align: left;
  align-items: flex-start;
  box-shadow: var(--shadow-card);
}

.chat-template-card:hover {
  box-shadow: var(--shadow-hover);
  transform: translateY(-2px);
}

.chat-template-card:active {
  transform: translateY(0);
  box-shadow: var(--shadow-sm);
}

.chat-template-card[data-template="email"] { background: linear-gradient(135deg, rgba(59,130,246,0.05) 0%, var(--color-card) 60%); }
.chat-template-card[data-template="application"] { background: linear-gradient(135deg, rgba(34,197,94,0.05) 0%, var(--color-card) 60%); }
.chat-template-card[data-template="authority"] { background: linear-gradient(135deg, rgba(139,92,246,0.05) 0%, var(--color-card) 60%); }
.chat-template-card[data-template="linkedin"] { background: linear-gradient(135deg, rgba(245,158,11,0.05) 0%, var(--color-card) 60%); }
.chat-template-card[data-template="improve"] { background: linear-gradient(135deg, rgba(var(--color-primary-rgb),0.05) 0%, var(--color-card) 60%); }
.chat-template-card[data-template="summarize"] { background: linear-gradient(135deg, rgba(6,182,212,0.05) 0%, var(--color-card) 60%); }

.chat-template-icon {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-bottom: var(--space-1);
}

.chat-template-icon svg {
  width: 22px;
  height: 22px;
}

.chat-template-title {
  font-size: var(--font-size-base);
  font-weight: 600;
  color: var(--color-text-primary);
  margin: 0;
  line-height: 1.3;
}

.chat-template-desc {
  font-size: var(--font-size-sm);
  font-weight: 400;
  color: var(--color-text-secondary, #646e78);
  margin: 0;
  line-height: 1.4;
}

.chat-template-add-btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: var(--space-1) var(--space-2);
  border: none;
  border-radius: var(--radius-sm);
  background: var(--color-primary-light);
  color: var(--color-primary);
  font-size: var(--font-size-xs);
  font-weight: 600;
  font-family: var(--font-family);
  cursor: pointer;
  transition: background var(--transition);
  align-self: flex-start;
  margin-top: var(--space-1);
}

.chat-template-add-btn:hover {
  background: rgba(var(--color-primary-rgb), 0.2);
}

.chat-template-add-btn svg {
  width: 14px;
  height: 14px;
}

.chat-templates-empty {
  
  font-size: var(--font-size-sm);
  font-weight: 400;
  color: #646e78; 
  font-style: italic;
  padding: var(--space-4) 0;
  font-family: var(--font-family);
}

.chat-empty.v-skole-only {
  display: none;
}

.chat-empty.v-voksen-only {
  display: none;
}

.v-skole .chat-empty.v-skole-only {
  display: flex;
}

.v-voksen .chat-empty.v-voksen-only {
  display: flex;
  flex-direction: column;
}

#chat-main.chat-has-conversation .chat-empty { display: none !important; }

.chat-templates-landing.v-skole-only {
  display: none;
}

.chat-templates-landing.v-voksen-only {
  display: none;
}

.v-skole .chat-templates-landing.v-skole-only {
  display: flex;
}

.v-voksen .chat-templates-landing.v-voksen-only {
  display: flex;
}

.chat-history-section {
  padding: var(--space-2) 0;
}

.chat-history-label {
  padding: var(--space-3) var(--space-5) var(--space-2);
  font-size: var(--font-size-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--color-text-secondary, #646e78);
  font-family: var(--font-family);
}

.chat-history-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-5);
  cursor: pointer;
  transition: background var(--transition);
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  font-family: var(--font-family);
  min-height: 44px;
  border-left: 3px solid transparent;
}

.chat-history-item:hover {
  background: var(--color-bg);
}

.chat-history-item.active {
  background: var(--color-primary);
  border-left-color: rgba(255, 255, 255, 0.3);
}

.chat-history-item.active .chat-history-title,
.chat-history-item.active .chat-history-time {
  color: #fff;
}

.chat-history-title {
  font-size: var(--font-size-sm);
  font-weight: 600;
  color: var(--color-text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  min-width: 0;
}

.chat-history-time {
  font-size: var(--font-size-xs);
  color: var(--color-text-secondary, #646e78);
  white-space: nowrap;
  flex-shrink: 0;
}

.chat-history-preview {
  font-size: var(--font-size-xs);
  color: var(--color-text-secondary, #646e78);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 2px;
}

.chat-history-actions {
  display: flex;
  gap: var(--space-1);
  opacity: 0;
  transition: opacity var(--transition);
  flex-shrink: 0;
}

.chat-history-item:hover .chat-history-actions {
  opacity: 1;
}

.chat-history-action-btn {
  width: 28px;
  height: 28px;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--color-text-secondary, #646e78);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--transition), color var(--transition);
  position: relative;
}

.chat-history-action-btn::before {
  content: '';
  position: absolute;
  inset: -8px;
  min-width: 44px;
  min-height: 44px;
}

.chat-history-action-btn:hover {
  background: var(--color-error-light);
  color: var(--color-error);
}

.chat-history-action-btn svg {
  width: 16px;
  height: 16px;
}

.chat-history-new-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  width: calc(100% - var(--space-5) * 2);
  margin: var(--space-3) var(--space-5);
  padding: var(--space-3) var(--space-4);
  border: 1px dashed var(--color-border);
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--color-primary);
  font-size: var(--font-size-sm);
  font-weight: 600;
  font-family: var(--font-family);
  cursor: pointer;
  transition: background var(--transition), border-color var(--transition);
  min-height: 44px;
}

.chat-history-new-btn:hover {
  background: var(--color-primary-light);
  border-color: var(--color-primary);
}

.chat-history-new-btn svg {
  width: 18px;
  height: 18px;
}

.chat-template-form {
  width: 100%;
  max-width: 560px;
  padding: var(--space-5);
  background: var(--color-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  margin-top: var(--space-4);
}

.chat-template-form-title {
  font-size: var(--font-size-base);
  font-weight: 600;
  color: var(--color-text-primary);
  margin: 0 0 var(--space-4) 0;
  font-family: var(--font-family);
}

.chat-template-form-group {
  margin-bottom: var(--space-4);
}

.chat-template-form-label {
  display: block;
  font-size: var(--font-size-sm);
  font-weight: 600;
  color: var(--color-text-primary);
  margin-bottom: var(--space-2);
  font-family: var(--font-family);
}

.chat-template-form-input,
.chat-template-form-textarea {
  width: 100%;
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-bg);
  color: var(--color-text-primary);
  font-size: var(--font-size-sm);
  font-family: var(--font-family);
  transition: border-color var(--transition), box-shadow var(--transition);
}

.chat-template-form-input:focus,
.chat-template-form-textarea:focus {
  outline: none;
  border-color: rgba(0, 0, 0, 0.3);
  box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.08);
  background: var(--color-card);
}
[data-theme="dark"] .chat-template-form-input:focus,
[data-theme="dark"] .chat-template-form-textarea:focus {
  border-color: rgba(255, 255, 255, 0.4);
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.1);
}

.chat-template-form-input::placeholder,
.chat-template-form-textarea::placeholder {
  color: var(--color-text-secondary, #646e78);
}

.chat-template-form-textarea {
  min-height: 80px;
  resize: vertical;
  line-height: 1.5;
}

.chat-template-form-hint {
  font-size: var(--font-size-xs);
  color: var(--color-text-secondary, #646e78);
  margin-top: var(--space-1);
  font-family: var(--font-family);
}

.chat-template-form-actions {
  display: flex;
  gap: var(--space-3);
  justify-content: flex-end;
  margin-top: var(--space-5);
}

.chat-template-form-cancel {
  padding: var(--space-2) var(--space-5);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--color-text-primary);
  font-size: var(--font-size-sm);
  font-weight: 600;
  font-family: var(--font-family);
  cursor: pointer;
  transition: background var(--transition);
  min-height: 44px;
}

.chat-template-form-cancel:hover {
  background: var(--color-bg);
}

.chat-template-form-save {
  padding: var(--space-2) var(--space-5);
  border: none;
  border-radius: var(--radius-md);
  background: var(--color-primary);
  color: #fff;
  font-size: var(--font-size-sm);
  font-weight: 600;
  font-family: var(--font-family);
  cursor: pointer;
  transition: background var(--transition), box-shadow var(--transition);
  box-shadow: 0 2px 6px rgba(var(--color-primary-rgb), 0.3);
  min-height: 44px;
}

.chat-template-form-save:hover {
  background: var(--color-primary-hover);
  box-shadow: 0 4px 12px rgba(var(--color-primary-rgb), 0.4);
}

.chat-template-form-save:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

@media (max-width: 767px) {
  .chat-templates-landing {
    padding: var(--space-6) var(--space-4);
  }

  .chat-templates-grid {
    grid-template-columns: 1fr;
  }

  .chat-template-card {
    padding: var(--space-4);
  }

  .chat-templates-header {
    margin-bottom: var(--space-6);
  }

  .chat-templates-avatar {
    width: 56px;
    height: 56px;
  }

  .chat-templates-title {
    font-size: var(--font-size-lg);
  }

  .chat-history-item {
    padding: var(--space-3) var(--space-4);
  }

  .chat-history-label {
    padding-left: var(--space-4);
    padding-right: var(--space-4);
  }

  .chat-history-new-btn {
    margin-left: var(--space-4);
    margin-right: var(--space-4);
    width: calc(100% - var(--space-4) * 2);
  }

  .chat-history-actions {
    opacity: 1;
  }

  .chat-template-form {
    padding: var(--space-4);
  }

  .chat-template-form-actions {
    flex-direction: column;
  }

  .chat-template-form-cancel,
  .chat-template-form-save {
    width: 100%;
    justify-content: center;
    text-align: left;
  }
}

[data-theme="dark"] .chat-template-card {
  background: var(--color-card);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

[data-theme="dark"] .chat-template-card:hover {
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
}

[data-theme="dark"] .chat-template-card[data-template="email"] { background: linear-gradient(135deg, rgba(59,130,246,0.1) 0%, var(--color-card) 60%); }
[data-theme="dark"] .chat-template-card[data-template="application"] { background: linear-gradient(135deg, rgba(34,197,94,0.1) 0%, var(--color-card) 60%); }
[data-theme="dark"] .chat-template-card[data-template="authority"] { background: linear-gradient(135deg, rgba(139,92,246,0.1) 0%, var(--color-card) 60%); }
[data-theme="dark"] .chat-template-card[data-template="linkedin"] { background: linear-gradient(135deg, rgba(245,158,11,0.1) 0%, var(--color-card) 60%); }
[data-theme="dark"] .chat-template-card[data-template="improve"] { background: linear-gradient(135deg, rgba(var(--color-primary-rgb),0.1) 0%, var(--color-card) 60%); }
[data-theme="dark"] .chat-template-card[data-template="summarize"] { background: linear-gradient(135deg, rgba(6,182,212,0.1) 0%, var(--color-card) 60%); }

[data-theme="dark"] .chat-template-form {
  background: var(--color-card);
  border-color: var(--color-border);
}

[data-theme="dark"] .chat-template-form-input,
[data-theme="dark"] .chat-template-form-textarea {
  background: var(--color-bg);
  border-color: var(--color-border);
  color: var(--color-text-primary);
}

[data-theme="dark"] .chat-template-form-cancel {
  border-color: var(--color-border);
  color: var(--color-text-primary);
}

[data-theme="dark"] .chat-template-form-cancel:hover {
  background: rgba(255, 255, 255, 0.05);
}

[data-theme="dark"] .chat-history-item:hover {
  background: rgba(255, 255, 255, 0.04);
}

[data-theme="dark"] .chat-history-action-btn:hover {
  background: rgba(255, 62, 29, 0.15);
}

.chat-template-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: var(--space-4);
  -webkit-font-smoothing: antialiased;
}

.chat-template-modal {
  background: var(--color-card);
  border-radius: 16px;
  width: 100%;
  max-width: 480px;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.16);
  overflow: hidden;
}

.chat-template-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px 0;
  border-bottom: none;
}

.chat-template-modal-header h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  color: var(--color-text-primary);
  font-family: var(--font-family);
}

.chat-template-modal-close {
  background: none;
  border: none;
  color: var(--color-text-secondary, #646e78);
  cursor: pointer;
  padding: 0;
  line-height: 1;
  transition: color 0.15s, background 0.15s;
  min-width: 32px;
  min-height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  font-size: 18px;
}

.chat-template-modal-close:hover {
  color: var(--color-text-primary);
  background: rgba(0, 0, 0, 0.06);
}
[data-theme="dark"] .chat-template-modal-close:hover {
  background: rgba(255, 255, 255, 0.08);
}

.chat-template-modal-body {
  padding: 16px 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.chat-template-modal-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--color-text-secondary, #646e78);
  margin-bottom: -4px;
  font-family: var(--font-family);
  display: block;
}

.chat-template-modal-input,
.chat-template-modal-textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--color-border);
  border-radius: 10px;
  font-size: 14px;
  font-family: var(--font-family);
  color: var(--color-text-primary);
  background: var(--color-bg);
  transition: border-color 0.15s, box-shadow 0.15s;
  box-sizing: border-box;
}

.chat-template-modal-input:focus,
.chat-template-modal-textarea:focus {
  outline: none;
  border-color: rgba(0, 0, 0, 0.25);
  box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.06);
  background: var(--color-card);
}
[data-theme="dark"] .chat-template-modal-input:focus,
[data-theme="dark"] .chat-template-modal-textarea:focus {
  border-color: rgba(255, 255, 255, 0.3);
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.08);
}

.chat-template-modal-input::placeholder,
.chat-template-modal-textarea::placeholder {
  color: var(--color-text-secondary, #646e78);
  opacity: 0.6;
}

.chat-template-modal-textarea {
  resize: vertical;
  min-height: 180px;
  line-height: 1.6;
}

.chat-template-icon-picker {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.chat-template-icon-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 4px;
}

.chat-template-icon-option {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1.5px solid transparent;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.04);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, transform 0.15s;
  color: var(--color-text-secondary, #646e78);
}
[data-theme="dark"] .chat-template-icon-option {
  background: rgba(255, 255, 255, 0.06);
}

.chat-template-icon-option svg {
  width: 18px;
  height: 18px;
}

.chat-template-icon-option:hover {
  background: rgba(0, 0, 0, 0.08);
  transform: scale(1.05);
}
[data-theme="dark"] .chat-template-icon-option:hover {
  background: rgba(255, 255, 255, 0.1);
}

.chat-template-icon-option.selected {
  border-color: var(--color-text-primary);
  background: rgba(0, 0, 0, 0.06);
  box-shadow: none;
}
[data-theme="dark"] .chat-template-icon-option.selected {
  border-color: rgba(255, 255, 255, 0.5);
  background: rgba(255, 255, 255, 0.1);
}

.chat-template-modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 12px 24px 20px;
  border-top: none;
}

.chat-template-modal-cancel {
  padding: 8px 20px;
  border: none;
  border-radius: 10px;
  background: transparent;
  color: var(--color-text-secondary, #646e78);
  font-size: 14px;
  font-family: var(--font-family);
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  min-height: 40px;
}

.chat-template-modal-cancel:hover {
  background: rgba(0, 0, 0, 0.06);
  color: var(--color-text-primary);
}
[data-theme="dark"] .chat-template-modal-cancel:hover {
  background: rgba(255, 255, 255, 0.08);
}

.chat-template-modal-save {
  padding: 8px 24px;
  border: none;
  border-radius: 10px;
  background: var(--color-text-primary, #1d1d1f);
  color: #fff;
  font-size: 14px;
  font-family: var(--font-family);
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s;
  min-height: 40px;
}
[data-theme="dark"] .chat-template-modal-save {
  background: #e8e8ed;
  color: #1d1d1f;
}

.chat-template-modal-save:hover {
  background: #333;
}
[data-theme="dark"] .chat-template-modal-save:hover {
  background: #fff;
}

.chat-template-delete {
  position: absolute;
  top: var(--space-2);
  right: var(--space-2);
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.06);
  color: var(--color-text-secondary, #646e78);
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s, background 0.15s, color 0.15s;
}

.chat-template-card:hover .chat-template-delete {
  opacity: 1;
}

.chat-template-delete:hover {
  background: var(--color-danger, #e24668);
  color: #fff;
}

.chat-template-custom {
  position: relative;
}

[data-theme="dark"] .chat-template-modal {
  background: #1a2035;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

[data-theme="dark"] .chat-template-modal-header h3 {
  color: #e8ecf4;
}

[data-theme="dark"] .chat-template-modal-label {
  color: #8a92a6;
}

[data-theme="dark"] .chat-template-modal-input,
[data-theme="dark"] .chat-template-modal-textarea {
  background: #111727;
  border-color: #2a3250;
  color: #e8ecf4;
}

[data-theme="dark"] .chat-template-modal-input:focus,
[data-theme="dark"] .chat-template-modal-textarea:focus {
  background: #1a2035;
  border-color: rgba(255, 255, 255, 0.3);
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.08);
}

[data-theme="dark"] .chat-template-modal-input::placeholder,
[data-theme="dark"] .chat-template-modal-textarea::placeholder {
  color: #5a6478;
}

[data-theme="dark"] .chat-template-delete {
  background: rgba(255, 255, 255, 0.1);
  color: var(--color-text-secondary, #646e78);
}

[data-theme="dark"] .chat-template-delete:hover {
  background: var(--color-danger, #e24668);
  color: #fff;
}

[data-theme="dark"] .chat-templates-empty {
  color: #8a92a6;
}

@media (max-width: 767px) {
  .chat-template-modal-overlay {
    padding: var(--space-3);
    align-items: flex-end;     
  }

  .chat-template-modal {
    max-width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  }

  .chat-template-modal-body {
    padding: var(--space-3) var(--space-4);
  }

  .chat-template-modal-header {
    padding: var(--space-3) var(--space-4);
  }

  .chat-template-modal-footer {
    padding: var(--space-3) var(--space-4);
    flex-direction: column;
  }

  .chat-template-modal-cancel,
  .chat-template-modal-save {
    width: 100%;
    text-align: left;
    justify-content: center;
  }
}

.chat-templates-header h3 {
  font-size: var(--font-size-xl);   
  font-weight: 600;
  color: var(--color-text-primary);
  margin: 0 0 var(--space-1) 0;
  font-family: var(--font-family);
}

.chat-sidebar-templates {
  padding: 0 var(--space-3);
  margin-top: var(--space-2);
  flex-shrink: 0;
}

.chat-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0;
  margin-bottom: var(--space-1);
}
.chat-section-header .chat-conv-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--color-text-secondary);
  padding: 8px 0 4px;
}

.chat-sidebar-tpl-btn {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  width: 100%;
  min-width: 0;
  overflow: hidden;
  padding: 8px var(--space-3);
  border: none;
  background: transparent;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background 0.15s ease;
  font-family: var(--font-family);
  text-align: left;
}

.chat-sidebar-tpl-btn:hover {
  background: rgba(0, 0, 0, 0.04);
}
[data-theme="dark"] .chat-sidebar-tpl-btn:hover {
  background: rgba(255, 255, 255, 0.06);
}

.chat-sidebar-tpl-icon {
  width: 30px;
  height: 30px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.chat-sidebar-tpl-icon svg {
  width: 16px;
  height: 16px;
}

.chat-sidebar-tpl-name {
  font-size: var(--font-size-sm);
  font-weight: 400;
  color: var(--color-text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  min-width: 0;
}

.chat-sidebar-tpl-add {
  width: 100%;
  border: 1px dashed var(--color-border);
  background: transparent;
  color: var(--color-text-secondary);
  font-size: var(--font-size-sm);
  font-weight: 500;
  padding: 10px 16px;
  border-radius: var(--radius-md);
  cursor: pointer;
  font-family: var(--font-family);
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.chat-sidebar-tpl-add:hover {
  background: rgba(0, 0, 0, 0.04);
  color: var(--color-text-primary);
  border-color: var(--color-text-secondary);
}
[data-theme="dark"] .chat-sidebar-tpl-add:hover {
  background: rgba(255, 255, 255, 0.06);
}

.chat-sidebar-custom-tpls:empty::after {
  content: '';
}

.chat-sidebar-tpl-actions {
  display: none;
  margin-left: auto;
  gap: 4px;
  flex-shrink: 0;
  pointer-events: none;
}

.chat-sidebar-tpl-btn:hover .chat-sidebar-tpl-actions {
  display: flex;
  pointer-events: auto;
}

.chat-sidebar-tpl-pin,
.chat-sidebar-tpl-edit,
.chat-sidebar-tpl-del {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 14px;
  color: var(--color-text-secondary);
  transition: background 0.15s ease, color 0.15s ease;
  position: relative;
}

.chat-sidebar-tpl-pin::before,
.chat-sidebar-tpl-edit::before,
.chat-sidebar-tpl-del::before {
  content: '';
  position: absolute;
  inset: -8px;
  min-width: 44px;
  min-height: 44px;
}

.chat-sidebar-tpl-pin:hover {
  background: rgba(0, 0, 0, 0.06);
  color: var(--color-text-primary);
}
[data-theme="dark"] .chat-sidebar-tpl-pin:hover {
  background: rgba(255, 255, 255, 0.08);
}
.chat-sidebar-tpl-pin.is-pinned {
  color: var(--color-text-secondary);
}

.chat-sidebar-tpl-edit:hover {
  background: rgba(0, 0, 0, 0.06);
  color: var(--color-text-primary);
}
[data-theme="dark"] .chat-sidebar-tpl-edit:hover {
  background: rgba(255, 255, 255, 0.08);
}

.chat-sidebar-tpl-del:hover {
  background: rgba(255, 62, 29, 0.1);
  color: #ff3e1d;
}

/* Small dot indicator for pinned templates in sidebar */
.chat-sidebar-tpl-pin-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--color-text-secondary, #646e78);
  flex-shrink: 0;
  margin-left: -6px;
  margin-right: -2px;
  opacity: 0.45;
}

/* "+N more" button in icon picker */
.chat-template-icon-more {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1.5px dashed var(--color-border, #e7e7e8);
  border-radius: 10px;
  background: transparent;
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  font-family: var(--font-family);
  color: var(--color-text-secondary, #646e78);
  transition: border-color 0.15s, background 0.15s, color 0.15s;
}
.chat-template-icon-more:hover {
  border-color: var(--color-text-secondary, #646e78);
  background: rgba(0, 0, 0, 0.04);
  color: var(--color-text-primary);
}
[data-theme="dark"] .chat-template-icon-more {
  border-color: rgba(255, 255, 255, 0.15);
}
[data-theme="dark"] .chat-template-icon-more:hover {
  border-color: rgba(255, 255, 255, 0.3);
  background: rgba(255, 255, 255, 0.06);
}

/* Conversation search input */
.chat-conv-search-wrap {
  padding: 0 0 8px;
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--color-card);
}

.chat-conv-search {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  font-size: 13px;
  font-family: var(--font-family);
  color: var(--color-text-primary);
  background: var(--color-bg);
  transition: border-color 0.15s, box-shadow 0.15s;
  box-sizing: border-box;
}

.chat-conv-search::placeholder {
  color: var(--color-text-secondary, #646e78);
  opacity: 0.7;
}

.chat-conv-search:focus {
  outline: none;
  border-color: rgba(0, 0, 0, 0.25);
  box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.06);
  background: var(--color-card);
}

[data-theme="dark"] .chat-conv-search {
  background: rgba(255, 255, 255, 0.04);
  border-color: rgba(255, 255, 255, 0.1);
  color: var(--color-text-primary);
}

[data-theme="dark"] .chat-conv-search:focus {
  border-color: rgba(255, 255, 255, 0.25);
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.06);
  background: rgba(255, 255, 255, 0.06);
}

[data-theme="dark"] .chat-conv-search-wrap {
  background: var(--color-card);
}

.chat-conv-history {
  padding: 0 12px 12px;
  margin-top: var(--space-1);
  border-top: none;
  padding-top: 0;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: thin;
  scrollbar-color: var(--color-border) transparent;
}

.chat-conv-history::-webkit-scrollbar {
  width: 4px;
}

.chat-conv-history::-webkit-scrollbar-thumb {
  background: var(--color-border);
  border-radius: 4px;
}

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

.chat-conv-show-more {
  display: block;
  width: 100%;
  padding: 8px 10px;
  min-height: 44px;
  border: none;
  background: transparent;
  color: var(--color-text-secondary, #646e78);
  font-size: 13px;
  font-weight: 500;
  font-family: var(--font-family);
  cursor: pointer;
  text-align: left;
  border-radius: 8px;
  transition: background 0.15s, color 0.15s;
  margin-top: 4px;
}

.chat-conv-show-more:hover {
  background: rgba(0, 0, 0, 0.04);
  color: var(--color-text-primary);
}
[data-theme="dark"] .chat-conv-show-more:hover {
  background: rgba(255, 255, 255, 0.06);
}

.chat-conv-label {
  display: flex !important;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 500;
  color: var(--color-text-secondary);
  padding: 12px 0 8px;
}

.chat-conv-label .menu-header-line {
  display: none;
}

.chat-conv-group-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--color-text-secondary);
  padding: 16px 10px 4px;
  user-select: none;
}
.chat-conv-group-label:first-child {
  padding-top: 4px;
}

.chat-conv-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 8px 10px;
  min-height: 44px;
  border: none;
  background: transparent;
  border-radius: 8px;
  cursor: pointer;
  font-family: var(--font-family);
  font-size: 13px;
  color: var(--color-text);
  transition: background 0.15s;
  text-align: left;
  margin-bottom: 1px;
}

.chat-conv-item:hover {
  background: rgba(0, 0, 0, 0.04);
}
[data-theme="dark"] .chat-conv-item:hover {
  background: rgba(255, 255, 255, 0.06);
}

.chat-conv-item.active {
  background: rgba(0, 0, 0, 0.06);
}
[data-theme="dark"] .chat-conv-item.active {
  background: rgba(255, 255, 255, 0.08);
}

.chat-conv-item-icon {
  flex-shrink: 0;
  opacity: 0.35;
  color: var(--color-text-secondary);
}

.chat-conv-item-title {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 400;
}

.chat-conv-item-del {
  display: none;
  border: none;
  background: transparent;
  color: var(--color-text-secondary);
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  padding: 2px 4px;
  border-radius: 4px;
  position: relative;
}

.chat-conv-item-del::before {
  content: '';
  position: absolute;
  inset: -10px;
  min-width: 44px;
  min-height: 44px;
}

.chat-conv-item:hover .chat-conv-item-del,
.chat-conv-item.active .chat-conv-item-del {
  display: block;
}

.chat-conv-item-del:hover {
  color: #b91c1c;
  background: rgba(185, 28, 28, 0.08);
}
[data-theme="dark"] .chat-conv-item-del:hover {
  color: #fca5a5;
  background: rgba(252, 165, 165, 0.12);
}

.chat-conv-empty {
  font-size: 13px;
  color: var(--color-text-secondary);
  padding: 8px 0;
  font-style: italic;
}

.chat-conv-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px;
}

.chat-conv-new-btn {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  border: none;
  background: transparent;
  color: var(--color-text-secondary);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, color 0.15s;
  position: relative;
}

.chat-conv-new-btn::before {
  content: '';
  position: absolute;
  inset: -8px;
  min-width: 44px;
  min-height: 44px;
}

.chat-conv-new-btn:hover {
  color: var(--color-text-primary);
  background: rgba(0, 0, 0, 0.06);
}
[data-theme="dark"] .chat-conv-new-btn:hover {
  background: rgba(255, 255, 255, 0.08);
}

@media (max-width: 767px) {
  .chat-sidebar-templates {
    padding: 0 var(--space-2);
  }
  .chat-sidebar-tpl-btn {
    padding: 6px var(--space-2);
  }
}
