/* #######################################################################
   🐢 Turtle Mail — UI/UX Stylesheet v0.7.1
   100% Pure CSS — Light/Dark parity + Gmail-style alignment
####################################################################### */

/* ===== Base / neutral tokens (non-color) ============================ */
*{box-sizing:border-box}
html,body{height:100%}
:root{
  --radius:12px;
  --elev:0 1px 2px rgba(0,0,0,.5),0 2px 8px rgba(0,0,0,.35);
  --elev-light:0 1px 2px rgba(15,23,42,.06),0 2px 8px rgba(15,23,42,.06);

  --brand:#00A33E;      /* turtle green */
  --brand-2:#008A35;
  --cta:#E76A1E;        /* turtle orange */
  --danger:#E53935;     /* turtle red */
  --info:#1976D2;       /* turtle blue */
}

/* ===== THEME PALETTES =============================================== */
.theme-light{
  color-scheme:light;
  --bg:#ffffff;
  --fg:#1f2328;
  --muted:#6b7280;
  --border:#e5e7eb;
  --hover:#f5f6f8;
  --chip:#eef2ff;
  --shadow:var(--elev-light);
}
.theme-dark{
  color-scheme:dark;
  --bg:#0b0e12;
  --fg:#e5e7eb;
  --muted:#9aa4b2;
  --border:#1f2937;
  --hover:#151922;
  --chip:#1c2233;
  --shadow:var(--elev);
}

/* ===== Global typography & transitions =============================== */
body{
  margin:0;
  background:var(--bg);
  color:var(--fg);
  font:14px/1.4 system-ui,-apple-system,Segoe UI,Roboto,Arial,sans-serif;
  transition:background-color .25s ease,color .25s ease,border-color .25s ease;
}
html.theme-light,html.theme-dark{
  transition:background-color .25s ease,color .25s ease,border-color .25s ease;
}
a{color:inherit;text-decoration:none}
kbd{font:12px/1 monospace;border:1px solid var(--border);border-bottom-width:2px;border-radius:4px;padding:1px 4px;background:var(--hover)}
.tiny{font-size:12px}

/* ===== Topbar ======================================================== */
.tm-topbar{
  position:sticky;top:0;z-index:1000;
  display:grid;grid-template-columns:minmax(220px,auto) 1fr auto;
  align-items:center;column-gap:12px;
  background:var(--bg);
  border-bottom:1px solid var(--border);
  padding:8px 16px;
  height:56px;
}
.tm-topbar__left,.tm-topbar__right{display:flex;align-items:center;gap:10px}
.tm-topbar__right{justify-self:end}
.tm-brand{display:flex;align-items:center;gap:10px}
.tm-brand .brand-sub{font-weight:700;opacity:.9}

/* Search pill */
.tm-search{
  align-self:center;justify-self:center;
  width:min(720px,100%);
  display:flex;align-items:center;gap:8px;
  height:44px;padding:0 12px 0 14px;
  border:1px solid var(--border);
  background:var(--hover);
  border-radius:999px;
  box-shadow:inset 0 0 0 1px transparent;
}
.tm-search:focus-within{box-shadow:0 1px 2px rgba(0,0,0,.25)}
.tm-search .search-icn{opacity:.85;display:inline-grid;place-items:center;width:20px}
.tm-search input{flex:1;border:0;background:transparent;outline:0;color:var(--fg);font:14px/1.2 inherit}
.tm-search .opts{
  width:32px;height:32px;border-radius:50%;
  border:1px solid var(--border);background:var(--bg);
  cursor:pointer;display:inline-grid;place-items:center;
}
.tm-search .opts:hover{background:var(--hover)}
.tm-avatar{width:32px;height:32px;border-radius:50%;object-fit:cover;cursor:pointer}

/* Light-specific adjustments for search */
.theme-light .tm-search{
  background:#f5f6f8;
  border-color:#d7d9de;
}
.theme-light .tm-search input::placeholder{color:#888}
.theme-light .tm-search .opts{
  background:#fff;
  border-color:#d7d9de;
}
.theme-light .tm-search .opts:hover{background:#f0f2f5}

/* ===== Layout grid (rails) ========================================== */
.tm-shell{
  display:grid;
  grid-template-columns:56px 264px 1fr 56px; /* app rail | folders | main | right apps */
  min-height:calc(100vh - 56px);
}
body.nav-collapsed .tm-shell{grid-template-columns:56px 72px 1fr 56px}

/* Subtle separators (no double borders) */
.tm-apprail,.tm-leftnav{
  box-shadow:inset -1px 0 0 var(--border);
  border-right:none;
}
.tm-apprail{display:flex;justify-content:center;padding:8px 0;background:var(--bg)}
.tm-leftnav{background:var(--bg);transition:transform .2s ease}
.tm-main{min-width:0}
.tm-rightrail{border-left:1px solid var(--border);display:flex;justify-content:center;padding:8px 0}

@media(max-width:1200px){
  .tm-shell{grid-template-columns:56px 0 1fr 48px}
  body.nav-collapsed .tm-shell{grid-template-columns:56px 0 1fr 48px}
  .tm-leftnav{transform:translateX(-100%)}
  .tm-leftnav.open{transform:translateX(0)}
}

/* ===== Rails (icons) ================================================= */
.apprail{display:flex;flex-direction:column;gap:8px}
.appicon{width:40px;height:40px;border-radius:12px;border:1px solid var(--border);display:grid;place-items:center;background:var(--bg);box-shadow:var(--shadow)}
.appicon img{width:22px;height:22px;object-fit:contain;opacity:.9;transition:opacity .15s}
.appicon:hover{background:var(--hover)}
.appicon:hover img{opacity:1}
.appicon.active{outline:2px solid var(--brand)}

.apps{display:flex;flex-direction:column;gap:8px}
.app{width:40px;height:40px;border-radius:12px;border:1px solid var(--border);background:var(--bg);box-shadow:var(--shadow);display:grid;place-items:center}
.app img{width:22px;height:22px;object-fit:contain;opacity:.9;transition:opacity .15s}
.app:hover{background:var(--hover)}
.app:hover img{opacity:1}

/* ===== Buttons / Compose / Folders =================================== */
.btn{border:1px solid var(--border);background:var(--bg);padding:6px 10px;border-radius:8px;cursor:pointer}
.btn:hover{background:var(--hover)}
.btn.icon.only{padding:6px;width:32px;height:32px;display:inline-grid;place-items:center}
.compose-pill{display:flex;align-items:center;gap:10px;border-radius:999px;padding:12px 18px;font-weight:600;background:var(--hover)}
.compose-pill:hover{filter:brightness(1.03)}

body.nav-collapsed .folders{padding:8px}
body.nav-collapsed .compose-pill{width:40px;height:40px;padding:0;border-radius:12px;justify-content:center}
body.nav-collapsed .compose-pill .label{display:none}
body.nav-collapsed .folder{justify-content:center}
body.nav-collapsed .folder .label,
body.nav-collapsed .folder .count{display:none}

.folders{padding:12px;display:flex;flex-direction:column;gap:6px}
.folder{display:flex;align-items:center;gap:12px;padding:10px 12px;border-radius:12px}
.folder .icon{width:20px;display:inline-grid;place-items:center}
.folder:hover{background:var(--hover)}
.folder.active{background:var(--hover);font-weight:700}
.folder .count{margin-left:auto;font-variant-numeric:tabular-nums;opacity:.9}
.folder .count.bad{color:var(--danger);font-weight:700}

/* ===== Inbox ========================================================= */
.tm-inbox{padding:12px 0}
.tm-toolbar{position:sticky;top:56px;z-index:900;display:flex;align-items:center;gap:8px;padding:10px 12px;border-bottom:1px solid var(--border);background:var(--bg)}
.tm-toolbar .group{display:flex;gap:8px}
.pager{display:flex;align-items:center;gap:8px}
.tm-list{margin:0;padding:0;list-style:none}
.tm-list .row{display:grid;grid-template-columns:36px 28px minmax(180px,1fr) 3fr 100px;gap:12px;align-items:center;padding:14px 16px;border-bottom:1px solid var(--border)}
.tm-list .row:hover{background:var(--hover)}
.tm-list .row.unread .from,.tm-list .row.unread .subject{font-weight:800}
.star{border:1px solid transparent;background:transparent;padding:2px 6px;border-radius:8px;cursor:pointer}
.time{justify-self:end}
.dash{opacity:.65;margin:0 4px}
.snippet{opacity:.85}

/* ===== Thread view =================================================== */
.tm-thread{padding:8px 0}
.tm-thread-head{position:sticky;top:56px;z-index:900;display:grid;grid-template-columns:auto 1fr auto;gap:12px;align-items:center;padding:8px 12px;background:var(--bg);border-bottom:1px solid var(--border)}
.thread-subject{margin:0;font-size:18px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.thread-participants{display:flex;gap:6px;padding:8px 12px;border-bottom:1px solid var(--border);background:var(--bg)}
.thread-stack{list-style:none;margin:0;padding:0}
.msg-card{padding:14px 16px;border-bottom:1px solid var(--border)}
.msg-card.unread .from{font-weight:700}
.msg-head{display:grid;grid-template-columns:40px 1fr auto;gap:10px;align-items:center}
.avatar{width:36px;height:36px;border-radius:999px;display:grid;place-items:center;font-weight:700;background:#dde6ff;color:#223}
.avatar.me{background:#d1fae5;color:#124}
.from-to .from{font-weight:600}
.msg-actions{display:flex;align-items:center;gap:8px}
.msg-body{margin-left:50px;margin-top:8px}
.msg-body p{margin:0 0 12px}
.quote summary{cursor:pointer}
.composer{border-top:1px solid var(--border);margin-top:8px;padding:12px 16px;display:flex;flex-direction:column;gap:8px}
.composer-head{display:grid;grid-template-columns:40px 1fr;gap:10px;align-items:center}
.composer textarea{width:100%;min-height:120px;resize:vertical;padding:10px;border:1px solid var(--border);border-radius:8px;background:var(--bg);color:var(--fg)}
.compose-actions{display:flex;align-items:center;gap:8px}

/* ===== Panels / Toast =============================================== */
.panel{width:min(560px,92vw);border:1px solid var(--border);border-radius:var(--radius);background:var(--bg);color:var(--fg);box-shadow:var(--shadow)}
.panel header,.panel footer{padding:10px 12px;border-bottom:1px solid var(--border)}
.panel footer{border-top:1px solid var(--border);border-bottom:0}
.panel .panel-body{padding:12px}
.toast{position:fixed;right:16px;bottom:16px;background:var(--bg);border:1px solid var(--border);padding:10px 12px;border-radius:10px;box-shadow:var(--shadow);display:none}
.toast.show{display:block}

/* ===== Density ====================================================== */
.compact .tm-list .row{padding:10px 12px;gap:10px}
.compact .msg-card{padding:10px 12px}
.compact .composer textarea{min-height:90px}