/* ==========================================================================
   TASKMANAGER v3 — COMPONENT LIBRARY
   Reusable UI Components referenzieren design-system.css Tokens.
   ========================================================================== */

/* ==========================================================================
   1. BUTTONS
   ========================================================================== */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  font-family: var(--font-family);
  font-weight: var(--fw-medium);
  line-height: 1;
  border: 1px solid transparent;
  border-radius: var(--radius-lg);
  cursor: pointer;
  transition: all var(--duration-fast) var(--ease-in-out);
  white-space: nowrap;
  user-select: none;
  text-decoration: none;
}

.btn:disabled {
  opacity: 0.5;
  pointer-events: none;
}

/* Sizes */
.btn-xs { font-size: var(--text-caption); padding: var(--space-1) var(--space-2); }
.btn-sm { font-size: var(--text-body-s);  padding: var(--space-2) var(--space-3); }
.btn-md { font-size: var(--text-body-m);  padding: var(--space-3) var(--space-4); min-width: 80px; }
.btn-lg { font-size: var(--text-body-l);  padding: var(--space-4) var(--space-6); min-width: 120px; }

/* Variants */
.btn-primary {
  background-color: var(--primary);
  color: var(--text-inverse);
  border-color: var(--primary);
}
.btn-primary:hover { background-color: var(--primary-hover); border-color: var(--primary-hover); transform: translateY(-1px); box-shadow: var(--shadow-md); }
.btn-primary:active { transform: translateY(0); box-shadow: none; }

.btn-secondary {
  background-color: var(--surface);
  color: var(--text);
  border-color: var(--border);
}
.btn-secondary:hover { background-color: var(--surface-alt); border-color: var(--text-muted); }

.btn-danger {
  background-color: var(--danger);
  color: var(--text-inverse);
  border-color: var(--danger);
}
.btn-danger:hover { opacity: 0.9; transform: translateY(-1px); box-shadow: var(--shadow-md); }

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

.btn-link {
  background-color: transparent;
  color: var(--primary);
  border-color: transparent;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.btn-link:hover { color: var(--primary-hover); }

/* Loading state */
.btn-loading {
  position: relative;
  color: transparent !important;
  pointer-events: none;
}
.btn-loading::after {
  content: "";
  position: absolute;
  width: 1em;
  height: 1em;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: var(--radius-full);
  animation: btn-spin 0.6s linear infinite;
}
.btn-loading.btn-primary::after,
.btn-loading.btn-danger::after {
  border-color: var(--text-inverse);
  border-right-color: transparent;
}

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

/* Icon-only button */
.btn-icon {
  padding: var(--space-2);
  min-width: unset;
  border-radius: var(--radius-md);
}


/* ==========================================================================
   2. INPUTS & FORMS
   ========================================================================== */

.form-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.form-label {
  font-size: var(--text-body-s);
  font-weight: var(--fw-medium);
  color: var(--text);
}

.form-input,
.form-select,
.form-textarea {
  font-family: var(--font-family);
  font-size: var(--text-body-m);
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background-color: var(--surface);
  color: var(--text);
  transition: border-color var(--duration-fast) var(--ease-in-out),
              box-shadow var(--duration-fast) var(--ease-in-out);
  width: 100%;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: var(--shadow-focus);
}

.form-input::placeholder { color: var(--text-muted); }

.form-input-error {
  border-color: var(--danger);
}
.form-input-error:focus {
  box-shadow: var(--shadow-focus-danger);
}

.form-error-text {
  font-size: var(--text-caption);
  color: var(--danger);
}

.form-helper-text {
  font-size: var(--text-caption);
  color: var(--text-muted);
}

.form-checkbox {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  cursor: pointer;
  font-size: var(--text-body-s);
}

.form-checkbox input[type="checkbox"] {
  width: 1rem;
  height: 1rem;
  accent-color: var(--primary);
}


/* ==========================================================================
   3. CARDS
   ========================================================================== */

.card {
  background-color: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.card-elevated {
  box-shadow: var(--shadow-lg);
}

.card-interactive {
  cursor: pointer;
  transition: all var(--duration-fast) var(--ease-in-out);
}
.card-interactive:hover {
  box-shadow: var(--shadow-md);
  border-color: var(--primary-light);
  transform: translateY(-1px);
}

.card-selected {
  border-color: var(--primary);
  box-shadow: var(--shadow-focus);
}

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

.card-body {
  padding: var(--space-6);
}

.card-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-6);
  border-top: 1px solid var(--border);
}


/* ==========================================================================
   4. MODALS & OVERLAYS
   ========================================================================== */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: var(--z-modal);
  animation: fadeIn var(--duration-fast) var(--ease-out);
  padding: var(--space-4);
}

.modal {
  background: var(--surface);
  border-radius: var(--radius-2xl);
  box-shadow: var(--shadow-2xl);
  width: 100%;
  max-width: 600px;
  max-height: 90vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  animation: scaleUp var(--duration-normal) var(--ease-out);
}

.modal-sm  { max-width: 400px; }
.modal-lg  { max-width: 800px; }
.modal-xl  { max-width: 1000px; }

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

.modal-title {
  font-size: var(--text-h4);
  font-weight: var(--fw-semibold);
}

.modal-body {
  padding: var(--space-6);
  overflow-y: auto;
  flex: 1;
}

.modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-6);
  border-top: 1px solid var(--border);
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: var(--space-1);
  border-radius: var(--radius-md);
  transition: background var(--duration-fast);
}
.modal-close:hover { background: var(--surface-alt); color: var(--text); }


/* ==========================================================================
   5. TOASTS / NOTIFICATIONS
   ========================================================================== */

.toast-container {
  position: fixed;
  top: var(--space-4);
  right: var(--space-4);
  z-index: var(--z-toast);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  padding: var(--space-4);
  border-radius: var(--radius-lg);
  border: 1px solid;
  box-shadow: var(--shadow-lg);
  min-width: 300px;
  max-width: 450px;
  animation: slideInRight var(--duration-normal) var(--ease-out);
  pointer-events: auto;
}

.toast-success { background: var(--alert-success-bg); border-color: var(--alert-success-border); color: var(--alert-success-fg); }
.toast-warning { background: var(--alert-warning-bg); border-color: var(--alert-warning-border); color: var(--alert-warning-fg); }
.toast-error   { background: var(--alert-error-bg);   border-color: var(--alert-error-border);   color: var(--alert-error-fg);   }
.toast-info    { background: var(--alert-info-bg);    border-color: var(--alert-info-border);    color: var(--alert-info-fg);    }

.toast-title   { font-weight: var(--fw-semibold); font-size: var(--text-body-s); }
.toast-message { font-size: var(--text-body-s); margin-top: var(--space-1); }
.toast-close   { margin-left: auto; background: none; border: none; cursor: pointer; color: inherit; opacity: 0.6; }
.toast-close:hover { opacity: 1; }


/* ==========================================================================
   6. BADGES & TAGS
   ========================================================================== */

.badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  font-size: var(--text-caption);
  font-weight: var(--fw-medium);
  padding: 2px var(--space-2);
  border-radius: var(--radius-full);
  line-height: 1.4;
}

.badge-open       { background: var(--alert-info-bg);    color: var(--alert-info-fg);    }
.badge-progress   { background: var(--alert-warning-bg); color: var(--alert-warning-fg); }
.badge-done       { background: var(--alert-success-bg); color: var(--alert-success-fg); }
.badge-cancelled  { background: var(--chip-bg);          color: var(--text-muted);       }
.badge-overdue    { background: var(--alert-error-bg);   color: var(--alert-error-fg);   }

.tag {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  font-size: var(--text-caption);
  padding: 2px var(--space-2);
  border-radius: var(--radius-md);
  background: var(--chip-bg);
  color: var(--chip-fg);
}

.tag-removable { padding-right: var(--space-1); }
.tag-remove {
  background: none;
  border: none;
  cursor: pointer;
  color: inherit;
  opacity: 0.6;
  font-size: var(--text-caption);
  line-height: 1;
  padding: 2px;
}
.tag-remove:hover { opacity: 1; }


/* ==========================================================================
   7. NAVIGATION COMPONENTS
   ========================================================================== */

/* Breadcrumbs */
.breadcrumbs {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-body-s);
  color: var(--text-secondary);
}
.breadcrumbs a { color: var(--text-secondary); text-decoration: none; }
.breadcrumbs a:hover { color: var(--primary); }
.breadcrumbs-sep { color: var(--text-muted); }
.breadcrumbs-current { color: var(--text); font-weight: var(--fw-medium); }

/* Tabs */
.tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--border);
}
.tab {
  padding: var(--space-3) var(--space-4);
  font-size: var(--text-body-s);
  font-weight: var(--fw-medium);
  color: var(--text-secondary);
  border: none;
  background: none;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: all var(--duration-fast);
}
.tab:hover { color: var(--text); }
.tab-active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}


/* ==========================================================================
   8. DROPDOWN / MENUS
   ========================================================================== */

.dropdown {
  position: relative;
  display: inline-block;
}

.dropdown-menu {
  position: absolute;
  top: 100%;
  left: 0;
  min-width: 180px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  z-index: var(--z-dropdown);
  padding: var(--space-1);
  animation: fadeIn var(--duration-fast) var(--ease-out);
}

.dropdown-item {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  width: 100%;
  padding: var(--space-2) var(--space-3);
  font-size: var(--text-body-s);
  color: var(--text);
  background: none;
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  text-align: left;
}
.dropdown-item:hover { background: var(--surface-alt); }
.dropdown-item-danger { color: var(--danger); }

.dropdown-divider {
  height: 1px;
  background: var(--border);
  margin: var(--space-1) 0;
}


/* ==========================================================================
   9. LISTS & TABLES
   ========================================================================== */

.list-row {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--border-subtle);
  transition: background var(--duration-fast);
}
.list-row:hover { background: var(--surface-alt); }
.list-row-selected { background: rgba(79, 70, 229, 0.06); }
.list-row-overdue { border-left: 3px solid var(--danger); }

.list-row-actions {
  margin-left: auto;
  display: flex;
  gap: var(--space-2);
  opacity: 0;
  transition: opacity var(--duration-fast);
}
.list-row:hover .list-row-actions { opacity: 1; }


/* ==========================================================================
   10. AVATARS
   ========================================================================== */

.avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-full);
  background: var(--primary);
  color: var(--text-inverse);
  font-weight: var(--fw-semibold);
  user-select: none;
  flex-shrink: 0;
}

.avatar-sm { width: 24px; height: 24px; font-size: 10px; }
.avatar-md { width: 32px; height: 32px; font-size: 12px; }
.avatar-lg { width: 40px; height: 40px; font-size: 14px; }
.avatar-xl { width: 64px; height: 64px; font-size: 22px; }


/* ==========================================================================
   11. EMPTY STATES
   ========================================================================== */

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-16) var(--space-8);
  text-align: center;
  color: var(--text-secondary);
}

.empty-state-icon {
  font-size: 3rem;
  margin-bottom: var(--space-4);
  opacity: 0.5;
}

.empty-state-title {
  font-size: var(--text-h5);
  font-weight: var(--fw-semibold);
  color: var(--text);
  margin-bottom: var(--space-2);
}

.empty-state-text {
  font-size: var(--text-body-s);
  max-width: 300px;
  margin-bottom: var(--space-6);
}


/* ==========================================================================
   12. SKELETON LOADING
   ========================================================================== */

.skeleton {
  background: linear-gradient(90deg, var(--surface-alt) 25%, var(--border-subtle) 50%, var(--surface-alt) 75%);
  background-size: 200% 100%;
  animation: skeleton-pulse 1.5s ease-in-out infinite;
  border-radius: var(--radius-md);
}

.skeleton-text { height: 1em; width: 100%; }
.skeleton-title { height: 1.5em; width: 60%; }
.skeleton-avatar { border-radius: var(--radius-full); }
.skeleton-card { height: 120px; width: 100%; }

@keyframes skeleton-pulse {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}


/* ==========================================================================
   13. PROGRESS RING (SVG)
   ========================================================================== */

.progress-ring {
  transform: rotate(-90deg);
}
.progress-ring-bg {
  fill: none;
  stroke: var(--border);
  stroke-width: 4;
}
.progress-ring-fill {
  fill: none;
  stroke: var(--primary);
  stroke-width: 4;
  stroke-linecap: round;
  transition: stroke-dashoffset var(--duration-normal) var(--ease-out);
}


/* ==========================================================================
   14. KEYFRAME ANIMATIONS
   ========================================================================== */

@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@keyframes slideUp {
  from { transform: translateY(20px); opacity: 0; }
  to   { transform: translateY(0); opacity: 1; }
}

@keyframes slideInRight {
  from { transform: translateX(100%); }
  to   { transform: translateX(0); }
}

@keyframes scaleUp {
  from { transform: scale(0.95); opacity: 0; }
  to   { transform: scale(1); opacity: 1; }
}

/* ==========================================================================
   16. RESPONSIVE DESIGN SYSTEM
   Breakpoints: SM=640px, MD=768px, LG=1024px, XL=1280px
   ========================================================================== */

/* ---- 16.1 Buttons (Touch-friendly at mobile) ---- */
@media (max-width: 768px) {
  .btn-md {
    padding: var(--space-3) var(--space-4);
    font-size: var(--text-body-s);
    min-width: unset;
  }
  .btn-lg {
    padding: var(--space-3) var(--space-5);
    font-size: var(--text-body-m);
    min-width: unset;
    width: 100%;
  }
  .btn-icon {
    min-height: 44px;
    min-width: 44px;
  }
}

/* ---- 16.2 Inputs (Touch targets) ---- */
@media (pointer: coarse) {
  .form-input,
  .form-select,
  .form-textarea {
    min-height: 44px;
    font-size: var(--text-body-m);
  }
  .form-checkbox input[type="checkbox"] {
    width: 1.25rem;
    height: 1.25rem;
  }
}

@media (max-width: 768px) {
  .form-group {
    margin-bottom: var(--space-3);
  }
}

/* ---- 16.3 Cards (Full width on mobile) ---- */
@media (max-width: 640px) {
  .card {
    border-radius: var(--radius-md);
  }
  .card-header {
    padding: var(--space-3) var(--space-4);
    flex-wrap: wrap;
    gap: var(--space-2);
  }
  .card-body {
    padding: var(--space-4);
  }
  .card-footer {
    padding: var(--space-3) var(--space-4);
    flex-wrap: wrap;
  }
}

/* ---- 16.4 Modals (Full-screen on mobile) ---- */
@media (max-width: 640px) {
  .modal-overlay {
    padding: 0;
    align-items: flex-end;
  }
  .modal {
    max-width: 100%;
    max-height: 95vh;
    border-radius: var(--radius-2xl) var(--radius-2xl) 0 0;
    animation: slideUp var(--duration-normal) var(--ease-out);
  }
  .modal-sm { max-width: 100%; }
  .modal-lg { max-width: 100%; }
  .modal-xl { max-width: 100%; }
  .modal-header {
    padding: var(--space-4);
  }
  .modal-body {
    padding: var(--space-4);
  }
  .modal-footer {
    padding: var(--space-3) var(--space-4);
    flex-direction: column-reverse;
  }
  .modal-footer .btn {
    width: 100%;
  }
}

/* ---- 16.5 Toasts (Full width on mobile) ---- */
@media (max-width: 480px) {
  .toast-container {
    top: var(--space-2);
    right: var(--space-2);
    left: var(--space-2);
  }
  .toast {
    min-width: unset;
    max-width: 100%;
    width: 100%;
  }
}

/* ---- 16.6 Badges & Tags ---- */
@media (max-width: 480px) {
  .badge {
    font-size: 10px;
    padding: 1px var(--space-1);
  }
  .tag {
    font-size: 10px;
    padding: 1px var(--space-1);
  }
}

/* ---- 16.7 Navigation ---- */
@media (max-width: 768px) {
  .tabs {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .tabs::-webkit-scrollbar {
    display: none;
  }
  .tab {
    padding: var(--space-2) var(--space-3);
    font-size: var(--text-caption);
    white-space: nowrap;
  }
  .breadcrumbs {
    font-size: var(--text-caption);
  }
}

/* ---- 16.8 Dropdowns (Full width on small screens) ---- */
@media (max-width: 480px) {
  .dropdown-menu {
    position: fixed;
    top: auto;
    bottom: 0;
    left: 0;
    right: 0;
    min-width: 100%;
    border-radius: var(--radius-2xl) var(--radius-2xl) 0 0;
    box-shadow: var(--shadow-2xl);
    padding: var(--space-2);
    animation: slideUp var(--duration-normal) var(--ease-out);
  }
  .dropdown-item {
    padding: var(--space-3) var(--space-4);
    font-size: var(--text-body-m);
    min-height: 44px;
  }
}

/* ---- 16.9 Tables (Mobile: Card view) ---- */
@media (max-width: 768px) {
  .table-wrapper {
    border: none;
    border-radius: 0;
    box-shadow: none;
    overflow: visible;
  }
}

/* ---- 16.10 List Rows (Touch targets) ---- */
@media (pointer: coarse) {
  .list-row {
    min-height: 48px;
    padding: var(--space-3);
  }
  .list-row-actions {
    opacity: 1;
  }
}

@media (max-width: 768px) {
  .list-row-actions {
    opacity: 1;
  }
}

/* ---- 16.11 Avatars ---- */
@media (max-width: 480px) {
  .avatar-sm { width: 20px; height: 20px; font-size: 8px; }
  .avatar-md { width: 28px; height: 28px; font-size: 10px; }
  .avatar-lg { width: 36px; height: 36px; font-size: 12px; }
  .avatar-xl { width: 52px; height: 52px; font-size: 18px; }
}

/* ---- 16.12 Empty States ---- */
@media (max-width: 480px) {
  .empty-state {
    padding: var(--space-8) var(--space-4);
  }
  .empty-state-icon {
    font-size: 2rem;
  }
}

/* ==========================================================================
   17. SMOOTH PAGE TRANSITIONS (View Transitions API)
   ========================================================================== */

@view-transition {
  navigation: auto;
}

::view-transition-old(root) {
  animation: vt-fade-out 200ms ease-out;
}

::view-transition-new(root) {
  animation: vt-fade-in 200ms ease-in;
}

@keyframes vt-fade-out {
  from { opacity: 1; }
  to   { opacity: 0; }
}

@keyframes vt-fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

/* ==========================================================================
   18. FOCUS VISIBLE ENHANCEMENT (Accessibility)
   ========================================================================== */

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

/* Remove outline for mouse users */
:focus:not(:focus-visible) {
  outline: none;
}

/* High-contrast focus for dark mode */
@media (prefers-contrast: high) {
  :focus-visible {
    outline-width: 3px;
    outline-offset: 3px;
  }
  .btn-primary:focus-visible {
    outline-color: var(--color-outline);
  }
}

/* ==========================================================================
   19. REDUCED MOTION (Accessibility)
   ========================================================================== */

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }

  .skeleton {
    animation: none;
    background: var(--surface-alt);
  }

  .card {
    animation: none;
    opacity: 1;
    transform: none;
  }

  ::view-transition-old(root),
  ::view-transition-new(root) {
    animation: none;
  }
}

/* ==========================================================================
   19b. AUTHOR BADGE (Admin-Modus)
   ========================================================================== */

.author-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 1px 6px;
  border-radius: var(--radius-pill);
  background: rgba(59, 130, 246, 0.08);
  border: 1px solid rgba(59, 130, 246, 0.2);
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--primary);
  white-space: nowrap;
  line-height: 1.4;
  flex-shrink: 0;
}

.author-badge__avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  font-size: 0.6rem;
  font-weight: 700;
  flex-shrink: 0;
}

.author-badge__name {
  max-width: 80px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

html[data-theme="dark"] .author-badge {
  background: rgba(96, 165, 250, 0.15);
  border-color: rgba(96, 165, 250, 0.3);
  color: var(--primary-hover);
}

html[data-theme="dark"] .author-badge__avatar {
  background: var(--primary);
}

@media (max-width: 768px) {
  .author-badge__name {
    display: none;
  }
}

/* ==========================================================================
   20. PRINT STYLES
   ========================================================================== */

@media print {
  .toast-container,
  .modal-overlay,
  .btn,
  .filterbar,
  .search-bar-primary,
  .new-item-form,
  .bulk-bar {
    display: none !important;
  }

  body {
    background: var(--color-outline);
    color: var(--text);
    font-size: 12pt;
  }

  .card {
    box-shadow: none;
    border: 1px solid var(--border);
    break-inside: avoid;
  }

  a {
    color: var(--text);
    text-decoration: underline;
  }
}
/* ==========================================================================
   PATCH: Dark-mode adaptivity + Motion presets + Type badges
   Apply AFTER existing components.css. Overrides specific sections.
   ========================================================================== */

/* ---- Type Badge Colors (new tokens) ---- */
.type-badge--task        { color: var(--type-task);        background: var(--type-task-bg); }
.type-badge--appointment { color: var(--type-appointment); background: var(--type-appointment-bg); }
.type-badge--event       { color: var(--type-event);       background: var(--type-event-bg); }
.type-badge--reminder    { color: var(--type-reminder);    background: var(--type-reminder-bg); }
.type-badge--birthday    { color: var(--type-birthday);    background: var(--type-birthday-bg); }

/* ---- Status Badge Colors ---- */
.badge--open      { color: var(--status-open);      background: rgba(59, 130, 246, 0.1); }
.badge--progress  { color: var(--status-progress);  background: rgba(245, 158, 11, 0.1); }
.badge--done      { color: var(--status-done);      background: rgba(16, 185, 129, 0.1); }
.badge--cancelled { color: var(--status-cancelled); background: rgba(148, 163, 184, 0.1); }

/* ---- Button: Spring animation on hover ---- */
.btn-primary {
  transition: transform var(--duration-fast) var(--ease-spring),
              box-shadow var(--duration-normal) var(--ease-default),
              background-color var(--duration-fast) var(--ease-default),
              border-color var(--duration-fast) var(--ease-default);
}

.btn-primary:hover {
  transform: translateY(-1px) scale(1.01);
}

.btn-primary:active {
  transform: translateY(0) scale(0.99);
}

.btn-ghost:hover {
  transition: background-color var(--duration-fast) var(--ease-default),
              color var(--duration-fast) var(--ease-default);
}

/* ---- Card: Subtle elevation shift on hover ---- */
.card-interactive {
  transition: transform var(--duration-normal) var(--ease-spring),
              box-shadow var(--duration-normal) var(--ease-default),
              border-color var(--duration-fast) var(--ease-default);
}

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

/* ---- Modal: Smoother entrance ---- */
.modal {
  animation: modal-in var(--duration-moderate) var(--ease-emphatic);
}

@keyframes modal-in {
  from {
    transform: scale(0.92) translateY(12px);
    opacity: 0;
  }
  to {
    transform: scale(1) translateY(0);
    opacity: 1;
  }
}

/* ---- Toast: Slide + fade ---- */
.toast {
  animation: toast-in var(--duration-moderate) var(--ease-emphatic);
}

@keyframes toast-in {
  from {
    transform: translateX(100%) scale(0.95);
    opacity: 0;
  }
  to {
    transform: translateX(0) scale(1);
    opacity: 1;
  }
}

/* ---- KBD styling ---- */
kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.6em;
  height: 1.6em;
  padding: 0 var(--space-1);
  font-family: var(--font-family-mono);
  font-size: 11px;
  font-weight: var(--fw-medium);
  color: var(--kbd-fg);
  background: var(--kbd-bg);
  border: 1px solid var(--kbd-border);
  border-radius: var(--radius-xs);
  line-height: 1;
  box-shadow: 0 1px 0 var(--kbd-border);
}

/* ---- Skeleton: Smoother shimmer ---- */
.skeleton {
  background: linear-gradient(90deg,
    var(--surface-alt) 0%,
    var(--border-subtle) 40%,
    var(--surface-alt) 80%
  );
  background-size: 300% 100%;
  animation: skeleton-shimmer 2s ease-in-out infinite;
}

@keyframes skeleton-shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -100% 0; }
}

/* ---- Divider ---- */
.divider {
  height: 1px;
  background: var(--border);
  border: none;
  margin: var(--space-4) 0;
}

/* ---- Surface Variants ---- */
.surface-raised {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

.surface-overlay {
  background: var(--surface-overlay);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
}

.surface-sunken {
  background: var(--surface-alt);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-inner);
}

/* ---- HTMX Loading Bar (polished) ---- */
.htmx-loading::after {
  height: 3px;
  background: linear-gradient(90deg, transparent, var(--primary), var(--primary-light), transparent);
  background-size: 200% 100%;
  animation: htmx-loading-bar 1.2s ease-in-out infinite;
  border-radius: var(--radius-full);
}

/* ── Checklist ──────────────────────────────────────── */

.checklist-list {
  margin: 0.5rem 0;
}

.checklist-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0.5rem;
  border-radius: 4px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  margin-bottom: 0.35rem;
  transition: background 0.15s ease;
}

.checklist-item:hover {
  background: var(--color-surface-hover);
}

.checklist-handle {
  cursor: grab;
  color: var(--color-muted);
  font-size: 1.1rem;
  line-height: 1;
  user-select: none;
  flex-shrink: 0;
}

.checklist-handle:active {
  cursor: grabbing;
}

.checklist-check {
  flex-shrink: 0;
  width: 1.1rem;
  height: 1.1rem;
  cursor: pointer;
  accent-color: var(--color-primary);
}

.checklist-text {
  flex: 1;
  font-size: 0.9rem;
  padding: 0.2rem 0.4rem;
  border-radius: 3px;
  border: 1px solid transparent;
  outline: none;
  word-break: break-word;
  min-width: 0;
}

.checklist-text:focus {
  border-color: var(--color-primary);
  background: var(--color-primary-light);
}

.checklist-text--done {
  text-decoration: line-through;
  color: var(--color-muted);
}

.checklist-remove {
  flex-shrink: 0;
  background: none;
  border: none;
  color: var(--color-muted);
  cursor: pointer;
  font-size: 1rem;
  padding: 0.2rem 0.4rem;
  border-radius: 3px;
  transition: color 0.15s ease;
}

.checklist-remove:hover {
  color: var(--color-error);
  background: var(--color-error-light);
}

.checklist-add {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.5rem;
  align-items: center;
}

.checklist-add input {
  flex: 1;
  padding: 0.45rem 0.5rem;
  border: 1px solid var(--color-border);
  border-radius: 4px;
  font-size: 0.9rem;
}

.checklist-progress {
  width: 100%;
  height: 4px;
  background: var(--color-border);
  border-radius: 2px;
  margin-top: 0.5rem;
  overflow: hidden;
}

.checklist-progress-bar {
  height: 100%;
  background: var(--color-success);
  border-radius: 2px;
  transition: width 0.3s ease;
}

.checklist-progress-text {
  font-size: 0.75rem;
  color: var(--color-muted);
  margin-top: 0.25rem;
  display: block;
}

/* Responsive: Mobile */
@media (max-width: 480px) {
  .checklist-item {
    gap: 0.35rem;
    padding: 0.35rem 0.4rem;
  }
  
  .checklist-text {
    font-size: 0.85rem;
  }
  
  .checklist-handle {
    font-size: 1rem;
  }
  
  .checklist-add {
    flex-direction: column;
    gap: 0.35rem;
  }
  
  .checklist-add input {
    width: 100%;
  }
  
  .checklist-add .btn {
    width: 100%;
  }
}

/* Drag & Drop States */
.checklist-item.sortable-ghost {
  opacity: 0.4;
  background: var(--color-primary-light);
}

.checklist-item.sortable-chosen {
  background: var(--color-primary-light);
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}
