/* ============================================================
   Netlife Mail — Premium Webmail UI
   Replaces Roundcube's default UI entirely
   Primary: #7C3AED (Violet 600)
   ============================================================ */

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

/* ============================================================
   PHASE 0: Hide ALL Roundcube chrome immediately
   ============================================================ */

#layout,
#layout-menu,
#taskmenu,
#layout-sidebar,
#layout-list,
#layout-content,
#messagecontframe,
.popover-header,
body > .loading,
#loading,
#rcm_attachment_list,
.toolbarmenu,
#toolbar-menu,
#folder-selector,
.rcm-listelement,
#mailtoolbar,
#mailsearchtoolbar,
#searchfilter,
#listcontrols,
#quotadisplay,
#listcount,
.listcontrols,
.pagenav,
#rcmbody,
body > table,
body > #rcm_messagepartmenu,
body > #rcm_forwardmenu,
body > #rcm_composeoptionsmenu,
#rcm_spellmenu,
.rcm-overlay,
#search-form,
#mainscreencontent {
  display: none !important;
}

/* Keep functional Roundcube elements alive but invisible offscreen */
#mailboxlist,
#messagelist,
#composebody,
table#messagelist,
#login-form,
#rcmloginuser,
#rcmloginpwd,
#rcmloginsubmit,
#_to,
#_from,
#_subject,
#_cc,
#_bcc,
#_message,
#compose-content,
.compose-headers,
#composetoolbar {
  position: absolute !important;
  left: -9999px !important;
  top: -9999px !important;
  visibility: hidden !important;
  display: block !important;
  pointer-events: none !important;
}

/* ============================================================
   GLOBAL RESET & BASE
   ============================================================ */

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

html, body {
  height: 100%;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 14px;
  line-height: 1.5;
  color: #0F172A;
  background: #F8FAFC;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ============================================================
   CSS CUSTOM PROPERTIES
   ============================================================ */

:root {
  /* Brand */
  --nl-primary: #7C3AED;
  --nl-primary-hover: #6D28D9;
  --nl-primary-light: #EDE9FE;
  --nl-primary-ghost: rgba(124, 58, 237, 0.08);
  --nl-primary-ring: rgba(124, 58, 237, 0.25);

  /* Neutrals */
  --nl-bg: #F8FAFC;
  --nl-bg-subtle: #F1F5F9;
  --nl-surface: #FFFFFF;
  --nl-border: #E2E8F0;
  --nl-border-subtle: #F1F5F9;

  /* Dark nav */
  --nl-nav-bg: #0F172A;
  --nl-nav-hover: #1E293B;
  --nl-nav-active: rgba(124, 58, 237, 0.12);

  /* Text */
  --nl-text-primary: #0F172A;
  --nl-text-secondary: #374151;
  --nl-text-tertiary: #64748B;
  --nl-text-muted: #94A3B8;

  /* Semantic */
  --nl-success: #22C55E;
  --nl-error: #EF4444;
  --nl-warning: #F59E0B;
  --nl-info: #3B82F6;

  /* Shadows */
  --nl-shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.04);
  --nl-shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08), 0 2px 6px rgba(0, 0, 0, 0.04);
  --nl-shadow-lg: 0 10px 30px rgba(0, 0, 0, 0.12), 0 4px 12px rgba(0, 0, 0, 0.06);
  --nl-shadow-xl: 0 25px 60px rgba(0, 0, 0, 0.18), 0 10px 24px rgba(0, 0, 0, 0.10);
  --nl-shadow-composer: 0 25px 60px rgba(0, 0, 0, 0.20);

  /* Radii */
  --nl-radius-sm: 6px;
  --nl-radius-md: 8px;
  --nl-radius-lg: 12px;
  --nl-radius-xl: 16px;
  --nl-radius-2xl: 20px;
  --nl-radius-full: 9999px;

  /* Transitions */
  --nl-transition-fast: 100ms cubic-bezier(0.4, 0, 0.2, 1);
  --nl-transition-base: 150ms cubic-bezier(0.4, 0, 0.2, 1);
  --nl-transition-slow: 250ms cubic-bezier(0.4, 0, 0.2, 1);
  --nl-transition-spring: 300ms cubic-bezier(0.16, 1, 0.3, 1);

  /* Layout */
  --nl-nav-width: 64px;
  --nl-list-width: 280px;
}

/* ============================================================
   LOADING OVERLAY
   ============================================================ */

#nl-loading {
  position: fixed;
  inset: 0;
  background: #0F172A;
  z-index: 99999;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 16px;
  transition: opacity 0.4s ease;
}

#nl-loading.nl-fade-out {
  opacity: 0;
  pointer-events: none;
}

.nl-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid #1E293B;
  border-top-color: #7C3AED;
  border-radius: 50%;
  animation: nl-spin 0.8s linear infinite;
}

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

#nl-loading p {
  font-size: 14px;
  color: #64748B;
  font-weight: 500;
  letter-spacing: 0.01em;
}

/* ============================================================
   MAIN APP LAYOUT
   ============================================================ */

#netlife-app {
  display: grid;
  grid-template-columns: var(--nl-nav-width) var(--nl-list-width) 1fr;
  height: 100vh;
  overflow: hidden;
  background: var(--nl-bg);
}

/* ============================================================
   NAV RAIL (#nl-nav)
   ============================================================ */

#nl-nav {
  background: var(--nl-nav-bg);
  width: var(--nl-nav-width);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 12px 0;
  position: relative;
  z-index: 100;
  flex-shrink: 0;
}

/* Logo */
.nl-logo {
  width: 40px;
  height: 40px;
  background: var(--nl-primary);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 4px;
  flex-shrink: 0;
  cursor: pointer;
  transition: transform var(--nl-transition-spring);
}

.nl-logo:hover {
  transform: scale(1.05);
}

.nl-logo svg {
  width: 22px;
  height: 22px;
  color: white;
}

/* Compose button */
.nl-compose-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: rgba(124, 58, 237, 0.12);
  color: var(--nl-primary);
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  margin-top: 28px;
  flex-shrink: 0;
  transition: background var(--nl-transition-base), color var(--nl-transition-base), transform var(--nl-transition-spring);
  position: relative;
}

.nl-compose-btn:hover {
  background: var(--nl-primary);
  color: white;
  transform: scale(1.08);
}

.nl-compose-btn svg {
  width: 20px;
  height: 20px;
}

/* Nav icons group */
.nl-nav-icons {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  margin-top: 20px;
  flex: 1;
  width: 100%;
  padding: 0 10px;
}

/* Individual nav item */
.nl-nav-item {
  position: relative;
  width: 44px;
  height: 44px;
  border-radius: 10px;
  color: #64748B;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background var(--nl-transition-base), color var(--nl-transition-base);
  flex-shrink: 0;
}

.nl-nav-item:hover {
  background: var(--nl-nav-hover);
  color: #CBD5E1;
}

.nl-nav-item.active {
  background: rgba(124, 58, 237, 0.15);
  color: var(--nl-primary);
}

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

/* Unread badge on nav item */
.nl-nav-badge {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 16px;
  height: 16px;
  background: var(--nl-primary);
  color: white;
  font-size: 10px;
  font-weight: 700;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  pointer-events: none;
}

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

/* Tooltip */
.nl-nav-item::after {
  content: attr(data-label);
  position: absolute;
  left: calc(100% + 10px);
  top: 50%;
  transform: translateY(-50%);
  background: #1E293B;
  color: white;
  font-size: 12px;
  font-weight: 500;
  padding: 6px 10px;
  border-radius: var(--nl-radius-sm);
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity var(--nl-transition-base);
  z-index: 200;
  font-family: 'Inter', sans-serif;
  box-shadow: var(--nl-shadow-md);
}

.nl-nav-item:hover::after {
  opacity: 1;
}

.nl-compose-btn::after {
  content: 'Redactar';
  position: absolute;
  left: calc(100% + 10px);
  top: 50%;
  transform: translateY(-50%);
  background: #1E293B;
  color: white;
  font-size: 12px;
  font-weight: 500;
  padding: 6px 10px;
  border-radius: var(--nl-radius-sm);
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity var(--nl-transition-base);
  z-index: 200;
  font-family: 'Inter', sans-serif;
  box-shadow: var(--nl-shadow-md);
}

.nl-compose-btn:hover::after {
  opacity: 1;
}

/* Nav bottom section */
.nl-nav-bottom {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 0 10px 4px;
  width: 100%;
}

.nl-nav-settings {
  position: relative;
  width: 44px;
  height: 44px;
  border-radius: 10px;
  color: #64748B;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background var(--nl-transition-base), color var(--nl-transition-base);
  flex-shrink: 0;
}

.nl-nav-settings:hover {
  background: var(--nl-nav-hover);
  color: #CBD5E1;
}

.nl-nav-settings::after {
  content: 'Configuración';
  position: absolute;
  left: calc(100% + 10px);
  top: 50%;
  transform: translateY(-50%);
  background: #1E293B;
  color: white;
  font-size: 12px;
  font-weight: 500;
  padding: 6px 10px;
  border-radius: var(--nl-radius-sm);
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity var(--nl-transition-base);
  z-index: 200;
  font-family: 'Inter', sans-serif;
  box-shadow: var(--nl-shadow-md);
}

.nl-nav-settings:hover::after {
  opacity: 1;
}

.nl-nav-settings svg {
  width: 20px;
  height: 20px;
}

.nl-user-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--nl-primary);
  color: white;
  font-size: 14px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform var(--nl-transition-spring), box-shadow var(--nl-transition-base);
  position: relative;
  flex-shrink: 0;
}

.nl-user-avatar:hover {
  transform: scale(1.08);
  box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.3);
}

.nl-user-avatar::after {
  content: attr(data-label);
  position: absolute;
  left: calc(100% + 10px);
  top: 50%;
  transform: translateY(-50%);
  background: #1E293B;
  color: white;
  font-size: 12px;
  font-weight: 500;
  padding: 6px 10px;
  border-radius: var(--nl-radius-sm);
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity var(--nl-transition-base);
  z-index: 200;
  font-family: 'Inter', sans-serif;
  box-shadow: var(--nl-shadow-md);
}

.nl-user-avatar:hover::after {
  opacity: 1;
}

/* ============================================================
   LIST PANEL (#nl-list)
   ============================================================ */

#nl-list {
  background: #F8FAFC;
  border-right: 1px solid var(--nl-border);
  width: var(--nl-list-width);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  flex-shrink: 0;
}

/* Search bar */
.nl-search-wrap {
  padding: 12px 16px;
  flex-shrink: 0;
}

.nl-search {
  position: relative;
  display: flex;
  align-items: center;
}

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

.nl-search input {
  width: 100%;
  height: 36px;
  background: #F1F5F9;
  border: 1.5px solid transparent;
  border-radius: var(--nl-radius-md);
  padding: 0 12px 0 34px;
  font-size: 13px;
  color: var(--nl-text-primary);
  font-family: 'Inter', sans-serif;
  outline: none;
  transition: background var(--nl-transition-base), border-color var(--nl-transition-base), box-shadow var(--nl-transition-base);
}

.nl-search input::placeholder {
  color: var(--nl-text-muted);
}

.nl-search input:focus {
  background: white;
  border-color: var(--nl-primary);
  box-shadow: 0 0 0 3px var(--nl-primary-ring);
}

/* Folder header */
.nl-folder-header {
  padding: 16px 20px 4px;
  flex-shrink: 0;
}

.nl-folder-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--nl-text-primary);
  line-height: 1.2;
}

.nl-folder-unread {
  font-size: 13px;
  color: var(--nl-text-tertiary);
  padding: 6px 20px 12px;
  flex-shrink: 0;
}

/* Filter chips */
.nl-filter-chips {
  display: flex;
  flex-direction: row;
  gap: 8px;
  padding: 0 20px 12px;
  flex-shrink: 0;
  overflow-x: auto;
  scrollbar-width: none;
}

.nl-filter-chips::-webkit-scrollbar {
  display: none;
}

.nl-chip {
  height: 28px;
  border-radius: var(--nl-radius-full);
  font-size: 12px;
  font-weight: 500;
  padding: 0 12px;
  border: none;
  cursor: pointer;
  white-space: nowrap;
  transition: background var(--nl-transition-base), color var(--nl-transition-base);
  font-family: 'Inter', sans-serif;
  flex-shrink: 0;
}

.nl-chip.active {
  background: var(--nl-primary);
  color: white;
}

.nl-chip:not(.active) {
  background: #F1F5F9;
  color: var(--nl-text-tertiary);
}

.nl-chip:not(.active):hover {
  background: #E2E8F0;
  color: var(--nl-text-secondary);
}

/* Mail list */
#nl-mail-list {
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  flex: 1;
  scrollbar-width: thin;
  scrollbar-color: #E2E8F0 transparent;
}

#nl-mail-list::-webkit-scrollbar {
  width: 4px;
}

#nl-mail-list::-webkit-scrollbar-track {
  background: transparent;
}

#nl-mail-list::-webkit-scrollbar-thumb {
  background: #E2E8F0;
  border-radius: 2px;
}

/* Empty list state */
.nl-list-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 1;
  padding: 48px 24px;
  color: var(--nl-text-muted);
  text-align: center;
  gap: 8px;
}

.nl-list-empty svg {
  width: 48px;
  height: 48px;
  opacity: 0.4;
  margin-bottom: 4px;
}

.nl-list-empty p {
  font-size: 13px;
  font-weight: 500;
  color: var(--nl-text-tertiary);
}

/* Mail row */
.nl-mail-row {
  padding: 12px 20px;
  border-bottom: 1px solid #F1F5F9;
  cursor: pointer;
  position: relative;
  transition: background var(--nl-transition-base);
  display: grid;
  grid-template-columns: 36px 1fr auto;
  grid-template-rows: auto auto auto;
  column-gap: 10px;
  border-left: 3px solid transparent;
  user-select: none;
}

.nl-mail-row.unread {
  background: #FAFAFF;
  border-left-color: var(--nl-primary);
}

.nl-mail-row.selected {
  background: var(--nl-primary-light);
  border-left-color: var(--nl-primary);
}

.nl-mail-row:hover:not(.selected) {
  background: #F1F5F9;
}

.nl-mail-row.unread:hover:not(.selected) {
  background: #F4F1FD;
}

/* Avatar in row */
.nl-row-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  color: white;
  font-weight: 600;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  grid-row: 1 / 3;
  align-self: center;
  flex-shrink: 0;
}

/* Sender name */
.nl-row-sender {
  font-size: 14px;
  color: var(--nl-text-primary);
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  grid-column: 2;
  grid-row: 1;
  align-self: end;
  padding-right: 4px;
  padding-top: 2px;
}

.nl-mail-row.unread .nl-row-sender {
  font-weight: 600;
}

/* Time */
.nl-row-time {
  font-size: 12px;
  color: var(--nl-text-muted);
  text-align: right;
  grid-column: 3;
  grid-row: 1;
  align-self: end;
  white-space: nowrap;
  flex-shrink: 0;
  padding-top: 2px;
}

/* Subject */
.nl-row-subject {
  font-size: 13px;
  color: #374151;
  grid-column: 2 / 4;
  grid-row: 2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-weight: 400;
  padding-top: 1px;
}

.nl-mail-row.unread .nl-row-subject {
  font-weight: 600;
  color: var(--nl-text-primary);
}

/* Preview */
.nl-row-preview {
  font-size: 12px;
  color: var(--nl-text-muted);
  grid-column: 2 / 4;
  grid-row: 3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding-top: 2px;
}

/* Row quick actions */
.nl-row-actions {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  gap: 4px;
  background: #F1F5F9;
  border-radius: var(--nl-radius-sm);
  padding: 4px;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--nl-transition-base);
  z-index: 10;
  box-shadow: var(--nl-shadow-sm);
}

.nl-mail-row:hover .nl-row-actions {
  opacity: 1;
  pointer-events: all;
}

.nl-row-action-btn {
  width: 26px;
  height: 26px;
  border-radius: 4px;
  border: none;
  background: transparent;
  color: var(--nl-text-tertiary);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background var(--nl-transition-base), color var(--nl-transition-base);
}

.nl-row-action-btn:hover {
  background: white;
  color: var(--nl-text-primary);
}

.nl-row-action-btn.danger:hover {
  background: #FEF2F2;
  color: var(--nl-error);
}

.nl-row-action-btn svg {
  width: 14px;
  height: 14px;
}

/* ============================================================
   READING PANEL (#nl-reader)
   ============================================================ */

#nl-reader {
  background: white;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
}

/* Empty state */
#nl-reader-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  gap: 12px;
  color: var(--nl-text-muted);
}

#nl-reader-empty svg {
  width: 80px;
  height: 80px;
  color: #CBD5E1;
}

#nl-reader-empty h3 {
  font-size: 18px;
  font-weight: 600;
  color: #374151;
  margin-top: 8px;
}

#nl-reader-empty p {
  font-size: 14px;
  color: var(--nl-text-muted);
}

.nl-empty-compose-btn {
  margin-top: 8px;
  border: 1.5px solid var(--nl-primary);
  color: var(--nl-primary);
  background: transparent;
  border-radius: var(--nl-radius-md);
  padding: 10px 20px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background var(--nl-transition-base), color var(--nl-transition-base), transform var(--nl-transition-spring);
  font-family: 'Inter', sans-serif;
}

.nl-empty-compose-btn:hover {
  background: var(--nl-primary);
  color: white;
  transform: translateY(-1px);
}

/* Message content */
#nl-reader-content {
  display: none;
  flex-direction: column;
  overflow-y: auto;
  flex: 1;
  scrollbar-width: thin;
  scrollbar-color: #E2E8F0 transparent;
}

#nl-reader-content.visible {
  display: flex;
}

#nl-reader-content::-webkit-scrollbar {
  width: 6px;
}

#nl-reader-content::-webkit-scrollbar-thumb {
  background: #E2E8F0;
  border-radius: 3px;
}

/* Message header */
.nl-msg-header {
  padding: 32px 40px 20px;
  border-bottom: 1px solid var(--nl-border-subtle);
  flex-shrink: 0;
}

.nl-msg-subject {
  font-size: 22px;
  font-weight: 700;
  color: var(--nl-text-primary);
  margin-bottom: 16px;
  line-height: 1.3;
}

.nl-sender-card {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border: 1px solid var(--nl-border-subtle);
  border-radius: var(--nl-radius-lg);
  padding: 14px 16px;
}

.nl-sender-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.nl-sender-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  color: white;
  font-size: 16px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.nl-sender-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nl-sender-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--nl-text-primary);
}

.nl-sender-email {
  font-size: 13px;
  color: var(--nl-text-tertiary);
}

.nl-msg-date {
  font-size: 13px;
  color: var(--nl-text-muted);
  white-space: nowrap;
}

/* Action bar */
.nl-msg-actions {
  padding: 14px 40px;
  display: flex;
  gap: 8px;
  border-bottom: 1px solid var(--nl-border-subtle);
  flex-shrink: 0;
  align-items: center;
  flex-wrap: wrap;
}

.nl-action-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--nl-border);
  border-radius: var(--nl-radius-md);
  padding: 8px 16px;
  font-size: 14px;
  color: var(--nl-text-secondary);
  cursor: pointer;
  background: white;
  font-family: 'Inter', sans-serif;
  font-weight: 500;
  transition: background var(--nl-transition-base), border-color var(--nl-transition-base), transform var(--nl-transition-fast);
}

.nl-action-btn:hover {
  background: var(--nl-bg);
  border-color: #CBD5E1;
}

.nl-action-btn:active {
  transform: scale(0.98);
}

.nl-action-btn svg {
  width: 16px;
  height: 16px;
}

.nl-action-btn.danger {
  color: var(--nl-error);
  margin-left: auto;
}

.nl-action-btn.danger:hover {
  background: #FEF2F2;
  border-color: #FECACA;
}

.nl-action-btn.primary {
  background: var(--nl-primary);
  color: white;
  border-color: var(--nl-primary);
}

.nl-action-btn.primary:hover {
  background: var(--nl-primary-hover);
  border-color: var(--nl-primary-hover);
}

/* Message body */
.nl-msg-body {
  padding: 24px 40px 40px;
  flex: 1;
}

.nl-msg-body-inner {
  font-size: 15px;
  line-height: 1.8;
  color: #374151;
  max-width: 720px;
}

.nl-msg-body-inner a {
  color: var(--nl-primary);
  text-decoration: none;
}

.nl-msg-body-inner a:hover {
  text-decoration: underline;
}

.nl-msg-body-inner p {
  margin-bottom: 16px;
}

.nl-msg-body-inner blockquote {
  border-left: 3px solid var(--nl-border);
  padding-left: 16px;
  color: var(--nl-text-muted);
  font-style: italic;
  margin: 16px 0;
}

/* Message iframe */
#nl-reader-body {
  flex: 1;
  min-height: 300px;
}

#nl-reader-body iframe {
  width: 100%;
  height: 100%;
  border: none;
  min-height: 400px;
}

/* ============================================================
   COMPOSER MODAL (#nl-composer)
   ============================================================ */

#nl-composer {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: 9999;
  display: none;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

#nl-composer.open {
  display: flex;
  animation: nl-overlay-in 0.2s ease;
}

@keyframes nl-overlay-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

.nl-composer-modal {
  width: 680px;
  max-width: calc(100vw - 48px);
  max-height: 80vh;
  background: white;
  border-radius: var(--nl-radius-xl);
  box-shadow: var(--nl-shadow-composer);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: nl-modal-in 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  position: relative;
}

@keyframes nl-modal-in {
  from {
    opacity: 0;
    transform: translateY(16px) scale(0.97);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* Composer header */
.nl-composer-header {
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--nl-border-subtle);
  flex-shrink: 0;
  cursor: grab;
}

.nl-composer-header:active {
  cursor: grabbing;
}

.nl-composer-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--nl-text-primary);
}

.nl-composer-close {
  width: 28px;
  height: 28px;
  border-radius: var(--nl-radius-sm);
  border: none;
  background: transparent;
  color: var(--nl-text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background var(--nl-transition-base), color var(--nl-transition-base);
}

.nl-composer-close:hover {
  background: var(--nl-border-subtle);
  color: var(--nl-text-secondary);
}

.nl-composer-close svg {
  width: 16px;
  height: 16px;
}

/* Composer fields */
.nl-composer-field {
  display: flex;
  align-items: center;
  border-bottom: 1px solid var(--nl-border-subtle);
  padding: 0 20px;
  height: 48px;
  flex-shrink: 0;
}

.nl-composer-field label {
  font-size: 11px;
  font-weight: 600;
  color: var(--nl-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  width: 52px;
  flex-shrink: 0;
}

.nl-composer-field input {
  flex: 1;
  border: none;
  outline: none;
  font-size: 14px;
  color: var(--nl-text-primary);
  background: transparent;
  font-family: 'Inter', sans-serif;
}

.nl-composer-field input::placeholder {
  color: var(--nl-text-muted);
}

.nl-composer-cc-toggle {
  font-size: 12px;
  color: var(--nl-primary);
  cursor: pointer;
  margin-left: auto;
  font-weight: 500;
  user-select: none;
  padding: 4px 8px;
  border-radius: 4px;
  transition: background var(--nl-transition-base);
}

.nl-composer-cc-toggle:hover {
  background: var(--nl-primary-ghost);
}

.nl-composer-cc-row {
  display: none;
}

.nl-composer-cc-row.visible {
  display: flex;
}

/* Composer body */
.nl-composer-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

.nl-composer-textarea {
  flex: 1;
  border: none;
  outline: none;
  padding: 20px;
  font-size: 15px;
  line-height: 1.8;
  color: #374151;
  resize: none;
  font-family: 'Inter', sans-serif;
  background: white;
  min-height: 180px;
}

.nl-composer-textarea::placeholder {
  color: var(--nl-text-muted);
}

/* Composer footer */
.nl-composer-footer {
  padding: 12px 20px;
  border-top: 1px solid var(--nl-border-subtle);
  display: flex;
  align-items: center;
  gap: 8px;
  background: #F8FAFC;
  flex-shrink: 0;
}

.nl-send-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--nl-primary);
  color: white;
  border-radius: var(--nl-radius-md);
  padding: 10px 24px;
  font-size: 14px;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: background var(--nl-transition-base), transform var(--nl-transition-spring);
  font-family: 'Inter', sans-serif;
}

.nl-send-btn:hover {
  background: var(--nl-primary-hover);
  transform: translateY(-1px);
}

.nl-send-btn:active {
  transform: translateY(0) scale(0.98);
}

.nl-send-btn svg {
  width: 16px;
  height: 16px;
}

.nl-composer-tool-btn {
  width: 36px;
  height: 36px;
  border-radius: var(--nl-radius-sm);
  color: var(--nl-text-muted);
  background: transparent;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background var(--nl-transition-base), color var(--nl-transition-base);
}

.nl-composer-tool-btn:hover {
  background: #F1F5F9;
  color: var(--nl-text-secondary);
}

.nl-composer-tool-btn svg {
  width: 18px;
  height: 18px;
}

.nl-composer-spacer {
  flex: 1;
}

/* Sending state */
.nl-send-btn.sending {
  opacity: 0.8;
  pointer-events: none;
}

.nl-send-btn.sending::after {
  content: '';
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: nl-spin 0.7s linear infinite;
  margin-left: 4px;
}

/* ============================================================
   NOTIFICATIONS
   ============================================================ */

#nl-notifications {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 10000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.nl-toast {
  background: #0F172A;
  color: white;
  border-radius: var(--nl-radius-lg);
  padding: 14px 18px;
  font-size: 13px;
  font-weight: 500;
  max-width: 360px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
  border-left: 3px solid var(--nl-primary);
  pointer-events: all;
  animation: nl-toast-in 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  line-height: 1.5;
}

.nl-toast.success {
  border-left-color: var(--nl-success);
}

.nl-toast.error {
  border-left-color: var(--nl-error);
}

.nl-toast.warning {
  border-left-color: var(--nl-warning);
}

.nl-toast.nl-toast-out {
  animation: nl-toast-out 0.25s ease forwards;
}

@keyframes nl-toast-in {
  from {
    opacity: 0;
    transform: translateX(20px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateX(0) scale(1);
  }
}

@keyframes nl-toast-out {
  from {
    opacity: 1;
    transform: translateX(0) scale(1);
    max-height: 80px;
    margin-bottom: 0;
  }
  to {
    opacity: 0;
    transform: translateX(20px) scale(0.95);
    max-height: 0;
    padding: 0;
    margin-bottom: -8px;
  }
}

/* ============================================================
   LOGIN PAGE
   ============================================================ */

body.task-login {
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #0F172A 0%, #1E1B4B 100%);
  overflow: hidden;
}

body.task-login::before {
  content: '';
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse 800px 600px at 20% 50%, rgba(124, 58, 237, 0.08) 0%, transparent 60%),
    radial-gradient(ellipse 600px 400px at 80% 20%, rgba(99, 102, 241, 0.06) 0%, transparent 60%);
  pointer-events: none;
}

#nl-login-wrap {
  position: relative;
  z-index: 1;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.nl-login-card {
  width: 440px;
  max-width: 100%;
  background: white;
  border-radius: var(--nl-radius-2xl);
  padding: 48px;
  box-shadow: 0 25px 50px rgba(0, 0, 0, 0.35), 0 0 0 1px rgba(255, 255, 255, 0.05);
  animation: nl-card-in 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes nl-card-in {
  from {
    opacity: 0;
    transform: translateY(24px) scale(0.96);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.nl-login-logo {
  text-align: center;
  margin-bottom: 32px;
}

.nl-login-logo-mark {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.nl-login-logo-icon {
  width: 44px;
  height: 44px;
  background: var(--nl-primary);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.nl-login-logo-icon svg {
  width: 24px;
  height: 24px;
  color: white;
}

.nl-login-brand {
  font-size: 26px;
  font-weight: 700;
  color: var(--nl-primary);
  letter-spacing: -0.5px;
}

.nl-login-title {
  font-size: 28px;
  font-weight: 700;
  color: var(--nl-text-primary);
  margin-bottom: 8px;
  letter-spacing: -0.5px;
}

.nl-login-subtitle {
  font-size: 14px;
  color: var(--nl-text-tertiary);
  margin-bottom: 32px;
}

.nl-login-field {
  margin-bottom: 16px;
}

.nl-login-field label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: #374151;
  margin-bottom: 8px;
}

.nl-login-field input {
  width: 100%;
  height: 48px;
  border: 1.5px solid var(--nl-border);
  border-radius: 10px;
  padding: 0 16px;
  font-size: 15px;
  color: var(--nl-text-primary);
  font-family: 'Inter', sans-serif;
  outline: none;
  background: white;
  transition: border-color var(--nl-transition-base), box-shadow var(--nl-transition-base);
}

.nl-login-field input:focus {
  border-color: var(--nl-primary);
  box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.2);
}

.nl-login-field input::placeholder {
  color: var(--nl-text-muted);
}

.nl-login-submit {
  width: 100%;
  height: 52px;
  background: var(--nl-primary);
  color: white;
  border-radius: 10px;
  font-size: 16px;
  font-weight: 600;
  border: none;
  cursor: pointer;
  margin-top: 24px;
  font-family: 'Inter', sans-serif;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: background var(--nl-transition-base), transform var(--nl-transition-spring);
}

.nl-login-submit:hover {
  background: var(--nl-primary-hover);
  transform: translateY(-1px);
}

.nl-login-submit:active {
  transform: translateY(0);
}

.nl-login-submit.loading {
  opacity: 0.85;
  pointer-events: none;
}

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

.nl-login-error {
  display: none;
  background: #FEF2F2;
  border: 1px solid #FECACA;
  border-radius: var(--nl-radius-md);
  padding: 12px 16px;
  font-size: 13px;
  color: #DC2626;
  margin-top: 16px;
  font-weight: 500;
}

.nl-login-error.visible {
  display: block;
  animation: nl-shake 0.3s ease;
}

@keyframes nl-shake {
  0%, 100% { transform: translateX(0); }
  20%       { transform: translateX(-6px); }
  40%       { transform: translateX(6px); }
  60%       { transform: translateX(-4px); }
  80%       { transform: translateX(4px); }
}

.nl-login-footer {
  margin-top: 24px;
  text-align: center;
  font-size: 12px;
  color: var(--nl-text-muted);
}

/* ============================================================
   RESPONSIVE
   ============================================================ */

@media (max-width: 900px) {
  #netlife-app {
    grid-template-columns: var(--nl-nav-width) 1fr;
  }

  #nl-list {
    display: none;
  }

  #nl-list.mobile-visible {
    display: flex;
    position: fixed;
    left: var(--nl-nav-width);
    top: 0;
    bottom: 0;
    z-index: 50;
    box-shadow: var(--nl-shadow-xl);
    width: 280px;
  }
}

@media (max-width: 600px) {
  #netlife-app {
    grid-template-columns: 1fr;
  }

  #nl-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    top: auto;
    width: 100%;
    height: 64px;
    flex-direction: row;
    justify-content: space-around;
    padding: 0 16px;
    z-index: 100;
  }

  .nl-logo {
    display: none;
  }

  .nl-nav-icons {
    flex-direction: row;
    margin-top: 0;
    gap: 0;
    justify-content: space-around;
  }

  .nl-nav-bottom {
    flex-direction: row;
    padding: 0;
  }

  .nl-compose-btn {
    margin-top: 0;
  }

  .nl-nav-item::after,
  .nl-compose-btn::after,
  .nl-nav-settings::after,
  .nl-user-avatar::after {
    display: none;
  }

  .nl-composer-modal {
    width: 100%;
    max-width: 100%;
    max-height: 95vh;
    border-radius: var(--nl-radius-xl) var(--nl-radius-xl) 0 0;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    margin: 0;
  }
}

/* ============================================================
   UTILITY ANIMATIONS
   ============================================================ */

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

.nl-animate-in {
  animation: nl-fade-in 0.2s ease both;
}

/* Row stagger */
.nl-mail-row:nth-child(1)  { animation-delay: 0ms; }
.nl-mail-row:nth-child(2)  { animation-delay: 30ms; }
.nl-mail-row:nth-child(3)  { animation-delay: 60ms; }
.nl-mail-row:nth-child(4)  { animation-delay: 90ms; }
.nl-mail-row:nth-child(5)  { animation-delay: 120ms; }
.nl-mail-row:nth-child(6)  { animation-delay: 150ms; }
.nl-mail-row:nth-child(7)  { animation-delay: 180ms; }
.nl-mail-row:nth-child(8)  { animation-delay: 210ms; }

/* ============================================================
   SCROLLBAR GLOBAL
   ============================================================ */

* {
  scrollbar-width: thin;
  scrollbar-color: #E2E8F0 transparent;
}

*::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

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

*::-webkit-scrollbar-thumb {
  background: #E2E8F0;
  border-radius: 3px;
}

*::-webkit-scrollbar-thumb:hover {
  background: #CBD5E1;
}
