/* ============================================================
   CloudDesk — Mobile-First Hybrid App Styles
   Aesthetic: Industrial-Minimal Dark with precision accents
   ============================================================ */

:root {
  --bg-0: #080b10;
  --bg-1: #0f1117;
  --bg-2: #161b24;
  --bg-3: #1e2535;
  --bg-4: #252d3d;
  --surface: #1a2030;
  --surface-2: #212840;
  --border: #2a3347;
  --border-light: #364155;

  --text-0: #f0f4fc;
  --text-1: #b8c4d8;
  --text-2: #7a8ba8;
  --text-3: #4a5770;

  --accent: #4f8eff;
  --accent-2: #7c5cfc;
  --accent-glow: rgba(79, 142, 255, 0.15);
  --green: #22d3a0;
  --amber: #f5a623;
  --red: #ff4d6a;
  --purple: #a78bfa;

  --font-display: 'Syne', sans-serif;
  --font-body: 'Instrument Sans', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;

  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 16px;
  --radius-xl: 24px;

  --sidebar-w: 240px;
  --header-h: 56px;
  --bottom-nav-h: 64px;

  --transition: 200ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: 400ms cubic-bezier(0.4, 0, 0.2, 1);

  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.4);
  --shadow: 0 4px 16px rgba(0, 0, 0, 0.5);
  --shadow-lg: 0 12px 40px rgba(0, 0, 0, 0.6);
}

[data-theme="light"] {
  --bg-0: #f0f4fb;
  --bg-1: #ffffff;
  --bg-2: #f5f7fd;
  --bg-3: #eaeff9;
  --bg-4: #dde5f5;
  --surface: #ffffff;
  --surface-2: #f5f7fd;
  --border: #d8e2f5;
  --border-light: #c5d3ec;
  --text-0: #0f1523;
  --text-1: #2d3c5e;
  --text-2: #5a6e96;
  --text-3: #8a9ab8;
  --accent-glow: rgba(79, 142, 255, 0.08);
}

[data-theme="oled"] {
  --bg-0: #000000;
  --bg-1: #000000;
  --bg-2: #0a0a0a;
  --bg-3: #111111;
  --bg-4: #1a1a1a;
  --surface: #0d0d0d;
  --border: #222222;
}

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

html,
body {
  height: 100%;
  overflow: hidden;
  background: var(--bg-0);
  color: var(--text-0);
  font-family: var(--font-body);
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

#app {
  height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

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

.screen.hidden {
  display: none !important;
}

.screen.active {
  display: flex;
}

/* ── SCROLLBARS ─────────────────── */
::-webkit-scrollbar {
  width: 4px;
  height: 4px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

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

::-webkit-scrollbar-thumb:hover {
  background: var(--border-light);
}

/* ── SETUP SCREEN ──────────────── */
.setup-container {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
  background: var(--bg-0);
  background-image:
    radial-gradient(ellipse 60% 50% at 50% 0%, rgba(79, 142, 255, 0.08) 0%, transparent 70%),
    radial-gradient(ellipse 40% 30% at 80% 80%, rgba(124, 92, 252, 0.06) 0%, transparent 60%);
  overflow-y: auto;
}

.setup-brand {
  text-align: center;
  margin-bottom: 40px;
}

.brand-orb {
  width: 72px;
  height: 72px;
  margin: 0 auto 20px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-2) 100%);
  position: relative;
  box-shadow: 0 0 40px rgba(79, 142, 255, 0.4);
  animation: pulse 3s ease-in-out infinite;
}

.brand-orb::before {
  content: '';
  position: absolute;
  inset: 3px;
  border-radius: 50%;
  background: var(--bg-0);
}

.brand-orb::after {
  content: '◉';
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  color: var(--accent);
  line-height: 72px;
  text-align: center;
}

@keyframes pulse {

  0%,
  100% {
    box-shadow: 0 0 30px rgba(79, 142, 255, 0.3);
  }

  50% {
    box-shadow: 0 0 60px rgba(79, 142, 255, 0.5);
  }
}

.brand-name {
  font-family: var(--font-display);
  font-size: 36px;
  font-weight: 800;
  letter-spacing: -0.02em;
  background: linear-gradient(135deg, var(--text-0) 0%, var(--accent) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.brand-tagline {
  color: var(--text-2);
  font-size: 13px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  font-family: var(--font-mono);
  margin-top: 8px;
}

.setup-card {
  width: 100%;
  max-width: 440px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 32px;
  box-shadow: var(--shadow-lg);
}

.setup-card h2 {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 6px;
}

.setup-desc {
  color: var(--text-2);
  font-size: 14px;
  margin-bottom: 24px;
}

/* ── FORMS ─────────────────────── */
.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-2);
  margin-bottom: 6px;
  font-family: var(--font-mono);
}

.form-group input,
.form-group textarea,
.form-group select {
  width: 100%;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 11px 14px;
  color: var(--text-0);
  font-family: var(--font-body);
  font-size: 15px;
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
  -webkit-appearance: none;
}

.form-group input:focus,
.form-group textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.form-group input::placeholder {
  color: var(--text-3);
}

.form-hint {
  display: block;
  font-size: 12px;
  color: var(--text-3);
  margin-top: 5px;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

/* ── BUTTONS ────────────────────── */
.btn-primary {
  width: 100%;
  padding: 13px 24px;
  background: var(--accent);
  color: white;
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 700;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  transition: all var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  letter-spacing: 0.02em;
  margin-top: 8px;
}

.btn-primary:hover {
  background: #6aa3ff;
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(79, 142, 255, 0.4);
}

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

.btn-ghost {
  padding: 9px 16px;
  background: transparent;
  color: var(--text-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 14px;
  font-family: var(--font-body);
  transition: all var(--transition);
}

.btn-ghost:hover {
  background: var(--bg-3);
  border-color: var(--border-light);
}

.btn-sm {
  padding: 7px 14px;
  background: var(--bg-3);
  color: var(--text-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 13px;
  font-family: var(--font-body);
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all var(--transition);
  white-space: nowrap;
}

.btn-sm:hover {
  background: var(--bg-4);
  border-color: var(--border-light);
}

.btn-sm svg {
  width: 14px;
  height: 14px;
}

.link-btn {
  background: none;
  border: none;
  color: var(--accent);
  cursor: pointer;
  font-size: 14px;
  font-family: var(--font-body);
  padding: 0;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.icon-btn {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  color: var(--text-1);
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: all var(--transition);
  flex-shrink: 0;
}

.icon-btn:hover {
  background: var(--bg-3);
  color: var(--text-0);
}

.icon-btn.active {
  color: var(--accent);
  background: var(--accent-glow);
}

.icon-btn svg {
  width: 18px;
  height: 18px;
}

.close-btn {
  background: none;
  border: none;
  color: var(--text-2);
  cursor: pointer;
  font-size: 18px;
  padding: 6px;
  border-radius: var(--radius-sm);
  transition: all var(--transition);
  line-height: 1;
}

.close-btn:hover {
  color: var(--text-0);
  background: var(--bg-3);
}

.error-msg {
  color: var(--red);
  font-size: 13px;
  margin-top: 10px;
  padding: 10px 14px;
  background: rgba(255, 77, 106, 0.08);
  border: 1px solid rgba(255, 77, 106, 0.2);
  border-radius: var(--radius-sm);
}

.demo-note {
  text-align: center;
  margin-top: 20px;
  font-size: 13px;
  color: var(--text-3);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

/* ── SPINNER ────────────────────── */
.spinner {
  width: 28px;
  height: 28px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.btn-loader {
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

.hidden {
  display: none !important;
}

/* ── APP LAYOUT ─────────────────── */
#main-app {
  height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.app-header {
  height: var(--header-h);
  background: var(--bg-1);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 8px 0 12px;
  gap: 8px;
  flex-shrink: 0;
  z-index: 100;
  backdrop-filter: blur(12px);
}

.menu-toggle {
  width: 40px;
  height: 40px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  background: none;
  border: none;
  cursor: pointer;
  border-radius: var(--radius-sm);
  flex-shrink: 0;
}

.menu-toggle span {
  display: block;
  width: 20px;
  height: 2px;
  background: var(--text-1);
  border-radius: 1px;
  transition: all var(--transition);
}

.menu-toggle:hover span {
  background: var(--text-0);
}

.header-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 17px;
  flex: 1;
  letter-spacing: -0.01em;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 2px;
}

.app-layout {
  display: flex;
  flex: 1;
  overflow: hidden;
  position: relative;
}

/* ── SIDEBAR ────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--bg-1);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  overflow: hidden;
  transition: transform var(--transition-slow);
  z-index: 200;
}

.sidebar-inner {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow-y: auto;
  overflow-x: hidden;
}

.sidebar-profile {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 20px 16px 16px;
  border-bottom: 1px solid var(--border);
}

.avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-2) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 16px;
  flex-shrink: 0;
  letter-spacing: 0;
}

.profile-info {
  min-width: 0;
}

.profile-name {
  font-weight: 600;
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.profile-server {
  font-size: 12px;
  color: var(--text-3);
  font-family: var(--font-mono);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-nav {
  padding: 12px 10px;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  background: none;
  border: none;
  color: var(--text-2);
  cursor: pointer;
  border-radius: var(--radius);
  font-size: 14px;
  font-family: var(--font-body);
  font-weight: 500;
  text-align: left;
  transition: all var(--transition);
  position: relative;
  width: 100%;
}

.nav-item svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.nav-item span:nth-child(2) {
  flex: 1;
}

.nav-item:hover {
  background: var(--bg-3);
  color: var(--text-0);
}

.nav-item.active {
  background: var(--accent-glow);
  color: var(--accent);
}

.nav-item.active svg {
  color: var(--accent);
}

.sidebar-footer {
  padding: 10px;
  border-top: 1px solid var(--border);
}

.sync-status {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  font-size: 12px;
  color: var(--text-3);
  font-family: var(--font-mono);
}

.sync-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--text-3);
}

.sync-dot.synced {
  background: var(--green);
  box-shadow: 0 0 6px var(--green);
}

.sync-dot.syncing {
  background: var(--amber);
  animation: blink 1s ease-in-out infinite;
}

.sync-dot.error {
  background: var(--red);
}

@keyframes blink {

  0%,
  100% {
    opacity: 1;
  }

  50% {
    opacity: 0.3;
  }
}

.logout-btn {
  color: var(--text-3);
}

.logout-btn:hover {
  color: var(--red) !important;
  background: rgba(255, 77, 106, 0.08) !important;
}

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(2px);
  z-index: 190;
}

/* ── CONTENT AREA ───────────────── */
.content-area {
  flex: 1;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  background: var(--bg-0);
}

.module {
  flex: 1;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.module-layout {
  display: flex;
  flex: 1;
  overflow: hidden;
}

/* ── LIST / DETAIL PANELS ───────── */
.list-panel {
  width: 360px;
  min-width: 280px;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  background: var(--bg-1);
  flex-shrink: 0;
}

.detail-panel {
  flex: 1;
  overflow-y: auto;
  background: var(--bg-0);
  display: flex;
  flex-direction: column;
}

.panel-toolbar {
  padding: 12px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-1);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.search-box {
  display: flex;
  align-items: center;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0 12px;
  gap: 8px;
}

.search-box svg {
  width: 15px;
  height: 15px;
  color: var(--text-3);
  flex-shrink: 0;
}

.search-box input {
  flex: 1;
  background: none;
  border: none;
  padding: 9px 0;
  color: var(--text-0);
  font-size: 14px;
  outline: none;
}

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

.folder-tabs {
  display: flex;
  gap: 4px;
  overflow-x: auto;
  scrollbar-width: none;
}

.folder-tabs::-webkit-scrollbar {
  display: none;
}

.tab {
  padding: 5px 12px;
  background: none;
  border: none;
  border-radius: var(--radius-sm);
  color: var(--text-2);
  font-size: 13px;
  cursor: pointer;
  white-space: nowrap;
  font-family: var(--font-body);
  font-weight: 500;
  transition: all var(--transition);
}

.tab:hover {
  background: var(--bg-3);
  color: var(--text-0);
}

.tab.active {
  background: var(--accent-glow);
  color: var(--accent);
}

/* ── BADGE ──────────────────────── */
.badge {
  background: var(--accent);
  color: white;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 20px;
  min-width: 20px;
  text-align: center;
  line-height: 1.4;
}

.badge[data-count="0"],
.badge:empty {
  display: none;
}

.badge-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
  position: absolute;
  top: 6px;
  right: 6px;
  display: none;
}

.badge-dot.visible {
  display: block;
}

/* ── EMAIL LIST ─────────────────── */
.email-list {
  flex: 1;
  overflow-y: auto;
}

.email-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background var(--transition);
  position: relative;
}

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

.email-item.selected {
  background: var(--accent-glow);
  border-left: 3px solid var(--accent);
}

.email-item.unread {
  border-left: 3px solid var(--accent);
}

.email-item.unread .email-sender {
  font-weight: 700;
  color: var(--text-0);
}

.email-item-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.email-sender {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-1);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}

.email-time {
  font-size: 11px;
  color: var(--text-3);
  font-family: var(--font-mono);
  flex-shrink: 0;
}

.email-subject {
  font-size: 13px;
  color: var(--text-1);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.email-preview {
  font-size: 12px;
  color: var(--text-3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.email-tags {
  display: flex;
  gap: 4px;
  margin-top: 2px;
  flex-wrap: wrap;
}

.tag {
  font-size: 10px;
  padding: 2px 7px;
  border-radius: 20px;
  background: var(--bg-3);
  color: var(--text-2);
  border: 1px solid var(--border);
  font-family: var(--font-mono);
}

/* ── EMAIL DETAIL ───────────────── */
.email-detail-view {
  padding: 24px;
  max-width: 720px;
  width: 100%;
}

.email-detail-header {
  margin-bottom: 20px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border);
}

.email-detail-subject {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 700;
  line-height: 1.3;
  margin-bottom: 16px;
}

.email-meta {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.email-meta-row {
  display: flex;
  gap: 8px;
  font-size: 13px;
}

.meta-label {
  color: var(--text-3);
  font-family: var(--font-mono);
  min-width: 48px;
}

.meta-value {
  color: var(--text-1);
}

.email-actions {
  display: flex;
  gap: 8px;
  margin-top: 16px;
  flex-wrap: wrap;
}

.email-body {
  font-size: 15px;
  line-height: 1.7;
  color: var(--text-1);
  white-space: pre-wrap;
  word-break: break-word;
}

.email-body a {
  color: var(--accent);
}

/* ── EMPTY / LOADING STATES ─────── */
.empty-state {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  color: var(--text-3);
  text-align: center;
  padding: 40px;
}

.empty-state svg {
  width: 56px;
  height: 56px;
  opacity: 0.3;
}

.empty-state p {
  font-size: 14px;
}

.loading-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px;
  gap: 12px;
  color: var(--text-3);
  font-size: 13px;
}

/* ── CALENDAR ───────────────────── */
.calendar-container {
  flex: 1;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  padding: 16px;
  gap: 16px;
  max-width: 1000px;
  width: 100%;
  margin: 0 auto;
  position: relative;
}

.calendar-header {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.calendar-header h2 {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 700;
  flex: 1;
}

.view-switcher {
  display: flex;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 3px;
  gap: 2px;
}

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  flex: 1;
  min-height: 0;
}

.cal-day-header {
  background: var(--bg-2);
  padding: 8px 4px;
  text-align: center;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-3);
  font-family: var(--font-mono);
}

.cal-day {
  background: var(--bg-1);
  padding: 6px;
  min-height: 80px;
  cursor: pointer;
  transition: background var(--transition);
  position: relative;
  overflow: hidden;
}

.cal-day:hover {
  background: var(--bg-2);
}

.cal-day.other-month {
  opacity: 0.35;
}

.cal-day.today {
  background: var(--bg-2);
}

.cal-day.today .cal-day-num {
  background: var(--accent);
  color: white;
}

.cal-day-num {
  width: 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 4px;
}

.cal-event {
  font-size: 11px;
  padding: 2px 5px;
  border-radius: 3px;
  margin-bottom: 2px;
  color: white;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
  font-weight: 500;
}

.calendar-agenda {
  flex: 1;
  overflow-y: auto;
}

.agenda-day {
  margin-bottom: 20px;
}

.agenda-day-header {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-3);
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 8px;
  letter-spacing: 0.08em;
}

.agenda-event {
  display: flex;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--border);
  margin-bottom: 6px;
  cursor: pointer;
  transition: all var(--transition);
}

.agenda-event:hover {
  border-color: var(--border-light);
  background: var(--surface-2);
}

.event-color-bar {
  width: 4px;
  border-radius: 2px;
  flex-shrink: 0;
}

.agenda-event-info {
  flex: 1;
}

.agenda-event-title {
  font-size: 14px;
  font-weight: 600;
}

.agenda-event-time {
  font-size: 12px;
  color: var(--text-3);
  font-family: var(--font-mono);
  margin-top: 2px;
}

/* ── EVENT PANEL ────────────────── */
.event-panel {
  position: absolute;
  right: 16px;
  top: 70px;
  width: 300px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  z-index: 50;
  padding: 20px;
}

.event-panel h3 {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 12px;
}

.event-panel-meta {
  font-size: 13px;
  color: var(--text-2);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

/* ── CONTACTS ───────────────────── */
.contacts-alpha-list {
  flex: 1;
  overflow-y: auto;
}

.alpha-section {}

.alpha-header {
  position: sticky;
  top: 0;
  padding: 6px 16px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-3);
  background: var(--bg-1);
  font-family: var(--font-mono);
  border-bottom: 1px solid var(--border);
}

.contact-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  transition: background var(--transition);
}

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

.contact-item.selected {
  background: var(--accent-glow);
}

.contact-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent-2) 0%, var(--accent) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
  flex-shrink: 0;
}

.contact-info {
  flex: 1;
  min-width: 0;
}

.contact-name {
  font-size: 14px;
  font-weight: 600;
}

.contact-sub {
  font-size: 12px;
  color: var(--text-3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── CONTACT DETAIL ─────────────── */
.contact-detail-view {
  padding: 32px;
}

.contact-detail-avatar {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent-2) 0%, var(--accent) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  font-weight: 700;
  margin-bottom: 16px;
}

.contact-detail-name {
  font-family: var(--font-display);
  font-size: 26px;
  font-weight: 700;
  margin-bottom: 4px;
}

.contact-detail-org {
  font-size: 14px;
  color: var(--text-3);
  margin-bottom: 24px;
}

.contact-groups {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}

.group-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  background: var(--accent);
  color: white;
  border-radius: 12px;
  font-size: 13px;
  font-weight: 500;
}

.group-badge .remove-group {
  background: none;
  border: none;
  color: white;
  font-size: 16px;
  cursor: pointer;
  padding: 0;
  line-height: 1;
  opacity: 0.8;
}

.group-badge .remove-group:hover {
  opacity: 1;
}

.contact-detail-avatar.starred::after {
  content: '⭐';
  position: absolute;
  bottom: 0;
  right: 0;
  font-size: 24px;
}

.contact-detail-avatar {
  position: relative;
}

.contact-fields {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.contact-field {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.contact-field-label {
  font-size: 11px;
  font-family: var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-3);
}

.contact-field-value {
  font-size: 15px;
  color: var(--text-0);
}

.contact-field-value a {
  color: var(--accent);
  text-decoration: none;
}

.contact-actions {
  display: flex;
  gap: 8px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

.contact-actions .btn-sm.active {
  background: var(--accent);
  color: white;
}

/* ── FILES ──────────────────────── */
.files-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: 16px;
  gap: 12px;
}

.files-toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.breadcrumb {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 1;
  min-width: 0;
  overflow-x: auto;
  scrollbar-width: none;
  font-size: 13px;
}

.breadcrumb::-webkit-scrollbar {
  display: none;
}

.breadcrumb button {
  background: none;
  border: none;
  color: var(--accent);
  cursor: pointer;
  font-size: 13px;
  font-family: var(--font-body);
  white-space: nowrap;
  padding: 2px 4px;
}

.breadcrumb button:hover {
  text-decoration: underline;
}

.breadcrumb .sep {
  color: var(--text-3);
}

.files-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.view-toggle {
  display: flex;
  gap: 2px;
}

.files-grid {
  flex: 1;
  overflow-y: auto;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 10px;
  align-content: start;
}

.files-grid.list-view {
  grid-template-columns: 1fr;
  gap: 1px;
}

.file-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 12px;
  cursor: pointer;
  transition: all var(--transition);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  text-align: center;
}

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

.file-icon {
  font-size: 36px;
  line-height: 1;
}

.file-name {
  font-size: 12px;
  color: var(--text-1);
  word-break: break-all;
  line-height: 1.3;
}

.file-size {
  font-size: 11px;
  color: var(--text-3);
  font-family: var(--font-mono);
}

.files-grid.list-view .file-card {
  flex-direction: row;
  padding: 10px 16px;
  border-radius: 0;
  border-left: none;
  border-right: none;
  border-top: none;
  text-align: left;
  align-items: center;
  gap: 14px;
  transform: none !important;
}

.files-grid.list-view .file-icon {
  font-size: 22px;
}

/* ── MODALS ─────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  z-index: 500;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 0;
  animation: fadeIn 0.15s ease;
}

@media (min-width: 640px) {
  .modal-overlay {
    align-items: center;
    padding: 20px;
  }
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  width: 100%;
  max-width: 560px;
  max-height: 92dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: slideUp 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: var(--shadow-lg);
}

@media (min-width: 640px) {
  .modal {
    border-radius: var(--radius-xl);
    max-height: 85dvh;
  }
}

@keyframes slideUp {
  from {
    transform: translateY(40px);
    opacity: 0;
  }

  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.modal-header h3 {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 700;
}

.modal-body {
  padding: 20px;
  overflow-y: auto;
  flex: 1;
}

.modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

/* ── COMPOSE ────────────────────── */
.compose-modal {
  max-width: 680px;
}

.compose-body {
  display: flex;
  flex-direction: column;
  flex: 1;
  overflow: hidden;
  position: relative;
}

.compose-field {
  display: flex;
  align-items: flex-start;
  gap: 0;
  border-bottom: 1px solid var(--border);
}

.compose-field label {
  padding: 12px 12px;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-3);
  font-family: var(--font-mono);
  min-width: 60px;
  padding-top: 14px;
}

.compose-field input {
  flex: 1;
  background: none;
  border: none;
  padding: 12px 12px 12px 0;
  color: var(--text-0);
  font-size: 14px;
  outline: none;
  font-family: var(--font-body);
}

.tag-input {
  flex: 1;
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  padding: 8px 8px 8px 0;
  align-items: center;
}

.tag-input input {
  flex: 1;
  min-width: 120px;
  background: none;
  border: none;
  padding: 4px 4px;
  color: var(--text-0);
  font-size: 14px;
  outline: none;
}

.email-tag {
  display: flex;
  align-items: center;
  gap: 4px;
  background: var(--accent-glow);
  color: var(--accent);
  border: 1px solid rgba(79, 142, 255, 0.3);
  border-radius: 20px;
  padding: 3px 8px;
  font-size: 12px;
  cursor: default;
}

.email-tag button {
  background: none;
  border: none;
  color: var(--accent);
  cursor: pointer;
  padding: 0;
  font-size: 14px;
  line-height: 1;
}

.compose-editor {
  flex: 1;
  min-height: 200px;
  padding: 16px;
  outline: none;
  font-size: 15px;
  line-height: 1.7;
  color: var(--text-0);
  font-family: var(--font-body);
  overflow-y: auto;
}

.compose-editor:empty::before {
  content: attr(placeholder);
  color: var(--text-3);
  pointer-events: none;
}

.compose-attachments {
  padding: 8px 16px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-height: 0;
  position: absolute;
  bottom: 0;
  right: 0;
}

.attachment-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 12px;
  color: var(--text-1);
}

/* ── COLOR PICKER ───────────────── */
.color-picker {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.color-swatch {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  transition: all var(--transition);
}

.color-swatch:hover {
  transform: scale(1.15);
}

.color-swatch.active {
  border-color: white;
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.3);
}

/* ── FAB ────────────────────────── */
.fab {
  position: absolute;
  bottom: 24px;
  right: 20px;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: var(--accent);
  color: white;
  font-size: 26px;
  border: none;
  cursor: pointer;
  box-shadow: 0 6px 20px rgba(79, 142, 255, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
  z-index: 20;
  line-height: 1;
}

.fab:hover {
  background: #6aa3ff;
  transform: scale(1.08);
}

.fab:active {
  transform: scale(0.97);
}

/* ── BOTTOM NAV ─────────────────── */
.bottom-nav {
  display: flex;
  background: var(--bg-1);
  border-top: 1px solid var(--border);
  height: var(--bottom-nav-h);
  flex-shrink: 0;
  z-index: 100;
  padding-bottom: env(safe-area-inset-bottom, 0);
}

.bottom-nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  background: none;
  border: none;
  color: var(--text-3);
  font-size: 10px;
  cursor: pointer;
  font-family: var(--font-body);
  transition: all var(--transition);
  position: relative;
  padding: 8px 0;
}

.bottom-nav-item svg {
  width: 22px;
  height: 22px;
  transition: all var(--transition);
}

.bottom-nav-item span {
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.03em;
}

.bottom-nav-item.active {
  color: var(--accent);
}

.bottom-nav-item:hover {
  color: var(--text-0);
}

/* ── SETTINGS ───────────────────── */
.settings-modal {
  max-width: 500px;
}

.settings-section {
  margin-bottom: 24px;
}

.settings-section h4 {
  font-family: var(--font-mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-3);
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

.settings-info {
  font-size: 13px;
  color: var(--text-2);
  line-height: 1.5;
}

.settings-note {
  font-size: 13px;
  color: var(--text-3);
  margin-bottom: 10px;
}

.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 0;
  cursor: pointer;
  font-size: 14px;
}

.toggle-row input[type="checkbox"] {
  display: none;
}

.toggle {
  width: 44px;
  height: 24px;
  background: var(--bg-4);
  border-radius: 12px;
  position: relative;
  transition: background var(--transition);
  flex-shrink: 0;
  border: 1px solid var(--border);
}

.toggle::after {
  content: '';
  position: absolute;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: white;
  top: 2px;
  left: 2px;
  transition: transform var(--transition);
}

input:checked~.toggle {
  background: var(--accent);
  border-color: var(--accent);
}

input:checked~.toggle::after {
  transform: translateX(20px);
}

.theme-switcher {
  display: flex;
  gap: 8px;
}

.theme-btn {
  flex: 1;
  padding: 9px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-2);
  font-size: 13px;
  cursor: pointer;
  font-family: var(--font-body);
  transition: all var(--transition);
}

.theme-btn:hover {
  border-color: var(--border-light);
  color: var(--text-0);
}

.theme-btn.active {
  background: var(--accent-glow);
  border-color: var(--accent);
  color: var(--accent);
}

.code-block {
  display: block;
  background: var(--bg-0);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--green);
  line-height: 1.8;
  white-space: pre-wrap;
}

/* ── TOAST ──────────────────────── */
.toast-container {
  position: fixed;
  bottom: calc(var(--bottom-nav-h) + 16px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 1000;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: none;
  width: 90%;
  max-width: 360px;
}

.toast {
  background: var(--bg-4);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: 12px 18px;
  font-size: 14px;
  color: var(--text-0);
  box-shadow: var(--shadow-lg);
  animation: toastIn 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  text-align: center;
  pointer-events: auto;
  backdrop-filter: blur(12px);
}

.toast.success {
  border-color: rgba(34, 211, 160, 0.4);
  color: var(--green);
}

.toast.error {
  border-color: rgba(255, 77, 106, 0.4);
  color: var(--red);
}

@keyframes toastIn {
  from {
    opacity: 0;
    transform: translateY(16px) scale(0.95);
  }

  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* ── FILE PREVIEW ───────────────── */
.preview-modal {
  max-width: 800px;
  max-height: 90dvh;
}

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

.preview-body {
  flex: 1;
  overflow: auto;
  padding: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.preview-body img {
  max-width: 100%;
  max-height: 60dvh;
  border-radius: var(--radius);
  object-fit: contain;
}

.preview-text {
  font-family: var(--font-mono);
  font-size: 12px;
  white-space: pre-wrap;
  color: var(--text-1);
  line-height: 1.6;
  word-break: break-all;
  max-width: 100%;
}

/* ── SYNC ANIMATION ─────────────── */
@keyframes rotate {
  to {
    transform: rotate(360deg);
  }
}

.syncing #sync-icon {
  animation: rotate 1s linear infinite;
  color: var(--amber);
}

/* ── RESPONSIVE ─────────────────── */
@media (max-width: 900px) {
  .list-panel {
    width: 300px;
  }
}

@media (max-width: 768px) {

  /* Mobile: full-screen list or detail */
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    height: 100dvh;
    transform: translateX(-100%);
  }

  .sidebar.open {
    transform: translateX(0);
    box-shadow: var(--shadow-lg);
  }

  .sidebar-overlay.open {
    display: block;
  }

  .menu-toggle {
    display: flex;
  }

  .module-layout {
    position: relative;
  }

  .list-panel {
    width: 100%;
    position: absolute;
    inset: 0;
    z-index: 10;
    transition: transform var(--transition-slow);
  }

  .detail-panel {
    position: absolute;
    inset: 0;
    z-index: 20;
    transform: translateX(100%);
    transition: transform var(--transition-slow);
    background: var(--bg-0);
  }

  .detail-panel.open {
    transform: translateX(0);
  }

  .detail-panel .mobile-back {
    display: flex;
  }

  .event-panel {
    position: fixed;
    bottom: var(--bottom-nav-h);
    right: 0;
    left: 0;
    top: auto;
    width: auto;
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    max-height: 60dvh;
    overflow-y: auto;
  }

  .calendar-container {
    padding: 10px;
  }

  .files-grid {
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  }
}

@media (min-width: 769px) {
  .bottom-nav {
    display: none;
  }

  .menu-toggle {
    display: none;
  }
}

/* ── MOBILE BACK BUTTON ─────────── */
.mobile-back {
  display: none;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-1);
  cursor: pointer;
  border: none;
  color: var(--accent);
  font-size: 14px;
  font-family: var(--font-body);
  font-weight: 600;
  width: 100%;
}

.mobile-back svg {
  width: 16px;
  height: 16px;
}

/* ── WEEK VIEW ──────────────────── */
.week-grid {
  display: grid;
  grid-template-columns: 48px repeat(7, 1fr);
  flex: 1;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.week-header-row {
  display: contents;
}

.week-hour-col {
  border-right: 1px solid var(--border);
}

.week-day-col {
  border-right: 1px solid var(--border);
}

/* Subtle scan lines for that premium CRT touch */
.app-header::after {
  content: '';
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(0deg, transparent, transparent 2px, rgba(255, 255, 255, 0.01) 2px, rgba(255, 255, 255, 0.01) 4px);
  pointer-events: none;
  opacity: 0.5;
}

/* Selection highlight */
::selection {
  background: var(--accent-glow);
  color: var(--accent);
}


.d-none {
  display: none !important;
}


.notes-layout {
  display: flex;
  height: calc(100vh - 120px);
  gap: 1px;
  background: var(--bg-3);
}

.notes-sidebar {
  width: 250px;
  background: var(--bg-1);
  overflow-y: auto;
  border-right: 1px solid var(--bg-3);
}

.note-item {
  padding: 12px 16px;
  cursor: pointer;
  border-bottom: 1px solid var(--bg-2);
  transition: background 0.2s;
}

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

.note-content {
  flex: 1;
  background: var(--bg-1);
  padding: 30px;
  overflow-y: auto;
}

.markdown-body {
  line-height: 1.6;
  color: var(--text-1);
}

.task-item.completed .task-title {
  text-decoration: line-through;
  color: var(--text-3);
}


.note-modal {
  max-width: 800px;
  width: 90%;
}

#note-title-input {
  width: 100%;
  padding: 12px;
  background: var(--bg-2);
  border: 1px solid var(--bg-3);
  border-radius: var(--radius);
  color: var(--text-1);
  font-size: 1.1rem;
  margin-bottom: 15px;
}

#note-textarea {
  width: 100%;
  height: 60vh;
  padding: 15px;
  background: var(--bg-1);
  border: 1px solid var(--bg-3);
  border-radius: var(--radius);
  color: var(--text-1);
  font-family: 'Monaco', 'Consolas', monospace;
  resize: vertical;
  line-height: 1.5;
}

.compose-attachments {
  padding: 8px;
  /* background: #f8fafc;
  border-bottom: 1px solid #e2e8f0; */
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.attachment-item {
  /* background: #fff; */
  border: 1px solid #cbd5e1;
  border-radius: 16px;
  padding: 4px 12px;
  font-size: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.remove-attachment {
  border: none;
  background: none;
  color: #ef4444;
  cursor: pointer;
  font-weight: bold;
  padding: 0 2px;
}

.remove-attachment:hover {
  color: #b91c1c;
}