/* ==========================================================================
   Amlaak Mail - Gmail-style UI
   ========================================================================== */

:root {
  /* Neutral Google palette */
  --gm-bg: #f6f8fc;
  --gm-surface: #ffffff;
  --gm-surface-2: #f2f6fc;
  --gm-text: #202124;
  --gm-text-2: #444746;
  --gm-muted: #5f6368;
  --gm-muted-2: #80868b;
  --gm-border: #e8eaed;
  --gm-divider: #ebedf0;

  /* Accents */
  --gm-blue: #1a73e8;
  --gm-blue-hover: #1557b0;
  --gm-blue-soft: #e8f0fe;
  --gm-pill: #d3e3fd;     /* active folder pill */
  --gm-pill-text: #001d35;
  --gm-compose: #c2e7ff;  /* Gmail compose background */
  --gm-compose-hover: #b3deff;
  --gm-red: #d93025;
  --gm-green: #188038;

  /* Amlaak brand (retained for logo / avatar accents) */
  --am-primary: #075990;
  --am-secondary: #6d124f;

  /* Shadows */
  --gm-shadow-1: 0 1px 2px 0 rgba(60, 64, 67, 0.1), 0 1px 3px 1px rgba(60, 64, 67, 0.08);
  --gm-shadow-2: 0 2px 6px 2px rgba(60, 64, 67, 0.15);
  --gm-shadow-3: 0 4px 16px rgba(32, 33, 36, 0.12);

  --gm-radius: 16px;
  --gm-radius-pill: 9999px;
}

/* Reset --------------------------------------------------------------- */
*,
*::before,
*::after { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--gm-bg);
  color: var(--gm-text);
  font-family: "Google Sans", "Roboto", "Segoe UI", Arial, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a { color: inherit; text-decoration: none; }
button { font: inherit; cursor: pointer; }

img { max-width: 100%; }

.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0);
  white-space: nowrap; border: 0;
}

/* Alerts -------------------------------------------------------------- */
.gm-alert {
  margin: 10px 24px 0;
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 13px;
  background: var(--gm-blue-soft);
  color: var(--gm-blue-hover);
}
.gm-alert.is-error { background: #fce8e6; color: #a50e0e; }
.gm-alert.is-success { background: #e6f4ea; color: var(--gm-green); }

/* ==========================================================================
   LOGIN (index.php) — Google sign-in inspired
   ========================================================================== */
.gm-login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: var(--gm-bg);
}

.gm-login-card {
  width: min(448px, 100%);
  background: var(--gm-surface);
  border: 1px solid var(--gm-border);
  border-radius: 28px;
  padding: 48px 40px 36px;
  box-shadow: var(--gm-shadow-1);
}

.gm-login-brand {
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 16px;
}
.gm-login-brand img {
  max-height: 52px;
  max-width: 180px;
  object-fit: contain;
}

.gm-login-card h1 {
  margin: 0 0 6px;
  text-align: center;
  color: var(--gm-text);
  font-size: 24px;
  font-weight: 400;
  letter-spacing: 0;
}

.gm-login-card .gm-login-sub {
  margin: 0 0 28px;
  text-align: center;
  color: var(--gm-text-2);
  font-size: 16px;
}

.gm-login-field {
  position: relative;
  margin-bottom: 18px;
}
.gm-login-field input {
  width: 100%;
  height: 56px;
  padding: 14px 14px 0;
  border: 1px solid #dadce0;
  border-radius: 4px;
  background: var(--gm-surface);
  color: var(--gm-text);
  font-size: 16px;
  outline: none;
  transition: border-color 150ms ease, box-shadow 150ms ease;
}
.gm-login-field input:focus {
  border-color: var(--gm-blue);
  box-shadow: inset 0 0 0 1px var(--gm-blue);
}
.gm-login-field label {
  position: absolute;
  top: 18px; left: 14px;
  color: var(--gm-muted);
  background: var(--gm-surface);
  padding: 0 4px;
  font-size: 16px;
  pointer-events: none;
  transition: transform 150ms ease, color 150ms ease, font-size 150ms ease;
  transform-origin: left top;
}
.gm-login-field input:focus + label,
.gm-login-field input:not(:placeholder-shown) + label {
  transform: translate(-4px, -26px);
  font-size: 12px;
  color: var(--gm-blue);
}
.gm-login-field input:not(:focus):not(:placeholder-shown) + label {
  color: var(--gm-muted);
}

.gm-login-alert {
  margin: 0 0 16px;
  padding: 10px 12px;
  border-radius: 4px;
  background: #fce8e6;
  color: #a50e0e;
  font-size: 13px;
}

.gm-login-actions {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  margin-top: 28px;
}
.gm-btn-primary {
  background: var(--gm-blue);
  color: #fff;
  border: 0;
  border-radius: 4px;
  padding: 10px 24px;
  font-size: 14px;
  font-weight: 500;
  letter-spacing: 0.25px;
  transition: background 120ms ease, box-shadow 120ms ease;
}
.gm-btn-primary:hover { background: var(--gm-blue-hover); box-shadow: var(--gm-shadow-1); }

.gm-login-note {
  margin: 28px 0 0;
  color: var(--gm-muted);
  font-size: 12px;
  text-align: center;
  line-height: 1.6;
}

/* ==========================================================================
   APP SHELL
   ========================================================================== */
.gm-app {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 256px minmax(0, 1fr);
  grid-template-rows: 64px minmax(0, 1fr);
  grid-template-areas:
    "header header"
    "sidebar main";
  background: var(--gm-bg);
}

/* ---------- HEADER ---------- */
.gm-header {
  grid-area: header;
  display: grid;
  grid-template-columns: 256px minmax(200px, 720px) 1fr;
  align-items: center;
  gap: 16px;
  padding: 8px 16px;
  background: var(--gm-bg);
  border-bottom: 1px solid transparent;
  position: sticky;
  top: 0;
  z-index: 20;
}

.gm-header__start {
  display: flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
}

.gm-iconbtn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px; height: 40px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--gm-text-2);
  transition: background 120ms ease, color 120ms ease;
}
.gm-iconbtn:hover { background: rgba(60, 64, 67, 0.08); color: var(--gm-text); }
.gm-iconbtn:active { background: rgba(60, 64, 67, 0.12); }

.gm-menu-btn { margin-right: 4px; }

.gm-brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 4px 8px;
  min-width: 0;
}
.gm-brand__logo {
  height: 36px;
  width: auto;
  max-width: 44px;
  object-fit: contain;
}
.gm-brand__name {
  color: var(--gm-muted);
  font-size: 22px;
  font-weight: 400;
  letter-spacing: -0.5px;
}

/* Header search pill */
.gm-search {
  display: flex;
  align-items: center;
  height: 48px;
  background: #eaf1fb;
  border-radius: 8px;
  padding: 0 12px;
  gap: 6px;
  transition: background 140ms ease, box-shadow 140ms ease;
  max-width: 720px;
  width: 100%;
  justify-self: start;
}
.gm-search:focus-within {
  background: var(--gm-surface);
  box-shadow: var(--gm-shadow-1);
}
.gm-search__btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px; height: 36px;
  border: 0; border-radius: 50%;
  background: transparent;
  color: var(--gm-text-2);
  flex: 0 0 auto;
}
.gm-search__btn:hover { background: rgba(60, 64, 67, 0.08); }
.gm-search__input {
  flex: 1;
  height: 100%;
  border: 0;
  background: transparent;
  font-size: 15px;
  color: var(--gm-text);
  outline: none;
  min-width: 0;
}
.gm-search__input::placeholder { color: var(--gm-muted); }
.gm-search__tune {
  width: 36px; height: 36px;
  color: var(--gm-muted);
}

.gm-header__end {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
  min-width: 0;
}

/* Account badge */
.gm-account {
  position: relative;
  margin-left: 4px;
  display: inline-flex;
  align-items: center;
  padding: 4px;
  border-radius: 50%;
  outline: none;
}
.gm-account:focus-visible,
.gm-account:hover { background: rgba(60, 64, 67, 0.08); }

.gm-avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px; height: 32px;
  border-radius: 50%;
  color: #fff;
  font-weight: 600;
  font-size: 14px;
  line-height: 1;
  background: var(--am-primary);
  user-select: none;
}
.gm-avatar--lg { width: 40px; height: 40px; font-size: 16px; }

.gm-account__menu {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  min-width: 240px;
  background: var(--gm-surface);
  border-radius: 12px;
  box-shadow: var(--gm-shadow-3);
  padding: 14px 16px;
  z-index: 50;
}
.gm-account__email {
  margin: 0 0 10px;
  color: var(--gm-text);
  font-size: 14px;
  word-break: break-all;
}
.gm-account__logout {
  display: inline-block;
  padding: 8px 14px;
  border: 1px solid var(--gm-border);
  border-radius: var(--gm-radius-pill);
  color: var(--gm-text-2);
  font-weight: 500;
  font-size: 13px;
  transition: background 120ms ease, border-color 120ms ease;
}
.gm-account__logout:hover { background: var(--gm-surface-2); border-color: var(--gm-muted-2); }

/* ---------- SIDEBAR ---------- */
.gm-sidebar {
  grid-area: sidebar;
  padding: 8px 8px 16px;
  overflow-y: auto;
}

.gm-compose {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  min-height: 56px;
  padding: 0 24px 0 16px;
  margin: 8px 8px 16px;
  border-radius: var(--gm-radius);
  background: var(--gm-compose);
  color: var(--gm-pill-text);
  font-weight: 500;
  font-size: 14px;
  letter-spacing: 0.1px;
  box-shadow: var(--gm-shadow-1);
  transition: background 150ms ease, box-shadow 150ms ease;
}
.gm-compose:hover {
  background: var(--gm-compose-hover);
  box-shadow: var(--gm-shadow-2);
}
.gm-compose.is-active { background: var(--gm-compose-hover); }

.gm-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-top: 4px;
}

.gm-nav__item {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 12px 0 24px;
  height: 32px;
  border: 0;
  background: transparent;
  color: var(--gm-text);
  font-size: 14px;
  font-weight: 500;
  text-align: left;
  border-radius: 0 16px 16px 0;
  transition: background 120ms ease, color 120ms ease;
  width: 100%;
}
.gm-nav__item .gm-nav__icon {
  display: inline-flex;
  width: 20px; height: 20px;
  color: var(--gm-text-2);
  flex: 0 0 auto;
}
.gm-nav__item:hover {
  background: rgba(32, 33, 36, 0.06);
}
.gm-nav__item.is-active {
  background: var(--gm-pill);
  color: var(--gm-pill-text);
  font-weight: 700;
}
.gm-nav__item.is-active .gm-nav__icon { color: var(--gm-pill-text); }

.gm-nav__item.is-stub {
  color: var(--gm-muted);
  cursor: default;
}
.gm-nav__item.is-stub:hover { background: rgba(32, 33, 36, 0.04); }

.gm-nav__label { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.gm-labels {
  margin-top: 18px;
  padding: 0 16px 0 24px;
}
.gm-labels__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 32px;
  color: var(--gm-text);
  font-size: 14px;
  font-weight: 500;
}
.gm-labels__plus {
  display: inline-flex;
  color: var(--gm-muted);
}

/* ---------- MAIN ---------- */
.gm-main {
  grid-area: main;
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: var(--gm-bg);
  padding: 4px 16px 24px 0;
}

.gm-card {
  background: var(--gm-surface);
  border-radius: var(--gm-radius);
  box-shadow: var(--gm-shadow-1);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-height: calc(100vh - 96px);
}

/* ---------- LIST TOOLBAR ---------- */
.gm-toolbar {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--gm-divider);
  min-height: 48px;
  flex-wrap: wrap;
}
.gm-toolbar__group {
  display: flex;
  align-items: center;
  gap: 2px;
}
.gm-toolbar__spacer { flex: 1; }

.gm-checkbox {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px; height: 18px;
  border: 2px solid #80868b;
  border-radius: 2px;
  background: transparent;
  transition: border-color 120ms ease, background 120ms ease;
}
.gm-checkbox-wrap {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 4px 6px 10px;
  border-radius: 20px;
  color: var(--gm-text-2);
}
.gm-checkbox-wrap:hover { background: rgba(60, 64, 67, 0.08); }

.gm-pagination {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--gm-muted);
  font-size: 13px;
  padding: 0 8px;
}

.gm-tabs {
  display: flex;
  border-bottom: 1px solid var(--gm-divider);
}
.gm-tab {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  padding: 14px 24px;
  min-width: 280px;
  flex: 1;
  max-width: 340px;
  color: var(--gm-muted);
  border: 0;
  background: transparent;
  font-size: 14px;
  font-weight: 500;
  border-bottom: 3px solid transparent;
  position: relative;
  top: 1px;
}
.gm-tab:hover { background: rgba(60, 64, 67, 0.04); }
.gm-tab.is-active {
  color: var(--gm-blue);
  border-bottom-color: var(--gm-blue);
  font-weight: 600;
}
.gm-tab__icon { display: inline-flex; }
.gm-tab__icon--primary { color: var(--gm-blue); }
.gm-tab__icon--promo { color: #188038; }
.gm-tab__icon--social { color: #1a73e8; }

/* ---------- EMAIL LIST ---------- */
.gm-list {
  display: flex;
  flex-direction: column;
}

.gm-row {
  display: grid;
  grid-template-columns: auto auto auto minmax(140px, 200px) minmax(0, 1fr) auto auto;
  column-gap: 12px;
  align-items: center;
  padding: 0 16px 0 8px;
  min-height: 40px;
  border-bottom: 1px solid var(--gm-divider);
  background: var(--gm-surface-2);
  color: var(--gm-text-2);
  cursor: pointer;
  transition: box-shadow 120ms ease, background 120ms ease, z-index 0s;
  position: relative;
}
.gm-row:hover {
  box-shadow: inset 1px 0 0 #dadce0, inset -1px 0 0 #dadce0, 0 1px 2px rgba(60, 64, 67, 0.15), 0 1px 3px 1px rgba(60, 64, 67, 0.08);
  z-index: 1;
  background: var(--gm-surface);
}
.gm-row.is-unread {
  background: var(--gm-surface);
  color: var(--gm-text);
}
.gm-row.is-unread .gm-row__sender,
.gm-row.is-unread .gm-row__subject,
.gm-row.is-unread .gm-row__date {
  font-weight: 700;
  color: var(--gm-text);
}

.gm-row__cell {
  display: inline-flex;
  align-items: center;
  padding: 6px 4px;
}
.gm-row__check {
  color: var(--gm-muted-2);
  padding-left: 4px;
}
.gm-row__star {
  color: var(--gm-muted-2);
  padding: 4px;
  border-radius: 50%;
  transition: background 120ms ease, color 120ms ease;
}
.gm-row__star:hover { background: rgba(60, 64, 67, 0.08); color: var(--gm-text-2); }

.gm-row__important {
  color: var(--gm-muted-2);
}

.gm-row__sender {
  font-size: 14px;
  color: inherit;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding: 8px 0;
}

.gm-row__preview {
  display: flex;
  align-items: baseline;
  gap: 6px;
  min-width: 0;
  overflow: hidden;
  padding: 8px 0;
}
.gm-row__subject {
  color: inherit;
  font-size: 14px;
  white-space: nowrap;
}
.gm-row__dash { color: var(--gm-muted); flex: 0 0 auto; }
.gm-row__snippet {
  color: var(--gm-muted);
  font-weight: 400;
  font-size: 14px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
  flex: 1;
}
.gm-row.is-unread .gm-row__snippet { color: var(--gm-text-2); }

.gm-row__attach {
  color: var(--gm-muted);
}
.gm-row__date {
  color: var(--gm-muted);
  font-size: 12px;
  text-align: right;
  white-space: nowrap;
  padding: 8px 0;
  min-width: 72px;
}

.gm-row__hoverbar {
  display: none;
  grid-column: 7 / 8;
  gap: 2px;
  align-items: center;
}
.gm-row:hover .gm-row__hoverbar { display: inline-flex; }
.gm-row:hover .gm-row__date { display: none; }

/* empty state */
.gm-empty {
  padding: 56px 24px;
  text-align: center;
  color: var(--gm-muted);
}
.gm-empty h2 {
  margin: 0 0 6px;
  color: var(--gm-text);
  font-weight: 400;
  font-size: 18px;
}

/* ---------- EMAIL DETAIL ---------- */
.gm-detail {
  display: flex;
  flex-direction: column;
  padding: 16px 24px 40px;
}

.gm-detail__subject-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 24px;
  align-items: start;
  padding: 12px 4px 20px;
}
.gm-detail__subject {
  margin: 0;
  font-size: 22px;
  font-weight: 400;
  color: var(--gm-text);
  line-height: 1.35;
  word-break: break-word;
}
.gm-detail__labels {
  display: inline-flex;
  gap: 6px;
  margin-left: 10px;
  vertical-align: middle;
}
.gm-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 8px 2px 10px;
  background: var(--gm-border);
  color: var(--gm-text-2);
  border-radius: 4px;
  font-size: 12px;
  font-weight: 500;
  line-height: 1.6;
}
.gm-chip__x {
  color: var(--gm-muted);
  display: inline-flex;
  align-items: center;
}

.gm-detail__actions {
  display: inline-flex;
  gap: 4px;
  color: var(--gm-muted);
}

.gm-thread {
  border-top: 1px solid var(--gm-divider);
  padding-top: 16px;
}

.gm-sender-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 14px;
  align-items: start;
  padding: 6px 4px 18px;
}
.gm-sender-row .gm-avatar { flex: 0 0 auto; }

.gm-sender-meta { min-width: 0; }
.gm-sender-meta__line1 {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 8px;
  min-width: 0;
}
.gm-sender-meta__name {
  font-weight: 700;
  color: var(--gm-text);
  font-size: 14px;
  overflow-wrap: anywhere;
}
.gm-sender-meta__email {
  color: var(--gm-muted);
  font-size: 12px;
  overflow-wrap: anywhere;
}
.gm-sender-meta__to {
  color: var(--gm-muted);
  font-size: 12px;
  margin-top: 2px;
  display: flex;
  align-items: center;
  gap: 4px;
}
.gm-sender-meta__date {
  color: var(--gm-muted);
  font-size: 12px;
  white-space: nowrap;
  padding-top: 3px;
}
.gm-sender-actions {
  display: inline-flex;
  gap: 4px;
  color: var(--gm-muted);
}

.gm-body {
  padding: 0 4px 8px;
  font-size: 14px;
  color: var(--gm-text);
  line-height: 1.6;
  word-break: break-word;
}
.gm-body p { margin: 0 0 1em; }
.gm-body a { color: var(--gm-blue); }
.gm-body img { max-width: 100%; height: auto; border-radius: 4px; }
.gm-body table { max-width: 100%; border-collapse: collapse; }
.gm-body pre {
  background: var(--gm-surface-2);
  padding: 12px;
  border-radius: 8px;
  overflow-x: auto;
}

.gm-attachments {
  margin-top: 26px;
  padding-top: 18px;
  border-top: 1px solid var(--gm-divider);
}
.gm-attachments__head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
  color: var(--gm-muted);
  font-size: 13px;
  font-weight: 500;
}
.gm-attachments__grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 10px;
  list-style: none;
  margin: 0; padding: 0;
}
.gm-attachment {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--gm-border);
  border-radius: 8px;
  background: var(--gm-surface);
  color: var(--gm-text-2);
  font-size: 13px;
  min-height: 56px;
  overflow-wrap: anywhere;
}
.gm-attachment__icon {
  flex: 0 0 auto;
  color: var(--gm-red);
}

.gm-thread-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 24px 0 0;
}
.gm-action-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 22px;
  border: 1px solid #dadce0;
  border-radius: var(--gm-radius-pill);
  background: var(--gm-surface);
  color: var(--gm-text-2);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background 140ms ease, box-shadow 140ms ease, border-color 140ms ease;
  text-decoration: none;
}
.gm-action-pill:hover {
  background: var(--gm-surface-2);
  box-shadow: var(--gm-shadow-1);
}
.gm-action-pill__badge {
  display: inline-flex;
  align-items: center;
  padding: 1px 8px;
  border-radius: 10px;
  background: var(--gm-blue);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.5px;
}

/* ---------- REPLY / COMPOSE FORMS ---------- */
.gm-reply {
  margin: 20px 0 0;
  border: 1px solid var(--gm-border);
  border-radius: 12px;
  background: var(--gm-surface);
  box-shadow: var(--gm-shadow-1);
  overflow: hidden;
}
.gm-reply__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 14px;
  background: var(--gm-surface-2);
  border-bottom: 1px solid var(--gm-divider);
}
.gm-reply__to {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  color: var(--gm-text-2);
  font-size: 13px;
  min-width: 0;
}
.gm-reply__to strong { color: var(--gm-text); font-weight: 500; }
.gm-reply__to-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  background: var(--gm-border);
  border-radius: var(--gm-radius-pill);
  font-size: 12px;
  font-weight: 500;
  color: var(--gm-text-2);
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.gm-reply__subj {
  padding: 10px 14px;
  border-bottom: 1px solid var(--gm-divider);
  display: flex;
  align-items: baseline;
  gap: 8px;
  color: var(--gm-text-2);
  font-size: 13px;
}
.gm-reply__subj strong { color: var(--gm-text); font-weight: 500; overflow-wrap: anywhere; }

.gm-reply__body textarea {
  display: block;
  width: 100%;
  min-height: 220px;
  padding: 16px 18px;
  border: 0;
  outline: none;
  resize: vertical;
  background: transparent;
  color: var(--gm-text);
  font-size: 14px;
  line-height: 1.55;
  font-family: inherit;
}

.gm-reply__actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 14px 14px;
  border-top: 1px solid var(--gm-divider);
}
.gm-send {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  background: var(--gm-blue);
  color: #fff;
  border: 0;
  border-radius: var(--gm-radius-pill);
  padding: 10px 22px;
  font-size: 14px;
  font-weight: 500;
  transition: background 120ms ease, box-shadow 120ms ease;
}
.gm-send:hover { background: var(--gm-blue-hover); box-shadow: var(--gm-shadow-1); }
.gm-send:disabled { opacity: 0.6; cursor: not-allowed; }
.gm-reply__tools {
  display: inline-flex;
  gap: 2px;
  color: var(--gm-muted);
}

/* Compose window (Gmail-style floating panel) */
.gm-compose-window {
  margin: 24px auto;
  max-width: 720px;
  background: var(--gm-surface);
  border-radius: 12px 12px 0 0;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.28);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.gm-compose-window__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 8px 8px 16px;
  background: #404040;
  color: #e8eaed;
  font-size: 14px;
  font-weight: 500;
}
.gm-compose-window__head-actions { display: inline-flex; gap: 2px; }
.gm-compose-window__head .gm-iconbtn { color: #e8eaed; width: 32px; height: 32px; }
.gm-compose-window__head .gm-iconbtn:hover { background: rgba(255,255,255,0.12); color: #fff; }

.gm-compose-window__field {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 16px;
  border-bottom: 1px solid var(--gm-divider);
}
.gm-compose-window__field label {
  color: var(--gm-muted);
  font-size: 13px;
  width: 50px;
  flex: 0 0 auto;
}
.gm-compose-window__field input,
.gm-compose-window__field textarea {
  flex: 1;
  border: 0;
  outline: none;
  background: transparent;
  font-family: inherit;
  font-size: 14px;
  color: var(--gm-text);
  padding: 8px 0;
  min-width: 0;
}
.gm-compose-window__body textarea {
  width: 100%;
  min-height: 320px;
  border: 0;
  outline: none;
  resize: vertical;
  padding: 16px;
  font-size: 14px;
  font-family: inherit;
  line-height: 1.55;
  color: var(--gm-text);
  background: transparent;
}
.gm-compose-window__foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px 14px;
  border-top: 1px solid var(--gm-divider);
  gap: 10px;
}
.gm-compose-window__foot-tools {
  display: inline-flex;
  gap: 2px;
  color: var(--gm-muted);
}

.gm-back-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border: 1px solid var(--gm-border);
  border-radius: var(--gm-radius-pill);
  background: var(--gm-surface);
  color: var(--gm-text-2);
  font-size: 13px;
  text-decoration: none;
  font-weight: 500;
}
.gm-back-btn:hover { background: var(--gm-surface-2); border-color: var(--gm-muted-2); }

/* Error card (used by send.php / reply.php) */
.gm-error-card {
  max-width: 640px;
  margin: 32px auto;
  padding: 32px 28px;
  background: var(--gm-surface);
  border-radius: 12px;
  box-shadow: var(--gm-shadow-1);
  text-align: left;
}
.gm-error-card h1 {
  margin: 0 0 16px;
  font-size: 22px;
  font-weight: 400;
  color: var(--gm-text);
}
.gm-error-card .gm-alert { margin: 0 0 16px; }
.gm-error-card__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 20px;
}

/* ==========================================================================
   RESPONSIVE
   ========================================================================== */
@media (max-width: 1100px) {
  .gm-app {
    grid-template-columns: 220px minmax(0, 1fr);
  }
  .gm-header {
    grid-template-columns: 220px minmax(200px, 1fr) auto;
  }
  .gm-tab { min-width: 220px; padding: 14px 16px; }
  .gm-hide-md { display: none !important; }
}

@media (max-width: 820px) {
  .gm-app {
    grid-template-columns: 1fr;
    grid-template-rows: 64px auto 1fr;
    grid-template-areas:
      "header"
      "sidebar"
      "main";
  }
  .gm-header {
    grid-template-columns: auto minmax(0, 1fr) auto;
    padding: 8px 12px;
    gap: 8px;
  }
  .gm-brand__name { display: none; }
  .gm-hide-sm { display: none !important; }

  .gm-sidebar {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding: 8px 12px;
    border-bottom: 1px solid var(--gm-divider);
  }
  .gm-compose {
    margin: 0;
    min-height: 44px;
    padding: 0 20px 0 14px;
    flex: 0 0 auto;
  }
  .gm-nav {
    flex-direction: row;
    margin: 0;
    flex: 1;
    gap: 2px;
  }
  .gm-nav__item {
    height: 40px;
    padding: 0 14px;
    border-radius: var(--gm-radius-pill);
    flex: 0 0 auto;
    width: auto;
  }
  .gm-nav__label { font-size: 13px; }
  .gm-labels { display: none; }

  .gm-main { padding: 8px; }
  .gm-card { min-height: calc(100vh - 160px); border-radius: 12px; }

  .gm-row {
    grid-template-columns: auto minmax(0, 1fr) auto;
    grid-template-areas:
      "check sender date"
      ".     preview preview";
    row-gap: 4px;
    padding: 10px 12px;
  }
  .gm-row__cell.gm-row__check { grid-area: check; }
  .gm-row__cell.gm-row__star { display: none; }
  .gm-row__important { display: none; }
  .gm-row__sender { grid-area: sender; }
  .gm-row__preview { grid-area: preview; }
  .gm-row__attach { display: none; }
  .gm-row__date { grid-area: date; }
  .gm-row__hoverbar { display: none !important; }
  .gm-row:hover .gm-row__date { display: block; }

  .gm-detail { padding: 12px 14px 24px; }
  .gm-detail__subject { font-size: 18px; }
  .gm-tab { min-width: auto; padding: 12px; }
}

@media (max-width: 520px) {
  .gm-search { height: 42px; }
  .gm-detail__subject-row { grid-template-columns: 1fr; gap: 8px; }
  .gm-detail__actions { justify-self: end; }
  .gm-sender-row { grid-template-columns: auto minmax(0, 1fr); }
  .gm-sender-meta__date,
  .gm-sender-actions { grid-column: 1 / -1; }
  .gm-compose-window { margin: 8px; border-radius: 12px; }
}
