:root {
  --otonde-orange: #F26B00;
  --otonde-orange-dark: #C85600;
  --otonde-orange-soft: #FFF0E4;
  --otonde-blue: #002B4D;
  --otonde-blue-2: #06213A;
  --ink: #172033;
  --muted: #64748B;
  --line: #E6EAF0;
  --paper: #FFFFFF;
  --surface: #F6F8FB;
  --surface-2: #EFF4FA;
  --gold: #D6A443;
  --danger: #D94747;
  --ok: #22A06B;
  --shadow: 0 22px 60px rgba(0, 43, 77, .12);
  --shadow-strong: 0 32px 90px rgba(0, 43, 77, .20);
  --radius: 22px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
body {
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 3% 4%, rgba(242, 107, 0, .16), transparent 28rem),
    radial-gradient(circle at 97% 0%, rgba(0, 43, 77, .12), transparent 32rem),
    linear-gradient(135deg, #F7FAFD 0%, #FFFFFF 43%, #F2F6FA 100%);
  overflow-x: hidden;
}
body.compose-open { overflow: hidden; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }
.ambient { position: fixed; border-radius: 999px; filter: blur(36px); opacity: .35; z-index: -1; pointer-events: none; }
.ambient-one { width: 280px; height: 280px; background: rgba(242, 107, 0, .24); left: -90px; top: -80px; }
.ambient-two { width: 320px; height: 320px; background: rgba(0, 43, 77, .18); right: -120px; bottom: 10vh; }

.omail-shell { display: grid; grid-template-columns: 292px minmax(0, 1fr); min-height: 100vh; }
.rail {
  border-right: 1px solid rgba(0, 43, 77, .09);
  padding: 24px 18px;
  background: rgba(255,255,255,.86);
  backdrop-filter: blur(18px);
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  overscroll-behavior: contain;
  box-shadow: 10px 0 40px rgba(0, 43, 77, .04);
  z-index: 20;
}
.rail-close { display: none; }
.rail-overlay { position: fixed; inset: 0; z-index: 18; background: rgba(0, 43, 77, .32); backdrop-filter: blur(3px); }
.brand-block { display: flex; gap: 13px; align-items: center; margin-bottom: 22px; padding: 10px; border-radius: 18px; background: linear-gradient(135deg, rgba(0,43,77,.04), rgba(242,107,0,.06)); }
.brand-symbol { width: 45px; height: 45px; object-fit: contain; filter: drop-shadow(0 8px 18px rgba(242, 107, 0, .22)); }
.brand-block strong { display: block; font-size: 21px; letter-spacing: -.02em; color: var(--otonde-blue); }
.brand-block span { display: block; color: var(--muted); font-size: 12px; font-weight: 700; }
.compose-primary, .gold-btn {
  border: 0;
  color: white;
  background: linear-gradient(135deg, var(--otonde-orange), #FF8A1D);
  font-weight: 900;
  border-radius: 18px;
  padding: 14px 18px;
  box-shadow: 0 16px 34px rgba(242, 107, 0, .25);
  transition: transform .18s ease, box-shadow .18s ease;
}
.compose-primary { width: 100%; margin-bottom: 20px; display:flex; align-items:center; justify-content:center; gap:10px; }
.compose-primary:hover, .gold-btn:hover, .send-btn:hover { transform: translateY(-1px); box-shadow: 0 18px 38px rgba(242,107,0,.31); }
.ghost-btn, .icon-btn, .soft-icon, .window-btn {
  border: 1px solid var(--line);
  background: rgba(255,255,255,.86);
  color: var(--ink);
  border-radius: 999px;
  padding: 10px 14px;
}
.ghost-btn.compact { padding: 7px 11px; font-size: 12px; }
.icon-btn, .soft-icon, .window-btn { width: 38px; height: 38px; display: grid; place-items: center; padding: 0; flex: 0 0 auto; }
.soft-icon { background: #F4F7FB; color: var(--otonde-blue); }
.folders { display: grid; gap: 7px; }
.folder {
  border: 1px solid transparent;
  background: transparent;
  color: #42536A;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 13px;
  border-radius: 15px;
  font-weight: 750;
  width: 100%;
}
.folder:hover, .folder.active { background: var(--otonde-orange-soft); color: var(--otonde-blue); border-color: rgba(242,107,0,.16); }
.folder b { font-size: 12px; color: var(--otonde-orange); }
.mailbox-card { margin-top: 20px; border: 1px solid var(--line); border-radius: 18px; padding: 14px; background: rgba(255,255,255,.72); }
.mailbox-card label { display: block; color: var(--muted); font-size: 12px; margin-bottom: 8px; font-weight: 850; }
.rail-note { margin-top: 18px; padding: 16px; border-radius: 20px; color: white; background: linear-gradient(135deg, var(--otonde-blue), #0A3A64); box-shadow: var(--shadow); }
.rail-note strong { display:block; margin-bottom:5px; }
.rail-note span { display:block; color: rgba(255,255,255,.76); font-size: 12px; line-height:1.45; }

select, input, textarea {
  width: 100%;
  border: 1px solid var(--line);
  background: rgba(255,255,255,.92);
  color: var(--ink);
  border-radius: 14px;
  padding: 11px 12px;
  outline: none;
}
input:focus, select:focus, textarea:focus, .compose-editor:focus { border-color: rgba(242,107,0,.45); box-shadow: 0 0 0 4px rgba(242,107,0,.10); }
select option { color: var(--ink); }

.workspace { min-width: 0; min-height: 100vh; display: grid; grid-template-rows: auto minmax(0, 1fr); }
.topbar {
  height: 76px;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px 24px;
  border-bottom: 1px solid rgba(0, 43, 77, .08);
  background: rgba(255,255,255,.78);
  backdrop-filter: blur(18px);
  position: sticky;
  top: 0;
  z-index: 10;
}
.menu-btn { border:0; background:transparent; color:var(--otonde-blue); font-size:24px; width: 42px; height: 42px; border-radius: 14px; display:grid; place-items:center; }
.menu-btn:hover { background: rgba(0,43,77,.07); }
.search-wrap { flex: 1; max-width: 880px; position: relative; }
.search-wrap span { position:absolute; left:18px; top:50%; transform:translateY(-50%); color:var(--muted); }
.search-wrap input { border-radius: 999px; background: #EEF3F9; border: 0; padding: 15px 18px 15px 50px; }
.top-actions, .user-area { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 13px; }
.auth-panel { max-width: 820px; margin: 9vh auto; text-align: center; border: 1px solid var(--line); border-radius: 34px; padding: 46px; background: rgba(255,255,255,.78); box-shadow: var(--shadow); }
.auth-panel img { max-width: 220px; margin-bottom: 18px; }
.eyebrow { color: var(--otonde-orange)!important; text-transform: uppercase; letter-spacing: .12em; font-size: 12px; font-weight: 900; }
.auth-panel h1 { font-size: clamp(31px, 5vw, 56px); line-height: 1.02; margin: 0 0 14px; color: var(--otonde-blue); letter-spacing:-.04em; }
.auth-panel p { color: var(--muted); max-width: 590px; margin: 0 auto 24px; }

.mail-panel { display: grid; grid-template-columns: minmax(360px, 500px) 1fr; height: calc(100vh - 76px); min-height: 0; overflow: hidden; }
.list-pane { border-right: 1px solid rgba(0, 43, 77, .08); min-width: 0; background: rgba(255,255,255,.60); display: grid; grid-template-rows: auto auto auto minmax(0, 1fr); min-height: 0; }
.pane-head { display: flex; justify-content: space-between; align-items: center; padding: 20px 24px; border-bottom: 1px solid var(--line); background: rgba(255,255,255,.78); }
.pane-head h2 { margin: 0; font-size: 24px; color: var(--otonde-blue); }
.pane-head p { margin: 4px 0 0; color: var(--muted); font-size: 12px; }
.mobile-folder-nav { display: none; }
.category-tabs { display: grid; grid-template-columns: repeat(5, 1fr); gap: 0; border-bottom: 1px solid var(--line); background: rgba(255,255,255,.64); }
.category-tab { border:0; background:transparent; padding: 14px 8px; color:var(--muted); font-weight:800; border-bottom:3px solid transparent; white-space: nowrap; }
.category-tab.active { color:var(--otonde-orange); border-bottom-color:var(--otonde-orange); background:rgba(242,107,0,.05); }
.message-list { min-height: 0; overflow-y: auto; overscroll-behavior: contain; }
.message-item { display: grid; gap: 7px; padding: 16px 20px; border: 0; border-bottom: 1px solid var(--line); background: transparent; color: var(--ink); text-align: left; width: 100%; }
.message-item:hover, .message-item.active { background: rgba(242,107,0,.07); }
.message-item.unread .mi-subject { font-weight: 950; color: var(--otonde-blue); }
.mi-top { display: flex; justify-content: space-between; gap: 12px; color: var(--muted); font-size: 12px; }
.mi-top span:first-child, .mi-subject, .mi-snippet { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.mi-subject { font-weight: 760; }
.mi-snippet { color: var(--muted); font-size: 13px; }
.mi-tags { display: flex; gap: 6px; flex-wrap: wrap; }
.pill { border: 1px solid var(--line); background:white; border-radius: 999px; padding: 3px 8px; color: var(--muted); font-size: 11px; }
.reader-pane { min-width: 0; padding: 28px; overflow-y: auto; overscroll-behavior: contain; min-height: 0; }
.empty-reader { min-height: 300px; display: grid; place-items: center; align-content:center; text-align:center; color: var(--muted); padding: 24px; }
.empty-mark { width:72px; height:72px; display:grid; place-items:center; border-radius:24px; background:var(--otonde-orange-soft); color:var(--otonde-orange); font-size:32px; margin-bottom:14px; }
.mobile-back { display:none; }
.email-card { background: rgba(255,255,255,.90); border:1px solid var(--line); border-radius: 28px; box-shadow: var(--shadow); overflow:hidden; }
.email-card header { padding: 26px; border-bottom: 1px solid var(--line); background: linear-gradient(135deg, #FFF, #F8FAFD); }
.email-card h1 { color: var(--otonde-blue); margin:0 0 14px; font-size: clamp(24px, 4vw, 38px); letter-spacing:-.03em; }
.meta-grid { display:grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap:8px 18px; color:var(--muted); font-size:13px; }
.reader-actions { display:flex; gap:8px; flex-wrap:wrap; margin-top:18px; }
.email-body { padding: 26px; line-height: 1.65; color: #23344B; overflow-wrap: anywhere; }
.email-body iframe { width:100%; min-height:420px; border:0; background:white; }
.attachments { padding: 0 26px 26px; display:flex; gap:8px; flex-wrap:wrap; }

.compose-modal { position: fixed; inset: auto 28px 24px auto; z-index: 60; }
.compose-card { width: min(780px, calc(100vw - 40px)); height: min(720px, calc(100dvh - 90px)); background: #fff; border: 1px solid rgba(0,43,77,.10); border-radius: 18px 18px 10px 10px; box-shadow: 0 30px 90px rgba(0,43,77,.24); display: grid; grid-template-rows: auto minmax(0, 1fr); overflow: hidden; }
.compose-modal.compose-full { inset: 24px; }
.compose-modal.compose-full .compose-card { width: calc(100vw - 48px); height: calc(100dvh - 48px); border-radius: 26px; }
.compose-modal.compose-minimized .compose-card { width: 360px; height: 56px; }
.compose-modal.compose-minimized .compose-form { display:none; }
.compose-titlebar { min-height: 54px; padding: 10px 14px 10px 20px; display:flex; align-items:center; justify-content:space-between; gap:12px; background: linear-gradient(135deg, var(--otonde-blue), #0A3A64); color:white; }
.compose-titlebar h2 { font-size: 15px; margin:0; }
.compose-titlebar p { margin:3px 0 0; font-size: 11px; color:rgba(255,255,255,.68); }
.compose-window-actions { display:flex; gap:6px; align-items:center; flex:0 0 auto; }
.window-btn { background: rgba(255,255,255,.10); border-color:rgba(255,255,255,.16); color:white; width: 32px; height:32px; }
.window-btn.danger:hover { background: rgba(217,71,71,.95); }
.premium-compose { min-height: 0; height: 100%; display:flex; flex-direction: column; overflow-y:auto; overscroll-behavior: contain; }
.from-row, .recipient-row, .cc-fields { display:flex; align-items:center; gap:10px; padding: 10px 18px; border-bottom:1px solid var(--line); flex: 0 0 auto; }
.from-row label { width:auto; font-size:12px; color:var(--muted); font-weight:900; white-space:nowrap; }
.from-row select { max-width: 320px; padding:8px 10px; }
.link-btn { border:0; background:transparent; color:var(--otonde-blue); font-weight:850; padding:6px; white-space: nowrap; }
.link-btn:hover { color:var(--otonde-orange); }
.recipient-row input, .cc-fields input, .subject-input { border:0; box-shadow:none!important; border-radius:0; background:white; padding: 13px 18px; }
.recipient-row { padding:0 12px; }
.cc-fields { padding:0; display:grid; grid-template-columns: 1fr 1fr; gap:0; }
.subject-input { border-bottom:1px solid var(--line); flex: 0 0 auto; }
.template-panel { margin: 12px 18px; border:1px solid var(--line); border-radius:18px; background:#fff; box-shadow:var(--shadow); overflow:hidden; flex: 0 0 auto; max-height: 280px; display: flex; flex-direction: column; }
.template-panel.hidden { display: none !important; }
.template-head { display:flex; justify-content:space-between; gap:12px; align-items:center; padding:13px 16px; background:var(--surface); border-bottom:1px solid var(--line); flex: 0 0 auto; }
.template-head strong { color:var(--otonde-blue); }
.template-head span { display:block; font-size:12px; color:var(--muted); }
.template-list { display:grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap:10px; padding:12px; overflow:auto; min-height:0; }
.template-card { text-align:left; border:1px solid var(--line); background:#fff; border-radius:14px; padding:12px; }
.template-card:hover { border-color:rgba(242,107,0,.45); background:var(--otonde-orange-soft); }
.template-card strong { display:block; color:var(--otonde-blue); }
.template-card span { color:var(--muted); font-size:12px; }
.writing-desk { display:flex; gap:7px; padding: 10px 18px; border-bottom:1px solid var(--line); overflow-x:auto; flex: 0 0 auto; }
.tool-btn { white-space:nowrap; border:1px solid var(--line); background:#F8FAFD; border-radius:999px; padding:7px 11px; color:#34465C; font-size:12px; font-weight:850; flex: 0 0 auto; }
.tool-btn:hover { background: var(--otonde-orange-soft); color: var(--otonde-blue); border-color: rgba(242,107,0,.22); }
.compose-editor { flex: 1 1 240px; min-height: 180px; overflow-y:auto; padding: 22px 24px; line-height:1.65; outline:none; border:0; font-size:15px; border-bottom: 1px solid var(--line); overflow-wrap: anywhere; }
.compose-editor:empty::before { content: attr(data-placeholder); color:#95A3B8; }
.compose-editor p { margin: 0 0 12px; }
.attachment-chips { display:flex; gap:8px; flex-wrap:wrap; padding: 8px 18px; border-top:1px solid var(--line); background:#FBFCFE; flex: 0 0 auto; max-height: 86px; overflow:auto; }
.attachment-chip { display:flex; align-items:center; gap:8px; border:1px solid var(--line); background:white; border-radius:999px; padding:7px 10px; font-size:12px; color:var(--otonde-blue); }
.attachment-chip button { border:0; background:transparent; color:var(--danger); font-weight:900; }
.metadata-drawer { display:grid; grid-template-columns: 1fr 1fr 1.2fr 1.4fr; gap:10px; padding: 12px 18px; border-top:1px solid var(--line); background:#FBFCFE; flex: 0 0 auto; }
.metadata-drawer label { color:var(--muted); font-size:11px; font-weight:900; }
.metadata-drawer input, .metadata-drawer select { margin-top:5px; padding:9px 10px; border-radius:12px; }
.compose-footer { display:flex; align-items:center; gap:14px; padding: 12px 18px; border-top:1px solid var(--line); background:#fff; position: sticky; bottom: 0; z-index: 5; flex: 0 0 auto; box-shadow: 0 -12px 24px rgba(0,43,77,.05); }
.send-cluster { display:flex; align-items:stretch; box-shadow: 0 12px 24px rgba(242,107,0,.22); border-radius:16px; overflow:hidden; flex: 0 0 auto; }
.send-btn, .send-arrow { border:0; background:linear-gradient(135deg, var(--otonde-orange), #FF8A1D); color:white; font-weight:950; padding: 12px 22px; }
.send-arrow { border-left:1px solid rgba(255,255,255,.35); padding:12px 13px; }
.format-toolbar { display:flex; align-items:center; gap:4px; flex:1 1 auto; min-width: 0; overflow-x:auto; }
.format-btn { border:0; background:transparent; color:#526274; height:34px; min-width:34px; border-radius:10px; display:grid; place-items:center; font-weight:850; flex: 0 0 auto; }
.format-btn:hover { background:#F0F3F8; color:var(--otonde-blue); }
.footer-right-tools { display:flex; align-items:center; gap:10px; flex: 0 0 auto; }
.footer-right-tools span { color:var(--muted); font-size:11px; white-space:nowrap; }
.trash-btn { border:0; background:transparent; font-size:18px; }
.toast { position: fixed; right: 24px; bottom: 24px; z-index: 90; background: var(--otonde-blue); color:white; border-radius: 16px; padding: 14px 18px; box-shadow: var(--shadow-strong); max-width: 360px; }

@media (min-width: 981px) {
  .menu-btn { display:none; }
}

@media (max-width: 1180px) {
  .mail-panel { grid-template-columns: minmax(330px, 440px) 1fr; }
  .metadata-drawer { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 980px) {
  .omail-shell { grid-template-columns: 1fr; }
  .workspace { min-height: 100dvh; }
  .rail {
    position: fixed;
    inset: 0 auto 0 0;
    width: min(88vw, 330px);
    height: 100dvh;
    transform: translateX(-104%);
    transition: transform .24s ease;
    box-shadow: 24px 0 70px rgba(0, 43, 77, .20);
  }
  body.rail-open .rail { transform: translateX(0); }
  .rail-close { display: grid; place-items: center; position: absolute; right: 16px; top: 14px; width: 34px; height: 34px; border: 1px solid var(--line); border-radius: 999px; background: white; color: var(--otonde-blue); font-size: 20px; }
  .brand-block { margin-right: 42px; }
  .rail-note { display:none; }
  .mailbox-card { margin-top: 14px; }
  .mail-panel { grid-template-columns: 1fr; height: calc(100dvh - 76px); }
  .list-pane { border-right: 0; height: 100%; }
  .reader-pane { display:none; height: 100%; padding: 16px; }
  .mail-panel.reader-open .list-pane { display:none; }
  .mail-panel.reader-open .reader-pane { display:block; }
  .mobile-back { display:inline-flex; align-items:center; gap:8px; border:1px solid var(--line); background:#fff; color:var(--otonde-blue); border-radius:999px; padding:10px 14px; margin: 0 0 14px; font-weight:850; }
  .mobile-folder-nav { display:flex; gap:8px; overflow-x:auto; padding:10px 12px; border-bottom:1px solid var(--line); background:rgba(255,255,255,.82); }
  .mobile-folder { border:1px solid var(--line); background:#fff; color:#42536A; border-radius:999px; padding:9px 12px; display:flex; align-items:center; gap:8px; white-space:nowrap; font-weight:850; }
  .mobile-folder b { color:var(--otonde-orange); font-size:11px; }
  .mobile-folder.active { color:var(--otonde-blue); background:var(--otonde-orange-soft); border-color:rgba(242,107,0,.25); }
  .category-tabs { overflow-x:auto; display:flex; }
  .category-tab { min-width:110px; }
  .reader-pane { min-height: 420px; }
  .meta-grid { grid-template-columns: 1fr; }
  .email-card { border-radius: 20px; }
  .email-card header, .email-body { padding: 18px; }
  .compose-modal { inset: auto 12px 12px 12px; }
  .compose-card { width:100%; }
}

@media (max-width: 720px) {
  .topbar { height: 68px; padding: 10px 12px; gap: 8px; }
  .search-wrap input { padding: 12px 14px 12px 42px; }
  .search-wrap span { left: 14px; }
  .top-actions .soft-icon { display:none; }
  .user-area span { display:none; }
  .ghost-btn { padding: 9px 11px; }
  .auth-panel { margin: 5vh 14px; padding: 28px 20px; border-radius: 26px; }
  .auth-panel img { max-width: 180px; }
  .mail-panel { height: calc(100dvh - 68px); }
  .pane-head { padding: 14px 16px; }
  .pane-head h2 { font-size: 21px; }
  .pane-head p { max-width: 220px; }
  .message-item { padding: 14px 16px; }
  .mi-tags .pill:nth-child(n+4) { display:none; }
  .compose-modal { inset: 0; }
  .compose-card { width: 100vw; height: 100dvh; max-height: none; border-radius: 0; border:0; }
  .compose-modal.compose-full { inset: 0; }
  .compose-modal.compose-full .compose-card { width:100vw; height:100dvh; border-radius:0; }
  .compose-modal.compose-minimized { inset: auto 12px 12px 12px; }
  .compose-modal.compose-minimized .compose-card { width:100%; height:56px; border-radius:18px; border:1px solid rgba(0,43,77,.12); }
  .compose-titlebar { min-height: 52px; padding: 9px 10px 9px 14px; }
  .compose-titlebar p { display:none; }
  .from-row, .recipient-row { padding: 8px 12px; gap: 8px; }
  .from-row { flex-wrap: wrap; }
  .from-row select { max-width:none; flex: 1 1 180px; }
  .recipient-row input, .cc-fields input, .subject-input { padding: 12px 12px; }
  .cc-fields { grid-template-columns:1fr; }
  .template-panel { margin: 10px 12px; max-height: 230px; }
  .template-list { grid-template-columns:1fr; }
  .writing-desk { padding: 9px 12px; }
  .compose-editor { min-height: 220px; padding: 16px; font-size: 14px; }
  .metadata-drawer { grid-template-columns:1fr; padding: 10px 12px; }
  .compose-footer { align-items:stretch; flex-wrap:wrap; padding: 10px 12px; gap: 8px; }
  .send-cluster { flex: 0 0 auto; }
  .send-btn { padding: 11px 20px; }
  .format-toolbar { order:3; width:100%; flex-basis:100%; padding: 2px 0; }
  .footer-right-tools { width:100%; justify-content:space-between; gap:8px; }
  .footer-right-tools span { display:none; }
  .toast { right: 12px; left: 12px; bottom: 12px; max-width: none; }
}

@media (max-width: 420px) {
  .compose-window-actions { gap: 3px; }
  .window-btn { width: 30px; height: 30px; }
  .mobile-folder { padding:8px 10px; }
  .category-tab { min-width: 96px; font-size: 13px; }
  .reader-actions .ghost-btn { width: 100%; }
}

/* Omail Stability v5: live connection state, mobile reconnect, and safer refresh controls */
.connection-status {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-width: 178px;
  max-width: 285px;
  border: 1px solid rgba(0, 43, 77, .08);
  background: rgba(255,255,255,.72);
  color: var(--muted);
  border-radius: 999px;
  padding: 9px 12px;
  font-size: 11px;
  font-weight: 800;
  white-space: nowrap;
  box-shadow: 0 8px 22px rgba(0,43,77,.06);
}
.connection-status strong { color: var(--otonde-blue); }
.connection-status span:last-child {
  overflow: hidden;
  text-overflow: ellipsis;
}
.status-dot {
  width: 9px;
  height: 9px;
  border-radius: 999px;
  background: var(--ok);
  box-shadow: 0 0 0 4px rgba(34,160,107,.13);
  flex: 0 0 auto;
}
.connection-status[data-status="reconnecting"] .status-dot,
.connection-status[data-status="refreshing"] .status-dot,
.mobile-connection-banner[data-status="reconnecting"],
.mobile-connection-banner[data-status="refreshing"] {
  background: var(--otonde-orange);
}
.connection-status[data-status="reconnecting"] .status-dot,
.connection-status[data-status="refreshing"] .status-dot {
  box-shadow: 0 0 0 4px rgba(242,107,0,.14);
  animation: omailPulse 1.15s ease-in-out infinite;
}
.connection-status[data-status="offline"] .status-dot,
.mobile-connection-banner[data-status="offline"] {
  background: var(--danger);
}
.connection-status[data-status="offline"] .status-dot {
  box-shadow: 0 0 0 4px rgba(217,71,71,.14);
}
.mobile-connection-banner {
  display: none;
  padding: 10px 14px;
  color: white;
  background: var(--otonde-orange);
  font-size: 12px;
  font-weight: 850;
  line-height: 1.35;
}
.refresh-action[disabled] {
  opacity: .55;
  cursor: progress;
  animation: omailSpin .9s linear infinite;
}
@keyframes omailPulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(.72); opacity: .58; }
}
@keyframes omailSpin {
  to { transform: rotate(360deg); }
}
@media (max-width: 1180px) {
  .connection-status { min-width: auto; max-width: 210px; }
  .connection-status span:last-child { display: none; }
}
@media (max-width: 720px) {
  .connection-status { display: none; }
  .mobile-connection-banner:not(.hidden) { display: block; }
  .pane-tools { display:flex; align-items:center; gap:8px; }
  .refresh-action { width: 40px; height: 40px; }
}

/* Omail v6: safer mailbox actions, emoji picker and writing type control */
.danger-action {
  color: var(--danger) !important;
  border-color: rgba(217, 71, 71, .28) !important;
  background: #fff7f7 !important;
}
.danger-action:hover {
  background: #ffe8e8 !important;
  border-color: rgba(217, 71, 71, .55) !important;
}
.enhanced-writing-desk {
  align-items: center;
  flex-wrap: nowrap;
}
.writing-mode-control {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  box-shadow: 0 10px 26px rgba(0,43,77,.05);
}
.writing-mode-control span {
  padding-left: 10px;
  font-size: 11px;
  font-weight: 950;
  color: var(--otonde-blue);
  white-space: nowrap;
}
.writing-mode-control select {
  width: 190px;
  border: 0;
  border-left: 1px solid var(--line);
  border-radius: 0;
  padding: 6px 8px;
  font-size: 12px;
  color: var(--ink);
  background: transparent;
  box-shadow: none !important;
}
.writing-mode-control .apply-mode {
  background: var(--otonde-orange-soft);
  color: var(--otonde-blue);
  border-color: rgba(242,107,0,.26);
}
.emoji-panel {
  margin: 0 18px 12px;
  border: 1px solid rgba(0,43,77,.10);
  border-radius: 18px;
  background: #fff;
  box-shadow: var(--shadow);
  overflow: hidden;
  flex: 0 0 auto;
  max-height: 230px;
  display: flex;
  flex-direction: column;
}
.emoji-panel.hidden { display: none !important; }
.emoji-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(135deg, #fff, var(--otonde-orange-soft));
}
.emoji-head strong { display:block; color: var(--otonde-blue); }
.emoji-head span { display:block; color: var(--muted); font-size: 11px; }
.emoji-grid {
  padding: 10px;
  display: grid;
  grid-template-columns: repeat(10, minmax(30px, 1fr));
  gap: 6px;
  overflow: auto;
}
.emoji-choice {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  min-height: 34px;
  font-size: 18px;
  cursor: pointer;
}
.emoji-choice:hover {
  background: var(--otonde-orange-soft);
  border-color: rgba(242,107,0,.38);
  transform: translateY(-1px);
}
@media (max-width: 720px) {
  .enhanced-writing-desk {
    flex-wrap: nowrap;
    overflow-x: auto;
  }
  .writing-mode-control {
    flex: 0 0 92%;
    border-radius: 18px;
    align-items: stretch;
  }
  .writing-mode-control span {
    display: none;
  }
  .writing-mode-control select {
    width: 100%;
    border-left: 0;
    padding: 10px;
  }
  .writing-mode-control .apply-mode {
    border-radius: 14px;
  }
  .emoji-panel {
    margin: 0 10px 10px;
    max-height: 210px;
  }
  .emoji-grid {
    grid-template-columns: repeat(6, minmax(34px, 1fr));
  }
  .reader-actions {
    gap: 8px;
    flex-wrap: wrap;
  }
  .reader-actions .ghost-btn {
    flex: 1 1 auto;
  }
}

/* Omail v7 multi-mailbox permission polish */
.mailbox-card small {
  display: block;
  margin-top: 8px;
  color: rgba(255,255,255,.58);
  font-size: 11px;
  line-height: 1.35;
}
.from-help {
  font-size: 11px;
  color: var(--muted, #64748b);
  white-space: nowrap;
}
.mailbox-pill {
  background: rgba(0, 43, 77, .08);
  color: #002B4D;
  border-color: rgba(0, 43, 77, .14);
}
.compose-primary:disabled {
  opacity: .5;
  cursor: not-allowed;
}
@media (max-width: 720px) {
  .from-row .from-help {
    width: 100%;
    margin-left: 0;
  }
}

/* Omail v8: font controls, attachment previews and Otonde branded signatures */
.format-strip {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 10px 18px;
  border-top: 1px solid rgba(0,43,77,.06);
  border-bottom: 1px solid rgba(0,43,77,.06);
  background: linear-gradient(135deg, rgba(255,255,255,.88), rgba(246,248,251,.92));
  flex: 0 0 auto;
}
.format-strip label {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}
.format-strip select {
  width: auto;
  min-width: 120px;
  padding: 7px 10px;
  border-radius: 12px;
  background: white;
}
.format-strip .format-hint {
  color: var(--muted);
  font-size: 11px;
  font-weight: 750;
}
.signature-box {
  margin: 0 18px 12px;
  border: 1px solid rgba(0,43,77,.10);
  border-radius: 18px;
  background: #fff;
  overflow: hidden;
  flex: 0 0 auto;
  box-shadow: 0 12px 28px rgba(0,43,77,.06);
}
.signature-options {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(135deg, rgba(0,43,77,.04), rgba(242,107,0,.06));
}
.check-control {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--otonde-blue);
  font-size: 12px;
  font-weight: 900;
  width: auto;
}
.check-control input {
  width: 16px;
  height: 16px;
  accent-color: var(--otonde-orange);
}
.signature-preview {
  padding: 12px 14px;
  background: #fff;
  overflow-x: auto;
}
.signature-preview table {
  margin: 0 !important;
}
.signature-disabled {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  padding: 4px 0;
}
.signature-box.signature-off {
  opacity: .72;
}
.attachment-preview-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 10px;
  width: 100%;
}
.compose-attachment-grid {
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
}
.attachment-preview-card {
  position: relative;
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  min-width: 0;
  border: 1px solid rgba(0,43,77,.10);
  background: linear-gradient(135deg, #fff, #F8FAFD);
  border-radius: 16px;
  padding: 10px;
  box-shadow: 0 10px 24px rgba(0,43,77,.06);
}
.attachment-thumb {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  overflow: hidden;
  border-radius: 14px;
  background: var(--otonde-orange-soft);
  color: var(--otonde-orange);
  font-size: 22px;
  font-weight: 900;
}
.attachment-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.attachment-info {
  min-width: 0;
}
.attachment-info strong {
  display: block;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  color: var(--otonde-blue);
  font-size: 13px;
}
.attachment-info small {
  display: block;
  color: var(--muted);
  font-size: 11px;
  margin-top: 3px;
  font-weight: 750;
}
.attachment-remove,
.attachment-open {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--otonde-blue);
  border-radius: 999px;
  min-width: 32px;
  height: 32px;
  display: inline-grid;
  place-items: center;
  text-decoration: none;
  font-weight: 900;
  padding: 0 10px;
  font-size: 12px;
}
.attachment-remove {
  color: var(--danger);
  font-size: 18px;
  padding: 0;
}
.attachment-open.muted {
  color: var(--muted);
  background: #F6F8FB;
}
.attachment-chips {
  margin: 0 18px 12px;
  flex: 0 0 auto;
}
.attachments .attachment-preview-grid {
  margin-top: 8px;
}
@media (max-width: 720px) {
  .format-strip {
    padding: 9px 12px;
    gap: 8px;
    overflow-x: auto;
    flex-wrap: nowrap;
  }
  .format-strip label,
  .format-strip .tool-btn,
  .format-strip .format-hint {
    flex: 0 0 auto;
  }
  .format-strip .format-hint {
    display: none;
  }
  .format-strip select {
    min-width: 128px;
  }
  .signature-box,
  .attachment-chips {
    margin: 0 12px 10px;
  }
  .signature-options {
    gap: 8px;
  }
  .signature-preview {
    padding: 10px;
  }
  .attachment-preview-grid,
  .compose-attachment-grid {
    grid-template-columns: 1fr;
  }
  .attachment-preview-card {
    grid-template-columns: 44px minmax(0, 1fr) auto;
  }
  .attachment-thumb {
    width: 44px;
    height: 44px;
  }
}
