:root {
  --bg-body: #05070f;
  --surface: #0b0f19;
  --surface-card: #111827;
  --primary: #6366f1;
  --primary-glow: rgba(99, 102, 241, 0.25);
  --secondary: #a855f7;
  --accent-green: #10b981;
  --accent-red: #ef4444;
  --accent-gold: #f59e0b;
  --text-main: #f8fafc;
  --text-muted: #475569;
  --text-dim: #94a3b8;
  --border: #1e293b;
  --radius-lg: 24px;
  --radius-md: 14px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: "Inter", sans-serif;
  letter-spacing: -0.01em;
}

@keyframes animatedBg {
  0% {
    background-position: 0% 50%;
  }
  50% {
    background-position: 100% 50%;
  }
  100% {
    background-position: 0% 50%;
  }
}

body {
  background: linear-gradient(-45deg, #05070f, #110c1f, #1e1b4b, #080a12);
  background-size: 400% 400%;
  animation: animatedBg 15s ease infinite;
  color: var(--text-main);
  display: flex;
  height: 100dvh;
  overflow: hidden;
  transition: background-image 0.5s ease;
  flex-direction: column;
  -webkit-text-size-adjust: 100%;
}

@media (min-width: 1024px) {
  body {
    flex-direction: row;
  }
}

::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: #1e293b;
  border-radius: 10px;
}

/* Navigation Sidebar */
.sidebar {
  width: 100%;
  height: auto;
  background-color: rgba(11, 15, 25, 0.85);
  backdrop-filter: blur(12px);
  border-right: none;
  border-bottom: 1px solid var(--border);
  padding: 12px 16px;
  padding-left: max(16px, env(safe-area-inset-left));
  padding-right: max(16px, env(safe-area-inset-right));
  display: flex;
  flex-direction: row;
  flex-shrink: 0;
  z-index: 10;
  transition: all 0.3s ease;
  overflow-x: auto;
  overflow-y: hidden;
  gap: 10px;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.sidebar::-webkit-scrollbar {
  display: none;
}

@keyframes scrollHint {
  0%   { transform: translateX(0); }
  25%  { transform: translateX(-10px); }
  50%  { transform: translateX(0); }
  75%  { transform: translateX(-5px); }
  100% { transform: translateX(0); }
}

/* Fade + arrow hint on mobile only */
@media (max-width: 1023px) {
  .sidebar {
    position: relative;
  }

  /* Right-edge fade overlay */
  .sidebar::after {
    content: "›";
    position: fixed;
    top: 0;
    right: 0;
    width: 48px;
    height: 60px; /* matches approximate top bar height */
    background: linear-gradient(to right, transparent, rgba(11, 15, 25, 0.92) 60%);
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding-right: 10px;
    font-size: 1.1rem;
    color: rgba(99, 102, 241, 0.8);
    pointer-events: none;
    z-index: 11;
    animation: scrollHint 1.8s ease-in-out 0.6s 2;
  }

  /* Hide the hint once the user has scrolled */
  .sidebar.scrolled::after {
    display: none;
  }
}

@media (min-width: 1024px) {
  .sidebar {
    width: 300px;
    height: auto;
    border-right: 1px solid var(--border);
    border-bottom: none;
    padding: 32px 20px;
    flex-direction: column;
    overflow-x: hidden;
    overflow-y: auto;
    gap: 0;
  }
}

.logo {
  font-size: 0;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 0;
  margin-right: 1rem;
  padding-left: 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  white-space: nowrap;
  flex-shrink: 0;
  position: relative;
}

.logo::before {
  content: "";
  display: none;
  width: 34px;
  height: 34px;
  flex: 0 0 34px;
  background: url("/image1.png") center center / contain no-repeat;
  transform: scale(2);
  transform-origin: center;
}

.logo img {
  width: 38px;
  height: 38px;
  object-fit: contain;
  flex: 0 0 38px;
}

.logo > :first-child:not(span) {
  font-size: 0;
  line-height: 0;
}

@media (max-width: 1023px) {
  .logo {
    font-size: 0;
    padding-left: 4px;
    margin-right: 6px;
    gap: 6px;
  }
}

@media (min-width: 1024px) {
  .logo {
    margin-bottom: 1.5rem;
    margin-right: 0;
  }
}
.logo span {
  background: linear-gradient(135deg, #fff 30%, var(--primary) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  font-size: 1.3rem;
}

/* Sidebar Widgets */
.sidebar-widget {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border);
  padding: 14px;
  border-radius: var(--radius-md);
  margin-bottom: 0;
  margin-right: 1rem;
  min-width: 150px;
  flex-shrink: 0;
}

/* Hide all widgets in the top bar on mobile — only show nav */
@media (max-width: 1023px) {
  .sidebar-widget:not(.sidebar-widget--mobile-visible) {
    display: none;
  }

  .sidebar-widget.sidebar-widget--mobile-visible {
    display: block;
    width: min(100%, 520px);
    margin-right: 0;
    margin-bottom: 10px;
    order: 999;
  }

  .sidebar-widget.sidebar-widget--mobile-visible .pomodoro-display {
    font-size: 1.9rem;
  }

  .sidebar-widget.sidebar-widget--mobile-visible .sidebar-widget-header {
    margin-bottom: 10px;
  }
}

@media (min-width: 1024px) {
  .sidebar-widget {
    margin-bottom: 1rem;
    margin-right: 0;
    min-width: auto;
    flex-shrink: 1;
  }
}
.sidebar-widget-header {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--primary);
  letter-spacing: 0.05em;
  margin-bottom: 8px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 6px;
}
.media-select,
.media-input-custom {
  width: 100%;
  background: #05070f;
  border: 1px solid var(--border);
  color: white;
  padding: 6px 8px;
  border-radius: 6px;
  font-size: 0.8rem;
  outline: none;
  margin-bottom: 8px;
}

/* Gamification XP Widget */
.xp-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.85rem;
  margin-bottom: 8px;
}
.level-text {
  font-weight: 700;
  color: var(--secondary);
}
.xp-text {
  font-family: "JetBrains Mono", monospace;
  color: var(--text-dim);
  font-size: 0.75rem;
}
.xp-bar-bg {
  width: 100%;
  height: 6px;
  background: #1e293b;
  border-radius: 10px;
  overflow: hidden;
}
.xp-bar-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--primary), var(--secondary));
  transition: width 0.5s ease-out;
}

/* Pomodoro Sidebar Widget */
.pomodoro-display {
  font-family: "JetBrains Mono", monospace;
  font-size: 2.6rem;
  font-weight: 700;
  color: var(--primary);
  text-align: center;
  margin: 10px 0;
}
.pomodoro-select {
  background: #05070f;
  border: 1px solid var(--border);
  color: white;
  border-radius: 4px;
  font-size: 0.7rem;
  padding: 2px 4px;
  outline: none;
}

/* AI Chat Widget */
.ai-sidebar-chat {
  height: 300px;
  overflow-y: auto;
  background: rgba(0, 0, 0, 0.2);
  border: 1px inset rgba(255, 255, 255, 0.05);
  border-radius: 8px;
  padding: 10px;
  margin-bottom: 10px;
  font-size: 0.85rem;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* Peer Chat Container - Make it scrollable */
.ai-chat-container {
  overflow-y: auto;
  background: rgba(0, 0, 0, 0.2);
  border: 1px inset rgba(255, 255, 255, 0.05);
  border-radius: 8px;
  padding: 10px;
  font-size: 0.85rem;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

#peer-chat-box.sync-chamber-messages {
  background: transparent;
  border: 1px inset rgba(255, 255, 255, 0.05);
  gap: 8px;
  padding: 10px;
}

.message-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  width: 100%;
  padding: 8px 14px 10px;
  transition: background 0.18s ease;
  position: relative;
}

.message-row:hover {
  background: rgba(255, 255, 255, 0.035);
}

.message-row.me {
  background: rgba(99, 102, 241, 0.06);
}

.message-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.74rem;
  font-weight: 700;
  flex: 0 0 30px;
}

.message-main {
  min-width: 0;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.message-topline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-width: 0;
}

.message-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  line-height: 1;
}

.message-author {
  font-size: 0.84rem;
  font-weight: 700;
  color: var(--text-main);
}

.message-time {
  font-size: 0.72rem;
  color: var(--text-dim);
}

.message-content {
  color: #dbe4f4;
  font-size: 0.88rem;
  line-height: 1.5;
  word-break: break-word;
}

.message-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  opacity: 0;
  transition: opacity 0.15s ease;
  padding-top: 0;
  flex: 0 0 auto;
  pointer-events: none;
}

.message-row:hover .message-actions {
  opacity: 1;
  pointer-events: auto;
}

.message-action-btn {
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-main);
  border-radius: 8px;
  padding: 4px 7px;
  font-size: 0.72rem;
  cursor: pointer;
  line-height: 1;
}

.message-action-btn:hover,
.message-action-btn.active {
  background: rgba(99, 102, 241, 0.18);
  border-color: rgba(99, 102, 241, 0.52);
}

.message-action-btn.reaction {
  font-size: 0.8rem;
  border-radius: 999px;
}

.message-reactions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 4px;
}

.message-reaction-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 28px;
  min-height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  background: rgba(99, 102, 241, 0.14);
  border: 1px solid rgba(99, 102, 241, 0.35);
  font-size: 0.82rem;
}

.message-reaction-chip.active {
  background: rgba(99, 102, 241, 0.24);
  border-color: rgba(99, 102, 241, 0.55);
}

.message-quote {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 8px 10px;
  border-left: 3px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.035);
}

.message-quote.reply {
  border-left-color: rgba(99, 102, 241, 0.75);
}

.message-quote.forward {
  border-left-color: rgba(34, 197, 94, 0.75);
}

.message-quote-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

.message-quote-sender {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-main);
}

.message-quote-text {
  font-size: 0.82rem;
  color: #cbd5e1;
  line-height: 1.35;
  word-break: break-word;
}

#sync-screen-share-panel {
  position: fixed;
  right: 18px;
  bottom: 18px;
  width: min(860px, calc(100vw - 40px));
  max-height: calc(100vh - 140px);
  overflow: auto;
  flex-shrink: 0;
  z-index: 70;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.35);
}

#sync-screen-share-panel video {
  height: 160px !important;
  max-height: 160px !important;
  width: 100%;
}

@media (max-width: 1100px) {
  #sync-screen-share-panel {
    width: calc(100vw - 24px);
    right: 12px;
    bottom: 12px;
    max-height: calc(100vh - 100px);
  }
  #sync-screen-share-panel video {
    height: 130px !important;
    max-height: 130px !important;
  }
}

#sync-compose-reply-preview {
  display: none;
}

.sync-composer-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.sync-composer-row .ai-input {
  flex: 1 1 240px;
  min-width: 0;
}

.sync-emoji-toggle {
  flex: 0 0 auto;
}

.sync-emoji-picker {
  display: none;
  flex-wrap: wrap;
  gap: 8px;
  padding: 10px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 14px;
  background: rgba(9, 12, 22, 0.95);
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.28);
  max-width: 100%;
}

.sync-emoji-option {
  all: unset;
  box-sizing: border-box;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-main);
  border-radius: 10px;
  cursor: pointer;
  font-size: 1rem;
  flex: 0 0 auto;
}

.sync-emoji-option:hover {
  background: rgba(99, 102, 241, 0.18);
  border-color: rgba(99, 102, 241, 0.48);
}

.forward-target-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  padding: 12px 14px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.03);
  color: var(--text-main);
  text-align: left;
}

.forward-target-row:hover {
  background: rgba(99, 102, 241, 0.14);
  border-color: rgba(99, 102, 241, 0.4);
}

.forward-target-main {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.forward-target-name {
  font-size: 0.9rem;
  font-weight: 700;
}

.forward-target-sub {
  font-size: 0.76rem;
  color: var(--text-muted);
}

.forward-target-pill {
  align-self: center;
  color: var(--primary);
  font-size: 0.76rem;
  font-weight: 700;
}

.chat-bubble {
  font-size: 0.85rem;
  line-height: 1.4;
  padding: 10px;
  border-radius: 8px;
}
.chat-bubble.bot {
  background: rgba(99, 102, 241, 0.1);
  border-left: 2px solid var(--primary);
}
.chat-bubble.bot strong {
  color: #a5b4fc;
}
.chat-bubble.user {
  background: rgba(255, 255, 255, 0.05);
}
.chat-bubble.user strong {
  color: #f472b6;
}
.chat-bubble.system {
  background: rgba(16, 185, 129, 0.05);
  border: 1px dashed rgba(16, 185, 129, 0.3);
  color: #cbd5e1;
  font-size: 0.75rem;
}
.chat-bubble.system-warning {
  background: rgba(239, 68, 68, 0.08);
  border: 1px solid rgba(239, 68, 68, 0.25);
  color: #fca5a5;
  font-size: 0.75rem;
  animation: fadeIn 0.2s ease;
}

.sync-status-banner {
  padding: 12px 14px;
  border: 1px solid rgba(16, 185, 129, 0.24);
  border-radius: 14px;
  background: rgba(16, 185, 129, 0.06);
  color: #d1fae5;
  font-size: 0.8rem;
  line-height: 1.4;
}

#group-network-view .chat-bubble {
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(148, 163, 184, 0.12);
}

#group-network-view .chat-bubble.system {
  border-style: solid;
  background: rgba(16, 185, 129, 0.06);
  color: #d1fae5;
  font-size: 0.8rem;
}

#group-network-view .chat-bubble.system-warning {
  background: rgba(239, 68, 68, 0.08);
  border: 1px solid rgba(239, 68, 68, 0.22);
}

@media (min-width: 1024px) and (max-width: 1450px) {
  #friends-detail-panel > .dashboard-grid {
    grid-template-columns: 1fr;
    gap: 14px;
  }

  #friends-detail-panel .study-chat-card,
  #friends-detail-panel .study-sidebar-card {
    grid-column: span 1 !important;
    min-height: auto;
    position: static;
  }

  #friends-detail-panel .study-chat-card {
    min-height: 58vh;
  }

  #friends-detail-panel .study-sidebar-card {
    min-height: 0;
  }

  #friends-detail-panel .study-sidebar-scroll {
    max-height: none;
    overflow: visible;
    padding-right: 0;
  }

  #friends-detail-panel .sync-chats-list {
    max-height: 220px;
  }

  #friends-detail-panel .sync-workbench-section {
    border-radius: 16px;
  }
}

@media (hover: none), (max-width: 768px) {
  .message-actions {
    opacity: 1;
    pointer-events: auto;
  }

  .message-row {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    padding: 10px 12px;
  }

  .message-avatar {
    margin-bottom: 2px;
  }

  .message-main {
    min-width: 0;
    width: 100%;
  }

  .message-actions {
    width: 100%;
    margin-top: 4px;
    justify-content: flex-start;
    margin-left: 0;
  }

  .message-topline {
    align-items: flex-start;
    flex-wrap: nowrap;
  }

  .message-time {
    margin-left: 0;
    margin-top: 2px;
  }

  .message-content,
  .message-quote-text {
    white-space: normal;
    overflow-wrap: break-word;
    word-break: normal;
    max-width: 100%;
  }

  .message-reactions {
    margin-top: 2px;
  }

  .sync-composer-row {
    align-items: stretch;
  }

  .sync-emoji-toggle,
  .sync-composer-row .btn-action {
    width: 100%;
  }

  .sync-control-row {
    flex-direction: column;
    align-items: stretch;
  }

  .sync-control-row > .edit-input,
  .sync-control-row > input[type="file"],
  .sync-control-row > select,
  .sync-control-row > .btn-action,
  .sync-control-row > .btn-outline,
  .sync-control-row > .btn-text {
    width: 100%;
    flex: 1 1 auto;
  }

  .sync-emoji-picker {
    gap: 6px;
  }
}

.ai-input {
  flex: 1;
  padding: 10px 14px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background-color: var(--bg-body);
  color: white;
  outline: none;
  font-size: 0.85rem;
  width: 100%;
}

/* Floating AI Button & Popup */
.ai-fab {
  position: fixed;
  bottom: max(20px, env(safe-area-inset-bottom));
  right: 20px;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  cursor: pointer;
  box-shadow: 0 10px 25px rgba(99, 102, 241, 0.4);
  z-index: 2000;
  border: none;
  transition:
    transform 0.2s,
    box-shadow 0.2s;
  touch-action: manipulation;
}

@media (min-width: 768px) {
  .ai-fab {
    bottom: 30px;
    right: 30px;
    width: 64px;
    height: 64px;
    font-size: 1.8rem;
  }
}
.ai-fab:hover {
  transform: scale(1.05);
  box-shadow: 0 12px 30px rgba(99, 102, 241, 0.6);
}
.ai-popup-panel {
  position: fixed;
  bottom: max(80px, calc(60px + env(safe-area-inset-bottom)));
  right: 16px;
  left: 16px;
  width: auto;
  background: rgba(17, 24, 39, 0.95);
  backdrop-filter: blur(16px);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
  display: none;
  flex-direction: column;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.8);
  z-index: 2000;
  animation: fadeIn 0.2s ease;
  max-height: 65vh;
}

@media (min-width: 768px) {
  .ai-popup-panel {
    width: 380px;
    bottom: 110px;
    right: 30px;
    left: auto;
    padding: 20px;
  }
}
.ai-popup-panel.active {
  display: flex;
}

/* Nav Links */
.nav-group {
  display: flex;
  flex-direction: column;
  margin-top: 10px;
}

.sidebar-tail {
  margin-top: auto;
  padding-top: 10px;
}

.sidebar-theme-btn {
  border: 1px solid var(--border);
}

@media (max-width: 1023px) {
  .nav-group {
    flex: 1;
    margin-top: 0;
    overflow-x: auto;
    scrollbar-width: none;
    flex-direction: row;
    gap: 8px;
    align-items: center;
    padding-bottom: 2px;
  }
  .nav-group::-webkit-scrollbar {
    display: none;
  }
  .sidebar-tail {
    margin-top: 0;
    padding-top: 0;
  }
}
.nav-link {
  padding: 10px 14px;
  border-radius: var(--radius-md);
  color: var(--text-dim);
  text-decoration: none;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 12px;
  transition: all 0.2s ease;
  margin-bottom: 4px;
  font-size: 0.9rem;
  cursor: pointer;
  border: none;
  background: transparent;
  width: 100%;
  text-align: left;
}
.nav-link:hover {
  background-color: rgba(255, 255, 255, 0.03);
  color: var(--text-main);
}
.nav-link.active {
  background: linear-gradient(
    90deg,
    rgba(99, 102, 241, 0.15) 0%,
    rgba(99, 102, 241, 0) 100%
  );
  color: #818cf8;
  border-left: 3px solid var(--primary);
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
  padding-left: 11px;
}

@media (max-width: 1023px) {
  .nav-link {
    width: auto;
    margin-bottom: 0;
    white-space: nowrap;
    padding: 10px 12px;
  }
  .nav-link.active {
    border-left: none;
    border-radius: var(--radius-md);
    padding-left: 12px;
  }
  .nav-link,
  .btn-text,
  .btn-outline,
  .btn-add-todo,
  .notes-filter-btn {
    min-height: 44px;
  }
}

.floating-media-player {
  position: fixed;
  z-index: 4000;
  left: 50%;
  top: 50%;
  width: min(70vw, 920px);
  height: min(55vh, 520px);
  transform: translate(-50%, -50%);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: rgba(11, 15, 25, 0.96);
  backdrop-filter: blur(8px);
  box-shadow: 0 20px 70px rgba(0, 0, 0, 0.55);
  display: none;
  overflow: hidden;
}

.floating-media-player.active {
  display: block;
}

.floating-media-header {
  height: 40px;
  padding: 0 10px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(255, 255, 255, 0.02);
  cursor: move;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}

.floating-media-body {
  width: 100%;
  height: calc(100% - 40px);
  background: #000;
}

.floating-media-body iframe {
  width: 100%;
  height: 100%;
  border: 0;
}

.floating-media-resize {
  position: absolute;
  right: 0;
  bottom: 0;
  width: 16px;
  height: 16px;
  cursor: nwse-resize;
  touch-action: none;
  background: linear-gradient(
    135deg,
    transparent 0%,
    transparent 45%,
    rgba(148, 163, 184, 0.8) 45%,
    rgba(148, 163, 184, 0.8) 100%
  );
}

.routine-drag-handle {
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

.kanban-task-title {
  touch-action: none;
}

.kanban-card-item.touch-source-dragging {
  opacity: 0.25;
}

.kanban-column.touch-drop-target {
  outline: 2px solid var(--accent, #7c3aed);
  outline-offset: 2px;
}

.kanban-drag-ghost {
  position: fixed;
  z-index: 9999;
  pointer-events: none;
  opacity: 0.92;
  transform: translate3d(0, 0, 0);
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.5);
}

/* View Panels */
.main-content {
  flex: 1;
  padding: 16px;
  padding-bottom: max(16px, env(safe-area-inset-bottom));
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  z-index: 10;
  background: rgba(5, 7, 15, 0.4);
  backdrop-filter: blur(4px);
}

@media (min-width: 1024px) {
  .main-content {
    padding: 32px;
  }
}
.app-view {
  display: none;
}
.app-view.active-view {
  display: block;
  animation: fadeIn 0.3s ease;
}
.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
  flex-wrap: wrap;
  gap: 12px;
}
.header h1 {
  font-size: 1.3rem;
  font-weight: 700;
  background: linear-gradient(180deg, #fff 0%, #cbd5e1 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

@media (min-width: 768px) {
  .header h1 {
    font-size: 1.6rem;
  }
}

.dashboard-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 20px;
}

/* =========================
   Scheduler (Google Calendar-ish)
   ========================= */
.scheduler-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.scheduler-seg {
  display: inline-flex;
  gap: 8px;
}

.scheduler-range {
  color: var(--text-muted);
  font-size: 0.85rem;
  white-space: nowrap;
}

.scheduler-root {
  height: min(640px, 70vh);
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  border-top: 1px solid var(--border);
}

.sched-grid {
  min-width: 760px;
  display: grid;
  grid-template-columns: 72px repeat(var(--sched-days, 7), 1fr);
}

.sched-head {
  position: sticky;
  top: 0;
  z-index: 5;
  background: rgba(5, 7, 15, 0.9);
  backdrop-filter: blur(6px);
  border-bottom: 1px solid var(--border);
}

.sched-head-cell {
  padding: 10px 8px;
  font-size: 0.78rem;
  color: var(--text-muted);
  border-right: 1px solid rgba(148, 163, 184, 0.12);
}

.sched-head-cell strong {
  color: var(--text);
  font-weight: 700;
  font-size: 0.9rem;
}

.sched-time-cell {
  height: 48px;
  padding: 6px 10px;
  font-size: 0.75rem;
  color: var(--text-muted);
  border-right: 1px solid rgba(148, 163, 184, 0.12);
  border-bottom: 1px solid rgba(148, 163, 184, 0.08);
}

.sched-day-col {
  position: relative;
  border-right: 1px solid rgba(148, 163, 184, 0.12);
  border-bottom: 1px solid rgba(148, 163, 184, 0.08);
  height: 48px;
  touch-action: none;
  cursor: crosshair;
}

.sched-day-col::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  bottom: 0;
  background: linear-gradient(
    90deg,
    rgba(99, 102, 241, 0.04),
    rgba(0, 0, 0, 0)
  );
  opacity: 0;
  pointer-events: none;
}

.sched-day-col.touch-drop-target::after {
  opacity: 1;
}

.sched-events-layer {
  position: absolute;
  inset: 0;
  pointer-events: auto;
  cursor: crosshair;
}

.sched-event {
  position: absolute;
  left: 6px;
  right: 6px;
  border-radius: 6px;
  background: rgba(124, 58, 237, 0.25);
  border: 1px solid rgba(124, 58, 237, 0.55);
  color: #fff;
  padding: 6px 8px;
  font-size: 0.78rem;
  line-height: 1.1;
  pointer-events: auto;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
  cursor: grab;
}

.sched-event .meta {
  margin-top: 4px;
  font-size: 0.7rem;
  color: rgba(226, 232, 240, 0.85);
}

.sched-event-resize {
  position: absolute;
  left: 0;
  right: 0;
  bottom: -2px;
  height: 14px;
  cursor: ns-resize;
}

.sched-selection {
  position: absolute;
  left: 6px;
  right: 6px;
  border-radius: 6px;
  background: rgba(34, 197, 94, 0.14);
  border: 1px dashed rgba(34, 197, 94, 0.6);
  pointer-events: none;
}

@media (min-width: 640px) {
  .dashboard-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (min-width: 1024px) {
  .dashboard-grid {
    grid-template-columns: repeat(12, 1fr);
  }
}
.card {
  background-color: rgba(17, 24, 39, 0.85);
  backdrop-filter: blur(8px);
  border-radius: var(--radius-lg);
  padding: 16px;
  border: 1px solid var(--border);
  box-shadow: 0 10px 30px -10px rgba(0, 0, 0, 0.7);
}

@media (min-width: 768px) {
  .card {
    padding: 24px;
  }
}

/* Mobile-responsive grid-column spans */
@media (max-width: 767px) {
  .card[style*="grid-column: span"] {
    grid-column: span 1 !important;
  }
}
.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}
.card-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-main);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* AOD Panel */
.aod-card {
  grid-column: span 12;
  background: radial-gradient(
    120% 120% at 50% 0%,
    rgba(27, 12, 45, 0.85) 0%,
    rgba(8, 10, 18, 0.9) 100%
  );
  border: 1px solid #2e1f4d;
  position: relative;
  overflow: hidden;
}
.aod-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 2px;
  background: linear-gradient(
    90deg,
    transparent,
    var(--secondary),
    transparent
  );
}
.aod-layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
  align-items: center;
}

@media (min-width: 640px) {
  .aod-layout {
    grid-template-columns: 1.5fr 2fr;
    gap: 20px;
  }
}

@media (min-width: 1024px) {
  .aod-layout {
    grid-template-columns: 2.5fr 3.5fr 2fr;
    gap: 24px;
  }
}

@media (min-width: 768px) and (max-width: 1199px) {
  .aod-layout {
    grid-template-columns: 1fr;
    gap: 14px;
  }

  .aod-time-block {
    border-right: none;
    padding-right: 0;
    padding-bottom: 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  }

  .aod-clock {
    font-size: clamp(3rem, 8vw, 4.3rem);
  }

  .current-phase-title {
    font-size: 1.15rem;
  }

  .next-up-block {
    width: 100%;
  }
}
.aod-time-block {
  border-right: 1px solid rgba(255, 255, 255, 0.05);
  padding-right: 12px;
}
.aod-clock {
  font-family: "JetBrains Mono", monospace;
  font-size: 3rem;
  font-weight: 700;
  color: #ffffff;
  line-height: 1;
  text-shadow: 0 0 25px rgba(168, 85, 247, 0.5);
}

@media (min-width: 640px) {
  .aod-clock {
    font-size: 4rem;
  }
}

@media (min-width: 1024px) {
  .aod-clock {
    font-size: 5.5rem;
  }
}

@media (min-width: 768px) and (max-width: 1199px) {
  .aod-clock {
    font-size: clamp(3rem, 8vw, 4.3rem);
  }
}
.aod-sub-date {
  font-size: 0.9rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-top: 10px;
  font-family: "JetBrains Mono", monospace;
}
.phase-badge {
  display: inline-block;
  background: rgba(168, 85, 247, 0.15);
  border: 1px solid var(--secondary);
  color: #d8b4fe;
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  margin-bottom: 8px;
}
.current-phase-title {
  font-size: 1.3rem;
  font-weight: 700;
  color: #ffffff;
  margin-bottom: 6px;
}
.current-phase-rules {
  font-size: 0.85rem;
  color: var(--text-dim);
  line-height: 1.4;
  max-height: 60px;
  overflow-y: auto;
  padding-right: 6px;
}

.next-up-block {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.05);
  padding: 14px;
  border-radius: var(--radius-md);
  position: relative;
}
.next-up-lbl {
  font-size: 0.7rem;
  color: var(--text-muted);
  text-transform: uppercase;
  font-weight: 700;
  letter-spacing: 0.05em;
}
.next-up-title {
  font-size: 0.9rem;
  font-weight: 600;
  color: #cbd5e1;
  margin-top: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.next-up-countdown {
  font-size: 0.8rem;
  font-family: "JetBrains Mono", monospace;
  color: var(--primary);
  margin-top: 4px;
  font-weight: 700;
}
.btn-edit-routine {
  display: block;
  margin-top: 8px;
  background: transparent;
  border: 1px solid rgba(131, 138, 248, 0.3);
  color: #818cf8;
  font-size: 0.7rem;
  font-weight: 600;
  padding: 4px 8px;
  border-radius: 6px;
  cursor: pointer;
  text-transform: uppercase;
  transition: all 0.2s;
  text-align: center;
  width: 100%;
}
.btn-edit-routine:hover {
  background: rgba(99, 102, 241, 0.1);
  border-color: var(--primary);
  color: white;
}

/* Routine Editor */
.routine-editor-view {
  display: none;
  grid-column: span 12;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  animation: fadeIn 0.2s ease;
}
.routine-editor-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 14px;
  max-height: 400px;
  overflow-y: auto;
  padding-right: 6px;
  margin-bottom: 20px;
}

.routine-edit-item {
  background: var(--surface-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px;
  transition: all 0.2s;
  cursor: grab;
}
.routine-edit-item:active {
  cursor: grabbing;
}
.routine-edit-item.drag-over {
  border-color: var(--primary);
  background: rgba(99, 102, 241, 0.05);
}

.edit-row-inputs {
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
}
.edit-input {
  background: var(--bg-body);
  border: 1px solid var(--border);
  color: white;
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 0.85rem;
  outline: none;
  width: 100%;
}
.edit-input.time-field {
  width: 100%;
  min-width: 0;
  font-family: "JetBrains Mono", monospace;
  text-align: center;
}
.routine-time-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 8px;
}
.routine-time-col {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.routine-time-label {
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  text-transform: uppercase;
}
.routine-time-controls {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 6px;
  min-width: 0;
}
.time-step-btn {
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.03);
  color: var(--text-dim);
  border-radius: 6px;
  padding: 6px 8px;
  font-size: 0.75rem;
  cursor: pointer;
  min-width: 44px;
  white-space: nowrap;
}
.time-step-btn:hover {
  border-color: var(--primary);
  color: white;
}
.routine-duration-pill {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 4px 10px;
  margin-bottom: 8px;
  font-size: 0.74rem;
  color: var(--text-muted);
}
.routine-add-block-btn {
  grid-column: 1 / -1;
}
.edit-textarea {
  width: 100%;
  height: 50px;
  background: var(--bg-body);
  border: 1px solid var(--border);
  color: var(--text-dim);
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 0.8rem;
  outline: none;
  resize: none;
}
.editor-actions-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-top: 1px solid var(--border);
  padding-top: 16px;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(5px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Buttons & Utilities */
.alarms-card {
  grid-column: span 12;
  display: flex;
  flex-direction: column;
  min-height: 250px;
}

.dashboard-summary-card,
.break-reminder-card {
  grid-column: span 12;
}

.dash-stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
}

.break-timer-display {
  font-family: "JetBrains Mono", monospace;
  font-size: 2.4rem;
  line-height: 1;
  color: var(--accent-green);
  margin: 8px 0 18px;
}

.break-controls-row {
  display: grid;
  grid-template-columns: 90px repeat(3, auto);
  gap: 10px;
  align-items: center;
}

@media (max-width: 767px) {
  .break-controls-row {
    grid-template-columns: 1fr 1fr;
  }
}
.btn-action {
  background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
  color: white;
  border: none;
  padding: 0 24px;
  border-radius: 30px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.btn-outline {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-main);
  padding: 8px 16px;
  border-radius: var(--radius-md);
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  font-size: 0.85rem;
}
.btn-outline:hover {
  background: rgba(255, 255, 255, 0.05);
}

.chart-container {
  position: relative;
  height: 250px;
  width: 100%;
}

.alarm-list-wrapper {
  flex: 1;
  overflow-y: auto;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 12px;
  align-content: flex-start;
}
.alarm-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 14px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.01);
  border-radius: var(--radius-md);
}
.alarm-item.disabled {
  opacity: 0.4;
}
.alarm-item.ringing {
  animation: pulse-red-border 1s infinite alternate;
  background: rgba(239, 68, 68, 0.1) !important;
}
@keyframes pulse-red-border {
  0% {
    border-color: var(--border);
  }
  100% {
    border-color: var(--accent-red);
  }
}
.alarm-time {
  font-size: 1.2rem;
  font-weight: 700;
  display: flex;
  align-items: baseline;
  gap: 6px;
}
.alarm-label {
  font-size: 0.8rem;
  color: var(--text-dim);
  margin-top: 1px;
}
.btn-text {
  border: none;
  background: none;
  color: #818cf8;
  font-weight: 600;
  cursor: pointer;
}

#study-group-view .btn-text,
#study-group-view .btn-outline,
#study-group-view .btn-action {
  min-width: 0;
  white-space: normal;
}

.sync-toolbox {
  margin-top: 18px;
  border-top: 1px solid var(--border);
  padding-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.sync-control-row {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.sync-control-row > .edit-input,
.sync-control-row > input[type="file"],
.sync-control-row > select {
  flex: 1 1 180px;
  min-width: 0;
}

.sync-control-row > .btn-action,
.sync-control-row > .btn-outline,
.sync-control-row > .btn-text {
  flex: 0 0 auto;
  max-width: 100%;
}

.sync-control-row--single {
  justify-content: flex-start;
}

.sync-operatives-panel {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 4px;
}

.sync-operatives-meta {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.sync-operatives-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-top: 2px;
}

.sync-groups-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.sync-workbench-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.02);
}

.sync-workbench-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.sync-workbench-row,
.sync-workbench-card-mini {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.02);
}

.sync-workbench-card-mini {
  display: block;
}

.sync-operative-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.02);
  min-width: 0;
}

.sync-operative-row > .sync-operative-meta {
  flex: 1 1 auto;
  padding-top: 1px;
}

.sync-operative-button {
  width: 100%;
  text-align: left;
  cursor: pointer;
}

.sync-operative-button:disabled {
  opacity: 0.9;
  cursor: default;
}

.sync-operative-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent-green);
  box-shadow: 0 0 10px rgba(16, 185, 129, 0.65);
  flex-shrink: 0;
}

.sync-operative-meta {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.sync-operative-meta strong {
  color: var(--text-main);
  font-size: 0.92rem;
  font-weight: 700;
  overflow-wrap: anywhere;
  line-height: 1.2;
}

.sync-operative-meta span {
  color: var(--text-dim);
  font-size: 0.76rem;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.sync-operatives-empty {
  color: var(--text-muted);
  font-size: 0.85rem;
  padding: 8px 0;
}

#friends-detail-panel {
  position: relative;
  min-height: 0;
  background:
    radial-gradient(circle at top left, rgba(99, 102, 241, 0.1), transparent 34%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.02), transparent 42%);
}

#friends-detail-panel[data-sync-chamber-embedded="1"] {
  padding: 0 !important;
  gap: 0 !important;
}

#friends-detail-panel[data-sync-chamber-embedded="1"] > .dashboard-grid {
  margin-top: 0;
  align-content: start;
}

#friends-detail-panel > .dashboard-grid {
  width: 100%;
  flex: 1 1 auto;
  min-height: 0;
  align-items: stretch;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 18px;
}

#friends-detail-panel .study-chat-card,
#friends-detail-panel .study-sidebar-card {
  height: auto !important;
  min-height: clamp(620px, 76vh, 920px);
  border-radius: 28px;
  border-color: rgba(99, 102, 241, 0.18);
  background: linear-gradient(180deg, rgba(17, 24, 39, 0.92), rgba(11, 15, 25, 0.96));
}

#friends-detail-panel .study-chat-card {
  grid-column: span 8 !important;
  box-shadow:
    0 24px 80px rgba(0, 0, 0, 0.35),
    inset 0 1px 0 rgba(255, 255, 255, 0.03);
}

#friends-detail-panel .study-sidebar-card {
  grid-column: span 4 !important;
  position: sticky;
  top: 0;
  box-shadow:
    0 24px 80px rgba(0, 0, 0, 0.28),
    inset 0 1px 0 rgba(255, 255, 255, 0.03);
}

#friends-detail-panel .ai-chat-container {
  min-height: clamp(360px, 52vh, 620px);
  border-radius: 20px;
  background:
    radial-gradient(circle at top, rgba(99, 102, 241, 0.08), transparent 32%),
    rgba(5, 7, 15, 0.72);
}

#friends-detail-panel .study-sidebar-scroll {
  flex: 1;
  min-height: 0;
}

#friends-detail-panel .sync-toolbox,
#friends-detail-panel .sync-workbench-section {
  border-color: rgba(148, 163, 184, 0.14);
  background: rgba(255, 255, 255, 0.025);
  backdrop-filter: blur(8px);
}

#friends-detail-panel .sync-workbench-section {
  padding: 14px;
  border-radius: 18px;
}

#friends-detail-panel .sync-workbench-row,
#friends-detail-panel .sync-workbench-card-mini {
  border-color: rgba(148, 163, 184, 0.16);
  background: rgba(255, 255, 255, 0.03);
}

#friends-detail-panel .sync-workbench-row {
  align-items: flex-start;
}

#friends-detail-panel .sync-workbench-card-mini {
  padding: 12px 14px;
}

#friends-detail-panel .sync-control-row {
  align-items: stretch;
}

#friends-detail-panel .sync-control-row > * {
  min-height: 40px;
}

#friends-detail-panel .sync-operatives-empty {
  padding: 12px 14px;
  border: 1px dashed rgba(148, 163, 184, 0.14);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.02);
  color: var(--text-dim);
}

.study-chat-card,
.study-sidebar-card {
  min-width: 0;
  min-height: 0;
}

.study-chat-card,
.study-sidebar-card {
  overflow: hidden;
}

.study-sidebar-card {
  display: flex;
  flex-direction: column;
}

.study-sidebar-scroll {
  display: flex;
  flex-direction: column;
  gap: 12px;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding-right: 4px;
  margin-top: 2px;
}

.sync-scroll-hint {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin: -4px 0 2px;
  padding: 0 2px;
  color: var(--text-muted);
  font-size: 0.72rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  opacity: 0.95;
}

.sync-scroll-hint span:last-child {
  color: var(--primary);
  font-size: 1rem;
  animation: syncScrollPulse 1.8s ease-in-out infinite;
}

@keyframes syncScrollPulse {
  0%,
  100% {
    transform: translateY(0);
    opacity: 0.6;
  }
  50% {
    transform: translateY(3px);
    opacity: 1;
  }
}

.btn-delete {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  margin-left: 10px;
  transition: color 0.2s;
}
.btn-delete:hover {
  color: var(--accent-red);
}

/* Toggles */
.toggle {
  position: relative;
  display: inline-block;
  width: 40px;
  height: 22px;
}
.toggle input {
  opacity: 0;
  width: 0;
  height: 0;
}
.slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #1e293b;
  transition: 0.3s;
  border-radius: 34px;
}
.slider:before {
  position: absolute;
  content: "";
  height: 14px;
  width: 14px;
  left: 4px;
  bottom: 4px;
  background-color: #94a3b8;
  transition: 0.3s;
  border-radius: 50%;
}
input:checked + .slider {
  background-color: var(--primary);
}
input:checked + .slider:before {
  transform: translateX(18px);
  background-color: white;
}

/* Calendar & Tasks Matrix */
.calendar-view-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
  align-items: start;
}

@media (min-width: 1024px) {
  .calendar-view-grid {
    grid-template-columns: 7fr 5fr;
    gap: 24px;
  }
}

/* Flashcard Grid */
.flashcard-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 20px;
}

@media (min-width: 1024px) {
  .flashcard-grid {
    grid-template-columns: 1fr 2fr;
  }
}
.days-header-row,
.dates-matrix-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 8px;
}
.dates-matrix-grid {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.days-header-row div {
  text-align: center;
  font-weight: 600;
  color: var(--text-muted);
  font-size: 0.75rem;
  text-transform: uppercase;
  padding: 4px 0;
}
.calendar-day-node {
  background: var(--surface-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  min-height: 80px;
  padding: 12px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}
.calendar-day-node:hover {
  background: #161f33;
  border-color: #3b82f6;
}
.calendar-day-node.active-selected {
  border-color: var(--secondary);
  background: rgba(168, 85, 247, 0.05);
}
.calendar-day-node.current-today {
  border-color: var(--primary);
  background: rgba(99, 102, 241, 0.05);
}
.day-num-lbl {
  font-size: 0.9rem;
  font-weight: 700;
}
.task-indicator-dot {
  width: 6px;
  height: 6px;
  background: var(--accent-green);
  border-radius: 50%;
  align-self: flex-end;
  box-shadow: 0 0 6px var(--accent-green);
}

@media (max-width: 1023px) {
  .days-header-row,
  .dates-matrix-grid {
    gap: 6px;
  }
  .calendar-day-node {
    min-height: 64px;
    padding: 10px;
  }
  .day-num-lbl {
    font-size: 0.85rem;
  }
}

.command-palette {
  position: fixed;
  inset: 0;
  z-index: 80;
  background: rgba(2, 6, 23, 0.72);
  display: none;
  align-items: flex-start;
  justify-content: center;
  padding-top: 12vh;
}
.command-palette-panel {
  width: min(720px, calc(100vw - 32px));
  background: #0b1120;
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: 0 28px 80px rgba(0, 0, 0, 0.45);
  padding: 14px;
}
.command-palette-input {
  width: 100%;
  border: 1px solid var(--border);
  background: var(--bg-body);
  color: white;
  border-radius: 14px;
  padding: 14px 16px;
  font-size: 1rem;
  outline: none;
}
.command-palette-results {
  margin-top: 12px;
  display: grid;
  gap: 8px;
  max-height: 48vh;
  overflow-y: auto;
}
.command-item {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.02);
  color: white;
  text-align: left;
}
.command-item:hover {
  border-color: var(--primary);
  background: rgba(99, 102, 241, 0.08);
}
.command-item-title {
  font-weight: 600;
}
.command-item-hint {
  color: var(--text-muted);
  font-size: 0.8rem;
  margin-top: 2px;
}
.command-item-key {
  color: var(--primary);
  font-size: 0.75rem;
}

.insights-grid {
  display: grid;
  grid-template-columns: 1.2fr 1fr 0.9fr;
  gap: 16px;
}
.insight-block {
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px;
  background: rgba(255, 255, 255, 0.02);
  min-height: 180px;
}
.insight-label {
  font-size: 0.8rem;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: 0.08em;
  margin-bottom: 10px;
}
.heatmap-grid {
  display: grid;
  grid-template-columns: repeat(12, minmax(12px, 1fr));
  gap: 6px;
}
.heatmap-cell {
  aspect-ratio: 1 / 1;
  border-radius: 4px;
  border: 1px solid rgba(255, 255, 255, 0.08);
}
.heat-level-0 { background: rgba(255,255,255,0.03); }
.heat-level-1 { background: rgba(99,102,241,0.22); }
.heat-level-2 { background: rgba(99,102,241,0.42); }
.heat-level-3 { background: rgba(16,185,129,0.55); }
.heat-level-4 { background: rgba(16,185,129,0.8); }
.achievement-list,
.focus-session-log {
  display: grid;
  gap: 8px;
}
.achievement-pill {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.02);
}
.achievement-icon {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: rgba(99, 102, 241, 0.16);
  color: #c7d2fe;
  font-weight: 700;
}
.achievement-title { font-weight: 600; }
.achievement-desc,
.focus-session-row,
.kanban-task-meta {
  font-size: 0.78rem;
  color: var(--text-muted);
}
.assistant-markdown {
  display: grid;
  gap: 8px;
  line-height: 1.45;
}
.assistant-markdown h2,
.assistant-markdown h3,
.assistant-markdown h4 {
  margin: 0;
  color: var(--text);
  line-height: 1.15;
}
.assistant-markdown h2 { font-size: 1.1rem; }
.assistant-markdown h3 { font-size: 1rem; }
.assistant-markdown h4 { font-size: 0.95rem; }
.assistant-markdown p {
  margin: 0;
}
.assistant-markdown ul {
  margin: 0;
  padding-left: 18px;
  display: grid;
  gap: 4px;
}
.assistant-markdown li {
  margin: 0;
}
.assistant-markdown code {
  padding: 1px 5px;
  border-radius: 6px;
  background: rgba(99, 102, 241, 0.12);
  color: var(--text);
}
.focus-session-row {
  display: flex;
  justify-content: space-between;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.02);
}

.kanban-board-toolbar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
.kanban-board {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

@media (max-width: 1023px) {
  .kanban-board {
    grid-template-columns: 1fr;
  }
}
.kanban-column {
  border: 1px solid var(--border);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.02);
  padding: 12px;
  min-height: 220px;
}
.kanban-column-head {
  display: flex;
  justify-content: space-between;
  color: #cbd5e1;
  font-weight: 600;
  margin-bottom: 10px;
}
.kanban-column-body {
  display: grid;
  gap: 10px;
}
.kanban-card-item {
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.03);
  border-radius: 12px;
  padding: 10px;
  cursor: grab;
}
.kanban-task-title {
  font-weight: 600;
  margin-bottom: 4px;
}
.kanban-task-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 8px;
}
.kanban-task-actions .btn-text {
  padding: 0;
  font-size: 0.75rem;
}

/* Integrated Task Workflow */
.todo-selected-date-title {
  font-size: 1rem;
  font-weight: 700;
  color: #cbd5e1;
}
.progress-box {
  margin: 12px 0;
}
.progress-bar-track {
  width: 100%;
  height: 6px;
  background: #1e293b;
  border-radius: 20px;
  overflow: hidden;
  margin-top: 4px;
}
.progress-fill-bar {
  height: 100%;
  width: 0%;
  background: var(--accent-green);
  transition: width 0.3s;
}
.streak-box {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px;
  margin: 16px 0;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}
.streak-label {
  font-size: 0.85rem;
  color: var(--text-dim);
}
.streak-value {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--accent-green);
}

/* Curriculum Controls */
.curriculum-controls {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 16px;
}
.curriculum-select-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}
.curriculum-select {
  flex: 1;
  min-width: 140px;
  background: var(--bg-body);
  border: 1px solid var(--border);
  color: white;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  outline: none;
  font-size: 0.9rem;
}
.curriculum-select.full-width {
  flex: 1 1 100%;
}
.btn-randomize {
  width: 100%;
  justify-content: center;
  background: rgba(99, 102, 241, 0.12);
  color: #c7d2fe;
  border: 1px solid rgba(99, 102, 241, 0.35);
  transition: all 0.2s;
  padding: 10px;
  border-radius: var(--radius-md);
  cursor: pointer;
  font-weight: 600;
}
.btn-randomize:hover {
  background: rgba(99, 102, 241, 0.18);
}

/* Advanced Todo Form */
.todo-advanced-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  margin-bottom: 16px;
  background: rgba(0, 0, 0, 0.2);
  padding: 16px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
}

@media (min-width: 640px) {
  .todo-advanced-grid {
    grid-template-columns: 1fr 1fr;
  }
}
.todo-input-full {
  grid-column: span 1;
}

@media (min-width: 640px) {
  .todo-input-full {
    grid-column: span 2;
  }
}
.todo-text-field {
  padding: 10px 14px;
  background: var(--bg-body);
  border: 1px solid var(--border);
  color: white;
  border-radius: var(--radius-md);
  outline: none;
  font-size: 0.85rem;
  width: 100%;
}
.btn-add-todo {
  grid-column: span 1;
  background: linear-gradient(135deg, #10b981, #059669);
  color: white;
  border: none;
  padding: 10px;
  border-radius: var(--radius-md);
  font-weight: 700;
  cursor: pointer;
  transition: 0.2s;
}

@media (min-width: 640px) {
  .btn-add-todo {
    grid-column: span 2;
  }
}

.todo-list-element {
  list-style: none;
  max-height: 220px;
  overflow-y: auto;
}
.todo-item-node {
  background: rgba(255, 255, 255, 0.01);
  border: 1px solid var(--border);
  padding: 12px;
  border-radius: var(--radius-md);
  margin-bottom: 10px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}
.todo-item-left {
  display: flex;
  gap: 12px;
  font-size: 0.9rem;
  align-items: flex-start;
  flex: 1;
}
.todo-checkbox {
  width: 16px;
  height: 16px;
  accent-color: var(--primary);
  margin-top: 3px;
  cursor: pointer;
}
.todo-content-stack {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.todo-text.completed {
  text-decoration: line-through;
  opacity: 0.4;
}
.task-badges-row {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.task-badge {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  padding: 3px 8px;
  border-radius: 20px;
  border: 1px solid transparent;
}

.badge-math {
  background: rgba(99, 102, 241, 0.15);
  color: #818cf8;
  border-color: rgba(99, 102, 241, 0.3);
}
.badge-physics {
  background: rgba(168, 85, 247, 0.15);
  color: #d8b4fe;
  border-color: rgba(168, 85, 247, 0.3);
}
.badge-science {
  background: rgba(16, 185, 129, 0.15);
  color: #6ee7b7;
  border-color: rgba(16, 185, 129, 0.3);
}
.badge-coding {
  background: rgba(16, 185, 129, 0.15);
  color: #6ee7b7;
  border-color: rgba(16, 185, 129, 0.3);
}
.badge-english {
  background: rgba(236, 72, 153, 0.15);
  color: #f472b6;
  border-color: rgba(236, 72, 153, 0.3);
}
.badge-general {
  background: rgba(148, 163, 184, 0.15);
  color: #cbd5e1;
  border-color: rgba(148, 163, 184, 0.3);
}
.badge-priority-high {
  background: rgba(239, 68, 68, 0.15);
  color: #fca5a5;
  border-color: rgba(239, 68, 68, 0.3);
}
.badge-time {
  background: rgba(245, 158, 11, 0.15);
  color: #fcd34d;
  border-color: rgba(245, 158, 11, 0.3);
}

/* Stats */
.stats-grid-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  margin-top: 12px;
}

@media (min-width: 640px) {
  .stats-grid-row {
    grid-template-columns: 1fr 1fr;
  }
}
.stat-mini-card {
  background: rgba(255, 255, 255, 0.01);
  border: 1px solid var(--border);
  padding: 16px;
  border-radius: var(--radius-md);
  text-align: center;
  flex: 1;
}
.stat-mini-card h4 {
  font-size: 0.8rem;
  color: var(--text-muted);
  text-transform: uppercase;
  margin-bottom: 8px;
}
.stat-mini-card p {
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--primary);
}

.analytics-shell {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.analytics-hero-card {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.analytics-hero-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
  flex-wrap: wrap;
}

.analytics-kicker {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--secondary);
  margin-bottom: 6px;
}

.analytics-hero-title {
  font-size: clamp(1.1rem, 2vw, 1.55rem);
  font-weight: 700;
  color: var(--text-main);
  line-height: 1.15;
}

.analytics-hero-subtitle {
  margin-top: 6px;
  color: var(--text-muted);
  font-size: 0.88rem;
  line-height: 1.5;
  max-width: 72ch;
}

.analytics-live-chip {
  align-self: flex-start;
  padding: 8px 12px;
  border-radius: 999px;
  border: 1px solid rgba(99, 102, 241, 0.25);
  background: rgba(99, 102, 241, 0.12);
  color: #c7d2fe;
  font-size: 0.78rem;
  white-space: nowrap;
}

.analytics-summary-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

@media (min-width: 768px) {
  .analytics-summary-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (min-width: 1280px) {
  .analytics-summary-grid {
    grid-template-columns: repeat(6, minmax(0, 1fr));
  }
}

.analytics-mini-card {
  text-align: left;
  min-width: 0;
}

.analytics-mini-card p {
  text-align: left;
}

.analytics-mini-subtext {
  margin-top: 6px;
  color: var(--text-muted);
  font-size: 0.78rem;
  line-height: 1.35;
}

.analytics-tab-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding-top: 4px;
}

.analytics-tab-btn {
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.02);
  color: var(--text-dim);
  padding: 9px 14px;
  border-radius: 999px;
  font-weight: 600;
  cursor: pointer;
  transition:
    background 0.15s,
    border-color 0.15s,
    color 0.15s,
    transform 0.15s;
}

.analytics-tab-btn:hover {
  transform: translateY(-1px);
  border-color: rgba(99, 102, 241, 0.4);
  color: var(--text-main);
}

.analytics-tab-btn.active {
  background: rgba(99, 102, 241, 0.16);
  border-color: rgba(99, 102, 241, 0.5);
  color: #e0e7ff;
}

.analytics-panel-card {
  min-width: 0;
}

.analytics-panel-note {
  color: var(--text-muted);
  font-size: 0.78rem;
}

.analytics-panel-card--wide {
  grid-column: 1 / -1;
}

.analytics-tab-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}

@media (min-width: 1100px) {
  .analytics-tab-grid--two {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .analytics-tab-grid--two .analytics-panel-card--wide {
    grid-column: 1 / -1;
  }
}

.analytics-list,
.analytics-progress-list,
.analytics-achievement-list {
  display: grid;
  gap: 10px;
}

.analytics-list-row,
.analytics-progress-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.02);
}

.analytics-list-main {
  min-width: 0;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.analytics-list-main strong {
  font-size: 0.92rem;
  color: var(--text-main);
}

.analytics-list-main span {
  color: var(--text-muted);
  font-size: 0.8rem;
  line-height: 1.35;
}

.analytics-list-side {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.analytics-score-chip {
  flex-shrink: 0;
  min-width: 34px;
  padding: 6px 10px;
  border-radius: 999px;
  text-align: center;
  background: rgba(99, 102, 241, 0.16);
  border: 1px solid rgba(99, 102, 241, 0.26);
  color: #c7d2fe;
  font-size: 0.76rem;
  font-weight: 700;
}

.analytics-check {
  color: var(--accent-green);
  font-size: 0.76rem;
  font-weight: 700;
}

.analytics-progress-copy {
  min-width: 0;
  flex: 0 0 42%;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.analytics-progress-copy strong {
  font-size: 0.9rem;
  color: var(--text-main);
}

.analytics-progress-copy span {
  color: var(--text-muted);
  font-size: 0.78rem;
}

.analytics-progress-track {
  flex: 1;
  height: 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.05);
  overflow: hidden;
}

.analytics-progress-fill {
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--primary), var(--secondary));
}

.analytics-progress-value {
  flex-shrink: 0;
  color: var(--text-dim);
  font-size: 0.78rem;
  font-weight: 600;
  min-width: 34px;
  text-align: right;
}

.analytics-empty-state {
  color: var(--text-muted);
  font-size: 0.85rem;
  padding: 10px 0;
}

@media (max-width: 767px) {
  .analytics-list-row,
  .analytics-progress-row {
    flex-direction: column;
    align-items: stretch;
  }

  .analytics-progress-copy,
  .analytics-progress-value,
  .analytics-list-side {
    width: 100%;
  }

  .analytics-progress-value {
    text-align: left;
  }
}

/* Settings View Layout */
.settings-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 24px;
}

@media (min-width: 768px) {
  .settings-grid {
    grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
  }
}
.settings-section {
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.settings-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}
.settings-row:last-child {
  border-bottom: none;
  padding-bottom: 0;
}
.settings-label {
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--text-main);
}
.settings-subtext {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 4px;
  line-height: 1.4;
}

/* Banner Overlays */
.alert-banner {
  display: none;
  position: fixed;
  top: 16px;
  left: 16px;
  right: 16px;
  transform: none;
  color: white;
  padding: 12px 16px;
  border-radius: 50px;
  z-index: 1000;
  font-weight: 600;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.4);
  align-items: center;
  gap: 20px;
  animation: bounceIn 0.3s;
  font-size: 0.9rem;
}

@media (min-width: 768px) {
  .alert-banner {
    top: 24px;
    left: 50%;
    right: auto;
    transform: translateX(-50%);
    padding: 16px 32px;
    font-size: 1rem;
    animation: bounceInCentered 0.3s;
  }
}
.alert-critical {
  background: var(--accent-red);
}
.alert-success {
  background: linear-gradient(135deg, var(--secondary), var(--primary));
}
@keyframes bounceIn {
  0% {
    transform: translateY(-60px);
    opacity: 0;
  }
  100% {
    transform: translateY(0);
    opacity: 1;
  }
}

@keyframes bounceInCentered {
  0% {
    transform: translate(-50%, -60px);
    opacity: 0;
  }
  100% {
    transform: translate(-50%, 0);
    opacity: 1;
  }
}
.btn-dismiss-alert {
  background: white;
  color: #000;
  border: none;
  padding: 6px 16px;
  border-radius: 20px;
  font-weight: 700;
  cursor: pointer;
}

.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  z-index: 100;
  justify-content: center;
  align-items: center;
}
.modal-content {
  background: var(--surface-card);
  border: 1px solid var(--border);
  padding: 20px;
  border-radius: var(--radius-lg);
  width: 90%;
  max-width: 320px;
}

@media (min-width: 640px) {
  .modal-content {
    padding: 24px;
    width: 320px;
  }
}
.modal-content input {
  width: 100%;
  padding: 10px;
  margin-bottom: 12px;
  background: var(--bg-body);
  border: 1px solid var(--border);
  color: white;
  border-radius: var(--radius-md);
  outline: none;
}

@media (max-width: 767px) {
  .nav-group {
    flex-direction: row;
    flex-wrap: nowrap;
    gap: 4px;
  }
  .nav-link {
    flex: 0 0 auto;
    justify-content: center;
    font-size: 0.72rem;
    padding: 6px 10px;
    min-height: 36px;
    white-space: nowrap;
    margin: 0;
    border-radius: 20px;
    touch-action: manipulation;
    gap: 6px;
  }
  .nav-link.active {
    border-left: none;
    border-bottom: none;
    border-radius: 20px;
    padding-left: 10px;
    background: rgba(99, 102, 241, 0.2);
    color: #c7d2fe;
  }
  .aod-time-block {
    border-right: none;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    padding-bottom: 12px;
    padding-right: 0;
  }
  .sketch-dashboard-grid {
    grid-template-columns: 1fr;
    height: auto;
  }
  /* Larger tap targets for interactive elements */
  .btn-action,
  .btn-outline,
  .btn-add-todo,
  .btn-randomize,
  .tool-btn,
  .tool-btn-action,
  .tool-btn-primary,
  .tool-btn-secondary {
    min-height: 44px;
    touch-action: manipulation;
  }
  /* Prevent zoom on input focus */
  input[type="text"],
  input[type="number"],
  input[type="time"],
  input[type="color"],
  select,
  textarea {
    font-size: 16px !important;
  }
  /* Canvas height on small screens */
  #canvas-wrapper {
    height: 280px;
  }
  /* Pomodoro timer slightly smaller on very small screens */
  .pomodoro-display {
    font-size: 2rem;
  }
  /* Flashcard */
  .flip-card {
    height: min(220px, 40vh);
    font-size: 1rem;
  }
  .flip-card-front,
  .flip-card-back {
    font-size: 1rem;
    padding: 16px;
  }
  /* Study controls stack vertically */
  .study-controls {
    flex-direction: column;
    gap: 10px;
    width: 100%;
  }
  .study-controls button {
    width: 100%;
    min-height: 44px;
  }
  .routine-time-grid {
    grid-template-columns: 1fr;
  }
  .insights-grid,
  .kanban-board {
    grid-template-columns: 1fr;
  }
  /* Toolbar wraps cleanly */
  .sketch-toolbar {
    gap: 8px;
    padding: 8px;
  }
  .toolbar-group:not(:last-child)::after {
    display: none;
  }
  /* Calendar day cells smaller */
  .calendar-day-node {
    min-height: 56px;
    padding: 8px 6px;
  }
  .day-num-lbl {
    font-size: 0.8rem;
  }
}
#canvas-wrapper {
  width: 100%;
  height: 350px;
  background: #05070f;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  position: relative;
  overflow: hidden;
  cursor: crosshair;
}

@media (min-width: 768px) {
  #canvas-wrapper {
    height: 600px;
  }
}

/* Ensure the canvas fills the wrapper exactly */
#canvas-wrapper canvas {
  display: block;
  width: 100%;
  height: 100%;
}

/* Sketchpad layout containers (scoped so dashboard pages are unaffected) */
.sketch-dashboard-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 20px;
  height: auto;
}

@media (min-width: 768px) {
  .sketch-dashboard-grid {
    grid-template-columns: 260px 1fr;
    height: 600px;
  }
}

.sketch-sidebar {
  background: var(--surface-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* Fix sidebar button spacing */
#sketches-list-container {
  flex-grow: 1;
  overflow-y: auto;
}

.sketch-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--bg-body);
  padding: 8px 12px;
  border-radius: 8px;
  margin-bottom: 8px;
  font-size: 14px;
}

/* Canvas styling */
.sketch-canvas-container {
  background: #05070f;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
}

#drawing-view .card-header {
  background: var(--surface-card);
  padding: 12px;
  border-bottom: 1px solid var(--border);
  display: flex;
  gap: 8px;
  align-items: center;
}
/* Premium Sketchpad Dashboard Suite Overhaul */
.drawing-view-container {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
  gap: 12px;
}

.sketch-toolbar {
  background: var(--surface-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  overflow-x: auto;
}

@media (min-width: 768px) {
  .sketch-toolbar {
    gap: 16px;
    padding: 10px 16px;
  }
}
.container {
  display: flex;       /* Required to make alignment work */
  align-items: center; /* Valid property inside the block */
  gap: 20px;
}

.toolbar-group {
  display: flex;
  align-items: center;
  gap: 8px;
  position: relative;
}

.toolbar-group:not(:last-child)::after {
  content: "";
  position: absolute;
  right: -10px;
  top: 20%;
  height: 60%;
  width: 1px;
  background: var(--border);
}

.layout-right {
  margin-left: auto;
}

.layout-right::after {
  display: none !important;
}

.group-label {
  font-size: 0.72rem;
  text-transform: uppercase;
  color: var(--text-dim);
  font-weight: 700;
  letter-spacing: 0.05em;
  margin-right: 4px;
}

.tool-btn,
.tool-btn-action,
.toolbar-select {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-main);
  padding: 6px 12px;
  font-size: 0.85rem;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.tool-btn:hover,
.tool-btn-action:hover,
.toolbar-select:hover {
  border-color: var(--primary);
  background: rgba(99, 102, 241, 0.08);
}

.tool-btn.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #ffffff;
  box-shadow: 0 0 12px var(--primary-glow);
}

.tool-btn-primary {
  background: var(--primary);
  color: #ffffff;
  border: none;
  padding: 7px 14px;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: transform 0.15s ease;
}

.tool-btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 0 14px var(--primary-glow);
}

.tool-btn-secondary {
  background: var(--secondary);
  color: #ffffff;
  border: none;
  padding: 7px 14px;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
}

.tool-btn-action.danger:hover {
  background: rgba(239, 68, 110, 0.15);
  border-color: var(--accent-red);
  color: var(--accent-red);
}

/* Color & Slider Precision Wrappers */
.picker-wrapper,
.slider-wrapper {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8rem;
  color: var(--text-dim);
}

.picker-wrapper input[type="color"] {
  appearance: none;
  -webkit-appearance: none;
  border: none;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  cursor: pointer;
  background: none;
}

.picker-wrapper input[type="color"]::-webkit-color-swatch-wrapper {
  padding: 0;
}

.picker-wrapper input[type="color"]::-webkit-color-swatch {
  border: 1px solid var(--border);
  border-radius: 50%;
}

.checkbox-inline {
  display: flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  font-size: 0.78rem;
}

.slider-wrapper input[type="range"] {
  accent-color: var(--primary);
  cursor: pointer;
  width: 80px;
}

/* Workspace Canvas Overwrites */
#canvas-wrapper {
  flex-grow: 1;
  width: 100%;
  height: 620px;
  background: #05070f;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  position: relative;
  overflow: hidden;
  box-shadow: inset 0 4px 20px rgba(0, 0, 0, 0.4);
}
/* Calendar Task Base Styles */
.calendar-task {
  padding: 12px;
  margin-bottom: 8px;
  border-radius: 8px;
  background-color: #1e1e24; /* Adjust to your dark theme */
  border-left: 4px solid transparent;
  transition: all 0.2s ease-in-out;
}

/* Urgency Color Coding */
.task-overdue {
  border-left-color: #ff4757;
} /* Bright Red */
.task-overdue .task-badge {
  background-color: rgba(255, 71, 87, 0.2);
  color: #ff4757;
}

.task-today {
  border-left-color: #ffa502;
} /* Orange */
.task-today .task-badge {
  background-color: rgba(255, 165, 2, 0.2);
  color: #ffa502;
}

.task-urgent {
  border-left-color: #eccc68;
} /* Yellow */
.task-urgent .task-badge {
  background-color: rgba(236, 204, 104, 0.2);
  color: #eccc68;
}

.task-upcoming {
  border-left-color: #2ed573;
} /* Green */
.task-upcoming .task-badge {
  background-color: rgba(46, 213, 115, 0.2);
  color: #2ed573;
}

/* Typography Formatting */
.task-header {
  display: flex;
  justify-content: space-between;
  font-size: 0.8em;
  margin-bottom: 4px;
}
.task-badge {
  padding: 2px 6px;
  border-radius: 4px;
  font-weight: bold;
  text-transform: uppercase;
}
.task-title {
  font-size: 1.1em;
  font-weight: bold;
  color: #ffffff;
}
.task-date {
  font-size: 0.8em;
  color: #888888;
  margin-top: 4px;
}
/* ==========================================================================
   FLASHCARD FLIP ENGINE
========================================================================== */
.study-modal-bg {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(5, 7, 15, 0.95);
  backdrop-filter: blur(10px);
  z-index: 3000;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 20px;
  padding-bottom: max(20px, env(safe-area-inset-bottom));
}

.study-controls {
  display: flex;
  gap: 16px;
  margin-top: 20px;
}

.flip-card {
  background-color: transparent;
  width: 100%;
  height: 250px;
  perspective: 800px;
  cursor: pointer;
  /* Isolate the 3D context so it doesn't bleed into page stacking */
  transform: translateZ(0);
}

.flip-card-inner {
  position: relative;
  width: 100%;
  height: 100%;
  text-align: center;
  transition: transform 0.6s cubic-bezier(0.4, 0.2, 0.2, 1);
  transform-style: preserve-3d;
  /* Fix blurry text during animation on webkit */
  -webkit-transform-style: preserve-3d;
}

.flip-card.is-flipped .flip-card-inner {
  transform: rotateY(180deg);
  -webkit-transform: rotateY(180deg);
}

.flip-card-front, .flip-card-back {
  position: absolute;
  width: 100%;
  height: 100%;
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  background: var(--surface-card);
  font-size: 1.25rem;
  box-shadow: 0 10px 30px rgba(0,0,0,0.5);
  /* Prevent text selection during swipe/tap */
  user-select: none;
  -webkit-user-select: none;
}

.flip-card-front {
  color: var(--text-main);
}

.flip-card-back {
  color: var(--accent-green);
  transform: rotateY(180deg);
  -webkit-transform: rotateY(180deg);
  border-color: rgba(16, 185, 129, 0.3);
  background: rgba(16, 185, 129, 0.05);
}
/* ======================================================
   NEW FEATURES: Dashboard stats, Break Reminder, Notes
   ====================================================== */

/* Notes view responsive layout */
#notes-view > div:not(.header) {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 16px;
  height: 620px;
}

@media (max-width: 767px) {
  #notes-view > div:not(.header) {
    grid-template-columns: 1fr;
    height: auto;
  }
  .dash-stat-pill {
    min-width: 100px;
  }
}
      mjx-container[display="true"] {
        overflow-x: auto;
        overflow-y: hidden;
        max-width: 100%;
        padding: 0.5rem 0;
      }

      /* Dashboard stat pills */
      .dash-stat-pill {
        display: flex; align-items: center; gap: 12px;
        background: rgba(255,255,255,0.02);
        border: 1px solid var(--border);
        border-radius: var(--radius-md);
        padding: 12px 16px;
        min-width: 120px;
        flex: 1;
      }
      .dash-stat-icon {
        width: 36px; height: 36px; border-radius: 10px;
        background: rgba(99,102,241,0.12);
        display: flex; align-items: center; justify-content: center;
        font-size: 1rem; flex-shrink: 0;
        color: var(--primary);
      }
      .dash-stat-num {
        font-size: 1.6rem; font-weight: 700; line-height: 1;
        color: var(--text-main);
        font-family: 'JetBrains Mono', monospace;
      }
      .dash-stat-label {
        font-size: 0.7rem; color: var(--text-muted);
        text-transform: uppercase; letter-spacing: 0.05em; margin-top: 3px;
      }
      .dash-task-row {
        display: flex; align-items: center; gap: 10px;
        padding: 10px 12px;
        border-radius: var(--radius-md);
        border: 1px solid var(--border);
        background: rgba(255,255,255,0.01);
        transition: background 0.15s;
      }
      .dash-task-row:hover { background: rgba(255,255,255,0.03); }
      .dash-task-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink:0; }

      /* Notes improvements */
      .notes-filter-btn {
        background: transparent; border: 1px solid var(--border);
        color: var(--text-dim); padding: 4px 10px; border-radius: 20px;
        font-size: 0.72rem; cursor: pointer; transition: all 0.15s;
        font-weight: 600;
      }
      .notes-filter-btn.active, .notes-filter-btn:hover {
        background: rgba(99,102,241,0.15); border-color: var(--primary); color: #c7d2fe;
      }
      .note-list-card {
        padding: 10px 12px; border-radius: var(--radius-md);
        border: 1px solid var(--border); cursor: pointer;
        transition: all 0.15s; background: rgba(255,255,255,0.01);
        position: relative;
      }
      .note-list-card:hover { border-color: rgba(99,102,241,0.4); background: rgba(99,102,241,0.04); }
      .note-list-card.active { border-color: var(--primary); background: rgba(99,102,241,0.08); }
      .note-list-card .note-pin { position: absolute; top: 8px; right: 8px; font-size: 0.7rem; opacity: 0.6; }
      .note-tag-chip {
        background: rgba(99,102,241,0.14); color: #a5b4fc;
        border: 1px solid rgba(99,102,241,0.3); border-radius: 20px;
        padding: 2px 8px; font-size: 0.65rem; font-weight: 600;
        cursor: pointer; display: inline-flex; align-items: center; gap: 4px;
      }
      .note-tag-chip:hover { background: rgba(239,68,68,0.15); border-color: var(--accent-red); color: #fca5a5; }
      .note-fmt-btn {
        background: transparent; border: 1px solid var(--border);
        color: var(--text-dim); padding: 4px 9px; border-radius: 6px;
        font-size: 0.75rem; cursor: pointer; transition: all 0.15s; font-family: 'JetBrains Mono', monospace;
      }
      .note-fmt-btn:hover { border-color: var(--primary); color: var(--text-main); background: rgba(99,102,241,0.08); }

      /* Markdown preview styles */
      #note-preview-pane h1, #note-preview-pane h2, #note-preview-pane h3 { color: var(--text-main); margin: 12px 0 6px; }
      #note-preview-pane h2 { font-size: 1.1rem; border-bottom: 1px solid var(--border); padding-bottom: 4px; }
      #note-preview-pane code { background: rgba(0,0,0,0.3); padding: 1px 5px; border-radius: 4px; font-family: 'JetBrains Mono',monospace; font-size: 0.85em; color: #a5b4fc; }
      #note-preview-pane pre { background: rgba(0,0,0,0.3); padding: 12px; border-radius: 8px; overflow-x: auto; margin: 8px 0; }
      #note-preview-pane pre code { background: none; padding: 0; }
      #note-preview-pane ul, #note-preview-pane ol { padding-left: 20px; margin: 6px 0; }
      #note-preview-pane li { margin: 3px 0; }
      #note-preview-pane hr { border: none; border-top: 1px solid var(--border); margin: 14px 0; }
      #note-preview-pane strong { color: white; }
      #note-preview-pane em { color: #c4b5fd; }
      #note-preview-pane input[type=checkbox] { accent-color: var(--primary); margin-right: 6px; }
      #note-preview-pane blockquote { border-left: 3px solid var(--primary); padding-left: 12px; color: var(--text-dim); margin: 8px 0; }

/* Mobile polish pass */
@media (max-width: 767px) {
  .sidebar::after {
    display: none !important;
    content: none !important;
  }

  body {
    height: auto;
    min-height: 100dvh;
    overflow-y: auto;
    overflow-x: hidden;
  }

  .sidebar {
    position: relative;
    top: auto;
    z-index: 30;
    padding: 10px 10px 8px;
    gap: 8px;
    border-bottom: 1px solid var(--border);
    overflow-x: hidden;
    overflow-y: visible;
    flex-direction: column;
    flex-wrap: nowrap;
    align-items: stretch;
  }

  .logo {
    min-width: max-content;
    padding-left: 2px;
  }

  .logo img {
    width: 30px;
    height: 30px;
    flex: 0 0 30px;
  }

  .logo span {
    font-size: 1.1rem;
  }

  .nav-group {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    align-items: stretch;
    overflow: visible;
    width: 100%;
    padding-bottom: 2px;
  }

  .nav-link {
    width: 100%;
    flex: none;
    min-height: 38px;
    margin-bottom: 0;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: 999px;
    white-space: nowrap;
    font-size: 0.82rem;
    background: rgba(255, 255, 255, 0.02);
    scroll-snap-align: unset;
  }

  .nav-link.active {
    border-left: 1px solid var(--primary);
    border-radius: 999px;
    padding-left: 12px;
  }

  .nav-link[onclick*="study-group-view"] {
    grid-column: 1 / -1;
    font-weight: 700;
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.18), rgba(168, 85, 247, 0.14));
    border-color: rgba(99, 102, 241, 0.4);
  }

  .sidebar-tail {
    display: none;
  }

  .sidebar-widget {
    width: 100%;
    min-width: 0;
    margin-right: 0;
  }

  .main-content {
    padding: 12px;
    overflow: visible;
    min-height: 0;
  }

  #operative-network-shell {
    flex-direction: column !important;
    height: auto !important;
    min-height: calc(100dvh - 120px);
    overflow: visible !important;
  }

  #operative-network-sidebar {
    width: 100% !important;
    min-width: 0 !important;
    border-right: none !important;
    border-bottom: 1px solid var(--border);
  }

  #operative-network-sidebar #friends-sidebar-list {
    max-height: 44vh;
    overflow-y: auto;
  }

  .header {
    margin-bottom: 14px;
  }

  .header h1 {
    font-size: 1.12rem;
  }

  .dashboard-grid {
    gap: 12px;
  }

  .card {
    padding: 14px;
    border-radius: 14px;
  }

  #study-group-view .card-header,
  #friends-detail-panel .card-header {
    flex-wrap: wrap;
    gap: 10px;
    align-items: flex-start;
  }

  #study-group-view .dashboard-grid,
  #friends-detail-panel .dashboard-grid {
    grid-template-columns: 1fr;
  }

  #study-group-view .study-chat-card,
  #study-group-view .study-sidebar-card,
  #friends-detail-panel .study-chat-card,
  #friends-detail-panel .study-sidebar-card {
    grid-column: span 1 !important;
    height: auto !important;
    min-height: 0 !important;
    position: static;
    width: 100%;
  }

  #study-group-view .study-chat-card,
  #friends-detail-panel .study-chat-card {
    min-height: 56vh;
  }

  #study-group-view .study-sidebar-card,
  #friends-detail-panel .study-sidebar-card {
    min-height: auto;
    margin-top: 0;
  }

  #study-group-view .ai-chat-container,
  #friends-detail-panel .ai-chat-container {
    min-height: 200px;
  }

  #study-group-view .ai-input-group,
  #study-group-view .sync-control-row,
  #study-group-view .sync-operatives-meta,
  #friends-detail-panel .sync-control-row,
  #friends-detail-panel .sync-operatives-meta {
    flex-direction: column;
    align-items: stretch;
  }

  #study-group-view .ai-input-group > *,
  #study-group-view .sync-control-row > *,
  #friends-detail-panel .sync-control-row > * {
    width: 100%;
  }

  #study-group-view .sync-control-row .btn-action,
  #study-group-view .sync-control-row .btn-outline,
  #study-group-view .sync-control-row .btn-text,
  #friends-detail-panel .sync-control-row .btn-action,
  #friends-detail-panel .sync-control-row .btn-outline,
  #friends-detail-panel .sync-control-row .btn-text {
    width: 100%;
  }

  #study-group-view .sync-chats-list,
  #sync-chats-list,
  #friends-detail-panel .sync-chats-list {
    max-height: 150px;
  }

  #friends-detail-panel {
    padding: 12px;
  }

  #friends-detail-panel > .dashboard-grid {
    gap: 12px;
  }

  #friends-detail-panel .study-sidebar-scroll {
    padding-right: 0;
    overflow: visible;
  }

  #friends-detail-panel .sync-scroll-hint {
    display: none;
  }

  #friends-detail-panel .sync-chats-list {
    max-height: none;
    overflow: visible;
    padding-right: 0;
    margin-bottom: 10px;
  }

  #friends-detail-panel .sync-workbench-row,
  #friends-detail-panel .sync-workbench-card-mini {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }

  #friends-detail-panel .sync-workbench-row > * {
    width: 100%;
  }

  #friends-detail-panel .study-chat-card {
    min-height: 58vh;
  }

  #friends-detail-panel .study-sidebar-card {
    min-height: auto;
  }

  #friends-detail-panel .ai-chat-container {
    min-height: 220px;
  }

  #friends-detail-panel .sync-workbench-section {
    padding: 12px;
    border-radius: 16px;
  }

  #friends-detail-panel .sync-control-row {
    gap: 8px;
  }

  #friends-detail-panel .sync-toolbox,
  #friends-detail-panel .sync-workbench-section {
    width: 100%;
  }

  #friends-detail-panel .sync-workbench-row,
  #friends-detail-panel .sync-workbench-card-mini {
    border-radius: 14px;
  }

  .card-title {
    font-size: 0.9rem;
  }

  .aod-layout {
    gap: 12px;
  }

  .aod-time-block {
    border-right: none;
    padding-right: 0;
    padding-bottom: 10px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  }

  .aod-clock {
    font-size: clamp(2.3rem, 13vw, 4rem);
  }

  .dash-stats-grid {
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }

  .dash-stat-pill {
    min-height: 64px;
    padding: 10px;
  }

  .break-timer-display {
    font-size: 2rem;
    margin: 6px 0 12px;
  }

  .break-controls-row {
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }

  .break-controls-row > * {
    width: 100%;
  }

  .calendar-view-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .todo-item-node {
    flex-direction: column;
    gap: 8px;
  }

  .todo-item-left {
    width: 100%;
  }

  .settings-grid {
    gap: 12px;
  }

  .settings-row {
    align-items: flex-start;
    gap: 8px;
  }

  .floating-media-player {
    width: calc(100vw - 16px);
    height: 42vh;
    left: 8px;
    top: 78px;
    transform: none;
    border-radius: 12px;
  }

  .floating-media-header {
    height: 38px;
    padding: 0 8px;
  }
}
