/* ============================================================
   GAWEKUN — GitBook Design System
   Clean, modern, documentation-like layout with soft shadows,
   thin borders, 6px border radius, and Inter typography.
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

/* ── Custom Theme Colors ──────────────────────────────────── */

/* Light Theme Variables */
:root, html.theme-light {
  --color-bg:            #F8FAFC; /* Slate 50 */
  --color-surface:       #FFFFFF; /* White */
  --color-surface-hover: #F1F5F9;
  --color-surface-2:     #FFFFFF; /* Sidebar background */
  --color-sidebar-bg:    #F8FAFC; /* Sidebar background in GitBook style */
  --color-border:        #E2E8F0; /* Slate 200 */
  --color-text:          #0F172A; /* Slate 900 */
  --color-text-muted:    #475569; /* Slate 600 */
  --color-text-light:    #94A3B8; /* Slate 400 */

  --color-primary:       #2C62F6; /* GitBook Blue */
  --color-primary-hover: #1A4ED8;
  --color-primary-light: #EFF6FF; /* Soft Blue */
  
  --color-success:       #10B981; /* Emerald 500 */
  --color-success-hover: #059669;
  --color-success-light: #ECFDF5;
  
  --color-danger:        #EF4444; /* Red 500 */
  --color-danger-hover:  #DC2626;
  --color-danger-light:  #FEF2F2;

  --color-warning:       #F59E0B; /* Amber 500 */
  --color-info:          #3B82F6;

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

  --border-radius:       6px;
  --border-radius-sm:    4px;
  --border:              1px solid var(--color-border);
  --border-thick:        1px solid var(--color-border);
  
  color-scheme: light;
}

/* Dark Theme Variables */
html.theme-dark {
  --color-bg:            #0F172A; /* Slate 900 */
  --color-surface:       #1E293B; /* Slate 800 */
  --color-surface-hover: #334155;
  --color-surface-2:     #1E293B;
  --color-sidebar-bg:    #0B0F19; /* Deeper Dark Sidebar */
  --color-border:        #334155; /* Slate 700 */
  --color-text:          #F8FAFC; /* Slate 50 */
  --color-text-muted:    #CBD5E1; /* Slate 300 */
  --color-text-light:    #64748B; /* Slate 500 */

  --color-primary:       #3884FF; /* Vibrant Blue for Dark */
  --color-primary-hover: #5B9AFF;
  --color-primary-light: #1E293B;
  
  --color-success:       #34D399; /* Emerald 400 */
  --color-success-hover: #10B981;
  --color-success-light: #064E3B;
  
  --color-danger:        #F87171; /* Red 400 */
  --color-danger-hover:  #EF4444;
  --color-danger-light:  #7F1D1D;

  --color-warning:       #FBBF24;
  --color-info:          #60A5FA;

  /* Shadows */
  --shadow-sm:           0 1px 2px 0 rgba(0, 0, 0, 0.3);
  --shadow-md:           0 4px 6px -1px rgba(0, 0, 0, 0.4), 0 2px 4px -2px rgba(0, 0, 0, 0.4);
  --shadow-lg:           0 10px 15px -3px rgba(0, 0, 0, 0.4), 0 4px 6px -4px rgba(0, 0, 0, 0.4);
  --shadow-xl:           0 20px 25px -5px rgba(0, 0, 0, 0.5), 0 10px 10px -5px rgba(0, 0, 0, 0.5);

  color-scheme: dark;
}

/* System Theme Fallback */
@media (prefers-color-scheme: dark) {
  html:not(.theme-light):not(.theme-dark) {
    --color-bg:            #0F172A;
    --color-surface:       #1E293B;
    --color-surface-hover: #334155;
    --color-surface-2:     #1E293B;
    --color-sidebar-bg:    #0B0F19;
    --color-border:        #334155;
    --color-text:          #F8FAFC;
    --color-text-muted:    #CBD5E1;
    --color-text-light:    #64748B;

    --color-primary:       #3884FF;
    --color-primary-hover: #5B9AFF;
    --color-primary-light: #1E293B;
    
    --color-success:       #34D399;
    --color-success-hover: #10B981;
    --color-success-light: #064E3B;
    
    --color-danger:        #F87171;
    --color-danger-hover:  #EF4444;
    --color-danger-light:  #7F1D1D;

    --color-warning:       #FBBF24;
    --color-info:          #60A5FA;

    --shadow-sm:           0 1px 2px 0 rgba(0, 0, 0, 0.3);
    --shadow-md:           0 4px 6px -1px rgba(0, 0, 0, 0.4), 0 2px 4px -2px rgba(0, 0, 0, 0.4);
    --shadow-lg:           0 10px 15px -3px rgba(0, 0, 0, 0.4), 0 4px 6px -4px rgba(0, 0, 0, 0.4);
    --shadow-xl:           0 20px 25px -5px rgba(0, 0, 0, 0.5), 0 10px 10px -5px rgba(0, 0, 0, 0.5);

    color-scheme: dark;
  }
}

/* ── Typography & Global Settings ────────────────────────── */
:root {
  --font-body:    'Inter', system-ui, -apple-system, sans-serif;
  --font-display: 'Inter', system-ui, -apple-system, sans-serif;

  --sidebar-width: 260px;
  --sidebar-collapsed: 0px;
  --header-height: 60px;
  --transition: 150ms ease;
  --transition-medium: 200ms cubic-bezier(0.4, 0, 0.2, 1);
}

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

html {
  height: 100%;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-body);
  background-color: var(--color-bg);
  color: var(--color-text);
  height: 100%;
  line-height: 1.5;
  -webkit-tap-highlight-color: transparent;
  overflow: hidden;
  transition: background-color var(--transition), color var(--transition);
}

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

button {
  cursor: pointer;
  border: none;
  background: none;
  font-family: inherit;
  outline: none;
}

input, textarea, select {
  font-family: inherit;
  color: var(--color-text);
  background: var(--color-surface);
  border: var(--border);
  border-radius: var(--border-radius);
  padding: 10px 14px;
  font-size: 14px;
  width: 100%;
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition), background-color var(--transition);
}
input:focus, textarea:focus, select:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 2px rgba(44, 98, 246, 0.15);
}
select {
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%2364748B' d='M6 8L0 0h12z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 36px;
}

/* Custom Scrollbars */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: var(--color-border);
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--color-text-light);
}

/* ── Typography Classes ──────────────────────────────────── */
.display-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.75rem;
  letter-spacing: -0.02em;
  color: var(--color-text);
}
.section-title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 0.95rem;
  text-transform: none;
  letter-spacing: normal;
  color: var(--color-text-muted);
}
.label-text {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-text-light);
}
.mono {
  font-family: SFMono-Regular, Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 0.9em;
}

/* ── GitBook Cards ───────────────────────────────────────── */
.nb-card {
  background: var(--color-surface);
  border: var(--border);
  border-radius: var(--border-radius);
  box-shadow: var(--shadow-sm);
  transition: transform var(--transition), box-shadow var(--transition), border-color var(--transition);
  padding: 16px;
}
.nb-card:hover {
  border-color: var(--color-text-light);
  box-shadow: var(--shadow-md);
}
.nb-card-flat {
  background: var(--color-surface);
  border: var(--border);
  border-radius: var(--border-radius);
  padding: 16px;
}
.nb-card-accent {
  background: var(--color-primary-light);
  border: 1px solid rgba(44, 98, 246, 0.2);
  border-radius: var(--border-radius);
  padding: 16px;
}

/* ── Buttons ─────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 16px;
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 500;
  border: 1px solid var(--color-border);
  border-radius: var(--border-radius);
  background: var(--color-surface);
  color: var(--color-text);
  box-shadow: var(--shadow-sm);
  transition: all var(--transition);
  white-space: nowrap;
  user-select: none;
}
.btn:hover {
  background: var(--color-surface-hover);
  border-color: var(--color-text-light);
}
.btn:active {
  transform: translateY(1px);
}

.btn-primary {
  background: var(--color-primary);
  border-color: var(--color-primary);
  color: #ffffff;
}
.btn-primary:hover {
  background: var(--color-primary-hover);
  border-color: var(--color-primary-hover);
}

.btn-danger {
  background: var(--color-danger);
  border-color: var(--color-danger);
  color: #ffffff;
}
.btn-danger:hover {
  background: var(--color-danger-hover);
  border-color: var(--color-danger-hover);
}

.btn-success {
  background: var(--color-success);
  border-color: var(--color-success);
  color: #ffffff;
}
.btn-success:hover {
  background: var(--color-success-hover);
  border-color: var(--color-success-hover);
}

.btn-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--color-text-muted);
  box-shadow: none;
}
.btn-ghost:hover {
  background: var(--color-surface-hover);
  color: var(--color-text);
}

.btn-icon {
  width: 36px;
  height: 36px;
  padding: 0;
  border: var(--border);
  border-radius: var(--border-radius);
  background: var(--color-surface);
  box-shadow: var(--shadow-sm);
}
.btn-icon:hover {
  background: var(--color-surface-hover);
}

.btn-sm {
  padding: 6px 12px;
  font-size: 12px;
}
.btn-lg {
  padding: 12px 24px;
  font-size: 14px;
}
.btn-full {
  width: 100%;
}

/* ── Badges ──────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  font-size: 11px;
  font-weight: 500;
  border-radius: 12px;
  background: var(--color-surface-hover);
  color: var(--color-text-muted);
  border: 1px solid var(--color-border);
}
.badge-accent  { background: var(--color-primary-light); color: var(--color-primary); border-color: rgba(44, 98, 246, 0.2); }
.badge-success { background: var(--color-success-light); color: var(--color-success); border-color: rgba(16, 185, 129, 0.2); }
.badge-danger  { background: var(--color-danger-light); color: var(--color-danger); border-color: rgba(239, 68, 68, 0.2); }
.badge-info    { background: var(--color-primary-light); color: var(--color-info); border-color: rgba(59, 130, 246, 0.2); }

/* ── Form Layouts ────────────────────────────────────────── */
.nb-input {
  background: var(--color-surface);
  border: var(--border);
  border-radius: var(--border-radius);
  padding: 10px 14px;
  font-size: 14px;
  font-weight: 400;
  transition: all var(--transition);
}
.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.form-label {
  font-size: 12px;
  font-weight: 500;
  text-transform: none;
  letter-spacing: normal;
  color: var(--color-text-muted);
}

/* ── Modals ──────────────────────────────────────────────── */
.nb-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.4);
  backdrop-filter: blur(2px);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 150ms ease;
}
.nb-overlay.active {
  opacity: 1;
  pointer-events: auto;
}
.nb-modal {
  background: var(--color-surface);
  border: var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow-xl);
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  overflow-y: auto;
  transform: scale(0.97);
  transition: transform var(--transition-medium);
  display: flex;
  flex-direction: column;
}
.nb-overlay.active .nb-modal {
  transform: scale(1);
}
.nb-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: var(--border);
}
.nb-modal-body {
  padding: 20px;
  overflow-y: auto;
}
.nb-modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 16px 20px;
  border-top: var(--border);
}

/* ── Sidebar Layout ──────────────────────────────────────── */
.app-layout {
  display: flex;
  height: 100dvh;
  overflow: hidden;
}

.sidebar {
  width: var(--sidebar-width);
  min-width: var(--sidebar-width);
  background: var(--color-sidebar-bg);
  border-right: var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: width var(--transition-medium), min-width var(--transition-medium), transform var(--transition-medium);
  z-index: 100;
  flex-shrink: 0;
}
.sidebar.collapsed {
  width: 0;
  min-width: 0;
}
.sidebar-header {
  padding: 16px;
  border-bottom: var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: var(--header-height);
  flex-shrink: 0;
}
.sidebar-logo {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.25rem;
  letter-spacing: -0.02em;
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--color-text);
}
.sidebar-logo img {
  width: 24px;
  height: 24px;
  object-fit: contain;
}
.sidebar-logo .logo-badge {
  background: var(--color-primary-light);
  color: var(--color-primary);
  border: 1px solid rgba(44, 98, 246, 0.15);
  padding: 1px 6px;
  border-radius: 10px;
  font-size: 0.7rem;
}
.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 12px 8px 8px;
}
.sidebar-nav::-webkit-scrollbar {
  display: none;
}

/* Sidebar User Footer */
.sidebar-user-footer {
  border-top: var(--border);
  padding: 12px;
  flex-shrink: 0;
  background: var(--color-sidebar-bg);
}
.sidebar-user-footer button {
  transition: opacity var(--transition);
}
.sidebar-user-footer button:hover {
  opacity: 0.8;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  margin-bottom: 2px;
  font-size: 14px;
  font-weight: 500;
  color: var(--color-text-muted);
  border-radius: var(--border-radius);
  transition: all var(--transition);
  cursor: pointer;
  white-space: nowrap;
  text-transform: none;
  letter-spacing: normal;
}
.nav-item:hover {
  background: var(--color-surface-hover);
  color: var(--color-text);
}
.nav-item.active {
  background: var(--color-primary-light);
  color: var(--color-primary);
  font-weight: 600;
}
.nav-item .nav-icon {
  width: 18px;
  text-align: center;
  font-size: 14px;
  flex-shrink: 0;
  color: inherit;
}
.nav-divider {
  border: none;
  border-top: var(--border);
  margin: 12px 12px;
}

/* Sidebar Footer (User Account Toggle) */
.sidebar-footer {
  border-top: var(--border);
  padding: 8px;
  flex-shrink: 0;
  position: relative;
  background: var(--color-sidebar-bg);
}
.user-toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
  border-radius: var(--border-radius);
  cursor: pointer;
  transition: background var(--transition);
  width: 100%;
  border: none;
  background: none;
  text-align: left;
}
.user-toggle:hover {
  background: var(--color-surface-hover);
}
.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: var(--border);
  object-fit: cover;
  flex-shrink: 0;
  background: var(--color-surface-hover);
}
.user-info {
  flex: 1;
  min-width: 0;
  overflow: hidden;
}
.user-name {
  font-weight: 600;
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--color-text);
}
.user-email {
  font-size: 11px;
  color: var(--color-text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.user-chevron {
  font-size: 10px;
  color: var(--color-text-muted);
  transition: transform var(--transition);
}
.user-toggle.open .user-chevron {
  transform: rotate(180deg);
}

/* User Dropdown Menu */
.user-dropdown {
  display: none;
  position: absolute;
  bottom: 60px;
  left: 8px;
  right: 8px;
  background: var(--color-surface);
  border: var(--border);
  border-radius: var(--border-radius);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  z-index: 101;
}
.user-dropdown.open {
  display: block;
}
.user-dropdown a, .user-dropdown button {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 12px;
  font-size: 13px;
  font-weight: 500;
  color: var(--color-text-muted);
  text-align: left;
  text-transform: none;
  letter-spacing: normal;
  transition: all var(--transition);
  cursor: pointer;
  border: none;
  background: none;
}
.user-dropdown a:hover, .user-dropdown button:hover {
  background: var(--color-surface-hover);
  color: var(--color-text);
}
.user-dropdown .logout-btn {
  color: var(--color-danger);
  border-top: var(--border);
}
.user-dropdown .logout-btn:hover {
  background: var(--color-danger-light);
  color: var(--color-danger);
}

/* Main Content Area */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
  background: var(--color-bg);
}

/* Top Header Bar */
.top-header {
  height: var(--header-height);
  border-bottom: var(--border);
  background: var(--color-surface);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 12px;
  flex-shrink: 0;
}
.hamburger-btn {
  width: 32px;
  height: 32px;
  border: var(--border);
  border-radius: var(--border-radius);
  background: var(--color-surface);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  cursor: pointer;
  transition: all var(--transition);
  flex-shrink: 0;
}
.hamburger-btn:hover {
  background: var(--color-surface-hover);
}
.hamburger-btn span {
  display: block;
  width: 16px;
  height: 1.5px;
  background: var(--color-text-muted);
  transition: all 200ms ease;
}
.top-header-title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.1rem;
  text-transform: none;
  letter-spacing: normal;
  color: var(--color-text);
  flex: 1;
}
.top-header-date {
  font-size: 12px;
  font-weight: 500;
  text-transform: none;
  letter-spacing: normal;
  color: var(--color-text-muted);
  background: var(--color-bg);
  border: var(--border);
  padding: 4px 10px;
  border-radius: 12px;
}

/* ── Page Content Area ───────────────────────────────────── */
.page-content {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  position: relative;
}
.page-section {
  display: none;
}
.page-section.active {
  display: block;
}
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
  gap: 12px;
}

/* ── Habit Cards ─────────────────────────────────────────── */
.habit-card {
  background: var(--color-surface);
  border: var(--border);
  border-radius: var(--border-radius);
  box-shadow: var(--shadow-sm);
  padding: 12px 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  transition: all var(--transition);
  cursor: pointer;
  position: relative;
}
.habit-card:hover {
  border-color: var(--color-primary);
  box-shadow: var(--shadow-md);
}
.habit-card::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 4px;
  background: var(--color-border);
  border-radius: 4px 0 0 4px;
  transition: width var(--transition);
}
.habit-card.status-success::before { background: var(--color-success); }
.habit-card.status-failed::before  { background: var(--color-danger); }

.habit-emoji {
  font-size: 1.25rem;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--color-bg);
  border: var(--border);
  border-radius: var(--border-radius);
  flex-shrink: 0;
}
.habit-info {
  flex: 1;
  min-width: 0;
}
.habit-name {
  font-weight: 600;
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--color-text);
}
.habit-meta {
  font-size: 12px;
  color: var(--color-text-muted);
  margin-top: 2px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.habit-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

.status-btn {
  width: 28px;
  height: 28px;
  border: var(--border);
  border-radius: var(--border-radius);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  transition: all var(--transition);
  background: var(--color-surface);
  color: var(--color-text-muted);
}
.status-btn:hover {
  background: var(--color-surface-hover);
  border-color: var(--color-text-light);
}
.status-btn.success { background: var(--color-success); color: #fff; border-color: var(--color-success); }
.status-btn.failed  { background: var(--color-danger); color: #fff; border-color: var(--color-danger); }

.streak-chip {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  font-size: 11px;
  font-weight: 500;
  padding: 1px 6px;
  border-radius: 10px;
  background: var(--color-primary-light);
  color: var(--color-primary);
  border: 1px solid rgba(44, 98, 246, 0.15);
}

/* ── Task Cards ──────────────────────────────────────────── */
.task-card {
  background: var(--color-surface);
  border: var(--border);
  border-radius: var(--border-radius);
  box-shadow: var(--shadow-sm);
  padding: 14px;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  transition: all var(--transition);
  cursor: pointer;
}
.task-card:hover {
  border-color: var(--color-primary);
  box-shadow: var(--shadow-md);
}
.task-card.completed {
  opacity: 0.65;
}
.task-card.completed .task-name {
  text-decoration: line-through;
  color: var(--color-text-light);
}
.task-check {
  width: 18px;
  height: 18px;
  border: 1.5px solid var(--color-text-light);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 2px;
  background: var(--color-surface);
  transition: all var(--transition);
}
.task-check:hover {
  border-color: var(--color-primary);
}
.task-check.done {
  background: var(--color-success);
  border-color: var(--color-success);
  color: #fff;
}
.task-check.done i {
  font-size: 9px;
}
.task-info {
  flex: 1;
  min-width: 0;
}
.task-name {
  font-weight: 600;
  font-size: 14px;
  color: var(--color-text);
}
.task-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 4px;
  flex-wrap: wrap;
}
.task-deadline {
  font-size: 11px;
  font-weight: 500;
  color: var(--color-danger);
  display: flex;
  align-items: center;
  gap: 4px;
}
.task-deadline.overdue {
  color: var(--color-danger);
  font-weight: 600;
}
.task-stat {
  font-size: 11px;
  font-weight: 500;
  color: var(--color-text-light);
  display: flex;
  align-items: center;
  gap: 3px;
}

/* Subtask progress bar */
.todo-progress-bar {
  height: 4px;
  background: var(--color-border);
  border-radius: 2px;
  margin-top: 8px;
  overflow: hidden;
}
.todo-progress-fill {
  height: 100%;
  background: var(--color-success);
  transition: width 300ms ease;
}

/* ── Today Dashboard Layout ──────────────────────────────── */
.greeting-block {
  background: var(--color-primary-light);
  border: 1px solid rgba(44, 98, 246, 0.15);
  border-radius: var(--border-radius);
  padding: 16px 20px;
  margin-bottom: 24px;
  position: relative;
  overflow: hidden;
}
.greeting-block::after {
  content: '⚡';
  position: absolute;
  right: 16px;
  bottom: -4px;
  font-size: 2.5rem;
  opacity: 0.1;
}
.greeting-text {
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--color-primary);
}
.greeting-sub {
  font-size: 13px;
  font-weight: 400;
  margin-top: 2px;
  color: var(--color-text-muted);
}

/* Split Columns View (Today tab) */
.today-columns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
}
.column-section {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.column-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--color-border);
  padding-bottom: 8px;
  margin-bottom: 4px;
}
.column-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--color-text);
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ── Empty States ────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 32px 16px;
  border: 1px dashed var(--color-border);
  border-radius: var(--border-radius);
  background: var(--color-surface);
}
.empty-state-icon {
  font-size: 1.75rem;
  margin-bottom: 8px;
  color: var(--color-text-light);
}
.empty-state-text {
  font-weight: 400;
  font-size: 13px;
  color: var(--color-text-muted);
}

/* ── Floating Action Button ──────────────────────────────── */
.fab {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 48px;
  height: 48px;
  background: var(--color-primary);
  color: #fff;
  border-radius: 50%;
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  cursor: pointer;
  transition: all var(--transition);
  z-index: 50;
}
.fab:hover {
  background: var(--color-primary-hover);
  transform: scale(1.05);
  box-shadow: var(--shadow-xl);
}

/* ── Calendar grid ───────────────────────────────────────── */
.calendar-day {
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 500;
  border-radius: var(--border-radius-sm);
  cursor: pointer;
  transition: all var(--transition);
  border: 1px solid transparent;
}
.calendar-day:hover {
  background: var(--color-surface-hover);
}
.calendar-day.today {
  border-color: var(--color-primary);
  font-weight: 600;
}
.calendar-day.success {
  background: var(--color-success);
  color: #fff;
}
.calendar-day.failed {
  background: var(--color-danger);
  color: #fff;
}
.calendar-day.pending {
  background: var(--color-warning);
  color: #fff;
}
.calendar-day.outside {
  opacity: 0.35;
  cursor: default;
}

/* ── Stats block ─────────────────────────────────────────── */
.stat-card {
  background: var(--color-surface);
  border: var(--border);
  border-radius: var(--border-radius);
  box-shadow: var(--shadow-sm);
  padding: 16px;
  text-align: center;
}
.stat-value {
  font-family: var(--font-display);
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--color-primary);
}
.stat-label {
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-text-muted);
  margin-top: 2px;
}

/* ── Checklist / Todos inside Task Detail ────────────────── */
.todo-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid var(--color-border);
}
.todo-item:last-child {
  border-bottom: none;
}
.todo-checkbox {
  width: 16px;
  height: 16px;
  border: 1.5px solid var(--color-text-light);
  border-radius: var(--border-radius-sm);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  margin-top: 3px;
  transition: all var(--transition);
  background: var(--color-surface);
}
.todo-checkbox.done {
  background: var(--color-success);
  border-color: var(--color-success);
  color: #fff;
}
.todo-checkbox.done i {
  font-size: 8px;
}
.todo-text {
  font-size: 13.5px;
  flex: 1;
  color: var(--color-text);
}
.todo-text.done {
  text-decoration: line-through;
  opacity: 0.6;
}

/* ── Comments UI ─────────────────────────────────────────── */
.comment-item {
  background: var(--color-bg);
  border: var(--border);
  border-radius: var(--border-radius);
  padding: 10px 12px;
  font-size: 13px;
  color: var(--color-text);
  margin-bottom: 8px;
}
.comment-time {
  font-size: 11px;
  color: var(--color-text-light);
  margin-top: 4px;
}

/* ── Mobile Layout Overlay & Nav ─────────────────────────── */
.mobile-bottom-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--color-surface);
  border-top: var(--border);
  z-index: 90;
  box-shadow: 0 -1px 3px rgba(0,0,0,0.05);
}
.mobile-nav-items {
  display: flex;
  justify-content: space-around;
  padding: 6px 0 calc(6px + env(safe-area-inset-bottom));
}
.mobile-nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  font-size: 10px;
  font-weight: 500;
  color: var(--color-text-muted);
  cursor: pointer;
  flex: 1;
}
.mobile-nav-item.active {
  color: var(--color-primary);
  font-weight: 600;
}
.mobile-nav-icon {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--border-radius);
  font-size: 14px;
  transition: all var(--transition);
}
.mobile-nav-item.active .mobile-nav-icon {
  background: var(--color-primary-light);
}

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.3);
  backdrop-filter: blur(1px);
  z-index: 99;
}
.sidebar-overlay.visible {
  display: block;
}

/* ── Responsive Styling ──────────────────────────────────── */
@media (max-width: 768px) {
  .today-columns {
    grid-template-columns: 1fr;
    gap: 20px;
  }

  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    height: 100%;
    transform: translateX(-100%);
    width: var(--sidebar-width) !important;
    min-width: var(--sidebar-width) !important;
    z-index: 100;
  }
  .sidebar.mobile-open {
    transform: translateX(0) !important;
  }
  .sidebar.collapsed {
    transform: translateX(-100%);
    width: var(--sidebar-width) !important;
  }

  .mobile-bottom-nav {
    display: block;
  }

  .page-content {
    padding: 16px;
    padding-bottom: 80px; /* Account for mobile nav */
  }

  .fab {
    bottom: 76px;
  }

  .nb-modal {
    max-width: 100%;
    margin: 0;
    border-radius: 8px 8px 0 0;
    max-height: 85vh;
  }
  .nb-overlay {
    align-items: flex-end;
    padding: 0;
  }
}

/* ── Animations ──────────────────────────────────────────── */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes slideInLeft {
  from { transform: translateX(-16px); opacity: 0; }
  to   { transform: translateX(0); opacity: 1; }
}
@keyframes spin { to { transform: rotate(360deg); } }

.animate-fade  { animation: fadeIn 200ms ease forwards; }
.animate-slide { animation: slideInLeft 200ms ease forwards; }

.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); }
.text-muted { color: var(--color-text-muted); }
.text-danger { color: var(--color-danger); }
.text-success { color: var(--color-success); }
.text-accent { color: var(--color-primary); }
.gap-2 { display: flex; gap: 8px; }
.gap-3 { display: flex; gap: 12px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.space-y > * + * { margin-top: 12px; }
.space-y-sm > * + * { margin-top: 8px; }
.mt-auto { margin-top: auto; }

.spinner {
  width: 18px;
  height: 18px;
  border: 2px solid var(--color-border);
  border-top-color: var(--color-primary);
  border-radius: 50%;
  animation: spin 600ms linear infinite;
  display: inline-block;
}

/* Toast System */
.toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.toast {
  background: var(--color-surface);
  border: var(--border);
  border-radius: var(--border-radius);
  box-shadow: var(--shadow-lg);
  padding: 10px 16px;
  font-size: 13px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 240px;
  max-width: 320px;
  animation: slideInLeft 150ms ease;
}
.toast.success { border-left: 4px solid var(--color-success); }
.toast.error   { border-left: 4px solid var(--color-danger); }
.toast.info    { border-left: 4px solid var(--color-primary); }

/* Day Buttons Selector */
.day-btn {
  flex: 1;
  padding: 8px 4px;
  font-size: 11px;
  font-weight: 600;
  border: var(--border);
  border-radius: var(--border-radius-sm);
  background: var(--color-surface);
  transition: all var(--transition);
}
.day-btn:hover {
  background: var(--color-surface-hover);
}
.day-btn.active {
  background: var(--color-primary);
  border-color: var(--color-primary);
  color: #fff;
}

.lightbox-overlay {
  display: none !important;
}

.lightbox-overlay.active {
  display: flex !important;
}

/* ── Responsive Table ────────────────────────────────────── */
.responsive-table-wrapper {
  overflow-x: auto;
  border: var(--border);
  border-radius: var(--border-radius);
  background: var(--color-surface);
  box-shadow: var(--shadow-sm);
}

.responsive-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}

.responsive-table th, .responsive-table td {
  padding: 12px 16px;
  border-bottom: var(--border);
  font-size: 13px;
  color: var(--color-text);
  vertical-align: middle;
}

.responsive-table th {
  background: var(--color-surface-hover);
  font-weight: 600;
  color: var(--color-text-muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.responsive-table tbody tr:last-child td {
  border-bottom: none;
}

.responsive-table tbody tr {
  transition: background var(--transition);
}

.responsive-table tbody tr:hover {
  background: var(--color-surface-hover);
}

@media (max-width: 768px) {
  .today-grid {
    grid-template-columns: 1fr !important;
  }
  .archive-grid {
    grid-template-columns: 1fr !important;
  }
  
  .responsive-table-wrapper {
    border: none;
    background: transparent;
    box-shadow: none;
  }
  .responsive-table thead {
    display: none;
  }
  .responsive-table, .responsive-table tbody, .responsive-table tr, .responsive-table td {
    display: block;
    width: 100%;
  }
  .responsive-table tr {
    margin-bottom: 12px;
    border: var(--border);
    border-radius: var(--border-radius);
    background: var(--color-surface);
    box-shadow: var(--shadow-sm);
    padding: 12px;
    position: relative;
    overflow: hidden;
  }
  .responsive-table tr:hover {
    box-shadow: var(--shadow-md);
    border-color: var(--color-primary);
  }
  
  /* Adds the success/danger side-border on mobile habit cards if we map classes */
  .responsive-table tr.status-success::before {
    content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--color-success);
  }
  .responsive-table tr.status-failed::before {
    content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--color-danger);
  }

  .responsive-table td {
    text-align: right;
    padding: 8px 0;
    border-bottom: 1px dashed var(--color-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
  }
  .responsive-table tbody tr:last-child td {
    border-bottom: 1px dashed var(--color-border);
  }
  .responsive-table td:last-child {
    border-bottom: none;
  }
  .responsive-table td::before {
    content: attr(data-label);
    font-weight: 600;
    font-size: 11px;
    text-transform: uppercase;
    color: var(--color-text-muted);
    text-align: left;
    margin-right: 12px;
    flex-shrink: 0;
  }
}

/* ── Media Gallery Grid ─────────────────────────────── */
.media-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 12px;
  padding: 4px 0;
}
.media-grid-item {
  position: relative;
  aspect-ratio: 1;
  overflow: hidden;
  border-radius: var(--border-radius);
  border: var(--border);
  background: var(--color-bg);
  cursor: pointer;
}
.media-grid-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.2s ease;
}
.media-grid-item:hover img {
  transform: scale(1.05);
}
.media-grid-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgba(0,0,0,0.65) 0%, transparent 50%);
  opacity: 0;
  transition: opacity 0.2s;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: 8px;
}
.media-grid-item:hover .media-grid-overlay {
  opacity: 1;
}
.media-grid-info {
  flex: 1;
  display: flex;
  align-items: flex-end;
}
.media-task-name {
  font-size: 11px;
  font-weight: 600;
  color: #fff;
  text-overflow: ellipsis;
  overflow: hidden;
  white-space: nowrap;
  max-width: 100%;
}
.media-delete-btn {
  background: var(--color-danger);
  border: none;
  border-radius: 4px;
  color: #fff;
  width: 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 11px;
  flex-shrink: 0;
  transition: background var(--transition);
}
.media-delete-btn:hover {
  background: #be0000;
}
@media (max-width: 768px) {
  .media-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}
@media (max-width: 480px) {
  .media-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* ── Quill WYSIWYG Overrides ────────────────────────── */
.ql-toolbar.ql-snow {
  border-color: var(--color-border) !important;
  border-radius: var(--border-radius) var(--border-radius) 0 0 !important;
  background: var(--color-bg) !important;
  padding: 6px 8px !important;
}
.ql-container.ql-snow {
  border-color: var(--color-border) !important;
  font-family: var(--font-body) !important;
  font-size: 13px !important;
  border-radius: 0 0 var(--border-radius) var(--border-radius) !important;
}
.ql-editor {
  min-height: 60px !important;
  color: var(--color-text) !important;
  line-height: 1.6 !important;
}
.ql-editor.ql-blank::before {
  color: var(--color-text-muted) !important;
  font-style: italic !important;
}
[data-theme="dark"] .ql-stroke {
  stroke: var(--color-text-muted) !important;
}
[data-theme="dark"] .ql-fill {
  fill: var(--color-text-muted) !important;
}
[data-theme="dark"] .ql-picker {
  color: var(--color-text-muted) !important;
}
