:root,
[data-theme="light"] {
  --bg: #F6F8FC;
  --bg-elevated: #FFFFFF;
  --bg-soft: #EEF2F9;
  --bg-hover: #E6ECF7;
  --text: #0F172A;
  --text-secondary: #475569;
  --text-muted: #64748B;
  --border: #E2E8F0;
  --border-strong: #CBD5E1;
  --primary: #2563EB;
  --primary-hover: #1D4ED8;
  --primary-soft: rgba(37, 99, 235, 0.1);
  --accent: #7C3AED;
  --success: #10B981;
  --success-soft: rgba(16, 185, 129, 0.12);
  --warning: #F59E0B;
  --warning-soft: rgba(245, 158, 11, 0.14);
  --danger: #EF4444;
  --danger-soft: rgba(239, 68, 68, 0.12);
  --shadow-sm: 0 2px 8px rgba(15, 23, 42, 0.04);
  --shadow-md: 0 10px 28px rgba(15, 23, 42, 0.07);
  --shadow-lg: 0 24px 54px rgba(15, 23, 42, 0.14);
  --radius-sm: 10px;
  --radius-md: 14px;
  --radius-lg: 20px;
}

[data-theme="dark"] {
  --bg: #0B1120;
  --bg-elevated: #131C31;
  --bg-soft: #1B2742;
  --bg-hover: #243354;
  --text: #F8FAFC;
  --text-secondary: #CBD5E1;
  --text-muted: #94A3B8;
  --border: rgba(255, 255, 255, 0.09);
  --border-strong: rgba(255, 255, 255, 0.18);
  --primary: #3B82F6;
  --primary-hover: #60A5FA;
  --primary-soft: rgba(59, 130, 246, 0.16);
  --accent: #A78BFA;
  --success: #34D399;
  --success-soft: rgba(52, 211, 153, 0.16);
  --warning: #FBBF24;
  --warning-soft: rgba(251, 191, 36, 0.16);
  --danger: #F87171;
  --danger-soft: rgba(248, 113, 113, 0.16);
  --shadow-sm: 0 2px 10px rgba(0, 0, 0, 0.25);
  --shadow-md: 0 12px 32px rgba(0, 0, 0, 0.38);
  --shadow-lg: 0 26px 64px rgba(0, 0, 0, 0.6);
}

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

html, body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Be Vietnam Pro', system-ui, -apple-system, sans-serif;
  font-size: 15px;
  line-height: 1.55;
  min-height: 100vh;
  transition: background-color 0.25s ease, color 0.25s ease;
  -webkit-font-smoothing: antialiased;
}

button, input, select, textarea {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
}

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

/* ===== BUTTONS ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 0.93rem;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text);
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.btn:hover {
  background: var(--bg-hover);
  border-color: var(--border-strong);
}

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

.btn-primary:hover {
  background: var(--primary-hover);
  border-color: var(--primary-hover);
  transform: translateY(-1px);
  box-shadow: 0 8px 20px rgba(37, 99, 235, 0.28);
}

.btn-soft {
  background: var(--primary-soft);
  border-color: transparent;
  color: var(--primary);
}

.btn-soft:hover {
  background: var(--primary);
  color: #FFFFFF;
}

.btn-danger {
  background: var(--danger-soft);
  border-color: transparent;
  color: var(--danger);
}

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

.btn-sm {
  padding: 6px 12px;
  font-size: 0.84rem;
  border-radius: 8px;
}

.icon-btn {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 1.08rem;
  transition: all 0.2s ease;
}

.icon-btn:hover {
  background: var(--bg-hover);
  transform: translateY(-1px);
}

/* ===== GUEST / PUBLIC PORTAL LAYOUT ===== */
.guest-shell {
  max-width: 1240px;
  margin: 0 auto;
  padding: 24px 24px 72px;
}

.guest-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 24px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  margin-bottom: 28px;
  flex-wrap: wrap;
}

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

.brand-logo {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: #FFFFFF;
  font-weight: 800;
  font-size: 1.25rem;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 8px 18px rgba(37, 99, 235, 0.28);
}

.brand-title {
  font-weight: 800;
  font-size: 1.12rem;
  letter-spacing: -0.3px;
}

.brand-sub {
  font-size: 0.83rem;
  color: var(--text-muted);
}

.guest-hero {
  background: linear-gradient(135deg, rgba(37, 99, 235, 0.1), rgba(124, 58, 237, 0.09));
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 40px 36px;
  margin-bottom: 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 28px;
  flex-wrap: wrap;
}

.guest-hero h1 {
  font-size: clamp(1.7rem, 3vw, 2.35rem);
  font-weight: 800;
  letter-spacing: -0.5px;
  margin-bottom: 8px;
}

.guest-hero p {
  color: var(--text-secondary);
  font-size: 1.02rem;
  max-width: 640px;
}

/* ===== OWNER WORKSPACE SHELL ===== */
.app-shell {
  display: grid;
  grid-template-columns: 268px 1fr;
  min-height: 100vh;
}

.sidebar {
  background: var(--bg-elevated);
  border-right: 1px solid var(--border);
  padding: 22px 16px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.nav-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-top: 22px;
}

.nav-label {
  font-size: 0.74rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-muted);
  padding: 8px 12px 4px;
}

.nav-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  padding: 11px 14px;
  border-radius: 12px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-weight: 600;
  font-size: 0.94rem;
  cursor: pointer;
  text-align: left;
  transition: all 0.18s ease;
}

.nav-btn:hover {
  background: var(--bg-soft);
  color: var(--text);
}

.nav-btn.active {
  background: var(--primary-soft);
  color: var(--primary);
  font-weight: 700;
}

.nav-btn-left {
  display: flex;
  align-items: center;
  gap: 11px;
}

.nav-count {
  font-size: 0.76rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 99px;
  background: var(--bg-soft);
  color: var(--text-muted);
}

.nav-btn.active .nav-count {
  background: var(--primary);
  color: #FFFFFF;
}

.main-area {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.topbar {
  height: 70px;
  padding: 0 32px;
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 50;
}

.search-box {
  flex: 1;
  max-width: 440px;
  position: relative;
}

.search-box input {
  width: 100%;
  padding: 10px 16px 10px 40px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--bg-soft);
  outline: none;
  transition: all 0.2s;
}

.search-box input:focus {
  background: var(--bg-elevated);
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}

.search-icon {
  position: absolute;
  left: 13px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
}

.content-wrap {
  padding: 28px 32px 72px;
  max-width: 1320px;
  width: 100%;
  margin: 0 auto;
}

.sec-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
  flex-wrap: wrap;
}

.sec-head h2 {
  font-size: 1.55rem;
  font-weight: 800;
  letter-spacing: -0.4px;
}

.sec-head p {
  color: var(--text-muted);
  font-size: 0.92rem;
  margin-top: 3px;
}

/* ===== STATS BENTO CARDS ===== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 16px;
  margin-bottom: 26px;
}

.stat-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 20px 22px;
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: center;
  gap: 16px;
}

.stat-icon {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.45rem;
  flex-shrink: 0;
}

.stat-num {
  font-size: 1.65rem;
  font-weight: 800;
  line-height: 1.1;
}

.stat-label {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 2px;
}

/* ===== FILTER PILLS ===== */
.filter-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}

.pill {
  padding: 7px 14px;
  border-radius: 99px;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text-secondary);
  font-size: 0.86rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.18s;
}

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

.pill.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #FFFFFF;
}

/* ===== DRIVE CARDS GRID ===== */
.drive-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(305px, 1fr));
  gap: 18px;
}

.drive-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 16px;
  transition: transform 0.22s ease, box-shadow 0.22s ease, border-color 0.22s ease;
}

.drive-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
  border-color: var(--border-strong);
}

.file-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.file-type-icon {
  width: 46px;
  height: 46px;
  border-radius: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.45rem;
  flex-shrink: 0;
  background: var(--bg-soft);
}

.vis-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 11px;
  border-radius: 99px;
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.18s;
}

.vis-private {
  background: var(--bg-soft);
  color: var(--text-secondary);
  border-color: var(--border);
}

.vis-unlisted {
  background: var(--warning-soft);
  color: #D97706;
}

[data-theme="dark"] .vis-unlisted { color: #FBBF24; }

.vis-public {
  background: var(--success-soft);
  color: #059669;
}

[data-theme="dark"] .vis-public { color: #34D399; }

.drive-title {
  font-size: 1.05rem;
  font-weight: 700;
  line-height: 1.38;
  margin-bottom: 6px;
}

.drive-desc {
  font-size: 0.88rem;
  color: var(--text-secondary);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.drive-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 0.8rem;
  color: var(--text-muted);
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.drive-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

/* ===== DROPZONE UPLOAD ===== */
.dropzone {
  border: 2px dashed var(--border-strong);
  border-radius: var(--radius-md);
  padding: 28px 20px;
  text-align: center;
  background: var(--bg-soft);
  cursor: pointer;
  transition: all 0.2s;
}

.dropzone:hover,
.dropzone.dragover {
  border-color: var(--primary);
  background: var(--primary-soft);
}

/* ===== NOTES CARDS ===== */
.notes-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
  gap: 18px;
}

.note-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-top: 5px solid var(--primary);
  border-radius: var(--radius-md);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 14px;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
}

.note-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
}

.note-card.color-amber { border-top-color: #F59E0B; }
.note-card.color-green { border-top-color: #10B981; }
.note-card.color-purple { border-top-color: #8B5CF6; }
.note-card.color-rose { border-top-color: #F43F5E; }

.note-body-preview {
  font-size: 0.9rem;
  color: var(--text-secondary);
  white-space: pre-line;
  display: -webkit-box;
  -webkit-line-clamp: 5;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ===== 3D FLASHCARD STUDY PLAYER ===== */
.flashcard-stage {
  max-width: 680px;
  margin: 0 auto;
  perspective: 1200px;
}

.flashcard-3d {
  width: 100%;
  min-height: 310px;
  position: relative;
  transform-style: preserve-3d;
  transition: transform 0.55s cubic-bezier(0.22, 1, 0.36, 1);
  cursor: pointer;
}

.flashcard-3d.flipped {
  transform: rotateY(180deg);
}

.fc-face {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  border-radius: 22px;
  padding: 36px 32px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  background: var(--bg-elevated);
  border: 2px solid var(--border-strong);
  box-shadow: var(--shadow-md);
}

.fc-back {
  transform: rotateY(180deg);
  border-color: var(--primary);
  background: linear-gradient(145deg, var(--bg-elevated), var(--primary-soft));
}

.fc-hint {
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--primary);
  margin-bottom: 14px;
}

.fc-text {
  font-size: 1.28rem;
  font-weight: 700;
  line-height: 1.5;
  white-space: pre-line;
}

/* ===== DEADLINES & POMODORO ===== */
.dl-layout {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 24px;
  align-items: start;
}

.dl-item {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 18px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 12px;
  box-shadow: var(--shadow-sm);
}

.dl-item.done {
  opacity: 0.6;
}

.dl-countdown {
  padding: 6px 12px;
  border-radius: 10px;
  font-weight: 700;
  font-size: 0.84rem;
  background: var(--warning-soft);
  color: #D97706;
  white-space: nowrap;
}

[data-theme="dark"] .dl-countdown { color: #FBBF24; }
.dl-countdown.urgent { background: var(--danger-soft); color: var(--danger); }
.dl-countdown.completed { background: var(--success-soft); color: var(--success); }

.pomo-box {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 26px 22px;
  text-align: center;
  box-shadow: var(--shadow-sm);
  position: sticky;
  top: 94px;
}

.pomo-time {
  font-size: 3.4rem;
  font-weight: 800;
  letter-spacing: -1px;
  font-variant-numeric: tabular-nums;
  margin: 14px 0;
  color: var(--primary);
}

/* ===== FORMS & MODALS ===== */
.form-group {
  margin-bottom: 15px;
}

.form-group label {
  display: block;
  font-size: 0.86rem;
  font-weight: 700;
  margin-bottom: 6px;
  color: var(--text-secondary);
}

.input, select.input, textarea.input {
  width: 100%;
  padding: 10px 14px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg-soft);
  outline: none;
  transition: border-color 0.2s, background-color 0.2s;
}

.input:focus {
  background: var(--bg-elevated);
  border-color: var(--primary);
}

textarea.input {
  min-height: 110px;
  resize: vertical;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.68);
  backdrop-filter: blur(5px);
  z-index: 9000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-backdrop.open {
  display: flex;
}

.modal-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 20px;
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  overflow-y: auto;
  padding: 26px 28px;
  box-shadow: var(--shadow-lg);
  animation: modalPop 0.22s ease;
}

.modal-card.wide {
  max-width: 980px;
}

@keyframes modalPop {
  from { opacity: 0; transform: translateY(14px) scale(0.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}

.modal-header h3 {
  font-size: 1.24rem;
  font-weight: 800;
}

/* ===== TOAST ===== */
.toast-wrap {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.toast {
  background: #0F172A;
  color: #FFFFFF;
  padding: 12px 18px;
  border-radius: 12px;
  font-size: 0.9rem;
  font-weight: 600;
  box-shadow: var(--shadow-lg);
  border-left: 4px solid var(--primary);
  animation: modalPop 0.2s ease;
}

.empty-box {
  text-align: center;
  padding: 52px 24px;
  background: var(--bg-elevated);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-lg);
  color: var(--text-muted);
}

/* ===== MOBILE RESPONSIVE ===== */
.mobile-menu-btn {
  display: none;
}

@media (max-width: 960px) {
  .app-shell {
    grid-template-columns: 1fr;
  }
  .sidebar {
    position: fixed;
    left: -280px;
    top: 0;
    bottom: 0;
    width: 270px;
    z-index: 8000;
    transition: left 0.25s ease;
  }
  .sidebar.open {
    left: 0;
    box-shadow: var(--shadow-lg);
  }
  .mobile-menu-btn {
    display: inline-flex;
  }
  .topbar {
    padding: 0 16px;
  }
  .content-wrap {
    padding: 20px 16px 64px;
  }
  .dl-layout {
    grid-template-columns: 1fr;
  }
}
