:root {
  --bg: #ffffff;
  --bg-secondary: #f8f9fa;
  --card: #ffffff;
  --card-hover: #f8f9fa;
  --text: #1a1a1a;
  --text-secondary: #4a5568;
  --text-muted: #718096;
  --border: #e2e8f0;
  --border-light: #edf2f7;
  --accent: #7c3aed;
  --accent-hover: #6d28d9;
  --accent-light: #ede9fe;
  --danger: #dc2626;
  --danger-light: #fee2e2;
  --warning: #f59e0b;
  --warning-light: #fef3c7;
  --success: #10b981;
  --success-light: #d1fae5;
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
  --radius: 12px;
  --radius-lg: 16px;
  --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

[data-theme="dark"] {
  --bg: #0f0f10;
  --bg-secondary: #18181b;
  --card: #1f1f23;
  --card-hover: #27272a;
  --text: #fafafa;
  --text-secondary: #d4d4d8;
  --text-muted: #a1a1aa;
  --border: #27272a;
  --border-light: #3f3f46;
  --accent: #8b5cf6;
  --accent-hover: #a78bfa;
  --accent-light: #2e1065;
  --danger: #ef4444;
  --danger-light: #7f1d1d;
  --warning: #f59e0b;
  --warning-light: #78350f;
  --success: #10b981;
  --success-light: #064e3b;
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.3);
  --shadow: 0 1px 3px 0 rgb(0 0 0 / 0.4), 0 1px 2px -1px rgb(0 0 0 / 0.3);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.4), 0 2px 4px -2px rgb(0 0 0 / 0.3);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.5), 0 4px 6px -4px rgb(0 0 0 / 0.4);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  height: 100%;
}

body {
  font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  transition: background-color 0.3s ease, color 0.3s ease;
}

.app {
  min-height: 100%;
  display: flex;
  flex-direction: column;
}

.topbar {
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  border-bottom: 1px solid var(--border);
  background: var(--card);
  position: sticky;
  top: 0;
  z-index: 20;
  transition: var(--transition);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--accent);
  animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

@keyframes pulse {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.6;
  }
}

.brand-text {
  font-weight: 700;
  font-size: 18px;
  letter-spacing: -0.02em;
  color: var(--text);
}

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

.icon-btn {
  border: 1px solid var(--border);
  background: var(--card);
  border-radius: 10px;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition);
  padding: 0;
}

.icon-btn svg {
  width: 18px;
  height: 18px;
  color: var(--text-secondary);
}

.icon-btn:hover {
  background: var(--card-hover);
  border-color: var(--border-light);
  transform: translateY(-1px);
}

.icon-btn:active {
  transform: translateY(0);
}

.icon {
  font-size: 18px;
  line-height: 1;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
}

.main {
  width: min(1200px, 100%);
  margin: 0 auto;
  padding: 24px;
  flex: 1;
}

.tabs {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 0 0 24px;
  padding: 6px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  position: relative;
}

.tab-indicator {
  position: absolute;
  height: calc(100% - 12px);
  background: var(--accent);
  border-radius: 10px;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 0;
}

.tab {
  border: none;
  background: transparent;
  padding: 10px 20px;
  border-radius: 10px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-muted);
  transition: var(--transition);
  position: relative;
  z-index: 1;
}

.tab:hover {
  color: var(--text-secondary);
}

.tab.active {
  color: #fff;
}

.tab-spacer {
  flex: 1;
}

.counts {
  font-size: 13px;
  color: var(--text-muted);
  font-weight: 500;
  padding-right: 8px;
}

.panel {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  overflow: hidden;
}

.toolbar {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-secondary);
}

.search {
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--border);
  background: var(--card);
  border-radius: var(--radius);
  padding: 10px 16px;
  transition: var(--transition);
}

.search:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-light);
}

.search-ic {
  color: var(--text-muted);
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
}

.search-ic svg {
  width: 18px;
  height: 18px;
}

.search input {
  border: none;
  outline: none;
  width: 100%;
  font-size: 14px;
  background: transparent;
  color: var(--text);
  font-weight: 500;
  line-height: 1.5;
}

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

.clear-search {
  border: none;
  background: transparent;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 16px;
  padding: 0;
  width: 20px;
  height: 20px;
  border-radius: 6px;
  transition: var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

.clear-search:hover {
  background: var(--bg-secondary);
  color: var(--text-secondary);
}

.status {
  padding: 12px 20px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  color: var(--text-muted);
  background: var(--bg-secondary);
  font-weight: 500;
}

.tasklist {
  display: flex;
  flex-direction: column;
}

.section {
  padding: 20px;
  background: var(--card);
  border-top: 1px solid var(--border);
}

.section:first-child {
  border-top: none;
}

.section h2 {
  margin: 0 0 16px;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.item {
  display: grid;
  grid-template-columns: 28px 1fr;
  gap: 14px;
  padding: 16px;
  border-top: 1px solid var(--border);
  border-radius: var(--radius);
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  margin-bottom: 8px;
  overflow: hidden;
}

.item.checking {
  animation: fadeAndCollapse 0.35s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

@keyframes fadeAndCollapse {
  0% {
    opacity: 1;
    max-height: 500px;
    margin-bottom: 8px;
  }
  40% {
    opacity: 0;
  }
  100% {
    opacity: 0;
    max-height: 0;
    margin-bottom: 0;
    padding-top: 0;
    padding-bottom: 0;
  }
}

.item.appearing {
  animation: expandAndFadeIn 0.35s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

@keyframes expandAndFadeIn {
  0% {
    opacity: 0;
    max-height: 0;
    margin-bottom: 0;
    padding-top: 0;
    padding-bottom: 0;
  }
  60% {
    opacity: 0;
  }
  100% {
    opacity: 1;
    max-height: 500px;
    margin-bottom: 8px;
    padding-top: 16px;
    padding-bottom: 16px;
  }
}

.item:first-child {
  border-top: none;
}

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

.cb {
  width: 20px;
  height: 20px;
  margin-top: 2px;
  cursor: pointer;
  accent-color: var(--accent);
  border-radius: 6px;
  transition: var(--transition);
}

.cb:checked {
  animation: checkBounce 0.3s ease-out;
}

@keyframes checkBounce {
  0% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.2);
  }
  100% {
    transform: scale(1);
  }
}

.title {
  font-size: 15px;
  line-height: 1.4;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.01em;
}

.meta {
  margin-top: 8px;
  font-size: 13px;
  color: var(--text-muted);
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  font-weight: 500;
}

.meta .due.overdue {
  color: var(--danger);
  font-weight: 700;
  padding: 2px 8px;
  background: var(--danger-light);
  border-radius: 6px;
}

.meta .due.soon {
  color: var(--warning);
  font-weight: 700;
  padding: 2px 8px;
  background: var(--warning-light);
  border-radius: 6px;
}

.details {
  margin-top: 12px;
}

.desc {
  border: 1px solid var(--border);
  background: var(--bg-secondary);
  border-radius: var(--radius);
  padding: 14px;
  font-size: 13px;
  color: var(--text-secondary);
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.6;
  font-weight: 500;
  max-height: 200px;
  overflow: hidden;
  position: relative;
  transition: max-height 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.desc.expanded {
  max-height: 2000px;
}

.desc.collapsed::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 60px;
  background: linear-gradient(to bottom, transparent, var(--bg-secondary));
  pointer-events: none;
}

.show-more {
  margin-top: 8px;
  border: none;
  background: transparent;
  color: var(--accent);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  padding: 4px 0;
  transition: var(--transition);
}

.show-more:hover {
  color: var(--accent-hover);
}

.actions {
  margin-top: 12px;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.linkbtn {
  border: 1px solid var(--accent);
  background: var(--accent-light);
  color: var(--accent);
  text-decoration: none;
  padding: 10px 16px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: var(--transition);
}

.linkbtn:hover {
  background: var(--accent);
  color: #fff;
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.linkbtn:active {
  transform: translateY(0);
}

.empty {
  padding: 48px 24px;
  color: var(--text-muted);
  font-size: 14px;
  text-align: center;
  font-weight: 500;
  min-width: 100%;
}

.backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 30;
  animation: fadeIn 0.2s ease-out;
}

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

.drawer {
  position: fixed;
  right: 0;
  top: 0;
  height: 100%;
  width: min(480px, 92vw);
  background: var(--card);
  border-left: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  z-index: 40;
  display: flex;
  flex-direction: column;
  animation: slideInDrawer 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

.hidden {
  display: none;
}

.drawer-header {
  height: 64px;
  padding: 0 24px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-secondary);
}

.drawer-title {
  font-weight: 700;
  font-size: 18px;
  letter-spacing: -0.02em;
}

.drawer-body {
  padding: 24px;
  overflow: auto;
  flex: 1;
}

.field {
  display: block;
  margin-bottom: 20px;
}

.label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 8px;
  display: block;
}

.hint {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 6px;
  line-height: 1.5;
  font-weight: 500;
}

.field input {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  font-size: 14px;
  outline: none;
  background: var(--bg-secondary);
  color: var(--text);
  transition: var(--transition);
  font-weight: 500;
}

.field input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-light);
  background: var(--card);
}

.row {
  display: flex;
  gap: 12px;
  align-items: flex-end;
}

.buttons {
  margin-top: 8px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.primary {
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #fff;
  padding: 12px 20px;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 14px;
  font-weight: 700;
  transition: var(--transition);
}

.primary:hover {
  background: var(--accent-hover);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.primary:active {
  transform: translateY(0);
}

.secondary {
  border: 1px solid var(--border);
  background: var(--bg-secondary);
  color: var(--text);
  padding: 12px 20px;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  transition: var(--transition);
}

.secondary:hover {
  background: var(--card-hover);
  border-color: var(--border-light);
  transform: translateY(-1px);
}

.secondary:active {
  transform: translateY(0);
}

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

.doclink {
  display: inline-block;
  margin-top: 8px;
  color: var(--accent);
  text-decoration: none;
  font-weight: 600;
  transition: var(--transition);
}

.doclink:hover {
  color: var(--accent-hover);
  text-decoration: underline;
}

.hint ul {
  margin-top: 8px;
  padding-left: 20px;
}

.hint li {
  margin-bottom: 4px;
  line-height: 1.6;
}

/* Theme Toggle */
.theme-toggle {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
  padding: 16px;
  background: var(--bg-secondary);
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

.theme-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  flex: 1;
}

.toggle-switch {
  position: relative;
  width: 48px;
  height: 26px;
  background: var(--border);
  border-radius: 999px;
  cursor: pointer;
  transition: var(--transition);
}

.toggle-switch.active {
  background: var(--accent);
}

.toggle-slider {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  background: #fff;
  border-radius: 999px;
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: var(--shadow-sm);
}

.toggle-switch.active .toggle-slider {
  transform: translateX(22px);
}

/* Responsive */
@media (max-width: 640px) {
  .topbar {
    padding: 0 16px;
  }

  .main {
    padding: 16px;
  }

  .brand-text {
    font-size: 16px;
  }

  .tabs {
    flex-wrap: wrap;
  }

  .counts {
    width: 100%;
    text-align: center;
    padding: 4px 0 0 0;
  }

  .buttons {
    flex-direction: column;
  }
}

/* Scrollbar */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: var(--bg);
}

::-webkit-scrollbar-thumb {
  background: var(--border-light);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}