/* StepAtlas Mail — Gmail design & layout, StepAtlas navy/teal branding.
   Manel (side agent) 2026-12-04. Adapted from the Malya Mail webmail
   stylesheet (same author): identical layout, StepAtlas palette
   (navy #14324f / teal #0a7c6e, matching stepatlas.org's sa.css). */
:root {
  --navy: #14324f;
  --navy2: #1d4066;
  --gold: #0a7c6e;
  --ink: #16283c;
  --mut: #5b7186;
  --line: #d8e1e9;
  --tint: #e0f2ee;
  --tint2: #f2f5f8;
  --active: #cfe8e2;
  --hover-shadow: 0 1px 2px rgba(20,50,79,.18), 0 1px 6px rgba(20,50,79,.12);
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: 'Roboto', Arial, Helvetica, sans-serif;
  color: var(--ink);
  background: linear-gradient(135deg, #d7e3ee 0%, #edf2f6 55%, #f2f5f8 100%);
  font-size: 14px;
  overflow: hidden;
}
button { font-family: inherit; cursor: pointer; background: none; border: 0; color: inherit; }
input, textarea, select { font-family: inherit; }
.ic { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: 0 0 auto; }
.icon-btn {
  width: 40px; height: 40px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center; color: #3c4f66;
}
.icon-btn:hover { background: rgba(20,50,79,.08); }
.icon-btn.small { width: 32px; height: 32px; }
.icon-btn.tiny { width: 22px; height: 22px; }
.icon-btn:disabled { opacity: .35; cursor: default; background: none; }
.btn-navy {
  background: var(--navy); color: #fff; border-radius: 999px;
  padding: 0 24px; height: 40px; font-size: 14px; font-weight: 500;
}
.btn-navy:hover { background: var(--navy2); box-shadow: var(--hover-shadow); }

/* ---------- login ---------- */
.login-wrap { min-height: 100%; display: flex; align-items: center; justify-content: center; padding: 20px; overflow: auto; }
.login-card {
  background: #fff; border-radius: 24px; box-shadow: 0 2px 10px rgba(20,50,79,.18), 0 12px 40px rgba(20,50,79,.12);
  width: 100%; max-width: 430px; padding: 44px 40px 36px; text-align: center;
}
.login-brand { font-size: 30px; font-weight: 700; color: var(--navy); letter-spacing: -.5px; line-height: 1.15; }
.login-brand span { color: var(--gold); font-weight: 400; }
.login-card h1 { font-size: 24px; font-weight: 400; margin: 14px 0 4px; color: var(--navy); }
.login-sub { color: var(--mut); margin: 0 0 26px; }
.fld { display: block; text-align: left; margin-bottom: 16px; }
.fld span { display: block; font-size: 13px; color: var(--navy2); margin-bottom: 6px; font-weight: 500; }
.fld input {
  width: 100%; height: 52px; border: 1px solid #9db2c8; border-radius: 6px;
  padding: 0 14px; font-size: 16px; outline: none; background: #fff;
}
.fld input:focus { border: 2px solid var(--navy); padding: 0 13px; }
.login-err { color: #b3261e; font-size: 13px; min-height: 18px; margin: 2px 0 8px; text-align: left; }
.login-btn { width: 100%; height: 44px; margin-top: 6px; }
.login-foot { color: var(--mut); font-size: 12.5px; line-height: 1.5; margin: 22px 0 0; }

/* ---------- top bar ---------- */
.topbar {
  height: 64px; display: flex; align-items: center; gap: 8px;
  padding: 0 16px 0 8px; position: relative; z-index: 40;
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 216px; padding-left: 8px; }
.brand .brand-name { font-size: 19px; font-weight: 700; color: var(--navy); letter-spacing: -.3px; }
.brand-mail { font-size: 20px; color: var(--gold); font-weight: 400; }
.searchpill {
  flex: 1 1 auto; max-width: 720px; height: 48px; margin: 0 auto 0 24px;
  background: var(--tint); border-radius: 999px; display: flex; align-items: center;
  gap: 10px; padding: 0 16px; color: var(--mut);
  transition: background .15s, box-shadow .15s;
}
.searchpill:focus-within { background: #fff; box-shadow: var(--hover-shadow); color: var(--navy); }
.searchpill input { flex: 1; border: 0; outline: none; background: none; font-size: 16px; color: var(--ink); min-width: 0; }
.searchpill input::placeholder { color: #7186a0; }
.top-right { margin-left: auto; display: flex; align-items: center; gap: 4px; position: relative; }
.avatar {
  width: 36px; height: 36px; border-radius: 50%; background: var(--navy); color: #fff;
  font-size: 16px; font-weight: 500; display: inline-flex; align-items: center; justify-content: center;
  border: 2px solid var(--gold); margin-left: 6px;
}
.menu {
  position: absolute; top: 52px; right: 0; background: #fff; border-radius: 12px;
  box-shadow: 0 4px 18px rgba(20,50,79,.25); min-width: 230px; padding: 6px 0; z-index: 90;
}
.menu-head { padding: 10px 16px; font-weight: 500; color: var(--navy); border-bottom: 1px solid var(--line); margin-bottom: 4px; word-break: break-all; }
.menu-item { display: block; width: 100%; text-align: left; padding: 9px 16px; font-size: 14px; }
.menu-item:hover { background: var(--tint); }
.menu-check { display: flex; gap: 10px; align-items: center; padding: 9px 16px; font-size: 14px; cursor: pointer; }
.menu-check:hover { background: var(--tint); }

/* ---------- layout ---------- */
.layout { display: flex; height: calc(100vh - 64px); height: calc(100dvh - 64px); }
.rail { width: 256px; flex: 0 0 256px; padding: 8px 16px 16px 0; overflow-y: auto; overflow-x: hidden; }
.compose-btn {
  display: flex; align-items: center; gap: 14px; height: 56px; padding: 0 24px 0 18px;
  margin: 0 0 18px 12px; background: #fff; color: var(--navy); border-radius: 16px;
  font-size: 14px; font-weight: 500; box-shadow: 0 1px 3px rgba(20,50,79,.28), 0 4px 12px rgba(20,50,79,.12);
}
.compose-btn:hover { box-shadow: 0 2px 6px rgba(20,50,79,.3), 0 8px 20px rgba(20,50,79,.16); background: #e0f2ee; }
.compose-btn .ic { stroke: var(--gold); stroke-width: 2.2; }
.folders { display: flex; flex-direction: column; }
.folder {
  display: flex; align-items: center; gap: 18px; height: 32px; padding: 0 12px 0 26px;
  border-radius: 0 16px 16px 0; font-size: 14px; color: var(--ink); text-align: left; width: 100%;
}
.folder .ic { width: 18px; height: 18px; color: #43597a; }
.folder:hover { background: rgba(20,50,79,.07); }
.folder.active { background: var(--active); font-weight: 700; color: var(--navy); }
.folder.active .ic { color: var(--navy); }
.folder .cnt { margin-left: auto; font-size: 12px; font-weight: 700; color: inherit; }
.folder .cnt.dim { font-weight: 400; color: var(--mut); }
.labels-head { padding: 18px 12px 6px 26px; font-size: 15px; font-weight: 500; color: var(--navy); display: flex; justify-content: space-between; align-items: center; }
body.rail-mini .rail { width: 72px; flex-basis: 72px; }
body.rail-mini .folder span, body.rail-mini .folder .cnt, body.rail-mini .labels-head, body.rail-mini .compose-btn span { display: none; }
body.rail-mini .compose-btn { padding: 0; width: 56px; justify-content: center; border-radius: 16px; }
body.rail-mini .folder { justify-content: center; padding: 0; border-radius: 16px; margin: 0 8px; }
body.rail-mini .brand { min-width: 0; }
body.rail-mini .brand-mail { display: none; }

.panel {
  flex: 1 1 auto; min-width: 0; background: #fff; border-radius: 20px;
  box-shadow: 0 1px 4px rgba(20,50,79,.16), 0 10px 34px rgba(20,50,79,.10);
  margin: 0 16px 16px 0; display: flex; flex-direction: column; overflow: hidden; position: relative;
}

/* ---------- toolbar / tabs ---------- */
.toolbar {
  min-height: 48px; display: flex; align-items: center; gap: 2px; padding: 4px 12px;
  border-bottom: 1px solid var(--line); position: relative; flex-wrap: wrap;
}
.toolbar input[type="checkbox"], .row input[type="checkbox"] {
  width: 17px; height: 17px; accent-color: var(--navy); cursor: pointer; margin: 0;
}
.selwrap { display: inline-flex; align-items: center; position: relative; padding-left: 6px; }
.pager { margin-left: auto; display: flex; align-items: center; gap: 2px; color: var(--mut); font-size: 12px; }
.pager span { margin-right: 8px; }
.tsep { width: 1px; height: 24px; background: var(--line); margin: 0 8px; }
.tabs { display: flex; border-bottom: 1px solid var(--line); padding: 0 8px; overflow-x: auto; }
.tab {
  flex: 0 1 248px; display: flex; align-items: center; gap: 14px; height: 54px; padding: 0 16px;
  font-size: 14px; color: var(--mut); box-shadow: inset 0 -3px 0 transparent; white-space: nowrap;
}
.tab:hover { background: var(--tint2); }
.tab.active { color: var(--navy); font-weight: 500; box-shadow: inset 0 -3px 0 var(--navy); }
.tab.active .ic { color: var(--gold); stroke-width: 2.1; }

/* ---------- message rows ---------- */
.rows { overflow-y: auto; flex: 1; }
.row {
  display: grid; align-items: center; column-gap: 6px;
  grid-template-columns: 30px 30px 228px minmax(0,1fr) 92px;
  grid-template-areas: "cb star who what when";
  padding: 0 14px 0 10px; min-height: 42px; border-bottom: 1px solid #e4ebf3;
  cursor: pointer; position: relative; background: var(--tint); color: #42556c;
}
.row.unread { background: #fff; color: var(--ink); }
.row.unread .who, .row.unread .subj, .row.unread .when { font-weight: 700; color: #12263f; }
.row.unread::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--gold); }
.row:hover { box-shadow: inset 0 -1px 0 #c9d8ea, 0 1px 3px rgba(20,50,79,.22); z-index: 2; }
.row.checked { background: #d7e5f5; }
.row .cb { grid-area: cb; display: flex; justify-content: center; }
.row .star { grid-area: star; display: inline-flex; justify-content: center; color: #a7b7c9; width: 28px; height: 28px; align-items: center; border-radius: 50%; }
.row .star:hover { background: rgba(20,50,79,.08); }
.row .star.on { color: var(--gold); }
.row .star.on .ic { fill: var(--gold); }
.row .star .ic { width: 18px; height: 18px; }
.row .who { grid-area: who; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 14px; }
.row .what { grid-area: what; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 14px; min-width: 0; }
.row .snip { color: var(--mut); font-weight: 400; }
.row .when { grid-area: when; text-align: right; font-size: 12px; color: var(--mut); }
.row.unread .when { color: var(--navy); }
.chips { display: inline-flex; gap: 6px; margin-left: 10px; vertical-align: middle; }
.chip {
  display: inline-flex; align-items: center; gap: 5px; border: 1px solid #ccd9e8; border-radius: 7px;
  padding: 2px 8px; font-size: 12px; color: #3c4f66; background: #fff; max-width: 210px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.chip .ic { width: 13px; height: 13px; color: #b3261e; }
body.compact .row { min-height: 34px; font-size: 13px; }
.empty { padding: 60px 20px; text-align: center; color: var(--mut); font-size: 15px; }
.loading { padding: 40px; text-align: center; color: var(--mut); }

/* ---------- thread ---------- */
#threadView { display: flex; flex-direction: column; min-height: 0; flex: 1; }
.thread-scroll { overflow-y: auto; padding: 6px 0 30px; }
.subject-row { display: flex; align-items: center; gap: 14px; padding: 14px 24px 4px 72px; flex-wrap: wrap; }
.subject-row h2 { font-size: 22px; font-weight: 400; color: var(--navy); margin: 0; }
.chip-label { background: var(--tint); color: var(--mut); font-size: 12px; border-radius: 5px; padding: 2px 7px; }
.msg { padding: 18px 24px 8px; border-top: 1px solid transparent; }
.msg + .msg { border-top: 1px solid var(--line); margin-top: 8px; }
.msg-head { display: grid; grid-template-columns: 40px minmax(0,1fr) auto; gap: 14px; align-items: start; }
.mavatar { width: 40px; height: 40px; border-radius: 50%; color: #fff; display: flex; align-items: center; justify-content: center; font-size: 17px; font-weight: 500; }
.msg-who { min-width: 0; }
.msg-who .nm { font-weight: 700; color: var(--ink); }
.msg-who .meta { color: var(--mut); font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.msg-side { display: flex; align-items: center; gap: 2px; color: var(--mut); font-size: 12.5px; }
.msg-side .icon-btn { width: 34px; height: 34px; }
.msg-body { margin: 12px 0 8px 54px; font-size: 14px; line-height: 1.6; color: #22344d; }
.msg-body pre.plain { white-space: pre-wrap; word-break: break-word; font: inherit; margin: 0; }
.msg-body iframe { width: 100%; border: 0; min-height: 60px; background: #fff; }
.show-images {
  margin: 0 0 10px 54px; background: #e0f2ee; border: 1px solid #bfe3db; color: #6d5410;
  border-radius: 8px; padding: 8px 12px; font-size: 13px; cursor: pointer;
}
.msg-atts { margin: 10px 0 6px 54px; display: flex; flex-wrap: wrap; gap: 8px; }
.att {
  display: inline-flex; align-items: center; gap: 8px; border: 1px solid #ccd9e8; border-radius: 9px;
  padding: 7px 12px; font-size: 13px; color: var(--navy); background: #fff; text-decoration: none;
}
.att:hover { background: var(--tint); box-shadow: var(--hover-shadow); }
.att .ic { color: #b3261e; width: 16px; height: 16px; }
.att .sz { color: var(--mut); font-size: 12px; }
.msg.collapsed { padding-top: 12px; padding-bottom: 12px; cursor: pointer; }
.msg.collapsed .msg-body, .msg.collapsed .msg-atts { display: none; }
.thread-actions { display: flex; gap: 12px; padding: 22px 24px 6px 72px; }
.pill-btn {
  display: inline-flex; align-items: center; gap: 9px; border: 1px solid #aebfd4; color: var(--navy2);
  border-radius: 999px; padding: 9px 20px; font-size: 14px; font-weight: 500; background: #fff;
}
.pill-btn:hover { background: var(--tint); box-shadow: var(--hover-shadow); }
.pill-btn .ic { width: 17px; height: 17px; }

/* ---------- compose / reply ---------- */
.compose {
  position: fixed; right: 24px; bottom: 0; width: 540px; max-width: calc(100vw - 24px); z-index: 120;
  background: #fff; border-radius: 14px 14px 0 0; box-shadow: 0 8px 34px rgba(20,50,79,.35), 0 2px 8px rgba(20,50,79,.25);
  display: flex; flex-direction: column; max-height: 82vh;
}
.compose.min { height: 42px; overflow: hidden; }
.compose.full { inset: 4vh 4vw; width: auto; max-width: none; border-radius: 14px; max-height: none; }
.compose-head {
  height: 42px; background: var(--tint); border-radius: 14px 14px 0 0; display: flex; align-items: center;
  padding: 0 8px 0 16px; font-weight: 500; color: var(--navy); font-size: 14px; cursor: pointer; flex: 0 0 auto;
}
.compose-head .sp { flex: 1; }
.compose-head .icon-btn { width: 32px; height: 32px; }
.compose form { display: flex; flex-direction: column; min-height: 0; }
.cfld { display: flex; align-items: center; gap: 8px; border-bottom: 1px solid var(--line); padding: 0 16px; min-height: 42px; }
.cfld input { flex: 1; border: 0; outline: none; font-size: 14px; height: 40px; min-width: 0; }
.cfld .ccbcc { color: var(--mut); font-size: 13px; }
.cfld .ccbcc button { color: var(--mut); padding: 4px; }
.cfld .ccbcc button:hover { color: var(--navy); text-decoration: underline; }
.compose textarea {
  border: 0; outline: none; resize: none; padding: 14px 16px; font-size: 14px; line-height: 1.55;
  min-height: 220px; flex: 1; font-family: inherit;
}
.compose.full textarea { min-height: 0; }
.c-atts { display: flex; flex-wrap: wrap; gap: 6px; padding: 6px 16px 0; }
.c-att { display: inline-flex; gap: 7px; align-items: center; background: var(--tint); border-radius: 7px; padding: 4px 6px 4px 10px; font-size: 12.5px; }
.c-att button { color: var(--mut); display: inline-flex; }
.compose-foot { display: flex; align-items: center; gap: 4px; padding: 10px 16px 14px; }
.send-btn {
  background: var(--navy); color: #fff; border-radius: 18px; height: 38px; padding: 0 22px;
  font-size: 14px; font-weight: 500; display: inline-flex; align-items: center; gap: 8px;
}
.send-btn:hover { background: var(--navy2); box-shadow: var(--hover-shadow); }
.send-btn:disabled { opacity: .55; }
.compose-foot .sp { flex: 1; }
.reply-edit { margin: 14px 24px 4px 72px; border: 1px solid #c3d2e4; border-radius: 14px; box-shadow: var(--hover-shadow); overflow: hidden; }
.reply-edit .cfld, .reply-edit textarea { width: 100%; }
.reply-edit textarea { border: 0; outline: none; resize: vertical; min-height: 130px; padding: 12px 16px; font-size: 14px; line-height: 1.55; width: 100%; }
.reply-edit .compose-foot { padding-top: 4px; }

/* ---------- toast / misc ---------- */
#toast {
  position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%); z-index: 300;
  background: var(--navy); color: #fff; border-radius: 9px; padding: 12px 20px; font-size: 14px;
  box-shadow: 0 6px 22px rgba(20,50,79,.4); max-width: 92vw; text-align: center;
}
[hidden] { display: none !important; }

/* ---------- responsive ---------- */
@media (max-width: 1100px) {
  .brand { min-width: 0; }
  .brand-mail { display: none; }
}
@media (max-width: 860px) {
  .rail {
    position: fixed; z-index: 200; top: 0; bottom: 0; left: 0; background: #f2f6fb;
    transform: translateX(-105%); transition: transform .2s; box-shadow: 4px 0 24px rgba(20,50,79,.25);
    padding-top: 14px; height: 100dvh;
  }
  .rail.open { transform: none; }
  body.rail-mini .rail { width: 256px; flex-basis: 256px; }
  body.rail-mini .folder span, body.rail-mini .folder .cnt, body.rail-mini .labels-head, body.rail-mini .compose-btn span { display: initial; }
  body.rail-mini .folder { justify-content: flex-start; padding: 0 12px 0 26px; border-radius: 0 16px 16px 0; margin: 0; }
  body.rail-mini .compose-btn { width: auto; padding: 0 24px 0 18px; justify-content: flex-start; }
  .panel { margin: 0 8px 8px; border-radius: 16px; }
  .searchpill { margin-left: 4px; }
  .row { grid-template-columns: 28px 28px minmax(0,1fr) 66px; grid-template-areas: "cb star who when" "cb star what what"; row-gap: 1px; padding-top: 7px; padding-bottom: 7px; }
  .row .what { font-size: 13px; }
  .chips { display: none; }
  .subject-row, .thread-actions { padding-left: 24px; }
  .msg-body, .show-images, .msg-atts { margin-left: 0; }
  .reply-edit { margin-left: 16px; margin-right: 16px; }
  .compose { right: 0; left: 0; width: auto; max-width: none; max-height: 100dvh; height: 100dvh; border-radius: 0; }
  .compose.min { height: 42px; top: auto; }
  .tab { flex-basis: auto; }
}
