/* Quest Todo - Mobile-First Styles (Optimized with CSS Nesting) */

:root {
  /* Colors */
  --bg-primary: #0f0f1a;
  --bg-secondary: #1a1a2e;
  --bg-card: #252542;
  /* --accent-primary and --accent-fire are injected from SETTINGS.py via template */
  --accent-secondary: #a29bfe;
  --accent-success: #00d9a5;
  --accent-warning: #ffeaa7;
  --text-primary: #ffffff;
  --text-secondary: #b2b2d8;
  --text-muted: #8585a8;
  --border-color: #3d3d5c;
  --shadow-color: rgba(108, 92, 231, 0.3);
  /* Spacing */
  --spacing-xs: 4px;
  --spacing-sm: 8px;
  --spacing-md: 12px;
  --spacing-lg: 16px;
  --spacing-xl: 20px;
  /* Transitions */
  --transition-fast: 0.2s ease;
  --transition-normal: 0.3s ease;
  --transition-slow: 0.5s ease;
  /* Danger */
  --danger: #dc3545;
  --danger-hover: #c82333;
  /* Z-index layers */
  --z-base: 0;
  --z-header: 50;
  --z-dropdown: 100;
  --z-particles: 1000;
  --z-popup: 2000;
  --z-media-popup: 2500;
  --z-levelup: 3000;
  --z-lightbox: 10000;
}

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

/* ===== UTILITY CLASSES ===== */
.flex-center { display: flex; align-items: center; justify-content: center; }
.flex-col { display: flex; flex-direction: column; }

.icon-btn {
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; border: none; border-radius: 50%;
  cursor: pointer; transition: all var(--transition-fast);
  padding: 0; line-height: 1;
}

/* Shared overlay backdrop */
.overlay {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: rgba(0, 0, 0, 0.7);
  opacity: 0; visibility: hidden;
  transition: opacity 0.3s, visibility 0.3s;
  &.show { opacity: 1; visibility: visible; }
}

/* Shared overlay inner panel */
.overlay-panel {
  background: var(--bg-secondary); border-radius: 16px;
  padding: 20px; min-width: 280px; max-width: 90vw;
  transform: scale(0.9); transition: transform 0.3s;
}
.overlay.show .overlay-panel { transform: scale(1); }

/* Shared overlay header */
.overlay-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 16px; font-weight: 600; font-size: 1rem; color: var(--text-primary);
}

/* Shared overlay close button */
.overlay-close {
  background: none; border: none; font-size: 24px; cursor: pointer; color: var(--text-secondary);
}

/* ===== FOCUS STYLES ===== */
:focus-visible {
  outline: 2px solid var(--accent-primary);
  outline-offset: 2px;
}

:focus:not(:focus-visible) {
  outline: none;
}

html { height: 100%; }

/* Hide scrollbars globally */
* {
  scrollbar-width: none; /* Firefox */
  -ms-overflow-style: none; /* IE/Edge */
  &::-webkit-scrollbar { display: none; } /* Chrome/Safari */
}
body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg-primary); color: var(--text-primary);
  height: 100%; overflow-x: hidden; margin: 0;
  opacity: 0; transition: opacity 0.3s ease;

  &.ready { opacity: 1; }
}

/* ===== ANIMATIONS ===== */
@keyframes shine { 0% { transform: translateX(-100%); } 100% { transform: translateX(100%); } }
@keyframes pulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.1); } }
@keyframes slide-in { from { opacity: 0; transform: translateX(-30px); } to { opacity: 1; transform: translateX(0); } }
@keyframes bounce { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-10px); } }
@keyframes spin { 0%, 100% { transform: rotate(0deg) scale(1); } 50% { transform: rotate(180deg) scale(1.2); } }
@keyframes flicker { 0% { transform: scale(1) rotate(-5deg); } 100% { transform: scale(1.1) rotate(5deg); } }

/* ===== BASE LAYOUT ===== */
.app-container { max-width: 100%; margin: 0 auto; padding: 8px; height: 100%; position: relative; display: flex; flex-direction: column; box-sizing: border-box; }
.main-content { position: relative; flex: 1; display: flex; flex-direction: column; min-height: 0; overflow-x: hidden; }

#particles { position: fixed; inset: 0; pointer-events: none; z-index: var(--z-particles); overflow: hidden; }
.particle { position: absolute; pointer-events: none; }

/* ===== COMBO BADGE ===== */
.combo-badge {
  display: flex; align-items: center; gap: 2px;
  padding: 3px 8px; border-radius: 12px; flex-shrink: 0;
  background: var(--bg-card); border: 1px solid var(--border-color);
  opacity: 0.4; transition: opacity 0.3s, border-color 0.3s;

  &.active { opacity: 1; border-color: var(--accent-fire); animation: pulse 0.5s ease; }
  .combo-fire { font-size: 0.7rem; }
  .combo-count { font-size: 0.75rem; font-weight: 700; color: var(--accent-fire); }
}

/* ===== XP ROW ===== */
.xp-row {
  display: flex; align-items: center; gap: var(--spacing-sm);
  position: relative;
  padding: 4px var(--spacing-sm);
  background: var(--bg-secondary); border-radius: 12px;
  border: 1px solid var(--border-color); box-shadow: 0 4px 20px rgba(0,0,0,0.3);

  .settings-wrapper { position: relative; flex-shrink: 0; }
}

.level-badge {
  display: flex; align-items: center; gap: 4px;
  background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
  padding: 3px 10px; border-radius: 12px; font-weight: 700; font-size: 0.75rem;
  white-space: nowrap; flex-shrink: 0;

  .level-icon { font-size: 0.8rem; animation: spin 3s linear infinite; }
}

/* Menu inner sections */
.menu-profile-row {
  display: flex; align-items: center; justify-content: space-between; gap: var(--spacing-sm);
  padding: 0 var(--spacing-xs);
}

.menu-stats {
  display: flex; justify-content: center; gap: var(--spacing-sm); padding: var(--spacing-xs) 0;

  .stat-item {
    display: flex; align-items: center; gap: 2px; padding: 4px 8px;
    background: var(--bg-secondary); border-radius: 8px; font-weight: 600; font-size: 0.8rem;
    white-space: nowrap;
  }
  .stat-icon { font-size: 0.85rem; }
}

.settings-dropdown .add-task-form {
  padding: 0 var(--spacing-xs);
}

.xp-container-full {
  width: 100%; cursor: pointer;

  .xp-bar {
    position: relative; height: 14px; background: var(--bg-card);
    border-radius: 7px; overflow: hidden; border: 1px solid var(--border-color);

    .xp-fill {
      height: 100%; width: 0%;
      background: linear-gradient(90deg, var(--accent-primary), var(--accent-success));
      border-radius: 6px; transition: width var(--transition-slow);
    }

    .xp-text {
      position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
      font-size: 0.6rem; font-weight: 600; text-shadow: 0 1px 2px rgba(0,0,0,0.5); white-space: nowrap;
    }
  }
}

/* ===== HEADER BLOCK ===== */
.header-block {
  position: relative; z-index: var(--z-header); /* must stay above .tab-animating (z-index: 40) */
}

/* ===== QUICK ADD ROW ===== */
.quick-add-row {
  display: none; gap: 6px; padding: 6px 8px;
  background: var(--bg-secondary); border-radius: 0 0 12px 12px;
  border: 1px solid var(--border-color); border-top: none;

  textarea {
    flex: 1; min-width: 0;
    padding: 6px 10px; font-size: 0.85rem;
    background: var(--bg-card); color: var(--text-primary);
    border: 1px solid var(--border-color); border-radius: 8px;
    outline: none;
    transition: border-color var(--transition-fast);
    resize: none; overflow: hidden;
    min-height: 1.4em; max-height: 6em;
    line-height: 1.4; font-family: inherit;

    &:focus { border-color: var(--accent-primary); }
    &::placeholder { color: var(--text-muted); }
  }

  .quick-add-submit {
    padding: 6px 14px; font-size: 0.8rem; font-weight: 600;
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    border: none; border-radius: 8px; color: white; cursor: pointer;
    transition: transform var(--transition-fast), box-shadow var(--transition-fast);
    white-space: nowrap;

    &:hover { transform: translateY(-1px); box-shadow: 0 3px 10px var(--shadow-color); }
    &:active { transform: translateY(0); }
  }

  &.show { display: flex; }
}

/* ===== ICON BUTTONS (shared) ===== */
.search-toggle-btn, .jump-current-btn, .add-task-btn {
  width: 32px; height: 32px;
  background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
  color: white;
  transition: transform var(--transition-fast), box-shadow var(--transition-fast);

  &:hover { transform: scale(1.1); box-shadow: 0 2px 12px var(--shadow-color); }
  &:active { transform: scale(0.95); }
}
.search-toggle-btn { font-size: 0.85rem; line-height: 1; }
.jump-current-btn { font-size: 0.9rem; line-height: 1; }
.add-task-btn { font-size: 1.2rem; font-weight: 300; line-height: 1; }

/* ===== SETTINGS ===== */
.settings-wrapper {
  .settings-btn {
    padding: 4px; width: 32px; height: 32px; background: var(--bg-card);
    border: 1px solid var(--border-color);
    user-select: none;
    transition: background var(--transition-fast), border-color var(--transition-fast), box-shadow var(--transition-fast), transform var(--transition-fast);
    font-size: 0.85rem; color: var(--accent-success);

    &:hover {
      background: var(--accent-primary); border-color: var(--accent-primary);
      transform: translateY(-1px); box-shadow: 0 4px 12px var(--shadow-color);
      .user-icon { background-color: var(--text-primary); }
    }
    &:active { transform: translateY(0); box-shadow: none; }
  }

  .settings-dropdown {
    position: absolute; top: calc(100% + 8px); right: 0; min-width: 260px;
    max-height: calc(100vh - 60px); overflow-y: auto;
    padding: var(--spacing-sm); background: var(--bg-card);
    border: 1px solid var(--border-color); border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.4); z-index: var(--z-dropdown);
    opacity: 0; visibility: hidden; transform: translateY(-10px) scale(0.95);
    transition: all var(--transition-fast);

    &.show { opacity: 1; visibility: visible; transform: translateY(0) scale(1); }
  }

  .user-icon {
    display: inline-block; width: 1.2em; height: 1.2em;
    background-color: var(--accent-success);
    transition: background-color var(--transition-fast);
    mask-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M12 12c2.7 0 5-2.3 5-5s-2.3-5-5-5-5 2.3-5 5 2.3 5 5 5zm0 2c-3.3 0-10 1.7-10 5v3h20v-3c0-3.3-6.7-5-10-5z'/%3E%3C/svg%3E");
    mask-size: contain; mask-repeat: no-repeat; mask-position: center;
    -webkit-mask-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M12 12c2.7 0 5-2.3 5-5s-2.3-5-5-5-5 2.3-5 5 2.3 5 5 5zm0 2c-3.3 0-10 1.7-10 5v3h20v-3c0-3.3-6.7-5-10-5z'/%3E%3C/svg%3E");
    -webkit-mask-size: contain; -webkit-mask-repeat: no-repeat; -webkit-mask-position: center;
  }
  .settings-divider { height: 1px; background: var(--border-color); margin: var(--spacing-xs) 0; }

  .settings-item {
    display: flex; align-items: center; gap: var(--spacing-sm);
    width: 100%; padding: var(--spacing-sm) var(--spacing-md);
    background: transparent; border: none; border-radius: 8px;
    color: var(--text-primary); font-size: 0.85rem;
    cursor: pointer; transition: all var(--transition-fast); text-decoration: none;

    &:hover { background: var(--bg-secondary); }
    &.tab-btn.active { background: var(--bg-secondary); color: var(--accent-primary); font-weight: 600; }
    &.settings-logout { color: var(--accent-fire); }
    &.settings-logout:hover { background: rgba(255, 107, 107, 0.15); }
  }

  .settings-label { flex: 1; text-align: left; }
  .settings-status { font-size: 0.75rem; color: var(--text-muted); background: var(--bg-secondary); padding: 2px 6px; border-radius: 4px; }
  .version-badge { font-size: 0.75rem; color: #00d9a5; background: var(--bg-secondary); padding: 2px 6px; border-radius: 4px; }

  .settings-item-wrapper {
    position: relative;
  }
  .settings-submenu {
    max-height: 0; overflow: hidden;
    padding: 0 var(--spacing-sm);
    transition: max-height var(--transition-fast), padding var(--transition-fast);
  }
  .settings-item-wrapper:hover > .settings-submenu,
  .settings-item-wrapper.open > .settings-submenu {
    max-height: 200px;
    padding: var(--spacing-sm);
  }
}

/* ===== ADD TASK FORM ===== */
.add-task-form { flex: 1; min-width: 0; margin: 0; padding: 0; }

.input-wrapper {
  display: flex; flex-direction: row; align-items: flex-end; gap: 4px;
  padding: 3px 2px 3px 6px;
  background: var(--bg-secondary);
  border-radius: 12px; border: 1px solid var(--border-color); transition: all var(--transition-normal);

  &:focus-within { border-color: var(--accent-primary); box-shadow: 0 0 20px var(--shadow-color); }

  #task-input {
    flex: 1; padding: 0;
    background: transparent; border: none; outline: none;
    font-size: 0.75rem; color: var(--text-primary);
    resize: none; overflow: hidden;
    min-height: 1.2em; max-height: 6em;
    line-height: 1.2; font-family: inherit;

    &::placeholder { color: var(--text-muted); }
  }

  .add-btn {
    display: flex; align-items: center; justify-content: center; gap: 2px;
    padding: 0 6px;
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    border: none; border-radius: 10px; color: white;
    font-size: 0.7rem; font-weight: 600; cursor: pointer;
    transition: all var(--transition-normal); height: 100%; min-width: 20px;

    &:hover { transform: translateY(-1px); box-shadow: 0 4px 15px var(--shadow-color); }
    .btn-icon { font-size: 1rem; font-weight: 300; }
    .btn-text { display: none; }
  }
}

/* ===== SCHEDULE FIELDS ===== */
.schedule-toggle-btn {
  width: 32px; height: 32px; min-width: 32px;
  background: var(--bg-card); border: 1px solid var(--border-color);
  border-radius: 8px; font-size: 1rem;
  color: var(--text-secondary);

  &:hover { border-color: var(--accent-primary); color: var(--accent-primary); }
  &.active { background: var(--accent-primary); border-color: var(--accent-primary); color: white; }
}

.schedule-fields {
  display: flex; gap: 8px; padding: 6px 0 0;

  .schedule-label {
    flex: 1; display: flex; flex-direction: column; gap: 2px;

    span { font-size: 0.65rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; }

    input[type="datetime-local"] {
      width: 100%; padding: 4px 6px;
      background: var(--bg-card); border: 1px solid var(--border-color); border-radius: 6px;
      color: var(--text-primary); font-size: 0.8rem;
      outline: none; transition: border-color var(--transition-fast);
      color-scheme: dark;

      &:focus { border-color: var(--accent-primary); }
    }
  }
}

/* ===== TASKS ===== */
.tasks-section {
  background: transparent; border-radius: 12px;
  padding: 0 8px 8px 8px; border: none; margin-top: 10px;
  flex: 1; display: flex; flex-direction: column; min-height: 0;
}

.section-title {
  display: flex; align-items: center; gap: var(--spacing-sm);
  font-size: 1.1rem; font-weight: 600; margin-bottom: 10px; color: var(--text-primary);

  .title-icon { font-size: 1.3rem; }
  .task-count { font-size: 0.9rem; color: var(--text-muted); font-weight: 400; }
}

.tasks-list {
  list-style: none;
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100vh;
  touch-action: pan-x;
  user-select: none;
  cursor: grab;
  overflow: hidden;
  z-index: 0;
}
.tasks-list.editing {
  touch-action: pan-y;
  user-select: text; -webkit-user-select: text;
}
.tasks-list.dragging { cursor: grabbing; }

.drum-wrapper {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  transform-style: preserve-3d;
}


.task-item {
  position: absolute;
  top: calc(50% - 25px);
  left: 8px; right: 8px;
  height: 50px; min-height: 50px;
  display: flex; align-items: center; gap: 1px; padding: 6px;
  overflow: hidden;
  background: var(--bg-card); border-radius: 8px; border: 1px solid var(--border-color);
  backface-visibility: visible;
  transition: border-color var(--transition-fast);

  &.time-night,
  &.time-morning,
  &.time-day,
  &.time-evening {
    border-color: transparent;
    overflow: hidden;
  }
  &.time-night::before,
  &.time-morning::before,
  &.time-day::before,
  &.time-evening::before {
    content: '';
    position: absolute;
    inset: 0;
    background-size: 100% 100%;
    background-repeat: no-repeat;
    background-position: center;
    border-radius: inherit;
    opacity: 0.45;
    z-index: 0;
    pointer-events: none;
  }
  &.time-night > *,
  &.time-morning > *,
  &.time-day > *,
  &.time-evening > * { position: relative; z-index: 1; }
  &.task-done.time-night::before,
  &.task-done.time-morning::before,
  &.task-done.time-day::before,
  &.task-done.time-evening::before { opacity: 0.2; }
  &.time-morning::before { background-image: url('bg_morning.png'); }
  &.time-day::before     { background-image: url('bg_day.png'); }
  &.time-evening::before { background-image: url('bg_evening.png'); }
  &.time-night::before   { background-image: url('bg_night.png'); }

  &.center { border: 2px solid var(--accent-fire); border-radius: 10px; height: auto; min-height: 50px; max-height: 60vh; transition: border-color 0.2s ease; flex-wrap: wrap; }
  &.center:has(.task-text[contenteditable="true"]),
  &.center:has(.task-description[contenteditable="true"]) { border-color: var(--accent-primary); }
  &.center .task-text { white-space: pre-wrap; text-overflow: unset; overflow-y: auto; max-height: calc(60vh - 20px); }
  .task-description { display: none; }
  &.center .task-description {
    display: block; flex-basis: 100%; order: 10;
    white-space: pre-wrap; word-break: break-word;
    font-size: 0.85rem; color: var(--text-secondary);
    margin-top: 6px; padding: 4px 6px;
    border-top: 1px solid var(--border-color);
    max-height: calc(40vh - 10px); overflow-y: auto;
    cursor: text; border-radius: 4px;
    transition: background 0.15s ease;
  }
  &.center .task-description.placeholder { color: var(--text-muted); font-style: italic; }
  &.center .task-description[contenteditable="true"] { background: rgba(108, 92, 231, 0.08); outline: none; }
  &:hover:not(.center) { border-color: var(--accent-primary); }
  &.day-header {
    border: none; background: transparent;
    justify-content: center; padding-left: 14px;
    height: 14px; min-height: 14px;
    top: calc(50% - 7px);
    font-size: 1.1rem; font-weight: 700;
    color: var(--text-muted); text-transform: uppercase;
    letter-spacing: 0.08em;
    pointer-events: none;
  }
  &.placeholder { border-style: dashed; }
  &.completing { animation: task-complete 0.3s ease forwards; }

  .task-media {
    width: 20px; height: 100%; flex-shrink: 0; display: flex; align-items: center; justify-content: center;
    font-size: 14px; cursor: pointer;
  }


  .task-checkbox {
    position: relative; width: 20px; height: 20px; cursor: pointer; flex-shrink: 0; align-self: center;

    input {
      position: absolute; opacity: 0; width: 100%; height: 100%; cursor: pointer; z-index: 1;
      &:hover + .checkbox-custom { border-color: var(--accent-success); }
      &:checked + .checkbox-custom { background: var(--accent-success); border-color: var(--accent-success); }
      &:checked + .checkbox-custom::after { opacity: 1; transform: scale(1); }
    }

    .checkbox-custom {
      position: absolute; inset: 0; background: var(--bg-secondary);
      border: 2px solid var(--border-color); border-radius: 6px;
      transition: all var(--transition-fast);
      display: flex; align-items: center; justify-content: center;

      &::after { content: '\2714'; color: white; font-size: 14px; opacity: 0; transform: scale(0); transition: all var(--transition-fast); }
    }
  }

  .task-completed-icon {
    cursor: pointer;
    .checkbox-completed { font-size: 16px; display: flex; align-items: center; justify-content: center; width: 20px; height: 20px; }
  }

  &.task-done { background: rgba(37, 37, 66, 0.4); }
  &.task-done .task-text { opacity: 0.45; }
  &.task-done .task-dates { opacity: 0.45; }

  .task-magic {
    width: 20px; height: 20px;
    background: transparent; border: 1.5px solid var(--border-color);
    font-size: 11px;
    &:hover { border-color: #c084fc; }
  }

  .task-add-sub {
    width: 20px; height: 20px;
    background: transparent; border: 1.5px solid var(--border-color);
    color: var(--text-muted); font-size: 14px; font-weight: 700;
    &:hover { border-color: var(--accent-primary); color: var(--accent-primary); }
  }

  .subtask-prefix { font-family: monospace; font-size: 0.9rem; font-weight: 700; white-space: pre; pointer-events: none; user-select: none; }
  .subtask-dash { position: relative; }
  .subtask-dash[data-depth="1"] { color: #c8b6ff; }
  .subtask-dash[data-depth="2"] { color: #00ffea; }
  .subtask-dash[data-depth="3"] { color: #fff44f; }
  .subtask-dash[data-depth="4"] { color: #ff9a76; }
  .subtask-dash[data-depth="5"] { color: #f0f0ff; }
  .subtask-dash.connected-down::after {
    content: '';
    position: absolute;
    left: 50%;
    top: 50%;
    width: 2px;
    height: 50px;
    background: currentColor;
    opacity: 0.45;
    transform: translateX(-50%);
    pointer-events: none;
  }
  .subtask-dash.connected-up::before {
    content: '';
    position: absolute;
    left: 50%;
    bottom: 50%;
    width: 2px;
    height: 50px;
    background: currentColor;
    opacity: 0.45;
    transform: translateX(-50%);
    pointer-events: none;
  }


  .task-text {
    flex: 1; font-size: inherit; color: var(--text-primary);
    transition: all var(--transition-normal); cursor: default; border-radius: 4px;
    min-width: 0; word-break: break-word; margin-left: 4px;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    user-select: none; -webkit-user-select: none;

    &[contenteditable="true"] { background: transparent; outline: none; cursor: default; caret-color: var(--text-primary); user-select: text; -webkit-user-select: text; }
    & .edit-highlight { background: rgba(108, 92, 231, 0.15); border-radius: 4px; padding: 2px 4px; margin: -2px -4px; box-decoration-break: clone; -webkit-box-decoration-break: clone; cursor: text; }
  }

  .task-xp {
    width: 52px; text-align: center; box-sizing: border-box;
  }

  .task-dates {
    display: flex; flex-direction: column; align-items: flex-end; justify-content: center; flex-shrink: 0;
    gap: 0; min-width: 0; overflow: hidden;
    padding: 1px 3px;
  }
  .gcal-recurrence-notice {
    font-size: 0.75rem; color: #4285f4; padding: 4px 0; opacity: 0.85;
  }

  .task-date {
    display: flex; flex-direction: column; align-items: center;
    font-size: 0.55rem; line-height: 1.1; white-space: nowrap;

    .task-date-day { font-weight: 700; }
    .task-date-time { font-weight: 600; opacity: 0.9; }

    &.task-date-start { color: var(--accent-success); }
    &.task-date-end { color: var(--accent-fire); }
    &.task-date-same { color: var(--accent-warning); }
  }

  .task-duration {
    font-size: 0.55rem;
    line-height: 1.1;
    font-weight: 600;
    white-space: nowrap;
    opacity: 0.7;
    color: var(--accent-warning);
    align-self: center;
  }

  .task-settings-wrap {
    position: relative; flex-shrink: 0;

    .task-settings {
      width: 30px; height: 30px; padding: 4px; background: transparent; border: 2px solid transparent;
      color: var(--text-muted); font-size: 0.85rem; cursor: pointer; border-radius: 50%;
      transition: all var(--transition-fast);
      display: flex; align-items: center; justify-content: center;

      &:hover { background: rgba(100, 180, 255, 0.2); color: var(--accent-info); }
    }

    &.open .task-settings { background: rgba(100, 180, 255, 0.15); color: var(--accent-info); }
  }

  &:has(.task-dates.has-recurrence) .task-settings,
  &:has(.task-dates.gcal-sourced) .task-settings {
    border-color: rgba(255, 255, 255, 0.7);
  }
}

.task-settings-menu {
  position: fixed;
  display: flex; flex-direction: column;
  background: var(--bg-card); border: 1px solid var(--border-subtle);
  border-radius: 8px; padding: 4px 0; min-width: 130px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.3); z-index: var(--z-popup);

  .task-menu-item {
    display: flex; align-items: center; gap: 6px;
    padding: 6px 12px; background: none; border: none;
    color: var(--text-primary); font-size: 0.8rem; cursor: pointer;
    white-space: nowrap; transition: background var(--transition-fast);

    &:hover { background: var(--bg-hover); }
  }

  .task-menu-icon { display: inline-block; width: 1.4em; text-align: center; flex-shrink: 0; }

  .task-menu-delete:hover { background: rgba(255, 107, 107, 0.15); color: var(--accent-fire); }
}

/* ===== FLAT VIEW MODE ===== */
.tasks-list.flat-view {
  position: fixed;
  overflow-y: auto;
  overflow-x: hidden;
  touch-action: pan-y;
  cursor: default;
  perspective: none;
}
.tasks-list.flat-view .flat-list {
  list-style: none;
  padding: 80px 8px 120px;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.tasks-list.flat-view .flat-item {
  position: relative;
  top: auto;
  left: auto;
  right: auto;
  transform: none !important;
  opacity: 1 !important;
  height: auto;
  min-height: 38px;
}
.tasks-list.flat-view .flat-header {
  position: relative;
  top: auto;
  transform: none !important;
  opacity: 1 !important;
  pointer-events: none;
}
.tasks-list.flat-view .task-text {
  white-space: pre-wrap;
  overflow: visible;
  text-overflow: unset;
}
.tasks-list.flat-view .task-dates {
  display: flex;
}

@keyframes task-complete {
  0% { opacity: 1; transform: translateX(0) scale(1); }
  50% { transform: translateX(20px) scale(1.02); background: var(--accent-success); }
  100% { opacity: 0; transform: translateX(100px) scale(0.8); }
}

/* ===== EMPTY STATE ===== */
.empty-state {
  text-align: center; padding: 12px var(--spacing-lg); display: none;

  &.show { display: block; animation: slide-in 0.5s ease; }

  .empty-icon { font-size: 3rem; margin-bottom: 8px; animation: bounce 2s ease-in-out infinite; }
  p { font-size: 0.9rem; color: var(--text-secondary); margin-bottom: 2px; }
  .empty-hint { font-size: 0.8rem !important; color: var(--text-muted) !important; }
}

/* ===== TABS CONTAINER ===== */
.tabs-container {
  display: flex;
  flex-direction: column;
  margin-bottom: 0;
  background: var(--bg-secondary);
  border-radius: 10px;
  border: 1px solid var(--border-color);
  overflow: hidden;
}

/* ===== TABS NAVIGATION ===== */
.tabs-nav {
  display: flex;
  gap: 2px;
  padding: 2px;
}

.tab-btn {
  flex: 1;
  padding: 4px var(--spacing-sm);
  background: transparent;
  border: none;
  border-radius: 6px;
  color: var(--text-secondary);
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.5px;
  cursor: pointer;
  transition: all var(--transition-fast);

  &:hover { color: var(--text-primary); background: rgba(108, 92, 231, 0.1); }
  &.active { background: var(--accent-primary); color: var(--text-primary); }
}

/* ===== SOCIAL SEARCH (in tabs) ===== */
.search-input-wrapper.social-search {
  display: none;
  padding: var(--spacing-xs) var(--spacing-sm);
  padding-top: 0;
  border-top: none;
  border-radius: 0;

  &.show { display: flex; }
}

/* ===== TAB CONTENT ===== */
.tab-content {
  padding: 0; margin: 0;
  flex: 1; min-height: 0; overflow-y: auto;
}
.tab-content.tab-animating {
  position: absolute;
  inset: 0;
  background: var(--bg-primary);
  transform-style: flat;
  z-index: 2;
}
#tab-todo {
  flex-direction: column; overflow: hidden;
}
#tab-todo.tab-animating {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100vh;
  overflow: visible;
  z-index: 40;
}

@keyframes fade-in {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes slide-out-left {
  from { opacity: 1; transform: translateX(0); }
  to { opacity: 0; transform: translateX(-100%); }
}
@keyframes slide-out-right {
  from { opacity: 1; transform: translateX(0); }
  to { opacity: 0; transform: translateX(100%); }
}
@keyframes slide-in-right {
  from { opacity: 0; transform: translateX(100%); }
  to { opacity: 1; transform: translateX(0); }
}
@keyframes slide-in-left {
  from { opacity: 0; transform: translateX(-100%); }
  to { opacity: 1; transform: translateX(0); }
}
.slide-out-left { animation: slide-out-left 1.5s ease forwards; }
.slide-out-right { animation: slide-out-right 1.5s ease forwards; }
.slide-in-right { animation: slide-in-right 1.5s ease forwards; }
.slide-in-left { animation: slide-in-left 1.5s ease forwards; }

/* ===== HISTORY LIST ===== */
.history-list {
  display: flex;
  flex-direction: column;
  gap: 3px;
  list-style: none;
  padding: 0;
  margin: 0;
}

/* Common card-row styles */
.history-item, .social-item, .user-card, .request-item {
  display: flex; align-items: center; gap: 6px; padding: 6px;
  background: var(--bg-card); border-radius: 8px; border: 1px solid var(--border-color);
}

.history-item {
  animation: slide-in 0.3s ease;
}

.history-icon {
  font-size: 1rem;
  flex-shrink: 0;
}

.history-action {
  flex: 1;
  font-size: 0.85rem;
  color: var(--text-primary);
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: pointer;
}
.history-item.expanded .history-action {
  white-space: pre-wrap;
  overflow: visible;
  text-overflow: unset;
}

/* Common XP badge styles */
.task-xp, .history-points, .social-xp {
  padding: 2px 6px; background: rgba(0, 217, 165, 0.2); border-radius: 16px;
  font-size: 0.7rem; font-weight: 600; color: var(--accent-success); white-space: nowrap; flex-shrink: 0;
}

.history-time {
  font-size: 0.7rem;
  color: var(--text-muted);
  white-space: nowrap;
  flex-shrink: 0;
}

/* ===== SOCIAL FEED ===== */
.social-feed {
  min-height: 150px;
}

.social-item {
  flex-wrap: wrap;
  margin-bottom: 4px;
}

.social-media {
  width: 100%;
  max-height: 300px;
  object-fit: cover;
  border-radius: 8px;
  order: -1;
}

.social-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--accent-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
  flex-shrink: 0;
}

.social-content { flex: 1; }
.social-user { font-weight: 600; color: var(--accent-secondary); font-size: 0.85rem; }
.social-action { color: var(--text-secondary); font-size: 0.8rem; }
.social-time { font-size: 0.7rem; color: var(--text-muted); margin-top: 2px; }

/* ===== SEARCH ===== */
.search-container { margin-bottom: var(--spacing-lg); }

.search-input-wrapper {
  display: flex;
  gap: var(--spacing-sm);
  padding: var(--spacing-xs) var(--spacing-xs) var(--spacing-xs) var(--spacing-md);
  background: var(--bg-secondary);
  border-radius: 10px;
  border: 2px solid var(--border-color);
  transition: all var(--transition-normal);
}

.search-input-wrapper:focus-within {
  border-color: var(--accent-primary);
  box-shadow: 0 0 20px var(--shadow-color);
}

#user-search-input {
  flex: 1;
  padding: var(--spacing-sm) 0;
  background: transparent;
  border: none;
  outline: none;
  font-size: 0.95rem;
  color: var(--text-primary);
}

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

.search-btn {
  padding: var(--spacing-sm) var(--spacing-md);
  background: var(--accent-primary);
  border: none;
  border-radius: 8px;
  color: white;
  cursor: pointer;
  transition: all var(--transition-fast);
  min-height: 36px;
  min-width: 44px;
}

.search-btn:hover { background: var(--accent-secondary); }

.search-results {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-sm);
}

/* ===== USER CARD ===== */
.user-card {
  animation: slide-in 0.3s ease;
}

/* Common info column styles */
.user-info, .request-info {
  flex: 1; display: flex; flex-direction: column; gap: 2px;
}

.user-info .user-name {
  font-weight: 600;
  color: var(--text-primary);
  font-size: 0.85rem;
}

.user-info .user-level {
  font-size: 0.7rem;
  color: var(--text-muted);
}

.add-friend-btn {
  padding: 4px 8px;
  background: var(--accent-primary);
  border: none;
  border-radius: 6px;
  color: white;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast);
  min-height: 28px;
  min-width: 70px;
}

.add-friend-btn:hover:not(:disabled) {
  background: var(--accent-secondary);
  transform: translateY(-1px);
}

.add-friend-btn:disabled {
  background: var(--bg-secondary);
  color: var(--text-muted);
  cursor: not-allowed;
}

.add-friend-btn.pending {
  background: var(--accent-warning);
  color: var(--bg-primary);
}

.add-friend-btn.accept {
  background: var(--accent-success);
}

/* ===== FRIENDS SECTIONS ===== */
.friends-section { margin-bottom: var(--spacing-lg); }

.section-subtitle {
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
  font-size: 0.95rem;
  font-weight: 600;
  margin-bottom: var(--spacing-md);
  color: var(--text-primary);
}

.badge {
  padding: 2px 8px;
  background: var(--accent-fire);
  border-radius: 12px;
  font-size: 0.75rem;
  color: white;
}

.requests-list {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-sm);
}

/* ===== REQUEST ITEM ===== */
.request-item {
  animation: slide-in 0.3s ease;
}

.request-info .user-name {
  font-weight: 600;
  color: var(--text-primary);
  font-size: 0.85rem;
}

.request-info .request-time,
.request-info .request-status {
  font-size: 0.7rem;
  color: var(--text-muted);
}

.request-actions {
  display: flex;
  gap: 4px;
}

.accept-btn, .reject-btn, .cancel-btn {
  width: 32px; height: 32px;
  border-radius: 6px; font-size: 0.9rem;
}

.accept-btn {
  background: var(--accent-success);
  color: white;
}

.accept-btn:hover { transform: scale(1.1); }

.reject-btn, .cancel-btn {
  background: rgba(255, 107, 107, 0.2);
  color: var(--accent-fire);
}

.reject-btn:hover, .cancel-btn:hover {
  background: var(--accent-fire);
  color: white;
}

/* ===== SOCIAL FEED ENHANCEMENTS ===== */
.social-meta {
  display: flex;
  gap: var(--spacing-md);
  margin-top: var(--spacing-xs);
  align-items: center;
}

.social-xp {
  padding: 2px 8px;
  border-radius: 12px;
}

.load-more-btn {
  display: none;
  width: 100%;
  padding: var(--spacing-md);
  background: var(--bg-card);
  border: 1px dashed var(--border-color);
  border-radius: 10px;
  color: var(--text-secondary);
  font-size: 0.85rem;
  cursor: pointer;
  transition: all var(--transition-fast);
  margin-top: var(--spacing-sm);
}

.load-more-btn:hover {
  background: var(--bg-secondary);
  border-color: var(--accent-primary);
  color: var(--accent-primary);
}
.load-more-btn.show { display: block; }

/* ===== ACHIEVEMENTS ===== */
.achievements-panel {
  margin-top: 0; background: var(--bg-secondary); border-radius: 12px;
  padding: 10px; border: 1px solid var(--border-color); position: relative;
  overflow-y: auto;

  .panel-title { display: flex; align-items: center; gap: var(--spacing-sm); font-size: 1.1rem; margin-bottom: 10px; color: var(--text-primary); }
}

.achievements-grid {
  display: grid; grid-template-columns: repeat(auto-fill, 100px); gap: 8px; justify-content: center;
}

.achievement-item {
  flex: 0 0 100px;
  display: flex; flex-direction: column; align-items: center;
  padding: 8px; background: var(--bg-card); border-radius: 10px;
  border: 2px solid var(--border-color); text-align: center;
  transition: all var(--transition-normal); opacity: 0.5; filter: grayscale(1);

  &.unlocked { opacity: 1; filter: grayscale(0); border-color: var(--accent-warning); animation: pulse 0.5s ease; }

  .achievement-icon { font-size: 2rem; margin-bottom: 4px; }
  .achievement-name { font-size: 0.75rem; font-weight: 600; color: var(--text-primary); margin-bottom: 2px; line-height: 1.2; }
  .achievement-desc { font-size: 0.65rem; color: var(--text-muted); line-height: 1.3; }
}

/* ===== POPUPS (shared) ===== */
.achievement-popup, .levelup-popup {
  background: rgba(0,0,0,0.8);
  pointer-events: none;

  &.show { pointer-events: auto; }
}

.achievement-popup {
  z-index: var(--z-popup);

  .popup-content {
    background: linear-gradient(135deg, var(--bg-secondary), var(--bg-card));
    border: 2px solid var(--accent-warning); border-radius: 12px;
    padding: var(--spacing-lg); text-align: center; box-shadow: 0 10px 40px rgba(255, 234, 167, 0.3);
  }

  .popup-icon { font-size: 2.5rem; animation: bounce 0.5s ease infinite alternate; }
  .popup-title { font-size: 0.8rem; color: var(--accent-warning); text-transform: uppercase; letter-spacing: 2px; margin: var(--spacing-sm) 0 var(--spacing-xs); }
  .popup-name { font-size: 1.1rem; font-weight: 700; color: var(--text-primary); }
  .popup-desc { font-size: 0.8rem; color: var(--text-secondary); margin-top: var(--spacing-xs); }
}

.levelup-popup {
  z-index: var(--z-levelup);

  .levelup-content { text-align: center; animation: levelup-appear 0.6s cubic-bezier(0.68, -0.55, 0.265, 1.55); }
  .levelup-stars { font-size: 2.5rem; margin-bottom: var(--spacing-lg); animation: pulse 0.5s ease infinite alternate; }
  .levelup-title {
    font-size: 2.5rem; font-weight: 800;
    background: linear-gradient(135deg, var(--accent-warning), var(--accent-fire));
    -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
    margin-bottom: var(--spacing-sm);
  }
  .levelup-level { font-size: 1.2rem; color: var(--text-secondary); }

  .levelup-achievements {
    margin-top: var(--spacing-lg); display: flex; flex-direction: column; gap: var(--spacing-sm); align-items: center;

    &:empty { display: none; }

    .levelup-ach {
      display: flex; align-items: center; gap: var(--spacing-sm);
      background: rgba(255, 234, 167, 0.1); border: 1px solid var(--accent-warning);
      border-radius: 8px; padding: var(--spacing-xs) var(--spacing-md);

      .levelup-ach-icon { font-size: 1.5rem; }
      .levelup-ach-text { text-align: left; }
      .levelup-ach-name { font-size: 0.9rem; font-weight: 700; color: var(--text-primary); }
      .levelup-ach-desc { font-size: 0.75rem; color: var(--text-secondary); }
    }
  }
}

@keyframes levelup-appear { from { transform: scale(0) rotate(-180deg); opacity: 0; } to { transform: scale(1) rotate(0deg); opacity: 1; } }

/* ===== SKELETON LOADING ===== */
.skeleton-loader {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-sm);
}

.skeleton-loader.hidden {
  display: none;
}

.skeleton-task {
  height: 36px;
  background: var(--bg-card);
  border-radius: 8px;
  position: relative;
  overflow: hidden;
}

.skeleton-task::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.1), transparent);
  animation: shine 1.5s infinite;
}

/* ===== DESKTOP LAYOUT ===== */
@media (min-width: 768px) {
  .app-container {
    max-width: 700px;
    margin: 0 auto;
    padding: var(--spacing-xl);
  }

  .input-wrapper .add-btn .btn-text {
    display: inline;
  }
}

/* ===== MOBILE LAYOUT ===== */
@media (max-width: 767px) {
  .app-container {
    padding: 4px;
  }

  /* Header row: tighter spacing */
  .xp-row {
    gap: 4px;
    padding: 3px 6px;
  }
  .level-badge {
    padding: 2px 6px;
    font-size: 0.7rem;
  }
  .combo-badge {
    padding: 2px 6px;
  }
  .xp-container-full .xp-bar {
    height: 12px;
  }
  .xp-container-full .xp-bar .xp-text {
    font-size: 0.55rem;
  }
  .search-toggle-btn, .jump-current-btn, .add-task-btn {
    width: 28px;
    height: 28px;
  }
  .search-toggle-btn { font-size: 0.75rem; }
  .jump-current-btn { font-size: 0.8rem; }
  .add-task-btn { font-size: 1rem; }
  .settings-wrapper .settings-btn {
    width: 28px;
    height: 28px;
    font-size: 0.75rem;
  }

  /* Quick add row */
  .quick-add-row {
    padding: 4px 6px;
  }

  /* Drum wrapper: small side margins */
  .drum-wrapper {
    left: 2%;
    right: 2%;
  }

  /* Task items on drum */
  .task-item {
    height: 42px;
    min-height: 42px;
    top: calc(50% - 21px);
    gap: 2px;
    padding: 4px;
    left: 4px;
    right: 4px;
    border-radius: 6px;
    font-size: 0.82rem;
  }
  .task-item.center {
    min-height: 50px;
    top: calc(50% - 25px);
    border-radius: 8px;
  }
  .task-item .task-dates {
    display: flex;
  }
  .task-item .subtask-prefix {
    font-size: 0.55rem;
    letter-spacing: -1px;
  }
  .task-item .task-checkbox {
    width: 18px;
    height: 18px;
  }
  .task-item .task-completed-icon .checkbox-completed {
    font-size: 14px;
    width: 18px;
    height: 18px;
  }
  .task-item .task-settings-wrap .task-settings {
    width: 26px;
    height: 26px;
    font-size: 0.75rem;
  }
  .task-item.day-header {
    font-size: 0.9rem;
    height: 12px;
    min-height: 12px;
    top: calc(50% - 6px);
  }

  /* Subtask vertical lines — synced with 42px row height */
  .subtask-dash.connected-down::after,
  .subtask-dash.connected-up::before {
    height: 42px;
  }

  /* Tasks section: reduce padding */
  .tasks-section {
    padding: 0 4px 4px 4px;
    margin-top: 6px;
  }

  /* Flat view mode */
  .tasks-list.flat-view .flat-list {
    padding: 60px 4px 80px;
    gap: 4px;
  }
  .tasks-list.flat-view .flat-item {
    min-height: 36px;
    font-size: 0.82rem;
  }

  /* Settings dropdown: full-width on mobile */
  .settings-wrapper .settings-dropdown {
    position: fixed;
    top: auto;
    bottom: 0;
    left: 0;
    right: 0;
    min-width: unset;
    max-height: 70vh;
    border-radius: 16px 16px 0 0;
    transform: translateY(10px) scale(0.98);
  }
  .settings-wrapper .settings-dropdown.show {
    transform: translateY(0) scale(1);
  }

  /* Popups: constrain to viewport */
  .overlay-panel {
    min-width: unset;
    width: calc(100vw - 32px);
    max-width: 340px;
  }
  .date-editor-content {
    width: calc(100vw - 32px);
    max-width: 340px;
  }
  .recurrence-choice-content {
    width: calc(100vw - 32px);
    max-width: 320px;
  }
  .media-popup {
    width: calc(100vw - 32px);
    max-width: 340px;
  }

  /* Tabs: smaller text */
  .tab-btn {
    font-size: 0.7rem;
    padding: 3px 4px;
  }

  /* History & social items */
  .history-item, .social-item, .user-card, .request-item {
    padding: 5px;
    gap: 4px;
  }
  .history-action {
    font-size: 0.8rem;
  }

  /* Achievements grid: fit smaller screens */
  .achievements-grid {
    grid-template-columns: repeat(auto-fill, 85px);
    gap: 6px;
  }
  .achievement-item {
    flex: 0 0 85px;
    padding: 6px;
  }
  .achievement-item .achievement-icon {
    font-size: 1.6rem;
  }
  .achievement-item .achievement-name {
    font-size: 0.7rem;
  }

  /* Popups: smaller on mobile */
  .achievement-popup .popup-content {
    padding: var(--spacing-md);
  }
  .levelup-popup .levelup-title {
    font-size: 2rem;
  }

  /* Search */
  .search-input-wrapper {
    padding: var(--spacing-xs);
  }
  #user-search-input {
    font-size: 0.85rem;
    padding: 6px 0;
  }
  .search-btn {
    min-height: 32px;
    min-width: 38px;
    padding: 6px 8px;
  }
}

/* ===== SKIP TO CONTENT ===== */
.skip-to-content {
  position: absolute;
  left: -9999px;
  top: var(--spacing-md);
  background: var(--accent-primary);
  color: var(--text-primary);
  padding: var(--spacing-sm) var(--spacing-md);
  border-radius: 4px;
  z-index: var(--z-particles);
  text-decoration: none;
  font-weight: 600;
}

.skip-to-content:focus {
  left: var(--spacing-md);
}

/* ===== CONNECT GCAL OVERLAY ===== */
.gcal-required-overlay {
  position: fixed; inset: 0; z-index: 900;
  background: rgba(15, 15, 26, 0.92);
  display: flex; align-items: center; justify-content: center;
  backdrop-filter: blur(4px);
}
.gcal-required-content {
  max-width: 360px; padding: 32px 24px;
  background: var(--bg-card); border: 2px solid var(--accent-fire);
  border-radius: 16px; text-align: center;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
}
.gcal-required-icon { font-size: 48px; margin-bottom: 12px; }
.gcal-required-title {
  font-size: 1.4rem; font-weight: 800; letter-spacing: 0.05em;
  color: var(--accent-fire); margin-bottom: 12px;
}
.gcal-required-desc {
  font-size: 0.95rem; color: var(--text-secondary);
  margin: 0 0 20px; line-height: 1.5;
}
.gcal-required-btn {
  background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
  color: white; border: none; border-radius: 10px;
  padding: 12px 24px; font-size: 1rem; font-weight: 600;
  cursor: pointer; transition: transform 0.15s ease;
}
.gcal-required-btn:hover { transform: translateY(-2px); }

/* ===== REDUCED MOTION ===== */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ===== MEDIA POPUP ===== */
.media-popup-overlay {
  z-index: var(--z-media-popup);
}

.media-popup-preview {
  margin-bottom: 16px;
  display: none;
}

.media-popup-preview.has-media {
  display: block;
}

.media-popup-preview img,
.media-popup-preview video {
  width: 100%;
  max-height: 200px;
  object-fit: contain;
  border-radius: 8px;
}

.media-popup-preview .delete-media-btn {
  margin-top: 8px;
  width: 100%;
  padding: 8px;
  background: var(--danger);
  color: white;
  border: none;
  border-radius: 8px;
  cursor: pointer;
}

.media-popup-preview .delete-media-btn:hover {
  background: var(--danger-hover);
}

.media-popup-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.media-btn {
  padding: 12px 16px;
  border: none;
  border-radius: 10px;
  background: var(--bg-primary);
  color: var(--text-primary);
  cursor: pointer;
  font-size: 14px;
  text-align: left;
  transition: background 0.2s;
}

.media-btn:hover {
  background: var(--accent-primary);
}

.media-btn.secondary {
  background: transparent;
  border: 1px solid var(--border-color);
}

.camera-view {
  margin-bottom: 16px;
}

.camera-view.hidden {
  display: none;
}

.camera-view video {
  width: 100%;
  border-radius: 8px;
  background: #000;
}

.camera-controls {
  display: flex;
  gap: 10px;
  margin-top: 10px;
}

.camera-controls .media-btn {
  flex: 1;
  text-align: center;
}

/* Task media with image */
.task-media.has-image {
  border-radius: 6px;
  overflow: hidden;
}

.task-media.has-image img,
.task-media.has-image video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* ===== RECURRENCE CHOICE DIALOG ===== */
.recurrence-choice-overlay {
  z-index: var(--z-popup);
}
.recurrence-choice-content { width: 300px; min-width: 260px; max-width: calc(100vw - 32px); }

.recurrence-choice-buttons { display: flex; flex-direction: column; gap: 8px; }

.recurrence-choice-btn {
  display: flex; align-items: center; gap: 12px;
  width: 100%; padding: 12px 16px;
  background: var(--bg-card); border: 1px solid var(--border-color); border-radius: 10px;
  color: var(--text-primary); font-size: 0.9rem;
  cursor: pointer; transition: border-color var(--transition-fast), background var(--transition-fast);
}
.recurrence-choice-btn:hover { border-color: var(--accent-primary); background: rgba(108, 92, 231, 0.1); }
.recurrence-choice-btn .rcb-icon { font-size: 1.2rem; }
.recurrence-choice-btn .rcb-label { font-weight: 500; }

/* ===== DATE EDITOR POPUP ===== */
.date-editor-overlay {
  z-index: var(--z-media-popup);
}
.date-editor-content { width: 320px; max-width: calc(100vw - 32px); }

.date-editor-fields { display: flex; flex-direction: column; gap: 10px; margin-bottom: 16px; }

.date-editor-label {
  display: flex; flex-direction: column; gap: 4px;

  span { font-size: 0.7rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; }

  input[type="datetime-local"],
  input[type="date"],
  input[type="number"],
  select {
    width: 100%; padding: 8px 10px;
    background: var(--bg-card); border: 1px solid var(--border-color); border-radius: 8px;
    color: var(--text-primary); font-size: 0.85rem;
    outline: none; transition: border-color var(--transition-fast);
    color-scheme: dark;

    &:focus { border-color: var(--accent-primary); }
  }
}

.date-editor-recurrence { margin-bottom: 16px; }

.recurrence-custom {
  display: none; flex-direction: column; gap: 10px;
  padding: 12px; margin-top: 10px;
  background: var(--bg-card); border-radius: 10px;
  border: 1px solid var(--border-color);
}
.recurrence-custom.show { display: flex; }

.recurrence-every-row {
  display: flex; gap: 8px;
  input { width: 60px; }
  select { flex: 1; }
}

.recurrence-weekdays {
  display: none; flex-wrap: wrap; gap: 6px;
}
.recurrence-weekdays.show { display: flex; }

.weekday-btn {
  width: 36px; height: 36px;
  background: var(--bg-secondary); border: 1px solid var(--border-color);
  color: var(--text-secondary); font-size: 0.75rem; font-weight: 600;

  &:hover { border-color: var(--accent-primary); color: var(--accent-primary); }
  &.active { background: var(--accent-primary); border-color: var(--accent-primary); color: white; }
}

.recurrence-end-section { display: flex; flex-direction: column; gap: 8px; }
.recurrence-end-field {
  width: 100%; padding: 8px 10px;
  background: var(--bg-card); border: 1px solid var(--border-color); border-radius: 8px;
  color: var(--text-primary); font-size: 0.85rem; outline: none;
  color-scheme: dark;
  transition: border-color var(--transition-fast);

  &:focus { border-color: var(--accent-primary); }
}

.date-editor-save {
  width: 100%; padding: 10px; font-size: 0.9rem; font-weight: 600;
  background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
  border: none; border-radius: 10px; color: white; cursor: pointer;
  transition: transform var(--transition-fast), box-shadow var(--transition-fast);

  &:hover { transform: translateY(-1px); box-shadow: 0 4px 15px var(--shadow-color); }
  &:active { transform: translateY(0); }
}

/* ===== SOCIAL LIGHTBOX ===== */
.social-lightbox {
  z-index: var(--z-lightbox);
  background: rgba(0, 0, 0, 0.9);
  cursor: pointer;
  transition: opacity 0.2s, visibility 0.2s;
}

.social-lightbox-content img,
.social-lightbox-content video {
  max-width: 90vw;
  max-height: 90vh;
  object-fit: contain;
  border-radius: 8px;
}

/* Fullscreen mode for video container (standard + Safari) */
.social-lightbox-content:fullscreen,
.social-lightbox-content:-webkit-full-screen {
  display: flex; align-items: center; justify-content: center; background: #000;
}

.social-lightbox-content:fullscreen video,
.social-lightbox-content:-webkit-full-screen video {
  max-width: 100vw; max-height: 100vh; width: 100%; height: 100%;
  object-fit: contain; border-radius: 0;
}

.social-media {
  cursor: pointer;
}

/* Video wrapper for play overlay */
.video-wrapper {
  position: relative;
  width: 100%;
  order: -1;
}

.video-wrapper .social-media {
  width: 100%;
  display: block;
}

.video-play-overlay {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 60px;
  height: 60px;
  background: rgba(0, 0, 0, 0.6);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.video-play-overlay .play-icon {
  color: white;
  font-size: 24px;
  margin-left: 4px;
}

.video-wrapper.playing .video-play-overlay {
  opacity: 0;
}
