/* ==========================================================================
   main.css — Global design system: reset, layout, typography, forms,
   buttons, cards, toasts, scrollbar, utilities, skeleton, markdown
   UI/UX Pro Max — Notion/Linear-level productivity app
   ========================================================================== */

/* ---------- CSS Custom Properties (Design Tokens) ---------- */
:root {
  /* Primary — Indigo */
  --primary-50: #EEF2FF;
  --primary-100: #E0E7FF;
  --primary-200: #C7D2FE;
  --primary-500: #6366F1;
  --primary-600: #4F46E5;
  --primary-700: #4338CA;

  /* Neutral */
  --gray-50: #F9FAFB;
  --gray-100: #F3F4F6;
  --gray-200: #E5E7EB;
  --gray-300: #D1D5DB;
  --gray-400: #9CA3AF;
  --gray-500: #6B7280;
  --gray-600: #4B5563;
  --gray-700: #374151;
  --gray-800: #1F2937;
  --gray-900: #111827;

  /* Sidebar Dark */
  --sidebar-bg: #0F172A;
  --sidebar-surface: #1E293B;
  --sidebar-hover: #334155;
  --sidebar-active: #3B4F6B;
  --sidebar-text: #94A3B8;
  --sidebar-text-bright: #E2E8F0;
  --sidebar-accent: #818CF8;

  /* Status */
  --success-500: #22C55E;
  --success-50: #F0FDF4;
  --warning-500: #F59E0B;
  --warning-50: #FFFBEB;
  --danger-500: #EF4444;
  --danger-50: #FEF2F2;
  --info-500: #3B82F6;
  --info-50: #EFF6FF;

  /* Semantic aliases (backward compat) */
  --primary: var(--primary-500);
  --primary-hover: var(--primary-600);
  --primary-light: var(--primary-50);
  --bg: var(--gray-50);
  --surface: #FFFFFF;
  --surface-hover: var(--gray-50);
  --border: var(--gray-200);
  --border-light: var(--gray-100);
  --text: var(--gray-900);
  --text-secondary: var(--gray-500);
  --text-muted: var(--gray-400);
  --success: var(--success-500);
  --success-light: var(--success-50);
  --warning: var(--warning-500);
  --warning-light: var(--warning-50);
  --danger: var(--danger-500);
  --danger-light: var(--danger-50);
  --info: var(--info-500);
  --info-light: var(--info-50);

  /* Layout */
  --sidebar-width: 280px;
  --header-height: 56px;
  --tab-bar-height: 44px;
  --ai-panel-width: 380px;
  --ai-panel-min-width: 250px;

  /* Shadows */
  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.1), 0 1px 2px rgba(0, 0, 0, 0.06);
  --shadow: var(--shadow-sm);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);

  /* Radius */
  --radius-sm: 6px;
  --radius: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  --radius-full: 9999px;

  /* Spacing (8px grid) */
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 12px;
  --space-lg: 16px;
  --space-xl: 24px;
  --space-2xl: 32px;
  --space-3xl: 48px;

  /* Typography */
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Noto Sans TC', 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', 'Cascadia Code', monospace;
  --text-xs: 0.75rem;     /* 12px */
  --text-sm: 0.8125rem;   /* 13px */
  --text-base: 0.875rem;  /* 14px */
  --text-lg: 1rem;        /* 16px */
  --text-xl: 1.25rem;     /* 20px */
  --text-2xl: 1.5rem;     /* 24px */
  --leading-tight: 1.3;
  --leading-normal: 1.5;
  --leading-relaxed: 1.6;

  /* Focus ring */
  --focus-ring: 0 0 0 2px var(--primary-100), 0 0 0 4px var(--primary-500);

  /* Transitions */
  --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-base: 200ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: 300ms cubic-bezier(0.4, 0, 0.2, 1);
  /* Shorthand aliases */
  --transition: var(--transition-base);

  /* Tab colors (backward compat) */
  --tab-active: var(--primary-500);
  --tab-inactive: var(--text-secondary);

  /* Legacy aliases (backward compat) */
  --color-primary: var(--primary-500);
  --color-primary-light: var(--sidebar-accent);
  --color-primary-dark: var(--primary-700);
  --color-primary-50: var(--primary-50);
  --color-primary-100: var(--primary-100);
  --color-bg: var(--bg);
  --color-bg-alt: var(--surface-hover);
  --color-surface: var(--surface);
  --color-border: var(--border);
  --color-border-light: var(--border-light);
  --color-sidebar-bg: var(--sidebar-bg);
  --color-sidebar-text: var(--sidebar-text);
  --color-sidebar-hover: var(--sidebar-hover);
  --color-sidebar-active: var(--sidebar-active);
  --color-text: var(--text);
  --color-text-secondary: var(--text-secondary);
  --color-text-muted: var(--text-muted);
  --color-text-inverse: #F8FAFC;
  --color-success: var(--success);
  --color-success-light: var(--success-light);
  --color-warning: var(--warning);
  --color-warning-light: var(--warning-light);
  --color-danger: var(--danger);
  --color-danger-light: var(--danger-light);
  --color-info: var(--info);
  --color-info-light: var(--info-light);
}

/* ---------- Modern CSS Reset ---------- */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  line-height: 1.5;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: var(--leading-normal);
  color: var(--text);
  background: var(--bg);
  display: flex;
  min-height: 100vh;
  min-height: 100dvh;
  overflow: hidden;
}

/* Remove default focus outline, add custom one globally */
:focus {
  outline: none;
}

:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

/* ---------- Typography ---------- */
h1, h2, h3, h4, h5, h6 {
  line-height: var(--leading-tight);
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.01em;
}

h1 { font-size: var(--text-2xl); font-weight: 700; }
h2 { font-size: var(--text-xl); font-weight: 600; }
h3 { font-size: var(--text-lg); font-weight: 600; }

p {
  line-height: var(--leading-relaxed);
}

a {
  color: var(--primary-500);
  text-decoration: none;
  transition: color var(--transition-fast);
}

a:hover {
  color: var(--primary-600);
  text-decoration: underline;
}

a:focus-visible {
  box-shadow: var(--focus-ring);
  border-radius: 2px;
}

img, svg {
  display: inline-block;
  vertical-align: middle;
}

ul, ol {
  list-style: none;
}

code, pre, kbd {
  font-family: var(--font-mono);
  font-size: var(--text-sm);
}

small {
  font-size: var(--text-xs);
}

strong {
  font-weight: 600;
}

/* ---------- Layout — CSS Grid: sidebar | main | ai-panel ---------- */
#sidebar {
  width: var(--sidebar-width);
  min-width: 200px;
  max-width: 500px;
  height: 100vh;
  height: 100dvh;
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  overflow-y: auto;
  overflow-x: hidden;
  flex-shrink: 0;
  transition: width var(--transition-slow), min-width var(--transition-slow), opacity var(--transition-slow);
  z-index: 20;
  position: relative;
}

#sidebar.collapsed {
  width: 0 !important;
  min-width: 0 !important;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
}

/* Resize handle on right edge */
#sidebar-resize-handle {
  position: absolute;
  top: 0;
  right: 0;
  width: 5px;
  height: 100%;
  cursor: col-resize;
  z-index: 25;
  background: transparent;
  transition: background var(--transition-fast);
}
#sidebar-resize-handle:hover,
#sidebar-resize-handle.active {
  background: var(--sidebar-accent);
}

#main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  background: var(--bg);
}

#app-header {
  height: var(--header-height);
  padding: 0 var(--space-xl);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.header-left {
  display: flex;
  align-items: center;
  gap: var(--space-md);
}

.header-left h1 {
  font-size: var(--text-xl);
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.02em;
}

.header-right {
  display: flex;
  align-items: center;
  gap: var(--space-md);
}

.shortcut-hint {
  display: inline-flex;
  align-items: center;
  padding: 2px 7px;
  font-size: var(--text-xs);
  font-family: var(--font-mono);
  color: var(--text-muted);
  background: var(--surface-hover);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  line-height: 1.5;
}

#tab-content {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-xl);
}

#ai-panel {
  width: var(--ai-panel-width);
  min-width: var(--ai-panel-min-width);
  max-width: 50vw;
  height: 100vh;
  height: 100dvh;
  background: var(--surface);
  border-left: 1px solid var(--border);
  flex-shrink: 0;
  z-index: 15;
  transition: width var(--transition-base);
}

#ai-panel.hidden {
  display: none;
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  font-weight: 500;
  line-height: 1;
  min-height: 36px;
  height: 36px;
  padding: 10px 20px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  cursor: pointer;
  transition: all var(--transition-fast);
  white-space: nowrap;
  user-select: none;
  text-decoration: none;
  position: relative;
}

.btn:hover {
  transform: translateY(-0.5px);
}

.btn:focus-visible {
  box-shadow: var(--focus-ring);
}

.btn:active {
  transform: scale(0.97) translateY(0);
}

.btn:disabled,
.btn[disabled] {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

/* Primary — indigo gradient */
.btn-primary {
  background: linear-gradient(135deg, var(--primary-500) 0%, var(--primary-600) 100%);
  color: #FFFFFF;
  box-shadow: 0 1px 3px rgba(99, 102, 241, 0.3);
}

.btn-primary:hover {
  background: linear-gradient(135deg, var(--primary-600) 0%, var(--primary-700) 100%);
  box-shadow: 0 3px 10px rgba(99, 102, 241, 0.35);
}

.btn-primary:active {
  background: linear-gradient(135deg, var(--primary-700) 0%, var(--primary-700) 100%);
  box-shadow: 0 1px 2px rgba(99, 102, 241, 0.3);
}

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

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

.btn-ghost:active {
  background: var(--gray-200);
}

/* Outline */
.btn-outline {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border);
}

.btn-outline:hover {
  background: var(--surface-hover);
  border-color: var(--primary-500);
  color: var(--primary-500);
}

.btn-outline:active {
  background: var(--primary-50);
}

/* Secondary */
.btn-secondary {
  background: var(--surface-hover);
  color: var(--text);
  border-color: var(--border);
}

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

.btn-secondary:active {
  background: var(--gray-300);
}

/* Danger */
.btn-danger {
  background: var(--danger-500);
  color: #FFFFFF;
  box-shadow: 0 1px 3px rgba(239, 68, 68, 0.25);
}

.btn-danger:hover {
  background: #DC2626;
  box-shadow: 0 3px 10px rgba(239, 68, 68, 0.3);
}

.btn-danger:active {
  background: #B91C1C;
}

/* Success */
.btn-success {
  background: var(--success-500);
  color: #FFFFFF;
}

.btn-success:hover {
  background: #16A34A;
}

.btn-success:active {
  background: #15803D;
}

/* Size variants */
.btn-sm {
  font-size: var(--text-xs);
  min-height: 28px;
  height: 28px;
  padding: 6px 12px;
}

.btn-xs {
  font-size: 11px;
  height: 24px;
  padding: 0 var(--space-sm);
  border-radius: var(--radius-sm);
}

.btn-lg {
  font-size: var(--text-base);
  height: 44px;
  padding: 0 var(--space-xl);
}

/* Icon-only button */
.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: none;
  border-radius: var(--radius);
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
  flex-shrink: 0;
}

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

.icon-btn:focus-visible {
  box-shadow: var(--focus-ring);
}

.icon-btn:active {
  transform: scale(0.92);
}

.icon-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

/* Notion push button */
.notion-push-btn {
  color: var(--text-muted);
  font-family: var(--font-mono, monospace);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
}
.notion-push-btn:hover {
  background: #000;
  color: #fff;
  border-color: #000;
}

/* ---------- Form Elements ---------- */
input[type="text"],
input[type="search"],
input[type="email"],
input[type="number"],
input[type="date"],
input[type="url"],
input[type="password"],
textarea,
select {
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--space-sm) var(--space-md);
  min-height: 36px;
  height: 36px;
  width: 100%;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast), background var(--transition-fast);
}

textarea {
  height: auto;
  resize: vertical;
  min-height: 72px;
  line-height: var(--leading-relaxed);
}

input:hover,
textarea:hover,
select:hover {
  border-color: var(--gray-300);
}

input:focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: var(--primary-500);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

input::placeholder,
textarea::placeholder {
  color: var(--text-muted);
}

input:disabled,
textarea:disabled,
select:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  background: var(--gray-50);
}

select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12' fill='none' stroke='%236B7280' stroke-width='2'%3E%3Cpolyline points='3 4.5 6 7.5 9 4.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 30px;
  cursor: pointer;
}

label {
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--text);
}

/* Explicit form-input class for styled inputs */
.form-input {
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--space-sm) var(--space-md);
  min-height: 36px;
  height: 36px;
  width: 100%;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast), background var(--transition-fast);
}

.form-input:hover {
  border-color: var(--gray-300);
}

.form-input:focus {
  outline: none;
  border-color: var(--primary-500);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

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

.form-input:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  background: var(--gray-50);
}

/* Form group for label + input pairs */
.form-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
}

.form-group label {
  font-size: var(--text-xs);
  font-weight: 500;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* ---------- Card ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xs);
  overflow: hidden;
  transition: box-shadow var(--transition-fast);
}

.card:hover {
  box-shadow: var(--shadow-md);
}

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

.card-title {
  font-size: var(--text-lg);
  font-weight: 600;
  color: var(--text);
}

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

/* ---------- Toast Notifications ---------- */
#toast-container {
  position: fixed;
  bottom: var(--space-xl);
  right: var(--space-xl);
  z-index: 9999;
  display: flex;
  flex-direction: column-reverse;
  gap: var(--space-sm);
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: var(--surface);
  border: 1px solid var(--gray-200);
  border-radius: 6px;
  box-shadow: 0 4px 12px rgba(15, 15, 15, 0.08), 0 0 0 1px rgba(15, 15, 15, 0.02);
  font-size: var(--text-sm);
  color: var(--text);
  pointer-events: auto;
  animation: toast-in 0.3s cubic-bezier(0.21, 1.02, 0.73, 1) forwards;
  max-width: 380px;
}

/* Notion 風：變體只靠 icon 顏色表達狀態，本體保持中性白卡 */
.toast.toast-success .toast-icon { color: var(--success-500); }
.toast.toast-warning .toast-icon { color: var(--warning-500); }
.toast.toast-danger  .toast-icon { color: var(--danger-500); }
.toast.toast-info    .toast-icon { color: var(--info-500); }

.toast .toast-icon {
  flex-shrink: 0;
  width: 16px;
  height: 16px;
}

.toast .toast-message {
  flex: 1;
  line-height: var(--leading-normal);
}

.toast .toast-close {
  flex-shrink: 0;
  opacity: 0.4;
  cursor: pointer;
  transition: opacity var(--transition-fast);
  padding: 2px;
  border: none;
  background: none;
  color: inherit;
}

.toast .toast-close:hover {
  opacity: 0.8;
}

.toast.removing {
  animation: toast-out 0.2s ease-in forwards;
}

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

@keyframes toast-out {
  from {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
  to {
    opacity: 0;
    transform: translateY(8px) scale(0.95);
  }
}

/* ---------- Scrollbar (thin, 6px, rounded) ---------- */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.12);
  border-radius: var(--radius-full);
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(0, 0, 0, 0.22);
}

/* Firefox scrollbar */
* {
  scrollbar-width: thin;
  scrollbar-color: rgba(0, 0, 0, 0.12) transparent;
}

/* ---------- Markdown Body ---------- */
.markdown-body {
  font-size: var(--text-base);
  line-height: var(--leading-relaxed);
  color: var(--text);
}

.markdown-body h1,
.markdown-body h2,
.markdown-body h3 {
  margin-top: 1em;
  margin-bottom: 0.5em;
  font-weight: 600;
  color: var(--text);
}

.markdown-body h1 { font-size: 1.4em; }
.markdown-body h2 { font-size: 1.2em; }
.markdown-body h3 { font-size: 1.05em; }

.markdown-body p {
  margin: 0 0 0.75em;
}

.markdown-body ul,
.markdown-body ol {
  margin: 0.5em 0 0.75em 0;
  padding-left: 1.5em;
  list-style: revert;
}

.markdown-body li {
  margin-bottom: 0.25em;
}

.markdown-body code {
  font-family: var(--font-mono);
  font-size: 0.88em;
  background: rgba(99, 102, 241, 0.08);
  color: var(--primary-600);
  padding: 2px 6px;
  border-radius: 4px;
}

.markdown-body pre {
  background: var(--gray-800);
  color: #CDD6F4;
  border-radius: var(--radius);
  padding: var(--space-lg);
  margin: 0.75em 0;
  overflow-x: auto;
  font-size: var(--text-xs);
  line-height: 1.6;
}

.markdown-body pre code {
  background: none;
  color: inherit;
  padding: 0;
  border-radius: 0;
  font-size: inherit;
}

.markdown-body blockquote {
  border-left: 3px solid var(--primary-500);
  margin: 0.5em 0;
  padding: 0.4em 0 0.4em var(--space-lg);
  color: var(--text-secondary);
  background: rgba(99, 102, 241, 0.03);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

.markdown-body table {
  width: 100%;
  border-collapse: collapse;
  margin: 0.75em 0;
  font-size: var(--text-sm);
}

.markdown-body th,
.markdown-body td {
  border: 1px solid var(--border);
  padding: var(--space-sm) var(--space-md);
  text-align: left;
}

.markdown-body th {
  background: var(--surface-hover);
  font-weight: 600;
}

.markdown-body hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 1em 0;
}

.markdown-body img {
  max-width: 100%;
  border-radius: var(--radius);
}

.markdown-body mark {
  background: rgba(245, 158, 11, 0.2);
  color: inherit;
  padding: 1px 4px;
  border-radius: 3px;
}

.markdown-body a {
  color: var(--primary-500);
  text-decoration: underline;
  text-underline-offset: 2px;
  transition: color var(--transition-fast);
}

.markdown-body a:hover {
  color: var(--primary-600);
}

.markdown-body ul li::marker,
.markdown-body ol li::marker {
  color: var(--text-muted);
}

.markdown-body > *:first-child {
  margin-top: 0;
}

.markdown-body > *:last-child {
  margin-bottom: 0;
}

/* ---------- Skeleton Loader ---------- */
.skeleton {
  background: linear-gradient(
    90deg,
    var(--gray-100) 25%,
    var(--gray-200) 50%,
    var(--gray-100) 75%
  );
  background-size: 200% 100%;
  animation: skeleton-pulse 1.5s ease-in-out infinite;
  border-radius: var(--radius);
}

.skeleton-text {
  height: 14px;
  margin-bottom: var(--space-sm);
}

.skeleton-text:last-child {
  width: 60%;
}

.skeleton-text.short {
  width: 40%;
}

.skeleton-card {
  height: 80px;
  margin-bottom: var(--space-md);
  border-radius: var(--radius-lg);
}

.skeleton-avatar {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-full);
}

.skeleton-button {
  width: 80px;
  height: 36px;
  border-radius: var(--radius);
}

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

/* ---------- Utility Classes ---------- */
.hidden { display: none !important; }
.flex { display: flex; }
.inline-flex { display: inline-flex; }
.flex-col { flex-direction: column; }
.flex-1 { flex: 1; }
.flex-2 { flex: 2; }
.flex-shrink-0 { flex-shrink: 0; }
.items-center { align-items: center; }
.items-start { align-items: flex-start; }
.justify-between { justify-content: space-between; }
.justify-center { justify-content: center; }
.justify-end { justify-content: flex-end; }
.flex-wrap { flex-wrap: wrap; }
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-left { text-align: left; }
.text-sm { font-size: var(--text-sm); }
.text-xs { font-size: var(--text-xs); }
.text-lg { font-size: var(--text-lg); }
.text-muted { color: var(--text-muted); }
.text-secondary { color: var(--text-secondary); }
.text-primary { color: var(--primary-500); }
.text-success { color: var(--success-500); }
.text-warning { color: var(--warning-500); }
.text-danger { color: var(--danger-500); }
.font-mono { font-family: var(--font-mono); }
.font-medium { font-weight: 500; }
.font-semibold { font-weight: 600; }
.font-bold { font-weight: 700; }

.truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.gap-1 { gap: var(--space-xs); }
.gap-2 { gap: var(--space-sm); }
.gap-3 { gap: var(--space-md); }
.gap-4 { gap: var(--space-lg); }
.gap-6 { gap: var(--space-xl); }
.gap-8 { gap: var(--space-2xl); }

.p-1 { padding: var(--space-xs); }
.p-2 { padding: var(--space-sm); }
.p-3 { padding: var(--space-md); }
.p-4 { padding: var(--space-lg); }
.p-6 { padding: var(--space-xl); }
.px-2 { padding-left: var(--space-sm); padding-right: var(--space-sm); }
.px-4 { padding-left: var(--space-lg); padding-right: var(--space-lg); }
.py-2 { padding-top: var(--space-sm); padding-bottom: var(--space-sm); }
.py-4 { padding-top: var(--space-lg); padding-bottom: var(--space-lg); }

.m-0 { margin: 0; }
.mt-1 { margin-top: var(--space-xs); }
.mt-2 { margin-top: var(--space-sm); }
.mt-3 { margin-top: var(--space-md); }
.mt-4 { margin-top: var(--space-lg); }
.mt-6 { margin-top: var(--space-xl); }
.mb-1 { margin-bottom: var(--space-xs); }
.mb-2 { margin-bottom: var(--space-sm); }
.mb-3 { margin-bottom: var(--space-md); }
.mb-4 { margin-bottom: var(--space-lg); }
.mb-6 { margin-bottom: var(--space-xl); }
.ml-auto { margin-left: auto; }
.mr-auto { margin-right: auto; }

.w-full { width: 100%; }
.min-w-0 { min-width: 0; }

.rounded { border-radius: var(--radius); }
.rounded-sm { border-radius: var(--radius-sm); }
.rounded-md { border-radius: var(--radius); }
.rounded-lg { border-radius: var(--radius-lg); }
.rounded-xl { border-radius: var(--radius-xl); }
.rounded-full { border-radius: var(--radius-full); }

.border { border: 1px solid var(--border); }
.border-b { border-bottom: 1px solid var(--border); }
.border-t { border-top: 1px solid var(--border); }

.shadow-sm { box-shadow: var(--shadow-sm); }
.shadow { box-shadow: var(--shadow); }
.shadow-md { box-shadow: var(--shadow-md); }

.opacity-50 { opacity: 0.5; }
.opacity-70 { opacity: 0.7; }

.pointer { cursor: pointer; }
.select-none { user-select: none; }
.relative { position: relative; }
.absolute { position: absolute; }
.overflow-hidden { overflow: hidden; }

/* ---------- Selection ---------- */
::selection {
  background: rgba(99, 102, 241, 0.2);
  color: var(--text);
}

/* ---------- Responsive ---------- */
@media (max-width: 768px) {
  #sidebar {
    position: fixed;
    left: 0;
    top: 0;
    width: var(--sidebar-width);
    margin-left: calc(-1 * var(--sidebar-width));
    z-index: 50;
    box-shadow: var(--shadow-xl);
    transition: margin-left var(--transition-base);
  }

  /* Desktop-era .collapsed state must not zero-out width on mobile;
     mobile hides via negative margin instead */
  #sidebar.collapsed {
    width: var(--sidebar-width) !important;
    min-width: 0 !important;
    opacity: 1;
    pointer-events: auto;
    overflow-y: auto;
  }

  #sidebar.open {
    margin-left: 0;
  }

  #ai-panel {
    position: fixed;
    right: 0;
    top: 0;
    width: 100vw;
    max-width: 100vw;
  }

  #app-header {
    padding: 0 var(--space-lg);
  }

  #tab-content {
    padding: var(--space-lg);
  }
}

/* ---------- Global .done state (strikethrough + muted) ---------- */
.done {
  text-decoration: line-through;
  color: var(--gray-400) !important;
  opacity: 0.7;
}

/* Calendar-specific done elements */
.agenda-event-title {
  border-left: 3px solid var(--primary-500);
  padding-left: 8px;
  font-size: var(--text-sm);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.agenda-event-title.done {
  border-left-color: var(--gray-300);
}
.day-event-title {
  font-size: var(--text-base);
}

/* ---------- Management Tab (Tab 4) ---------- */
.mgmt-expander-summary {
  cursor: pointer;
  user-select: none;
  list-style: none;
}

.mgmt-expander-summary::-webkit-details-marker {
  display: none;
}

details[open] > .mgmt-expander-summary .chevron {
  transform: rotate(90deg);
}

.chevron {
  transition: transform var(--transition-fast);
  flex-shrink: 0;
}

.mgmt-form-row {
  display: flex;
  align-items: center;
  gap: var(--space-lg);
}

.mgmt-form-label {
  display: block;
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: var(--space-xs);
}

.mgmt-form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: var(--space-lg);
}

.mgmt-field {
  min-width: 0;
}

.mgmt-radio-group {
  display: flex;
  gap: var(--space-xl);
}

.mgmt-radio {
  display: inline-flex;
  align-items: center;
  gap: var(--space-sm);
  cursor: pointer;
  font-size: var(--text-sm);
}

.mgmt-radio input[type="radio"] {
  width: 16px;
  height: 16px;
  accent-color: var(--primary-500);
  cursor: pointer;
}

.mgmt-form-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-lg);
}

.mgmt-btn-row {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

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

.mgmt-info-msg {
  font-size: var(--text-sm);
  color: var(--warning-500);
  padding: var(--space-sm) 0;
}

/* Sub-project drag handle */
.mgmt-drag-handle {
  display: flex;
  align-items: center;
  padding: 2px 4px;
  color: var(--text-muted);
  cursor: grab;
  opacity: 0.35;
  transition: opacity var(--transition-fast);
  flex-shrink: 0;
}
.mgmt-drag-handle:hover { opacity: 0.8; }
.mgmt-drag-handle:active { cursor: grabbing; }

/* Category group drag handle */
.mgmt-cat-drag-handle {
  display: flex;
  align-items: center;
  padding: 2px 4px;
  color: var(--text-muted);
  cursor: grab;
  opacity: 0.35;
  transition: opacity var(--transition-fast);
  flex-shrink: 0;
}
.mgmt-cat-drag-handle:hover { opacity: 0.8; }
.mgmt-cat-drag-handle:active { cursor: grabbing; }

/* Sortable states */
.mgmt-sortable-ghost {
  opacity: 0.25;
  background: var(--primary-50);
  border-radius: var(--radius);
}
.mgmt-sortable-chosen {
  box-shadow: var(--shadow-md);
  z-index: 10;
}

/* Sub-project expanders */
.mgmt-sub-expander {
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  overflow: hidden;
}

.mgmt-sub-summary {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-md) var(--space-lg);
  cursor: pointer;
  user-select: none;
  list-style: none;
  font-size: var(--text-sm);
  transition: background var(--transition-fast);
}

.mgmt-sub-summary::-webkit-details-marker {
  display: none;
}

.mgmt-sub-summary:hover {
  background: var(--surface-hover);
}

.mgmt-sub-expander[open] > .mgmt-sub-summary .chevron {
  transform: rotate(90deg);
}

.mgmt-sub-title {
  font-weight: 500;
}

.mgmt-sub-assignee {
  font-size: var(--text-xs);
}

.mgmt-jump-btn {
  margin-left: auto;
  flex-shrink: 0;
  cursor: pointer;
  padding: 3px 6px;
  color: var(--text-muted);
  border-radius: var(--radius-sm);
  opacity: 0;
  transition: opacity 0.15s, color 0.15s, background 0.15s;
}
.mgmt-sub-summary:hover .mgmt-jump-btn { opacity: 0.6; }
.mgmt-jump-btn:hover {
  opacity: 1 !important;
  color: var(--primary-500);
  background: var(--primary-50);
}

.mgmt-sub-body {
  padding: var(--space-lg);
  border-top: 1px solid var(--border-light);
  background: var(--gray-50);
}

/* Quick-add row */
.mgmt-quick-add-grid {
  display: grid;
  grid-template-columns: 3fr 3fr 1fr;
  gap: var(--space-sm);
  align-items: center;
}

/* Standalone header */
.mgmt-standalone-header h3 {
  font-size: var(--text-lg);
  font-weight: 600;
}

/* Spinner inline */
.spinner-inline {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid var(--gray-200);
  border-top-color: var(--primary-500);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  vertical-align: middle;
  margin-right: var(--space-xs);
}

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

/* ============================================
   專案摘要區塊
   ============================================ */
.summary-section > .card-header {
  gap: var(--space-sm);
}
.summary-section .summary-chevron {
  transition: transform var(--transition-fast);
  margin-left: auto;
}
.summary-section[open] > .card-header .summary-chevron {
  transform: rotate(90deg);
}

/* 顯示模式 */
.summary-fields {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-md);
}
.summary-field-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: var(--space-xs);
}
.summary-field-value {
  font-size: 13px;
  line-height: 1.6;
  color: var(--text-primary);
}
.summary-field-value p { margin: 0 0 var(--space-xs) 0; }
.summary-field-value p:last-child { margin-bottom: 0; }
.summary-field-value mark {
  background: rgba(245, 158, 11, 0.2);
  color: inherit;
  padding: 1px 4px;
  border-radius: 3px;
}
.summary-field-value strong { font-weight: 600; }
.summary-field-value code {
  background: var(--gray-100);
  padding: 1px 4px;
  border-radius: 3px;
  font-size: 0.9em;
}
.summary-field-value ol,
.summary-field-value ul {
  margin: var(--space-xs) 0;
  padding-left: 1.4em;
}
.summary-field-value li {
  margin-bottom: 2px;
}
.summary-field-value li:last-child { margin-bottom: 0; }

.summary-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: var(--space-md);
  padding-top: var(--space-sm);
  border-top: 1px solid var(--border-light);
}
.summary-meta-actions {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
}
.summary-empty-actions {
  display: flex;
  align-items: center;
  gap: var(--space-md);
}

/* 編輯模式 */
.summary-edit-fields {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-md);
}
.summary-textarea {
  resize: vertical;
  min-height: 48px;
  font-size: 13px;
}
.summary-edit-actions {
  display: flex;
  gap: var(--space-sm);
  margin-top: var(--space-md);
}

/* 歷史紀錄 */
.summary-history {
  border-top: 1px solid var(--border-light);
  padding-top: var(--space-sm);
}
.summary-history-toggle {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  font-size: 12px;
  color: var(--text-muted);
  cursor: pointer;
  user-select: none;
  list-style: none;
}
.summary-history-toggle::-webkit-details-marker { display: none; }
.summary-history-toggle .chevron {
  transition: transform var(--transition-fast);
}
.summary-history[open] > .summary-history-toggle .chevron {
  transform: rotate(90deg);
}
.summary-history-list {
  margin-top: var(--space-sm);
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}
.summary-history-item {
  padding: var(--space-sm) var(--space-md);
  background: var(--gray-50);
  border-radius: var(--radius-md);
  border-left: 3px solid var(--gray-200);
}
.summary-history-item-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-xs);
}
.summary-history-date {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
}
.summary-history-delete {
  opacity: 0;
  transition: opacity var(--transition-fast);
  padding: 2px 4px;
}
.summary-history-item:hover .summary-history-delete {
  opacity: 1;
}
.summary-history-actions {
  text-align: right;
}
.summary-history-fields {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.summary-history-field {
  font-size: 12px;
  line-height: 1.5;
  color: var(--text-secondary);
}
.summary-history-label {
  font-weight: 600;
  color: var(--text-muted);
  margin-right: var(--space-xs);
  flex-shrink: 0;
}
.summary-history-label::after { content: "："; }
.summary-history-value {
  white-space: pre-line;
}

/* === Quick Mode === */
.mode-toggle {
  display: flex;
  gap: 4px;
  margin-top: 8px;
}
.mode-btn {
  padding: 6px 16px;
  border: 1px solid var(--border-200);
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--text-400);
  font-size: 13px;
  cursor: pointer;
  transition: all 0.15s;
}
.mode-btn:hover { color: var(--text-200); border-color: var(--text-400); }
.mode-btn.active {
  background: var(--primary-500);
  border-color: var(--primary-500);
  color: white;
}

.quick-confirm .form-row { display: flex; gap: 16px; }
.quick-confirm .flex-1 { flex: 1; }

.radio-group { display: flex; gap: 16px; margin-top: 6px; }
.radio-label {
  display: flex; align-items: center; gap: 6px;
  font-size: 14px; cursor: pointer;
}
.radio-label input[type="radio"] { accent-color: var(--primary-500); }

.quick-success { padding: 16px; }
.success-inline {
  display: flex; align-items: center; gap: 8px;
  color: var(--success-500);
  font-weight: 600;
}

.quick-loading .loading-inline {
  display: flex; align-items: center; gap: 8px;
  padding: 16px;
  color: var(--text-400);
}

/* === Quick Confirm Enhancements === */
.checkbox-group { display: flex; gap: 20px; margin-top: 6px; }
.checkbox-label {
  display: flex; align-items: center; gap: 6px;
  font-size: 14px; cursor: pointer;
}
.checkbox-label input[type="checkbox"] { accent-color: var(--primary-500); width: 16px; height: 16px; }

.todo-row {
  display: flex; gap: 8px; align-items: flex-start;
  margin-bottom: 8px;
}
.todo-row .flex-2 { flex: 2; }
.todo-row .flex-1 { flex: 1; }
.btn-icon { padding: 6px 8px; min-width: auto; font-size: 16px; line-height: 1; }

#todo-section { margin-top: 16px; padding: 16px; background: var(--bg-100); border-radius: var(--radius-md); border: 1px solid var(--border-200); }

/* === Progress Star Button === */
.progress-hero-select {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.progress-star-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
  color: var(--gray-400);
  transition: color 0.15s;
  display: flex;
  align-items: center;
}
.progress-star-btn svg { fill: none; }
.progress-star-btn:hover { color: #FBBF24; }
.progress-star-btn.starred { color: #FBBF24; }
.progress-star-btn.starred svg { fill: #FBBF24; }

.progress-bg-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
  color: var(--gray-400);
  transition: color 0.15s;
  display: flex;
  align-items: center;
}
.progress-bg-btn:hover { color: var(--primary-500); }
.progress-bg-btn.active { color: var(--warning-500); }

/* 改名 / 封存 icon 按鈕：與 star/bg 統一 bare-icon 樣式，四顆 icon 等距對齊 */
.progress-rename-btn,
.progress-archive-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
  color: var(--text-secondary);
  transition: color 0.15s;
  display: flex;
  align-items: center;
}
.progress-rename-btn:hover { color: var(--primary-500); }
.progress-archive-btn:hover { color: var(--danger-500); }

/* 複製路徑小按鈕（給 CLI 用）：icon + 短文字，跟 bare-icon 鄰居協調 */
.progress-copy-divider {
  width: 1px;
  height: 14px;
  background: var(--border-light);
  margin: 0 2px;
}
.progress-copy-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  background: none;
  border: 1px solid var(--border-light);
  border-radius: 4px;
  font-size: 11px;
  color: var(--text-secondary);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
  font-family: var(--font-mono, ui-monospace, SFMono-Regular, Menlo, monospace);
}
.progress-copy-btn:hover {
  background: var(--gray-50);
  border-color: var(--gray-300);
  color: var(--text);
}
.progress-copy-btn svg {
  flex-shrink: 0;
  opacity: 0.7;
}
.progress-copy-btn--flash {
  background: var(--success-50) !important;
  border-color: var(--success-500) !important;
  color: var(--success-500) !important;
  transition: background 0.2s, border-color 0.2s, color 0.2s;
}

/* === AI 智慧去重面板 === */
.dedup-panel {
  margin: 8px 0 14px;
  padding: 12px 14px;
  background: var(--gray-50);
  border-radius: 4px;
  font-size: 13px;
  line-height: 1.55;
}
.dedup-loading {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text-secondary);
  padding: 4px 0;
  flex-wrap: wrap;
}
.dedup-loading-eta {
  font-size: 11px;
  color: var(--text-muted);
  padding: 2px 6px;
  background: rgba(0, 0, 0, 0.04);
  border-radius: 3px;
}
.dedup-loading-timer {
  font-size: 11px;
  color: var(--text-muted);
  font-family: var(--font-mono, ui-monospace, Menlo, monospace);
  margin-left: auto;
}
.dedup-spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid var(--gray-200);
  border-top-color: var(--primary-500);
  border-radius: 50%;
  animation: dedup-spin 0.8s linear infinite;
  flex-shrink: 0;
}
@keyframes dedup-spin {
  to { transform: rotate(360deg); }
}

/* 通用 ... 動畫（可被其他地方共用） */
.dots-loading::after {
  content: "";
  animation: dots-loading 1.2s steps(4, end) infinite;
}
@keyframes dots-loading {
  0%   { content: ""; }
  25%  { content: "."; }
  50%  { content: ".."; }
  75%  { content: "..."; }
  100% { content: ""; }
}

/* 按鈕內小 spinner */
.inline-spinner {
  display: inline-block;
  width: 10px;
  height: 10px;
  border: 1.5px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  animation: dedup-spin 0.8s linear infinite;
  vertical-align: -1px;
}
.dedup-error {
  color: var(--danger-600, var(--danger-500));
  background: var(--danger-50);
  padding: 10px 12px;
  border-radius: 4px;
}
.dedup-empty {
  color: var(--success-600, var(--success-500));
  background: var(--success-50);
  padding: 10px 12px;
  border-radius: 4px;
  margin-bottom: 8px;
}
.dedup-header {
  margin-bottom: 10px;
  color: var(--text);
}
.dedup-header strong { color: var(--warning-600, var(--warning-500)); }
.dedup-section { margin-top: 10px; }
.dedup-section-title {
  margin: 0 0 6px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}
.dedup-group {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 8px 10px;
  margin-bottom: 6px;
  background: var(--surface);
  border: 1px solid var(--border-light);
  border-radius: 4px;
  cursor: pointer;
  user-select: none;
  transition: opacity 0.15s, background 0.15s;
}
.dedup-group:hover { background: var(--gray-50); }
.dedup-group--ai {
  border-color: color-mix(in srgb, #7C3AED 30%, var(--border-light));
  background: color-mix(in srgb, #7C3AED 3%, var(--surface));
}
.dedup-ai-tag {
  display: inline-block;
  padding: 1px 5px;
  margin-left: 4px;
  background: #7C3AED;
  color: #fff;
  border-radius: 3px;
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.3px;
}
.dedup-group-cb {
  flex-shrink: 0;
  margin: 3px 0 0;
  cursor: pointer;
  accent-color: var(--primary-500, #3b82f6);
}
.dedup-group-body { flex: 1; min-width: 0; }
.dedup-group--unchecked { opacity: 0.45; }
.dedup-group--unchecked .dedup-remove { text-decoration: none; }
.dedup-group--unchecked .dedup-keep,
.dedup-group--unchecked .dedup-remove,
.dedup-group--unchecked .dedup-reason {
  color: var(--text-muted);
}

.dedup-toggles {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-left: 10px;
  font-size: 11px;
}
.dedup-link-btn {
  background: transparent;
  border: none;
  padding: 0;
  font-size: 11px;
  color: var(--primary-600, var(--primary-500));
  cursor: pointer;
}
.dedup-link-btn:hover { text-decoration: underline; }
.dedup-sep { color: var(--gray-400); }

.dedup-group-date {
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 4px;
  font-family: var(--font-mono, ui-monospace, Menlo, monospace);
}
.dedup-keep {
  color: var(--success-600, var(--success-500));
  font-size: 12px;
  margin: 2px 0;
}
.dedup-keep span { color: var(--text); }
.dedup-remove {
  color: var(--danger-500);
  font-size: 12px;
  margin: 2px 0;
  text-decoration: line-through;
  opacity: 0.7;
}
.dedup-reason {
  margin-top: 4px;
  font-size: 11px;
  color: var(--text-muted);
  font-style: italic;
}
.dedup-actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
  flex-wrap: wrap;
}
.dedup-success {
  background: var(--success-50);
  color: var(--success-600, var(--success-500));
  padding: 10px 12px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.dedup-backup-tag {
  font-size: 11px;
  color: var(--text-muted);
  font-family: var(--font-mono, ui-monospace, Menlo, monospace);
  background: rgba(0, 0, 0, 0.04);
  padding: 2px 6px;
  border-radius: 3px;
}

/* === Progress Rename Form === */
.progress-rename-form {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.5rem;
}
.progress-rename-form .form-input {
  flex: 1;
  max-width: 300px;
}

/* === Name Correction Panel === */
.name-correction-panel {
  margin-top: 0.5rem;
  padding: 0.75rem 1rem;
  background: var(--danger-50);
  border: 1px solid color-mix(in srgb, var(--danger-500) 25%, transparent);
  border-radius: 8px;
  animation: nameCheckSlideIn 0.2s ease-out;
}
@keyframes nameCheckSlideIn {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}
.name-check-header {
  font-size: 0.8125rem;
  color: var(--gray-700);
  margin-bottom: 0.5rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}
.name-check-toggles {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  margin-left: auto;
  font-size: 0.75rem;
}
.name-check-toggles .btn-link-sm {
  background: transparent;
  border: none;
  padding: 0;
  color: var(--primary-600, var(--link-color, #2563eb));
  cursor: pointer;
  font-size: 0.75rem;
}
.name-check-toggles .btn-link-sm:hover {
  text-decoration: underline;
}
.name-check-sep {
  color: var(--gray-400);
}
.name-check-list {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin-bottom: 0.625rem;
}
.name-check-item {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  font-size: 0.9375rem;
  padding: 0.35rem 0.5rem 0.4rem 0.4rem;
  background: var(--surface);
  border-radius: 4px;
  border: 1px solid var(--border-light);
  cursor: pointer;
  user-select: none;
  transition: opacity 0.15s;
}
.name-check-row {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
}
.name-check-item:has(.name-check-box:not(:checked)) {
  opacity: 0.45;
}
.name-check-item:has(.name-check-box:not(:checked)) .name-ins {
  text-decoration: line-through;
}
.name-check-box {
  margin: 0;
  cursor: pointer;
  accent-color: var(--primary-500, #3b82f6);
}
.name-check-contexts {
  display: flex;
  flex-direction: column;
  gap: 0.125rem;
  margin-left: 1.4rem;
  font-size: 0.8125rem;
  color: var(--text-secondary, var(--gray-600));
  line-height: 1.5;
}
.name-check-context {
  white-space: normal;
  word-break: break-word;
}
.name-ctx-mark {
  background: color-mix(in srgb, var(--danger-500) 18%, transparent);
  color: var(--danger-600, var(--danger-500));
  padding: 0 2px;
  border-radius: 2px;
  font-weight: 600;
}
.name-del {
  color: var(--danger-500);
  text-decoration: line-through;
  font-weight: 500;
}
.name-arrow {
  color: var(--gray-400);
  font-size: 0.75rem;
}
.name-ins {
  color: var(--success-500);
  font-weight: 600;
  text-decoration: none;
}
.name-display-tag {
  color: var(--text-muted);
  font-size: 0.75rem;
}
.name-check-actions {
  display: flex;
  gap: 0.5rem;
}

/* === Typing Dots Animation === */
.typing-dots {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 0;
}
.typing-dots span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-400, #888);
  animation: typingBounce 1.4s ease-in-out infinite;
}
.typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typingBounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-6px); opacity: 1; }
}
