/* ============================================================
   Medisyn Bot — design ispirato a claude.ai: tipografia pulita,
   layout calmo, accenti minimali. Palette medical (blu profondo + verde salvia).
   ============================================================ */

:root {
  --bg:            #faf9f6;
  --bg-elev:       #ffffff;
  --bg-sidebar:    #f4f2ed;
  --border:        #e6e2da;
  --border-strong: #d6d1c5;
  --text:          #1f1e1b;
  --text-muted:    #6b6a63;
  --text-faint:    #8b8a83;
  --accent:        #0b5e8f;          /* blu medisyn */
  --accent-hover:  #094b72;
  --accent-soft:   #e4f0f7;
  --assistant-bg:  #ffffff;
  --user-bg:       #ebe8e1;
  --code-bg:       #f0ede5;
  --danger:        #b23a2b;
  --ok:            #2e7d5f;
  --radius:        10px;
  --radius-lg:     14px;
  --shadow-sm:     0 1px 2px rgba(20, 20, 18, 0.04);
  --shadow-md:     0 4px 12px rgba(20, 20, 18, 0.06);
  --font-sans:     -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono:     "SF Mono", "JetBrains Mono", Menlo, Monaco, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg:            #1a1915;
    --bg-elev:       #24231e;
    --bg-sidebar:    #1f1e1a;
    --border:        #332f28;
    --border-strong: #45403a;
    --text:          #f5f3ee;
    --text-muted:    #b0aca2;
    --text-faint:    #807c73;
    --accent:        #4fa3d1;
    --accent-hover:  #6ab6df;
    --accent-soft:   #1b3344;
    --assistant-bg:  #24231e;
    --user-bg:       #2e2c26;
    --code-bg:       #181712;
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

button { font-family: inherit; cursor: pointer; border: 0; background: none; color: inherit; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
input, textarea { font-family: inherit; font-size: inherit; color: inherit; }

#app { height: 100%; }

/* ============================================================
   LOGIN
   ============================================================ */
.login-root {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100dvh;
  padding: 24px;
  background:
    radial-gradient(1200px 800px at 30% -10%, rgba(11,94,143,0.08), transparent 60%),
    radial-gradient(900px 700px at 80% 110%, rgba(108,196,161,0.10), transparent 60%),
    var(--bg);
}

.login-card {
  width: 100%;
  max-width: 420px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 36px 32px;
  box-shadow: var(--shadow-md);
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 28px;
}
.login-brand svg { width: 36px; height: 36px; }
.login-brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.1;
}
.login-brand-text strong { font-size: 17px; letter-spacing: -0.01em; }
.login-brand-text span { font-size: 12px; color: var(--text-muted); }

.login-title { font-size: 22px; font-weight: 600; margin: 0 0 6px; letter-spacing: -0.01em; }
.login-sub   { font-size: 14px; color: var(--text-muted); margin: 0 0 24px; }

.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.field label { font-size: 13px; font-weight: 500; color: var(--text-muted); }
.field input {
  border: 1px solid var(--border-strong);
  background: var(--bg);
  border-radius: var(--radius);
  padding: 10px 12px;
  font-size: 15px;
  transition: border-color .15s, box-shadow .15s;
}
.field input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 16px;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 500;
  transition: background .15s, transform .05s;
  user-select: none;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-primary:active { transform: translateY(1px); }
.btn-primary[disabled] { opacity: .6; cursor: wait; }
.btn-ghost { color: var(--text-muted); padding: 6px 10px; }
.btn-ghost:hover { color: var(--text); background: var(--bg); }

.login-submit { width: 100%; margin-top: 8px; }

.login-error {
  margin-top: 14px;
  padding: 10px 12px;
  background: #fdecea;
  border: 1px solid #f5c6c0;
  color: var(--danger);
  border-radius: var(--radius);
  font-size: 13px;
}
@media (prefers-color-scheme: dark) {
  .login-error { background: #3a1f1c; border-color: #5c2a23; color: #ff9a8d; }
}

.login-foot { margin-top: 28px; font-size: 12px; color: var(--text-faint); text-align: center; }

/* ============================================================
   CHAT — layout tre colonne (sidebar + thread + composer)
   ============================================================ */
.chat-root {
  display: grid;
  grid-template-columns: 280px 1fr;
  grid-template-rows: 100dvh;
  height: 100dvh;
  overflow: hidden;
}

.sidebar {
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 0;
}

.sidebar-head {
  padding: 14px 14px 10px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.sidebar-head svg { width: 26px; height: 26px; }
.sidebar-head-text { line-height: 1.1; }
.sidebar-head-text strong { display: block; font-size: 14px; letter-spacing: -0.01em; }
.sidebar-head-text span { font-size: 11px; color: var(--text-muted); }

.new-chat-btn {
  margin: 4px 10px 10px;
  padding: 8px 12px;
  border-radius: var(--radius);
  border: 1px solid var(--border-strong);
  background: var(--bg-elev);
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 500;
  transition: background .12s;
}
.new-chat-btn:hover { background: var(--accent-soft); }

.chat-list {
  flex: 1 1 auto;
  overflow-y: auto;
  min-height: 0;
  padding: 6px 6px 14px;
}
.chat-list-group-title {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-faint);
  padding: 10px 10px 4px;
}
.chat-item {
  display: block;
  width: 100%;
  text-align: left;
  padding: 7px 10px;
  border-radius: 8px;
  font-size: 13.5px;
  color: var(--text);
  line-height: 1.35;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: background .1s;
}
.chat-item:hover { background: var(--bg-elev); }
.chat-item.active { background: var(--accent-soft); color: var(--accent); font-weight: 500; }

.sidebar-foot {
  border-top: 1px solid var(--border);
  padding: 10px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  color: var(--text-muted);
}
.user-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.user-chip-avatar {
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--accent); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 600;
  flex-shrink: 0;
}
.user-chip-text {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.logout-btn {
  color: var(--text-muted);
  padding: 4px 8px;
  border-radius: 6px;
}
.logout-btn:hover { color: var(--danger); background: var(--bg-elev); }

/* ============================================================
   THREAD
   ============================================================ */
.thread {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  background: var(--bg);
}

.thread-head {
  border-bottom: 1px solid var(--border);
  padding: 14px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.thread-head-title {
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 80%;
}
.thread-head-meta { font-size: 12px; color: var(--text-muted); }

.messages {
  flex: 1 1 auto;
  overflow-y: auto;
  min-height: 0;
  padding: 32px 24px 40px;
  scroll-behavior: smooth;
  overscroll-behavior: contain;
}
.messages-inner { max-width: 780px; margin: 0 auto; display: flex; flex-direction: column; gap: 28px; }

.welcome {
  text-align: center;
  padding: 60px 20px 20px;
  color: var(--text-muted);
}
.welcome h1 {
  font-size: 28px;
  font-weight: 600;
  letter-spacing: -0.015em;
  color: var(--text);
  margin: 0 0 10px;
}
.welcome p { max-width: 460px; margin: 0 auto; font-size: 15px; }
.suggestion-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 10px;
  max-width: 620px;
  margin: 30px auto 0;
}
.suggestion {
  text-align: left;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-elev);
  font-size: 13.5px;
  color: var(--text);
  line-height: 1.4;
  transition: border-color .12s, transform .06s;
}
.suggestion:hover { border-color: var(--accent); }
.suggestion:active { transform: translateY(1px); }
.suggestion-label {
  display: block;
  font-size: 11px;
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 4px;
}

.msg { display: flex; flex-direction: column; gap: 8px; }
.msg-role {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 0.02em;
  display: flex;
  align-items: center;
  gap: 6px;
}
.msg-role-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--accent);
  display: inline-block;
}
.msg.user .msg-role-dot { background: var(--text-faint); }

.refused-badge {
  display: inline-block;
  margin-left: 8px;
  padding: 1px 8px;
  border-radius: 999px;
  background: #fff4d6;
  color: #8a6410;
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: 0.03em;
  text-transform: lowercase;
}
@media (prefers-color-scheme: dark) {
  .refused-badge { background: #3b2f14; color: #f0c571; }
}
.msg.refused .msg-bubble { color: var(--text-muted); }

.msg-bubble {
  font-size: 15px;
  line-height: 1.65;
  color: var(--text);
  word-wrap: break-word;
}

.msg.user .msg-bubble {
  background: var(--user-bg);
  padding: 12px 16px;
  border-radius: var(--radius-lg);
  align-self: flex-start;
  max-width: 90%;
}

.msg-bubble p { margin: 0 0 12px; }
.msg-bubble p:last-child { margin-bottom: 0; }
.msg-bubble ul, .msg-bubble ol { padding-left: 22px; margin: 0 0 12px; }
.msg-bubble li { margin-bottom: 4px; }
.msg-bubble h1, .msg-bubble h2, .msg-bubble h3 {
  margin: 18px 0 8px;
  letter-spacing: -0.01em;
}
.msg-bubble h2 { font-size: 18px; }
.msg-bubble h3 { font-size: 16px; }
.msg-bubble code {
  font-family: var(--font-mono);
  background: var(--code-bg);
  padding: 1.5px 6px;
  border-radius: 5px;
  font-size: 0.88em;
}
.msg-bubble pre {
  background: var(--code-bg);
  padding: 12px 14px;
  border-radius: var(--radius);
  overflow-x: auto;
  font-size: 13px;
  margin: 0 0 12px;
}
.msg-bubble pre code { background: none; padding: 0; }
.msg-bubble table {
  border-collapse: collapse;
  margin: 8px 0 14px;
  font-size: 13.5px;
}
.msg-bubble th, .msg-bubble td {
  border: 1px solid var(--border);
  padding: 6px 10px;
  text-align: left;
}
.msg-bubble th { background: var(--bg-sidebar); font-weight: 600; }

.tool-card {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  background: var(--accent-soft);
  border: 1px solid transparent;
  border-radius: 8px;
  font-size: 12.5px;
  color: var(--accent);
  margin: 4px 0;
}
.tool-card.running { opacity: .75; }
.tool-card.done { border-color: transparent; }
.tool-card .dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--accent);
}
.tool-card.running .dot { animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse {
  0%, 100% { opacity: .3; transform: scale(.8); }
  50%      { opacity: 1; transform: scale(1.2); }
}

.cursor {
  display: inline-block;
  width: 8px;
  height: 1.1em;
  background: var(--text);
  margin-left: 2px;
  vertical-align: text-bottom;
  animation: blink 1s steps(2) infinite;
}
@keyframes blink { 50% { opacity: 0; } }

/* ============================================================
   COMPOSER
   ============================================================ */
.composer-wrap {
  flex: 0 0 auto;
  border-top: 1px solid var(--border);
  background: var(--bg);
  padding: 14px 24px 20px;
  padding-bottom: max(20px, env(safe-area-inset-bottom));
}
.composer {
  max-width: 780px;
  margin: 0 auto;
  background: var(--bg-elev);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  padding: 8px 8px 8px 14px;
  display: flex;
  align-items: flex-end;
  gap: 8px;
  box-shadow: var(--shadow-sm);
  transition: border-color .15s, box-shadow .15s;
}
.composer:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.composer textarea {
  flex: 1;
  resize: none;
  border: 0;
  outline: 0;
  background: transparent;
  font-size: 15px;
  line-height: 1.5;
  padding: 8px 0;
  max-height: 180px;
  min-height: 22px;
}

.send-btn {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  background: var(--accent);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  transition: background .12s, transform .06s;
  flex-shrink: 0;
}
.send-btn:hover { background: var(--accent-hover); }
.send-btn:active { transform: translateY(1px); }
.send-btn[disabled] { background: var(--border-strong); cursor: not-allowed; }

.composer-foot {
  max-width: 780px;
  margin: 6px auto 0;
  font-size: 11px;
  color: var(--text-faint);
  text-align: center;
  letter-spacing: 0.01em;
}

/* Loading dots */
.thinking {
  display: inline-flex;
  gap: 4px;
  align-items: center;
  color: var(--text-faint);
  font-size: 13px;
}
.thinking span {
  width: 5px; height: 5px; border-radius: 50%;
  background: var(--text-faint);
  animation: jump 1.2s ease-in-out infinite;
}
.thinking span:nth-child(2) { animation-delay: .15s; }
.thinking span:nth-child(3) { animation-delay: .3s; }
@keyframes jump { 0%, 80%, 100% { transform: translateY(0); } 40% { transform: translateY(-4px); } }

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 820px) {
  .chat-root { grid-template-columns: 1fr; grid-template-rows: 100dvh; }
  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: 80%;
    max-width: 300px;
    z-index: 20;
    transform: translateX(-100%);
    transition: transform .2s ease;
    box-shadow: var(--shadow-md);
  }
  .chat-root.drawer-open .sidebar { transform: translateX(0); }
  .chat-root.drawer-open::after {
    content: "";
    position: fixed; inset: 0; background: rgba(0,0,0,.35);
    z-index: 15;
  }
  .thread-head .menu-btn { display: flex; }
  .messages { padding: 24px 16px 32px; }
  .composer-wrap { padding: 10px 14px 18px; }
}
.menu-btn {
  display: none;
  width: 34px; height: 34px;
  align-items: center; justify-content: center;
  border-radius: 8px;
  color: var(--text-muted);
}
.menu-btn:hover { background: var(--bg-sidebar); color: var(--text); }

/* ============================================================
   Tab bar sidebar (Chat / Notifiche)
   ============================================================ */
.sidebar-tabs {
  display: flex;
  gap: 4px;
  padding: 4px 10px 8px;
  border-bottom: 1px solid var(--border);
}
.sidebar-tab {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 7px 8px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  transition: background .12s, color .12s;
}
.sidebar-tab:hover { background: var(--bg-elev); color: var(--text); }
.sidebar-tab.active { background: var(--accent-soft); color: var(--accent); }
.sidebar-tab .badge {
  background: var(--accent);
  color: #fff;
  font-size: 10px;
  line-height: 1;
  padding: 3px 6px;
  border-radius: 999px;
  font-weight: 600;
}
.sidebar-tab.active .badge { background: var(--accent); }

/* ============================================================
   Notifiche — timeline + dettaglio
   ============================================================ */
.notif-head {
  border-bottom: 1px solid var(--border);
  padding: 14px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.notif-head-title { font-size: 14px; font-weight: 500; }
.notif-head-meta { font-size: 12px; color: var(--text-muted); }
.dry-run-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: 999px;
  background: #fff4d6;
  color: #8a6410;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .03em;
  text-transform: uppercase;
}
@media (prefers-color-scheme: dark) {
  .dry-run-pill { background: #3b2f14; color: #f0c571; }
}

.notif-list {
  flex: 1 1 auto;
  overflow-y: auto;
  min-height: 0;
  padding: 24px;
}
.notif-list-inner { max-width: 780px; margin: 0 auto; }
.notif-empty {
  text-align: center;
  padding: 80px 20px;
  color: var(--text-muted);
}
.notif-empty h2 {
  font-size: 22px; font-weight: 600; letter-spacing: -0.01em;
  color: var(--text); margin: 0 0 8px;
}
.notif-empty p { max-width: 460px; margin: 0 auto 18px; font-size: 14px; }

/* --- Inbox style (email list) --- */
.notif-inbox {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.notif-item {
  width: 100%;
  text-align: left;
  background: transparent;
  border: 0;
  border-bottom: 1px solid var(--border);
  padding: 14px 18px;
  display: grid;
  grid-template-columns: 40px 1fr auto;
  column-gap: 14px;
  row-gap: 3px;
  align-items: start;
  cursor: pointer;
  transition: background .1s;
}
.notif-item:last-child { border-bottom: 0; }
.notif-item:hover { background: var(--bg-sidebar); }
.notif-item:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }

.notif-avatar {
  grid-row: 1 / span 3;
  align-self: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, #0b5e8f, #6cc4a1);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.02em;
  flex-shrink: 0;
}

.notif-row1 {
  grid-column: 2;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  min-width: 0;
}
.notif-from {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.005em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.notif-date {
  font-size: 11.5px;
  color: var(--text-faint);
  flex-shrink: 0;
  white-space: nowrap;
}

.notif-subject {
  grid-column: 2;
  font-size: 13.5px;
  color: var(--text);
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.notif-preview {
  grid-column: 2;
  font-size: 12.5px;
  color: var(--text-muted);
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
  overflow: hidden;
  line-height: 1.4;
}
.notif-pills {
  grid-column: 3;
  grid-row: 2 / span 2;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
  flex-shrink: 0;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.01em;
}
.status-pill.sent      { background: #dff5e8; color: #1d6b47; }
.status-pill.simulated { background: #fff4d6; color: #8a6410; }
.status-pill.failed    { background: #fdecea; color: var(--danger); }
@media (prefers-color-scheme: dark) {
  .status-pill.sent      { background: #153b2b; color: #6ed4a4; }
  .status-pill.simulated { background: #3b2f14; color: #f0c571; }
  .status-pill.failed    { background: #3a1f1c; color: #ff9a8d; }
}
.urgenza-pill {
  background: #fdecea;
  color: var(--danger);
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
@media (prefers-color-scheme: dark) {
  .urgenza-pill { background: #3a1f1c; color: #ff9a8d; }
}

/* ============================================================
   Modal dettaglio notifica
   ============================================================ */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(15, 14, 12, .45);
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  backdrop-filter: blur(2px);
  animation: fade .15s ease;
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.modal {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 720px;
  max-height: 88vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 48px rgba(0,0,0,.18);
}

/* --- Email client style --- */
.email-head {
  padding: 22px 26px 18px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-elev);
}
.email-head-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}
.email-subject {
  margin: 0 0 12px;
  font-size: 20px;
  font-weight: 600;
  line-height: 1.3;
  letter-spacing: -0.01em;
  color: var(--text);
}
.email-envelope {
  display: grid;
  grid-template-columns: 44px 1fr auto;
  column-gap: 14px;
  row-gap: 3px;
  align-items: start;
}
.email-envelope .notif-avatar { grid-row: 1 / span 2; align-self: center; width: 42px; height: 42px; font-size: 14px; }
.email-line {
  grid-column: 2;
  font-size: 13px;
  color: var(--text);
  line-height: 1.5;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.email-line .label {
  color: var(--text-faint);
  display: inline-block;
  width: 44px;
  margin-right: 6px;
  font-weight: 500;
}
.email-meta-date {
  grid-column: 3;
  grid-row: 1;
  font-size: 12px;
  color: var(--text-muted);
  text-align: right;
  white-space: nowrap;
}
.email-pills {
  grid-column: 3;
  grid-row: 2;
  display: flex;
  gap: 6px;
  align-self: end;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.email-details-btn {
  grid-column: 2 / -1;
  justify-self: start;
  margin-top: 6px;
  font-size: 11.5px;
  color: var(--text-muted);
  padding: 2px 0;
  letter-spacing: 0.02em;
}
.email-details-btn:hover { color: var(--accent); }

.email-details {
  grid-column: 2 / -1;
  margin-top: 8px;
  background: var(--bg-sidebar);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 12.5px;
  color: var(--text);
  display: grid;
  grid-template-columns: 100px 1fr;
  gap: 4px 12px;
}
.email-details dt { color: var(--text-muted); font-weight: 500; }
.email-details dd { margin: 0; word-break: break-word; }

.email-body {
  flex: 1;
  overflow-y: auto;
  padding: 24px 26px;
  background: var(--bg);
  min-height: 0;
}
.email-body-html {
  max-width: 640px;
  font-size: 14px;
  color: var(--text);
  line-height: 1.6;
}
.email-body-html h2 { margin: 0 0 6px; font-size: 18px; font-weight: 600; letter-spacing: -0.005em; color: var(--accent); }
.email-body-html h3 { margin: 18px 0 6px; font-size: 14px; font-weight: 600; }
.email-body-html table { border-collapse: collapse; margin: 6px 0 14px; }
.email-body-html table td { padding: 4px 10px 4px 0; font-size: 13.5px; vertical-align: top; }
.email-body-html table td b { font-weight: 600; color: var(--text-muted); }
.email-body-html div[style*="background"] { background: var(--bg-sidebar) !important; color: var(--text) !important; border: 1px solid var(--border); border-radius: 8px; padding: 12px 14px !important; white-space: pre-wrap; }
.email-body-html p { margin: 0 0 8px; }
.email-body-html p[style*="color:#8b8a83"] { font-size: 11.5px; color: var(--text-faint) !important; margin-top: 20px; }

.modal-close {
  width: 30px; height: 30px;
  border-radius: 8px;
  color: var(--text-muted);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.modal-close:hover { background: var(--bg-sidebar); color: var(--text); }

.email-err {
  background: #fdecea;
  color: var(--danger);
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 13px;
  margin-bottom: 12px;
}
@media (prefers-color-scheme: dark) {
  .email-err { background: #3a1f1c; color: #ff9a8d; }
}

/* scrollbar sottile */
.messages::-webkit-scrollbar,
.chat-list::-webkit-scrollbar { width: 8px; }
.messages::-webkit-scrollbar-thumb,
.chat-list::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: 8px;
}
.messages::-webkit-scrollbar-thumb:hover,
.chat-list::-webkit-scrollbar-thumb:hover {
  background: var(--text-faint);
}
