/* =================================================================
   Nepamail — Copilot canvas × nepal.gov.np sky palette.
   Soft sky-gradient body, frosted-glass panels, pill controls,
   crimson sovereign accent, gold (saffron) secondary, all on
   Inter/Segoe with the same Outlook 3-pane layout underneath.
   ================================================================= */

:root {
  /* nepal.gov.np sky tones */
  --sky-0:        #6f9fd6;
  --sky-1:        #97bdea;
  --sky-2:        #c2dbf6;
  --sky-3:        #e9f3fe;
  --sky-ink:      #15325b;
  --sky-ink-2:    #4a5e7e;
  --sky-ink-3:    #7f8fa8;

  /* Sovereign accents (Nepal flag + emblem palette) */
  --crimson:      #9d0f2c;
  --crimson-deep: #6e0a1f;
  --crimson-soft: rgba(220, 20, 60, 0.08);
  --crimson-glow: rgba(220, 20, 60, 0.18);
  --saffron:      #9a6f12;
  --saffron-soft: rgba(154, 111, 18, 0.10);
  --aurora:       rgba(120, 165, 225, 0.55);

  /* Surfaces — frosted glass over the sky background */
  --np-bg-card:        rgba(255, 255, 255, 0.82);
  --np-glass:          rgba(255, 255, 255, 0.62);
  --np-glass-strong:   rgba(255, 255, 255, 0.92);
  --np-tile:           rgba(255, 255, 255, 0.46);
  --np-tile-hover:     rgba(255, 255, 255, 0.72);
  --np-border:         rgba(21, 50, 91, 0.10);
  --np-border-strong:  rgba(21, 50, 91, 0.20);
  --np-divider:        rgba(21, 50, 91, 0.06);

  /* Text */
  --np-text:           #15325b;
  --np-text-2:         #4a5e7e;
  --np-text-3:         #7f8fa8;
  --np-text-on-dark:   #F0EDE8;

  /* Status */
  --np-success:        #1B7F3A;
  --np-info:           #0078D4;
  --np-warning:        #C46A1F;
  --np-danger:         #A4262C;

  /* Layout */
  --np-topbar-h:       56px;
  --np-rail-w:         260px;
  --np-list-w:         400px;
  --np-radius:         10px;
  --np-radius-lg:      18px;
  --np-radius-pill:    999px;

  --np-shadow-1: 0 1px 3px rgba(15, 40, 90, 0.06), 0 1px 2px rgba(15, 40, 90, 0.04);
  --np-shadow-2: 0 6px 24px rgba(15, 40, 90, 0.10), 0 2px 6px rgba(15, 40, 90, 0.06);
  --np-shadow-3: 0 24px 60px rgba(15, 40, 90, 0.18), 0 6px 16px rgba(15, 40, 90, 0.12);
  --np-glow:     0 0 0 4px rgba(220, 20, 60, 0.15);

  --np-font: "Segoe UI", "Segoe UI Web (West European)",
             -apple-system, BlinkMacSystemFont, "Inter", "Roboto",
             "Helvetica Neue", Arial, sans-serif;
  --np-font-display: "Inter", "Segoe UI", system-ui, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0;
  font-family: var(--np-font);
  font-size: 14px;
  color: var(--np-text);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Sky background (matches nepal.gov.np .sky):
   soft radial sky-blue glow top-right + faint crimson kiss bottom-left,
   over a vertical sky gradient from pale at top to mid-sky at bottom. */
body {
  min-height: 100vh;
  background:
    radial-gradient(1200px 620px at 72% -12%, rgba(0, 56, 147, 0.45), transparent 60%),
    radial-gradient(900px 520px at 14% 4%, rgba(220, 20, 60, 0.10), transparent 55%),
    linear-gradient(180deg, var(--sky-3) 0%, var(--sky-2) 35%, var(--sky-1) 100%);
  background-attachment: fixed;
}

a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
code {
  font-family: 'SF Mono', Consolas, 'Liberation Mono', Menlo, monospace;
  font-size: 0.92em;
  background: rgba(21, 50, 91, 0.06);
  padding: 1px 6px;
  border-radius: 4px;
  color: var(--sky-ink);
}

.brand-accent { color: var(--crimson); }

/* =================================================================
   LOGIN SCREEN — deep sky to crimson gradient, frosted card
   ================================================================= */
.login-shell {
  min-height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr auto;
  padding: 32px;
  background:
    radial-gradient(1100px 600px at 78% 10%, rgba(220, 20, 60, 0.22), transparent 60%),
    radial-gradient(900px 520px at 16% 14%, rgba(120, 165, 225, 0.45), transparent 55%),
    linear-gradient(180deg, #0b1d3d 0%, #15325b 55%, #1f2540 100%);
  color: #F0EDE8;
}

.login-brand {
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  padding-top: 24px;
}
.login-emblem {
  width: 96px; height: 96px; object-fit: contain;
  filter: drop-shadow(0 8px 30px rgba(220, 20, 60, 0.45));
}
.login-wordmark {
  font-size: 44px; font-weight: 800; letter-spacing: -1px;
  margin-top: 12px;
}
.login-tagline {
  font-size: 12px; letter-spacing: 5px;
  color: rgba(255, 255, 255, 0.65);
  text-transform: uppercase;
}

.login-card {
  align-self: center; justify-self: center;
  width: min(440px, 100%);
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(20px);
  color: var(--np-text);
  border-radius: var(--np-radius-lg);
  padding: 40px 36px 32px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.45);
  border: 1px solid rgba(255, 255, 255, 0.4);
}
.login-title { margin: 0 0 6px; font-weight: 700; font-size: 26px; }
.login-sub { margin: 0 0 24px; color: var(--np-text-2); font-size: 13px; }
.login-label {
  display: block; font-size: 12px; font-weight: 600;
  color: var(--np-text-2); margin: 14px 0 6px;
  letter-spacing: 0.5px;
}
.login-input {
  width: 100%; padding: 12px 14px;
  border: 1px solid var(--np-border);
  border-radius: var(--np-radius);
  font-size: 14px; font-family: inherit;
  background: #fff;
  transition: border-color 120ms, box-shadow 120ms;
}
.login-input:focus {
  outline: none;
  border-color: var(--crimson);
  box-shadow: 0 0 0 3px rgba(220, 20, 60, 0.15);
}
.login-error {
  margin: 12px 0 0;
  padding: 10px 12px; border-radius: var(--np-radius);
  background: #FDE7E9; color: var(--np-danger);
  font-size: 13px;
  border: 1px solid #F1707B;
}
.login-submit {
  margin-top: 24px;
  width: 100%; padding: 13px 18px;
  background: linear-gradient(135deg, var(--crimson) 0%, #DC143C 100%);
  color: #fff;
  border: none; border-radius: var(--np-radius-pill);
  font-weight: 600; font-size: 14px;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  box-shadow: 0 8px 20px rgba(157, 15, 44, 0.30);
  transition: transform 80ms, box-shadow 120ms, filter 120ms;
}
.login-submit:hover { filter: brightness(1.08); box-shadow: 0 12px 28px rgba(157, 15, 44, 0.42); }
.login-submit:active { transform: translateY(1px); }
.login-footer {
  margin-top: 22px; font-size: 12px;
  color: var(--np-text-3); line-height: 1.6; text-align: center;
}
.login-bottom {
  text-align: center; font-size: 12px; color: rgba(255, 255, 255, 0.6);
  padding: 16px 0 0;
}
.login-bottom a { text-decoration: underline; }
.login-bottom .dot { margin: 0 6px; }

/* =================================================================
   TOP BAR — frosted gradient with sovereign accent line
   ================================================================= */
.topbar {
  position: sticky; top: 0;
  height: var(--np-topbar-h);
  background:
    linear-gradient(90deg, rgba(11, 29, 61, 0.94) 0%, rgba(21, 50, 91, 0.94) 55%, rgba(110, 10, 31, 0.92) 100%);
  backdrop-filter: blur(20px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.10);
  color: #fff;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  padding: 0 12px;
  z-index: 80;
  box-shadow: 0 1px 12px rgba(15, 40, 90, 0.18);
}
/* Thin saffron line at the bottom of the top bar for sovereign signal */
.topbar::after {
  content: ''; position: absolute; left: 0; right: 0; bottom: -2px;
  height: 2px;
  background: linear-gradient(90deg, var(--crimson), var(--saffron), var(--crimson));
  opacity: 0.5;
}
.topbar-left { display: flex; align-items: center; gap: 8px; }
.waffle {
  width: 44px; height: 44px;
  background: transparent; color: #fff; border: none;
  border-radius: var(--np-radius);
  display: inline-flex; align-items: center; justify-content: center;
  transition: background 100ms;
}
.waffle:hover { background: rgba(255, 255, 255, 0.13); }

.topbar-brand { display: flex; align-items: center; gap: 12px; padding: 0 4px; }
.topbar-emblem {
  width: 32px; height: 32px; object-fit: contain;
  filter: drop-shadow(0 2px 6px rgba(0, 0, 0, 0.35));
}
.topbar-wordmark {
  font-size: 18px; font-weight: 700; letter-spacing: -0.5px;
  color: #fff;
}
.topbar-wordmark .brand-accent { color: #ff9a8a; }

.topbar-search {
  position: relative; max-width: 720px;
  margin: 0 16px; justify-self: center;
  width: 100%;
}
.topbar-search-icon {
  position: absolute; left: 16px; top: 50%;
  transform: translateY(-50%);
  color: var(--np-text-3);
}
.topbar-search input {
  width: 100%; height: 42px;
  padding: 0 16px 0 44px;
  border: none; border-radius: var(--np-radius-pill);
  background: rgba(255, 255, 255, 0.95);
  color: var(--np-text);
  font-family: inherit; font-size: 14px;
  transition: box-shadow 120ms;
}
.topbar-search input:focus {
  outline: none;
  background: #fff;
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.35);
}

.topbar-right { display: flex; align-items: center; gap: 4px; }
.iconbtn {
  width: 44px; height: 44px;
  background: transparent; color: #fff; border: none;
  border-radius: var(--np-radius);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 16px;
  transition: background 100ms;
}
.iconbtn:hover { background: rgba(255, 255, 255, 0.13); }

.account {
  width: 44px; height: 44px;
  background: transparent; border: none; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  margin-left: 4px;
}
.account-avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: linear-gradient(135deg, #ff9a8a 0%, var(--crimson) 100%);
  color: #fff;
  font-weight: 700; font-size: 13px;
  display: inline-flex; align-items: center; justify-content: center;
  box-shadow: 0 2px 8px rgba(157, 15, 44, 0.35);
}

/* =================================================================
   WAFFLE LAUNCHER — frosted card, Copilot-style tiles
   ================================================================= */
.waffle-menu {
  position: absolute; top: calc(var(--np-topbar-h) + 6px); left: 12px;
  width: 360px;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(24px);
  border: 1px solid var(--np-border);
  border-radius: var(--np-radius-lg);
  box-shadow: var(--np-shadow-3);
  z-index: 100;
  padding: 18px;
}
.waffle-header {
  font-size: 11px; font-weight: 700; letter-spacing: 2px;
  text-transform: uppercase; color: var(--np-text-3);
  padding: 4px 6px 14px;
}
.waffle-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}
.waffle-app {
  display: flex; flex-direction: column; align-items: center;
  padding: 16px 8px; border-radius: var(--np-radius);
  color: var(--np-text);
  transition: background 120ms, transform 80ms;
  position: relative;
}
.waffle-app:hover {
  background: var(--np-tile-hover);
  transform: translateY(-1px);
}
.waffle-app.active::after {
  content: ''; position: absolute; bottom: 6px; height: 3px;
  width: 24px; left: 50%; transform: translateX(-50%);
  background: var(--crimson); border-radius: 2px;
}
.waffle-icon {
  width: 48px; height: 48px; border-radius: 12px;
  display: inline-flex; align-items: center; justify-content: center;
  color: #fff;
  box-shadow: 0 4px 12px rgba(15, 40, 90, 0.14);
}
.waffle-icon.mail        { background: linear-gradient(135deg, var(--crimson) 0%, #DC143C 100%); }
.waffle-icon.calendar    { background: linear-gradient(135deg, #2B5797 0%, #0078D4 100%); }
.waffle-icon.contacts    { background: linear-gradient(135deg, #1B7F3A 0%, #4CAF50 100%); }
.waffle-icon.people      { background: linear-gradient(135deg, #5C2D91 0%, #8B5CF6 100%); }
.waffle-icon.nepaconnect { background: linear-gradient(135deg, #15325b 0%, #4a5e7e 100%); }
.waffle-icon.admin       { background: linear-gradient(135deg, var(--saffron) 0%, #C49A2F 100%); }
.waffle-label { margin-top: 10px; font-size: 12.5px; font-weight: 500; }
.waffle-footer {
  margin-top: 16px; padding: 14px 6px 4px;
  border-top: 1px solid var(--np-divider);
  font-size: 11px; color: var(--np-text-3); text-align: center;
}

.admin-only, .admin-only-soft { display: none; }
body.role-admin .admin-only { display: flex; }
body.role-admin .admin-only-soft { display: block; }
.rail-item.admin-only-soft { display: none; }
body.role-admin .rail-item.admin-only-soft { display: flex; }

/* =================================================================
   MAIN — three-pane Outlook layout, transparent over the sky
   ================================================================= */
.main {
  display: grid;
  grid-template-columns: var(--np-rail-w) var(--np-list-w) 1fr;
  height: calc(100vh - var(--np-topbar-h));
  background: transparent;
  gap: 12px;
  padding: 12px;
}

/* ---------------- LEFT RAIL (frosted) ---------------- */
.rail {
  background: var(--np-glass);
  backdrop-filter: blur(24px);
  border: 1px solid var(--np-border);
  border-radius: var(--np-radius-lg);
  padding: 14px 10px;
  overflow-y: auto;
  box-shadow: var(--np-shadow-1);
}
.rail-compose {
  width: 100%;
  background: linear-gradient(135deg, var(--crimson) 0%, #DC143C 100%);
  color: #fff; border: none;
  border-radius: var(--np-radius-pill);
  padding: 12px 16px;
  font-weight: 600; font-size: 14px;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  margin-bottom: 14px;
  box-shadow: 0 6px 18px rgba(157, 15, 44, 0.28);
  transition: filter 120ms, transform 80ms;
}
.rail-compose:hover { filter: brightness(1.08); transform: translateY(-1px); }
.rail-compose:active { transform: translateY(0); }

.rail-section {
  font-size: 11px; letter-spacing: 1.5px; text-transform: uppercase;
  color: var(--np-text-3); font-weight: 700;
  padding: 14px 12px 6px;
}
.rail-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px;
  border-radius: var(--np-radius);
  font-size: 13.5px; cursor: pointer;
  color: var(--np-text);
  transition: background 100ms;
}
.rail-item:hover { background: var(--np-tile-hover); }
.rail-item.active {
  background: var(--crimson-soft);
  color: var(--crimson-deep);
  font-weight: 600;
}
.rail-icon { width: 16px; height: 16px; color: var(--np-text-2); }
.rail-item.active .rail-icon { color: var(--crimson); }
.rail-badge {
  margin-left: auto;
  font-size: 11px; font-weight: 700;
  background: var(--crimson); color: #fff;
  padding: 2px 8px; border-radius: var(--np-radius-pill);
  min-width: 18px; text-align: center;
}
.rail-badge:empty { display: none; }
.rail-section-admin {
  margin-top: 12px;
  border-top: 1px solid var(--np-divider);
}

/* ---------------- MESSAGE LIST (frosted) ---------------- */
.list {
  background: var(--np-bg-card);
  backdrop-filter: blur(20px);
  border: 1px solid var(--np-border);
  border-radius: var(--np-radius-lg);
  display: flex; flex-direction: column;
  min-width: 0;
  box-shadow: var(--np-shadow-1);
  overflow: hidden;
}
.list-head {
  padding: 18px 18px 10px;
  border-bottom: 1px solid var(--np-divider);
}
.list-head h2 {
  margin: 0 0 8px;
  font-size: 19px; font-weight: 700;
  color: var(--np-text);
  font-family: var(--np-font-display);
}
.list-filters { display: flex; gap: 16px; font-size: 13px; }
.list-filter {
  background: transparent; border: none;
  color: var(--np-text-2); padding: 4px 0;
  font-weight: 500; position: relative;
  transition: color 100ms;
}
.list-filter.active { color: var(--crimson); font-weight: 600; }
.list-filter.active::after {
  content: ''; position: absolute; left: 0; right: 0; bottom: -8px;
  height: 2px; background: var(--crimson); border-radius: 1px;
}

.list-items { flex: 1; overflow-y: auto; padding: 6px; }
.list-item {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 12px; padding: 12px;
  border-radius: var(--np-radius);
  cursor: pointer;
  margin-bottom: 2px;
  transition: background 100ms;
}
.list-item:hover { background: var(--np-tile-hover); }
.list-item.selected {
  background: var(--crimson-soft);
  border-left: 3px solid var(--crimson);
  padding-left: 9px;
}
.list-avatar {
  width: 38px; height: 38px; border-radius: 50%;
  background: var(--np-info); color: #fff;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700;
  box-shadow: 0 2px 6px rgba(15, 40, 90, 0.20);
}
.list-meta { min-width: 0; }
.list-meta-line1 {
  display: flex; align-items: baseline; justify-content: space-between;
  margin-bottom: 2px;
}
.list-meta-from { font-weight: 600; font-size: 13.5px; color: var(--np-text); }
.list-meta-time { color: var(--np-text-3); font-size: 11px; }
.list-meta-subject {
  font-size: 13px; color: var(--np-text); margin-bottom: 2px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.list-meta-preview {
  font-size: 12.5px; color: var(--np-text-3);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.list-item.unread .list-meta-from,
.list-item.unread .list-meta-subject { font-weight: 700; }
.list-side { display: flex; flex-direction: column; align-items: end; gap: 4px; }
.list-tag {
  font-size: 10px; font-weight: 700; letter-spacing: 0.6px;
  text-transform: uppercase;
  padding: 2px 7px; border-radius: var(--np-radius-pill);
}
.list-tag-encrypted { background: rgba(27, 127, 58, 0.14); color: var(--np-success); }
.list-tag-attach   { background: rgba(0, 120, 212, 0.12); color: var(--np-info); }

/* ---------------- READING PANE ---------------- */
.reader {
  background: var(--np-bg-card);
  backdrop-filter: blur(20px);
  border: 1px solid var(--np-border);
  border-radius: var(--np-radius-lg);
  overflow-y: auto;
  box-shadow: var(--np-shadow-1);
}
.reader-empty {
  height: 100%;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  color: var(--np-text-2);
  padding: 32px;
}
.reader-empty-emblem { width: 96px; height: 96px; opacity: 0.45; margin-bottom: 16px; }
.reader-empty h3 { font-weight: 700; margin: 0; color: var(--np-text); }
.reader-empty p { margin-top: 8px; font-size: 13px; }

.reader-content { min-height: 100%; }
.reader-head { padding: 24px 32px; border-bottom: 1px solid var(--np-divider); }
.reader-subject {
  font-size: 24px; font-weight: 700; margin: 0 0 12px;
  font-family: var(--np-font-display);
  color: var(--np-text);
}
.reader-meta { display: flex; gap: 14px; align-items: center; }
.reader-avatar {
  width: 42px; height: 42px; border-radius: 50%;
  background: var(--np-info); color: #fff;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 14px; font-weight: 700;
}
.reader-meta-info { flex: 1; }
.reader-meta-from { font-weight: 600; font-size: 14px; }
.reader-meta-date { font-size: 12px; color: var(--np-text-3); }
.reader-meta-to   { font-size: 12px; color: var(--np-text-2); margin-top: 2px; }

.reader-actions {
  padding: 12px 24px; border-bottom: 1px solid var(--np-divider);
  display: flex; gap: 6px;
  background: rgba(255, 255, 255, 0.50);
}
.reader-action {
  background: transparent; border: none;
  padding: 8px 14px; border-radius: var(--np-radius-pill);
  font-size: 13px; font-weight: 500;
  display: inline-flex; align-items: center; gap: 6px;
  color: var(--np-text);
  transition: background 100ms;
}
.reader-action:hover { background: var(--np-tile-hover); }
.reader-action.primary {
  background: linear-gradient(135deg, var(--crimson) 0%, #DC143C 100%);
  color: #fff;
  box-shadow: 0 4px 12px rgba(157, 15, 44, 0.25);
}
.reader-action.primary:hover { filter: brightness(1.08); }

.reader-body {
  padding: 28px 32px; font-size: 14.5px; line-height: 1.7;
  color: var(--np-text); max-width: 760px;
}
.reader-body p { margin: 0 0 14px; }

/* =================================================================
   COMPOSE MODAL — Copilot-style frosted floating dock
   ================================================================= */
.compose-shell {
  position: fixed; right: 24px; bottom: 0;
  width: min(720px, calc(100vw - 48px));
  z-index: 200;
}
.compose {
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(24px);
  border: 1px solid var(--np-border);
  border-bottom: none;
  border-radius: var(--np-radius-lg) var(--np-radius-lg) 0 0;
  box-shadow: var(--np-shadow-3);
  overflow: hidden;
  max-height: calc(100vh - 32px);
  display: flex; flex-direction: column;
}
.compose-head {
  display: flex; align-items: center; justify-content: space-between;
  background:
    linear-gradient(90deg, rgba(11, 29, 61, 0.94), rgba(110, 10, 31, 0.92));
  color: #fff;
  padding: 8px 8px 8px 18px;
}
.compose-title {
  display: flex; align-items: center; gap: 8px;
  font-weight: 600; font-size: 14px;
}
.compose-actions-top .iconbtn { width: 32px; height: 32px; color: #fff; }

.compose-fields {
  padding: 10px 18px 0;
  border-bottom: 1px solid var(--np-divider);
}
.compose-row {
  display: grid; grid-template-columns: 70px 1fr;
  align-items: center; gap: 12px;
  padding: 7px 0;
  border-bottom: 1px solid var(--np-divider);
}
.compose-row:last-child { border-bottom: none; }
.compose-row label {
  font-size: 12.5px; font-weight: 600;
  color: var(--np-text-2);
  letter-spacing: 0.3px;
}
.compose-row input {
  border: none; padding: 6px 0;
  font-size: 14px; font-family: inherit;
  background: transparent;
  color: var(--np-text);
}
.compose-row input:focus { outline: none; }
.compose-from {
  font-size: 14px;
  color: var(--np-text);
  font-weight: 500;
}

/* ===== Shinga AI BAR — Copilot purple/midnight ===== */
.ai-bar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px;
  padding: 12px 16px;
  background: linear-gradient(90deg, #2A2540 0%, #1F1D40 50%, #2A1B40 100%);
  color: #F0EDE8;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}
.ai-bar-title {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 11px; font-weight: 700; letter-spacing: 1.5px;
  text-transform: uppercase; color: #C9C2EE;
  margin-right: 8px;
}
.ai-action {
  background: rgba(255, 255, 255, 0.08);
  color: #F0EDE8;
  border: 1px solid rgba(201, 194, 238, 0.25);
  padding: 6px 12px; border-radius: var(--np-radius-pill);
  font-size: 12.5px; font-weight: 500;
  display: inline-flex; align-items: center; gap: 6px;
  transition: background 100ms, border-color 100ms;
}
.ai-action:hover {
  background: rgba(201, 194, 238, 0.18);
  border-color: rgba(201, 194, 238, 0.5);
}
.ai-bar-locale {
  margin-left: auto;
  font-size: 11px; color: rgba(201, 194, 238, 0.6);
}

.compose-body {
  flex: 1; min-height: 220px;
  padding: 18px;
  border: none; resize: none;
  font-family: inherit; font-size: 14.5px; line-height: 1.65;
  color: var(--np-text);
  background: transparent;
}
.compose-body:focus { outline: none; }

.compose-foot {
  display: flex; align-items: center; gap: 6px;
  padding: 12px 16px;
  border-top: 1px solid var(--np-divider);
  background: rgba(255, 255, 255, 0.50);
}
.compose-send {
  background: linear-gradient(135deg, var(--crimson) 0%, #DC143C 100%);
  color: #fff; border: none;
  padding: 9px 20px; border-radius: var(--np-radius-pill);
  display: inline-flex; align-items: center; gap: 6px;
  font-weight: 600; font-size: 13.5px;
  box-shadow: 0 4px 12px rgba(157, 15, 44, 0.30);
  transition: filter 120ms;
}
.compose-send:hover { filter: brightness(1.08); }
.compose-send:disabled {
  opacity: 0.6; cursor: not-allowed;
  background: linear-gradient(135deg, #b8a4a8 0%, #c9b0b4 100%);
  box-shadow: none;
}
.compose-secondary {
  background: rgba(255, 255, 255, 0.7);
  border: 1px solid var(--np-border);
  padding: 7px 13px; border-radius: var(--np-radius-pill);
  font-size: 13px; color: var(--np-text);
  display: inline-flex; align-items: center; gap: 5px;
}
.compose-secondary:hover { background: #fff; }
.compose-status {
  margin-left: auto; font-size: 11.5px; color: var(--np-text-3);
}

/* =================================================================
   SVG ICONS — globally styled
   ================================================================= */
.icon, svg.rail-icon, .iconbtn svg, .waffle-icon svg, .ai-action svg,
.compose-send svg, .compose-secondary svg, .rail-compose svg,
.reader-action svg, .settings-nav-item svg, .btn-primary svg,
.btn-danger svg, .btn-secondary svg, .modal-title svg,
.compose-title svg, .ai-bar-title svg, .ai-panel-title svg,
.login-submit svg, .topbar-search-icon, .waffle svg, .account svg {
  flex-shrink: 0; vertical-align: middle;
}
svg.rail-icon { width: 16px; height: 16px; }

button svg, button svg *, a svg, a svg * { pointer-events: none; }

/* =================================================================
   SETTINGS MODAL
   ================================================================= */
.modal-shell {
  position: fixed; inset: 0;
  background: rgba(15, 40, 90, 0.38);
  backdrop-filter: blur(4px);
  z-index: 300;
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
  animation: fadeIn 160ms ease;
}
/* The HTML `hidden` attribute must beat our display:flex. Without this,
   .modal-shell flashes open on every page load before JS gets a chance
   to confirm-hide it. */
/* ANY element with the [hidden] attribute must beat its CSS display
   rule. Without this the .login-shell (display:grid) and .modal-shell
   (display:flex) ignore hidden=true and stay visible after login. */
[hidden],
.login-shell[hidden],
#appShell[hidden],
.modal-shell[hidden],
.ai-panel[hidden],
.compose-shell[hidden],
.waffle-menu[hidden] { display: none !important; }
@keyframes fadeIn { from { opacity: 0; } }
.modal {
  background: rgba(255, 255, 255, 0.97);
  backdrop-filter: blur(28px);
  border: 1px solid rgba(255, 255, 255, 0.6);
  border-radius: var(--np-radius-lg);
  box-shadow: var(--np-shadow-3);
  width: min(720px, 100%);
  max-height: calc(100vh - 48px);
  display: flex; flex-direction: column;
  overflow: hidden;
}
.modal-lg { width: min(880px, 100%); }
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 22px;
  border-bottom: 1px solid var(--np-divider);
}
.modal-title {
  display: flex; align-items: center; gap: 10px;
  font-weight: 700; font-size: 17px;
  color: var(--np-text);
  font-family: var(--np-font-display);
}
.modal-title svg { color: var(--crimson); }
.modal-head .iconbtn { color: var(--np-text-2); width: 36px; height: 36px; }
.modal-head .iconbtn:hover { background: var(--np-tile); }

.settings-body {
  display: grid;
  grid-template-columns: 220px 1fr;
  flex: 1; overflow: hidden;
}
.settings-nav {
  border-right: 1px solid var(--np-divider);
  padding: 14px 10px;
  background: rgba(233, 243, 254, 0.45);
  overflow-y: auto;
}
.settings-nav-item {
  display: flex; align-items: center; gap: 10px;
  width: 100%; text-align: left;
  background: transparent; border: none;
  padding: 10px 12px;
  border-radius: var(--np-radius);
  font-size: 13.5px; color: var(--np-text);
  margin-bottom: 3px;
  transition: background 100ms;
}
.settings-nav-item:hover { background: var(--np-tile-hover); }
.settings-nav-item.active {
  background: var(--crimson-soft);
  color: var(--crimson-deep);
  font-weight: 600;
}
.settings-nav-item svg { color: var(--np-text-2); }
.settings-nav-item.active svg { color: var(--crimson); }

.settings-pane {
  padding: 26px 28px;
  overflow-y: auto;
}
.settings-pane h3 {
  margin: 0 0 6px;
  font-size: 19px; font-weight: 700;
  color: var(--np-text);
  font-family: var(--np-font-display);
}
.settings-help {
  font-size: 12.5px; color: var(--np-text-2);
  margin: 0 0 22px; line-height: 1.6;
}
.settings-label {
  display: block; font-size: 12.5px; font-weight: 600;
  color: var(--np-text-2);
  margin-bottom: 6px;
  letter-spacing: 0.3px;
}
.settings-textarea {
  width: 100%;
  border: 1px solid var(--np-border);
  border-radius: var(--np-radius);
  padding: 14px 16px;
  font-family: 'SF Mono', Consolas, 'Liberation Mono', Menlo, monospace;
  font-size: 13px; line-height: 1.65;
  color: var(--np-text);
  background: rgba(255, 255, 255, 0.7);
  resize: vertical;
  transition: border-color 120ms, box-shadow 120ms;
}

/* ---- HTML signature editor (contenteditable) ---- */
.signature-editor-toolbar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 4px;
  padding: 8px 12px;
  background: rgba(255, 255, 255, 0.85);
  border: 1px solid var(--np-border);
  border-bottom: none;
  border-radius: var(--np-radius) var(--np-radius) 0 0;
}
.sig-tool {
  width: 30px; height: 30px;
  background: transparent; border: none; border-radius: 4px;
  font-size: 13px; color: var(--np-text);
  display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer;
}
.sig-tool:hover { background: var(--np-tile-hover); }
.sig-tool-sep {
  width: 1px; height: 18px;
  background: var(--np-border);
  margin: 0 4px;
}
.sig-tool-hint {
  margin-left: auto; font-size: 11.5px; color: var(--np-text-3);
}

.signature-editor {
  min-height: 200px;
  width: 100%;
  border: 1px solid var(--np-border);
  border-top: none;
  border-radius: 0 0 var(--np-radius) var(--np-radius);
  padding: 14px 16px;
  font-family: var(--np-font);
  font-size: 14px; line-height: 1.6;
  color: var(--np-text);
  background: #fff;
  overflow-y: auto;
  outline: none;
  transition: box-shadow 120ms;
}
.signature-editor:focus { box-shadow: 0 0 0 3px rgba(220, 20, 60, 0.15); }
.signature-editor:empty::before {
  content: attr(data-placeholder);
  color: var(--np-text-3); font-style: italic;
}
.signature-editor img { max-width: 240px; height: auto; }
.signature-editor a { color: var(--np-info); text-decoration: underline; }
.signature-editor p { margin: 0 0 6px; }
.signature-editor h1, .signature-editor h2, .signature-editor h3 {
  margin: 12px 0 6px; font-weight: 600;
}
.settings-textarea:focus {
  outline: none; border-color: var(--crimson);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(220, 20, 60, 0.15);
}
.settings-toggle {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 0;
  border-bottom: 1px solid var(--np-divider);
  font-size: 13.5px; color: var(--np-text-2);
}
.settings-toggle input { margin: 0; accent-color: var(--crimson); }
.settings-actions { display: flex; gap: 10px; align-items: center; margin-top: 22px; }
.btn-primary {
  display: inline-flex; align-items: center; gap: 6px;
  background: linear-gradient(135deg, var(--crimson) 0%, #DC143C 100%);
  color: #fff; border: none;
  padding: 10px 18px; border-radius: var(--np-radius-pill);
  font-weight: 600; font-size: 13px;
  box-shadow: 0 4px 14px rgba(157, 15, 44, 0.25);
  transition: filter 120ms;
}
.btn-primary:hover { filter: brightness(1.08); }
.btn-secondary {
  display: inline-flex; align-items: center; gap: 6px;
  background: rgba(255, 255, 255, 0.85);
  color: var(--np-text);
  border: 1px solid var(--np-border);
  padding: 9px 16px; border-radius: var(--np-radius-pill);
  font-weight: 500; font-size: 13px;
}
.btn-secondary:hover { background: #fff; }
.btn-danger {
  display: inline-flex; align-items: center; gap: 6px;
  background: rgba(164, 38, 44, 0.10); color: var(--np-danger);
  border: 1px solid rgba(164, 38, 44, 0.30);
  padding: 10px 18px; border-radius: var(--np-radius-pill);
  font-weight: 600; font-size: 13px;
}
.btn-danger:hover { background: rgba(164, 38, 44, 0.18); }

.settings-preview {
  margin-top: 20px;
  padding: 16px;
  background: rgba(233, 243, 254, 0.55);
  border-left: 3px solid var(--crimson);
  border-radius: var(--np-radius);
}
.settings-preview-label {
  font-size: 11px; letter-spacing: 1.2px;
  text-transform: uppercase;
  color: var(--np-text-3);
  font-weight: 700;
  margin-bottom: 8px;
}
.settings-preview pre {
  margin: 0;
  font-family: inherit;
  font-size: 13px; line-height: 1.65;
  white-space: pre-wrap;
  color: var(--np-text);
}

.account-card {
  display: flex; gap: 18px;
  background: rgba(233, 243, 254, 0.55);
  padding: 18px;
  border-radius: var(--np-radius);
  border: 1px solid var(--np-border);
  margin-bottom: 18px;
}
.account-card-avatar {
  width: 64px; height: 64px; border-radius: 50%;
  background: linear-gradient(135deg, #ff9a8a 0%, var(--crimson) 100%);
  color: #fff;
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 22px;
  box-shadow: 0 4px 14px rgba(157, 15, 44, 0.30);
}
.account-card-info { flex: 1; }
.account-card-name { font-weight: 700; font-size: 17px; }
.account-card-email { font-size: 13px; color: var(--np-text-2); margin: 4px 0 8px; }
.role-pill {
  display: inline-block;
  font-size: 10.5px; letter-spacing: 1px; text-transform: uppercase;
  background: var(--crimson-soft); color: var(--crimson-deep);
  padding: 3px 12px; border-radius: var(--np-radius-pill);
  font-weight: 700;
}
.about-list {
  margin: 12px 0 0; padding: 0; list-style: none;
  font-size: 13px; color: var(--np-text-2); line-height: 1.9;
}
.about-list a { color: var(--crimson); text-decoration: underline; }

/* =================================================================
   AI SIDE PANEL
   ================================================================= */
.ai-panel {
  position: fixed; right: 0; top: var(--np-topbar-h);
  width: 380px; height: calc(100vh - var(--np-topbar-h));
  background: linear-gradient(180deg, rgba(31, 29, 64, 0.97) 0%, rgba(11, 5, 6, 0.95) 100%);
  backdrop-filter: blur(24px);
  border-left: 1px solid rgba(255, 255, 255, 0.10);
  box-shadow: -8px 0 30px rgba(15, 40, 90, 0.30);
  z-index: 150;
  display: flex; flex-direction: column;
  animation: slideIn 220ms ease;
  color: #F0EDE8;
}
@keyframes slideIn { from { transform: translateX(100%); } to { transform: translateX(0); } }
.ai-panel-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.10);
}
.ai-panel-head .iconbtn { color: #F0EDE8; }
.ai-panel-head .iconbtn:hover { background: rgba(255, 255, 255, 0.13); }
.ai-panel-title {
  display: inline-flex; align-items: center; gap: 8px;
  font-weight: 700; font-size: 15px; color: #C9C2EE;
  font-family: var(--np-font-display);
}
.ai-panel-body { flex: 1; overflow-y: auto; padding: 18px; }
.ai-hint {
  background: rgba(201, 194, 238, 0.08);
  border-left: 3px solid #C9C2EE;
  padding: 14px;
  border-radius: var(--np-radius);
  font-size: 12.5px; color: rgba(240, 237, 232, 0.85);
  line-height: 1.6;
  margin-bottom: 18px;
}
.ai-hint strong { color: #fff; }
.ai-suggestions { display: flex; flex-direction: column; gap: 8px; }
.ai-suggest {
  text-align: left;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(201, 194, 238, 0.20);
  padding: 11px 14px;
  border-radius: var(--np-radius);
  font-size: 13px; color: #F0EDE8;
  transition: background 100ms, border-color 100ms;
}
.ai-suggest:hover {
  background: rgba(201, 194, 238, 0.14);
  border-color: rgba(201, 194, 238, 0.40);
}
.ai-panel-foot {
  display: grid; grid-template-columns: 1fr auto; gap: 8px;
  padding: 12px 18px;
  border-top: 1px solid rgba(255, 255, 255, 0.10);
}
.ai-panel-foot input {
  padding: 10px 14px;
  border: 1px solid rgba(201, 194, 238, 0.30);
  border-radius: var(--np-radius-pill);
  font-family: inherit; font-size: 13px;
  background: rgba(255, 255, 255, 0.06);
  color: #F0EDE8;
}
.ai-panel-foot input::placeholder { color: rgba(201, 194, 238, 0.5); }
.ai-panel-foot input:focus {
  outline: none;
  border-color: #C9C2EE;
  background: rgba(255, 255, 255, 0.10);
}
.ai-panel-foot button {
  width: 44px;
  background: linear-gradient(135deg, #C9C2EE 0%, #8B5CF6 100%);
  color: #1F1D40; border: none;
  border-radius: var(--np-radius-pill);
  display: inline-flex; align-items: center; justify-content: center;
}

/* =================================================================
   TOASTS
   ================================================================= */
.toast-root {
  position: fixed; right: 20px; bottom: 20px;
  display: flex; flex-direction: column-reverse; gap: 10px;
  z-index: 500;
}
.toast {
  background: rgba(11, 29, 61, 0.95);
  backdrop-filter: blur(20px);
  color: #F0EDE8;
  padding: 14px 18px; border-radius: var(--np-radius);
  font-size: 13px; max-width: 380px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: var(--np-shadow-2);
  animation: toastIn 200ms ease;
}
@keyframes toastIn { from { transform: translateY(20px); opacity: 0; } }

/* =================================================================
   RESPONSIVE
   ================================================================= */
@media (max-width: 1100px) {
  :root { --np-list-w: 320px; --np-rail-w: 220px; }
}
@media (max-width: 800px) {
  .main {
    grid-template-columns: 0 1fr;
    gap: 8px; padding: 8px;
  }
  .rail { display: none; }
  .topbar-search { display: none; }
}
