:root {
  --gus-green: #004d3d;
  --gus-green-deep: #00382d;
  --gus-green-soft: #e6f2ef;
  --gus-green-mid: #0a6b56;
  --gus-compose: #c6e4db;
  --ink: #202124;
  --muted: #5f6368;
  --line: #e0e3e1;
  --surface: #ffffff;
  --canvas: #f6f8fc;
  --row-hover: #f2f6f4;
  --row-read: #f7f9f8;
  --danger: #c5221f;
  --warn: #8a6d1f;
  --font: "Roboto", "Helvetica Neue", Arial, sans-serif;
  --topbar-h: 96px;
  --sidebar-w: 256px;
}

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

html, body {
  margin: 0;
  min-height: 100%;
  font-family: var(--font);
  color: var(--ink);
  background: var(--canvas);
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

a { color: var(--gus-green-mid); text-decoration: none; }
a:hover { text-decoration: underline; }
[x-cloak] { display: none !important; }

/* —— Auth (login) —— */
.auth-page { min-height: 100vh; }
.auth-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 2rem 1rem;
  position: relative;
  overflow: hidden;
}
.auth-atmosphere {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 80% 60% at 10% 0%, rgba(0, 77, 61, 0.14), transparent 55%),
    radial-gradient(ellipse 70% 50% at 100% 100%, rgba(0, 77, 61, 0.1), transparent 50%),
    linear-gradient(160deg, #ffffff 0%, #eef6f3 45%, #e4efe9 100%);
  z-index: 0;
}
.auth-card {
  position: relative;
  z-index: 1;
  width: min(420px, 100%);
  background: var(--surface);
  border: 1px solid rgba(0, 77, 61, 0.08);
  border-radius: 20px;
  padding: 2.25rem 2rem 1.75rem;
  box-shadow: 0 18px 50px rgba(0, 40, 30, 0.08);
  animation: rise 0.55s ease-out both;
}
.auth-brand { display: flex; justify-content: center; margin-bottom: 0.75rem; }
.auth-logo { width: min(280px, 100%); height: auto; display: block; }
.auth-tagline {
  text-align: center;
  color: var(--muted);
  font-size: 0.95rem;
  margin: 0 0 1.5rem;
}
.auth-form { display: flex; flex-direction: column; gap: 1rem; }
.auth-footnote {
  margin: 1.25rem 0 0;
  text-align: center;
  font-size: 0.75rem;
  color: var(--muted);
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  font-size: 0.85rem;
  font-weight: 600;
}
.field-input {
  font: inherit;
  font-weight: 400;
  padding: 0.75rem 0.9rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
}
.field-input:focus {
  outline: none;
  border-color: var(--gus-green);
  box-shadow: 0 0 0 3px rgba(0, 77, 61, 0.15);
}
.field-error { color: var(--danger); font-weight: 500; font-size: 0.8rem; }
.field-hint { font-weight: 400; color: var(--muted); font-size: 0.78rem; }
.form-errors { color: var(--danger); font-size: 0.9rem; }

/* —— Brand watermark —— */
.g-watermark {
  position: fixed;
  inset: 0;
  z-index: 5;
  pointer-events: none;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.g-watermark img {
  width: min(68vw, 540px);
  max-width: 92%;
  height: auto;
  opacity: 0.07;
  user-select: none;
  -webkit-user-drag: none;
}
body.g-app .g-watermark {
  /* Bias toward the mail pane (desktop) */
  padding-left: min(18vw, 220px);
}
@media (max-width: 960px) {
  body.g-app .g-watermark {
    padding-left: 0;
  }
  .g-watermark img {
    width: min(78vw, 400px);
    opacity: 0.065;
  }
}
.g-topbar,
.g-sidebar,
.g-sidebar-scrim,
.g-profile-dropdown,
.g-compose-win,
.g-compose-backdrop {
  z-index: 40;
}
.g-compose-win { z-index: 90; }
.g-compose-backdrop { z-index: 85; }
.g-progress { z-index: 400; }
.toast-stack { z-index: 200; }
.auth-card { position: relative; z-index: 2; }

.btn {
  font: inherit;
  font-weight: 600;
  border: none;
  border-radius: 24px;
  padding: 0.7rem 1.25rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  text-decoration: none;
  transition: background 0.15s, box-shadow 0.15s, transform 0.1s;
}
.btn:hover { text-decoration: none; }
.btn:active { transform: scale(0.98); }
.btn-block { width: 100%; }
.btn-primary { background: var(--gus-green); color: #fff; }
.btn-primary:hover { background: var(--gus-green-deep); color: #fff; }
.btn-secondary { background: var(--gus-green-soft); color: var(--gus-green); }
.btn-secondary:hover { background: #d5ebe4; }
.btn.is-busy,
.btn:disabled {
  opacity: 0.88;
  cursor: wait;
  pointer-events: none;
}

/* —— Busy / spinner —— */
.g-spinner {
  width: 0.95em;
  height: 0.95em;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  display: none;
  flex-shrink: 0;
  animation: spin 0.65s linear infinite;
  vertical-align: middle;
}
.is-busy > .g-spinner {
  display: inline-block;
}
.g-btn-label {
  display: inline;
}
.is-busy.g-icon-btn > svg,
.is-busy.g-compose-tool > svg {
  display: none;
}
.is-busy.g-icon-btn::before,
.is-busy.g-compose-tool::before {
  content: "";
  width: 16px;
  height: 16px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin 0.65s linear infinite;
}
.g-compose-win.is-sending .g-compose-tool,
.g-compose-win.is-sending .g-compose-ctrl,
.g-compose-win.is-sending .g-link-btn {
  pointer-events: none;
  opacity: 0.45;
}
.g-profile-logout {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
}
.g-profile-logout.is-busy,
.g-text-btn.is-busy {
  opacity: 0.75;
  cursor: wait;
  pointer-events: none;
}
.g-progress {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 5px;
  z-index: 400;
  pointer-events: none;
  overflow: hidden;
  background: rgba(0, 77, 61, 0.12);
}
.g-progress[hidden] {
  display: none !important;
}
.g-progress:not([hidden])::after,
.g-progress.is-active::after {
  content: "";
  display: block;
  height: 100%;
  width: 38%;
  background: var(--gus-green);
  border-radius: 0 3px 3px 0;
  box-shadow: 0 0 0 1px rgba(0, 77, 61, 0.15);
  animation: g-progress-slide 0.95s ease-in-out infinite;
}
@keyframes g-progress-slide {
  0% { transform: translateX(-130%); }
  100% { transform: translateX(340%); }
}
#mailbox-panel.is-loading {
  position: relative;
  pointer-events: none;
}
#mailbox-panel.is-loading::after {
  content: "";
  position: absolute;
  inset: 0;
  background: rgba(255, 255, 255, 0.35);
  z-index: 5;
  pointer-events: none;
}
.g-thread-toggle.is-busy {
  opacity: 0.7;
  cursor: wait;
  pointer-events: none;
}
.auth-form.is-busy .field {
  pointer-events: none;
  opacity: 0.85;
}
#bulk-form.is-busy {
  cursor: wait;
}
#bulk-form.is-busy .g-toolbar-selected .g-icon-btn {
  pointer-events: none;
  opacity: 0.55;
}
#bulk-form.is-busy .g-toolbar-selected .g-icon-btn.is-busy {
  opacity: 0.9;
}

/* —— Toasts —— */
.toast-stack {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-width: min(360px, calc(100vw - 2rem));
}
.toast {
  padding: 0.85rem 1rem;
  border-radius: 10px;
  background: var(--ink);
  color: #fff;
  font-size: 0.9rem;
  animation: rise 0.35s ease both;
}
.toast-success { background: var(--gus-green); }
.toast-error { background: var(--danger); }
.toast-warning { background: var(--warn); }

.banner {
  margin: 0.5rem 1rem 0;
  padding: 0.75rem 1rem;
  border-radius: 10px;
  font-size: 0.9rem;
}
.banner-warn {
  background: #fff8e6;
  color: var(--warn);
  border: 1px solid #f0e0a8;
}

/* —— Gmail-like app shell —— */
.g-app { background: var(--canvas); }
.g-shell {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
}

.g-topbar {
  height: var(--topbar-h);
  display: grid;
  grid-template-columns: auto minmax(0, 720px) auto;
  align-items: center;
  gap: 1rem;
  padding: 0 1rem 0 0.5rem;
  background: var(--canvas);
  position: sticky;
  top: 0;
  z-index: 40;
}

.g-topbar-left {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  min-width: 180px;
}

.g-brand {
  display: flex;
  align-items: center;
  text-decoration: none;
  color: var(--ink);
  padding: 0.15rem 0.4rem;
}
.g-brand:hover { text-decoration: none; }
.g-brand-logo {
  height: 84px;
  width: auto;
  max-width: 340px;
  object-fit: contain;
  display: block;
  background: transparent;
}

.g-icon-btn {
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  text-decoration: none;
  flex-shrink: 0;
}
.g-icon-btn svg {
  width: 18px;
  height: 18px;
}
.g-icon-btn:hover {
  background: rgba(0, 0, 0, 0.06);
  color: var(--ink);
  text-decoration: none;
}

.g-search {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: #eaf1ef;
  border-radius: 28px;
  padding: 0 0.5rem 0 1rem;
  height: 46px;
  width: 100%;
  max-width: 720px;
  justify-self: center;
  transition: background 0.15s, box-shadow 0.15s;
}
.g-search:focus-within {
  background: #fff;
  box-shadow: 0 1px 3px rgba(60, 64, 67, 0.3), 0 4px 8px rgba(60, 64, 67, 0.15);
}
.g-search-icon { color: var(--muted); display: flex; }
.g-search-input {
  flex: 1;
  border: none;
  background: transparent;
  font: inherit;
  font-size: 1rem;
  outline: none;
  color: var(--ink);
  min-width: 0;
}
.g-search-submit {
  border: none;
  background: var(--gus-green);
  color: #fff;
  font: inherit;
  font-weight: 500;
  font-size: 0.85rem;
  padding: 0.45rem 0.9rem;
  border-radius: 18px;
  cursor: pointer;
}
.g-search-submit:hover { background: var(--gus-green-deep); }

.g-topbar-right {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  min-width: 120px;
}
.g-profile {
  position: relative;
}
.g-profile-btn {
  border: none;
  background: transparent;
  padding: 0;
  cursor: pointer;
  border-radius: 50%;
}
.g-avatar-profile {
  width: 40px;
  height: 40px;
  background: var(--gus-green);
  color: #fff;
}
.g-profile-dropdown {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  min-width: 240px;
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.18);
  border: 1px solid var(--line);
  padding: 0.75rem;
  z-index: 60;
}
.g-profile-email {
  font-size: 0.85rem;
  color: var(--ink);
  padding: 0.35rem 0.5rem 0.75rem;
  word-break: break-all;
  border-bottom: 1px solid var(--line);
  margin-bottom: 0.5rem;
}
.g-profile-logout {
  width: 100%;
  border: none;
  background: var(--gus-green-soft);
  color: var(--gus-green-deep);
  font: inherit;
  font-weight: 600;
  padding: 0.65rem 0.75rem;
  border-radius: 8px;
  cursor: pointer;
}
.g-profile-logout:hover { background: #d5ebe4; }

.g-body {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  flex: 1;
  min-height: 0;
  transition: grid-template-columns 0.22s ease;
}

.g-body.is-sidebar-closed {
  grid-template-columns: 0 1fr;
}

.g-sidebar {
  padding: 0.5rem 0.75rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  height: calc(100vh - var(--topbar-h));
  position: sticky;
  top: var(--topbar-h);
  overflow-x: hidden;
  overflow-y: auto;
  width: var(--sidebar-w);
  min-width: 0;
  transition: opacity 0.2s ease, transform 0.22s ease;
}

.g-body.is-sidebar-closed .g-sidebar {
  opacity: 0;
  pointer-events: none;
  transform: translateX(-12px);
}

.g-compose {
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
  align-self: flex-start;
  margin: 0.25rem 0 0.75rem 0.35rem;
  padding: 0.9rem 1.4rem;
  border-radius: 16px;
  background: var(--gus-compose);
  color: var(--gus-green-deep);
  font-weight: 600;
  font-size: 0.95rem;
  text-decoration: none;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
  transition: box-shadow 0.15s, background 0.15s;
}
.g-compose:hover {
  background: #b6ddd2;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.12);
  text-decoration: none;
}

.g-nav {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}
.g-nav-item {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.55rem 1rem 0.55rem 1.35rem;
  border-radius: 0 20px 20px 0;
  color: var(--ink);
  font-size: 0.92rem;
  font-weight: 500;
  text-decoration: none;
  margin-right: 0.5rem;
}
.g-nav-item:hover {
  background: rgba(0, 0, 0, 0.04);
  text-decoration: none;
}
.g-nav-item.is-active {
  background: var(--gus-green-soft);
  color: var(--gus-green-deep);
  font-weight: 700;
}
.g-nav-item svg { flex-shrink: 0; opacity: 0.85; }

.g-sidebar-footer {
  margin-top: auto;
  padding: 1rem 0.75rem 0.5rem;
  border-top: 1px solid var(--line);
}
.g-sidebar-email {
  font-size: 0.75rem;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.g-sidebar-scrim {
  display: none;
  position: fixed;
  inset: var(--topbar-h) 0 0 0;
  border: none;
  padding: 0;
  margin: 0;
  background: rgba(0, 0, 0, 0.32);
  z-index: 45;
  cursor: pointer;
}
.g-sidebar-scrim:not([hidden]) {
  display: block;
}

.g-main {
  background: var(--surface);
  border-radius: 16px 0 0 0;
  margin-right: 0;
  min-height: calc(100vh - var(--topbar-h) - 8px);
  margin-top: 0;
  box-shadow: inset 1px 0 0 var(--line);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.g-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.2rem 0.75rem;
  border-bottom: 1px solid transparent;
  min-height: 48px;
}
.g-toolbar-left {
  display: flex;
  align-items: center;
  gap: 0.1rem;
}
.g-toolbar-right { color: var(--muted); font-size: 0.8rem; padding-right: 0.5rem; }
.g-toolbar-label { font-weight: 600; margin-left: 0.35rem; }
.g-select-wrap {
  display: inline-flex;
  align-items: center;
  padding: 0 0.25rem 0 0.35rem;
}
.g-toolbar-idle,
.g-toolbar-selected {
  display: inline-flex;
  align-items: center;
  gap: 0.15rem;
}
.g-toolbar-idle[hidden],
.g-toolbar-selected[hidden],
.g-selection-banner[hidden] {
  display: none !important;
}
.g-toolbar-selected .g-icon-btn {
  color: #3c4043;
  width: 32px;
  height: 32px;
}
.g-toolbar-selected .g-icon-btn:hover {
  background: rgba(60, 64, 67, 0.08);
  color: #202124;
}
.g-toolbar-selected .g-icon-btn svg {
  width: 18px;
  height: 18px;
}
.g-toolbar-divider {
  width: 1px;
  height: 22px;
  background: #dadce0;
  margin: 0 0.4rem;
}
.g-selection-banner {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.65rem 1rem;
  background: #f1f3f4;
  color: #3c4043;
  font-size: 0.875rem;
  font-weight: 400;
  border-bottom: 1px solid #e0e0e0;
  text-align: center;
}
.g-selection-banner strong {
  font-weight: 600;
}
#bulk-form.has-selection .g-mail-row.is-selected {
  background: #c2dbff !important;
  box-shadow: none;
}
#bulk-form.has-selection .g-mail-row.is-selected:hover {
  box-shadow: inset 1px 0 0 #dadce0, inset -1px 0 0 #dadce0;
  background: #c2dbff !important;
}
.g-mail-row.is-selected .g-mail-from,
.g-mail-row.is-selected .g-mail-subject,
.g-mail-row.is-selected .g-mail-date {
  font-weight: 400;
}
.g-mail-row.is-selected.is-unread .g-mail-from,
.g-mail-row.is-selected.is-unread .g-mail-subject,
.g-mail-row.is-selected.is-unread .g-mail-date {
  font-weight: 700;
}
.g-text-btn {
  border: none;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-weight: 600;
  font-size: 0.85rem;
  padding: 0.45rem 0.7rem;
  border-radius: 6px;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}
.g-text-btn:hover { background: rgba(0, 0, 0, 0.05); color: var(--ink); text-decoration: none; }
.g-text-danger { color: var(--danger); }
.g-text-danger:hover { background: #fce8e6; color: var(--danger); }
.inline-form { display: inline; margin: 0; }

.g-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--gus-green);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 0.85rem;
  text-transform: uppercase;
}
.g-avatar-lg { width: 40px; height: 40px; font-size: 1rem; }

.g-pagination {
  display: flex;
  align-items: center;
  gap: 0.15rem;
}
.g-icon-btn.is-disabled {
  opacity: 0.35;
  pointer-events: none;
}
.g-icon-btn.is-spinning svg {
  animation: spin 0.7s linear infinite;
}
@keyframes spin {
  to { transform: rotate(360deg); }
}
.g-tab-hint {
  font-weight: 400;
  color: var(--muted);
  margin-left: 0.35rem;
  font-size: 0.8rem;
}
.g-mail-row.is-selected {
  background: #c2dbff !important;
}
.g-check {
  width: 16px;
  height: 16px;
  accent-color: var(--gus-green);
  margin: 0 0.35rem 0 0.5rem;
  cursor: pointer;
}
.toast.is-hiding {
  opacity: 0;
  transform: translateY(-8px);
  transition: opacity 0.25s, transform 0.25s;
}
.toast-stack {
  pointer-events: none;
}

.g-tabs {
  display: flex;
  border-bottom: 1px solid var(--line);
  padding: 0 0.5rem;
}
.g-tab {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.85rem 1.25rem;
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--muted);
  border-bottom: 3px solid transparent;
  margin-bottom: -1px;
}
.g-tab.is-active {
  color: var(--gus-green);
  border-bottom-color: var(--gus-green);
}

.g-list-wrap {
  flex: 1;
  overflow: auto;
}

.g-mail-table { display: flex; flex-direction: column; }

.g-mail-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  border-bottom: 1px solid #eceff1;
  min-height: 40px;
  background: #fff;
  transition: box-shadow 0.12s, background 0.12s;
  position: relative;
}
.g-mail-row:hover {
  box-shadow: inset 1px 0 0 #dadce0, inset -1px 0 0 #dadce0, 0 1px 2px 0 rgba(60, 64, 67, 0.3), 0 1px 3px 1px rgba(60, 64, 67, 0.15);
  z-index: 1;
  background: #fff;
}
.g-mail-row:not(.is-unread) {
  background: var(--row-read);
}
.g-mail-row:not(.is-unread):hover { background: #fff; }

.g-row-actions {
  display: none;
  align-items: center;
  gap: 0.1rem;
  padding-right: 0.5rem;
  background: inherit;
}
@media (hover: hover) and (pointer: fine) {
  .g-mail-row:hover .g-row-actions,
  .g-mail-row.is-selected .g-row-actions {
    display: inline-flex;
  }
  .g-mail-row:hover .g-mail-date,
  .g-mail-row.is-selected .g-mail-date {
    display: none;
  }
}
@media (hover: none), (pointer: coarse) {
  .g-mail-row .g-mail-date {
    display: block;
  }
  .g-mail-row.is-selected .g-row-actions {
    display: inline-flex;
  }
}
.g-row-actions .g-icon-btn {
  color: #3c4043;
  width: 30px;
  height: 30px;
}
.g-row-actions .g-icon-btn svg {
  width: 16px;
  height: 16px;
}
.g-mail-att {
  display: inline-flex;
  vertical-align: middle;
  margin-left: 0.35rem;
  color: #5f6368;
}
.g-mail-from {
  font-size: 0.9rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: #202124;
  min-width: 0;
}

.g-mail-controls {
  display: flex;
  align-items: center;
  padding-left: 0.25rem;
  gap: 0.1rem;
}
.g-star {
  color: #dadce0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.35rem;
  border: none;
  background: transparent;
  border-radius: 50%;
  cursor: pointer;
  width: 32px;
  height: 32px;
}
.g-star svg {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
}
.g-star.is-on {
  color: #f4b400;
}
.g-star.is-on svg {
  fill: currentColor;
  stroke: currentColor;
}
.g-star:hover {
  background: rgba(0, 0, 0, 0.06);
  color: #f4b400;
}
.g-star.is-busy {
  opacity: 0.55;
  pointer-events: none;
  cursor: wait;
}

.g-mail-main {
  display: grid;
  grid-template-columns: 200px minmax(0, 1fr) 72px;
  align-items: center;
  gap: 0.75rem;
  padding: 0.55rem 1rem 0.55rem 0.25rem;
  color: inherit;
  text-decoration: none;
  min-width: 0;
}
.g-mail-main:hover { text-decoration: none; color: inherit; }

.g-mail-from {
  font-size: 0.9rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: #202124;
}
.g-mail-content {
  font-size: 0.9rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}
.g-mail-subject { color: #202124; }
.g-mail-sep,
.g-mail-snippet { color: var(--muted); }
.g-mail-att { margin-left: 0.35rem; font-size: 0.75rem; }
.g-mail-date {
  font-size: 0.8rem;
  color: var(--muted);
  text-align: right;
  white-space: nowrap;
}

.g-mail-row.is-unread .g-mail-from,
.g-mail-row.is-unread .g-mail-subject,
.g-mail-row.is-unread .g-mail-date {
  font-weight: 700;
  color: #202124;
}

.g-empty {
  text-align: center;
  padding: 5rem 1.5rem;
  color: var(--muted);
}
.g-empty-title {
  margin: 0 0 0.35rem;
  font-size: 1.35rem;
  font-weight: 400;
  color: var(--ink);
}
.g-empty-copy { margin: 0; }

/* Read view */
.g-read {
  padding: 1.25rem 1.75rem 2.5rem;
  max-width: 960px;
}
.g-read-subject {
  margin: 0 0 1.25rem;
  font-size: 1.4rem;
  font-weight: 400;
  line-height: 1.35;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.55rem;
}
.g-thread-badge {
  display: inline-flex;
  align-items: center;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--gus-green);
  background: #e6f2ef;
  border-radius: 999px;
  padding: 0.2rem 0.55rem;
}
.g-thread-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.25rem;
  height: 1.25rem;
  margin-left: 0.35rem;
  padding: 0 0.35rem;
  border-radius: 4px;
  background: #e8eaed;
  color: #3c4043;
  font-size: 0.75rem;
  font-weight: 600;
  vertical-align: middle;
}
.g-mail-row.is-unread .g-thread-count {
  background: #d2e3fc;
  color: #174ea6;
}
.g-thread {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}
.g-thread-msg {
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  background: #fff;
  padding: 0.85rem 1rem 1rem;
}
.g-thread-msg.is-current {
  border-color: #c5d4cf;
  box-shadow: 0 1px 2px rgba(0, 77, 61, 0.06);
}
.g-thread-head {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 0.75rem;
  align-items: start;
  margin-bottom: 0.75rem;
}
.g-thread-from { font-weight: 600; font-size: 0.92rem; }
.g-thread-to { font-size: 0.78rem; color: var(--muted); margin-top: 0.12rem; }
.g-thread-date { font-size: 0.78rem; color: var(--muted); white-space: nowrap; }
.g-thread-msg.is-collapsed .g-thread-body,
.g-thread-msg.is-collapsed .g-thread-collapse-wrap,
.g-thread-msg.is-collapsed .attachment-bar {
  display: none;
}
.g-thread-msg.is-collapsed .g-thread-preview {
  display: block;
}
.g-thread-preview {
  display: none;
}
.g-thread-preview-text {
  margin: 0 0 0.55rem;
  color: #5f6368;
  font-size: 0.9rem;
  line-height: 1.45;
}
.g-thread-toggle {
  border: none;
  background: none;
  color: var(--gus-green);
  font: inherit;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  padding: 0;
}
.g-thread-toggle:hover { text-decoration: underline; }
.g-thread-collapse-wrap {
  margin-top: 0.75rem;
  padding-top: 0.5rem;
  border-top: 1px solid #f1f3f4;
}
.g-thread-body {
  max-width: 100%;
  overflow-x: auto;
}
.g-read-meta {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 0.85rem;
  align-items: start;
  margin-bottom: 1.25rem;
}
.g-read-from { font-weight: 600; font-size: 0.95rem; }
.g-read-to { font-size: 0.8rem; color: var(--muted); margin-top: 0.15rem; }
.g-read-date { font-size: 0.8rem; color: var(--muted); }

.attachment-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1.25rem;
}
.attachment-chip {
  display: inline-flex;
  gap: 0.35rem;
  padding: 0.45rem 0.75rem;
  background: var(--gus-green-soft);
  border-radius: 999px;
  font-size: 0.85rem;
  color: var(--gus-green);
  text-decoration: none;
}
.attachment-chip:hover { background: #d5ebe4; text-decoration: none; }
.muted { opacity: 0.7; }
.message-body {
  font-size: 0.95rem;
  line-height: 1.6;
  overflow-wrap: anywhere;
}
.message-body img { max-width: 100%; height: auto; }
.g-mail-frame {
  width: 100%;
  min-height: 280px;
  border: 0;
  background: #fff;
  display: block;
}
.plain-body {
  white-space: pre-wrap;
  font-family: inherit;
  margin: 0;
}

/* Compose */
.g-compose-form {
  display: flex;
  flex-direction: column;
  max-width: 900px;
  margin: 0.5rem 1rem 2rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
  overflow: hidden;
}
.g-compose-row {
  display: grid;
  grid-template-columns: 72px 1fr;
  align-items: center;
  gap: 0.5rem;
  padding: 0.35rem 1rem;
  border-bottom: 1px solid var(--line);
}
.g-compose-row label {
  font-size: 0.85rem;
  color: var(--muted);
}
.g-compose-row input[type="text"],
.g-compose-row input[type="file"] {
  border: none;
  font: inherit;
  padding: 0.55rem 0;
  outline: none;
  width: 100%;
  background: transparent;
}
.g-compose-attach {
  align-items: center;
}
.g-compose-body {
  border: none;
  resize: vertical;
  min-height: 280px;
  padding: 1rem;
  font: inherit;
  line-height: 1.5;
  outline: none;
}
.compose-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.85rem 1rem 1rem;
}
.g-send { min-width: 96px; }

/* —— Floating compose window (Gmail-style) —— */
.g-compose-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.32);
  z-index: 80;
}
.g-compose-backdrop:not([hidden]) { display: block; }

.g-compose-win {
  position: fixed;
  right: 16px;
  bottom: 0;
  width: min(520px, calc(100vw - 24px));
  height: min(520px, calc(100vh - 80px));
  z-index: 90;
  display: none;
  flex-direction: column;
  font-family: Roboto, Helvetica, Arial, sans-serif;
}
.g-compose-win.is-open { display: flex; }
.g-compose-win.is-minimized {
  height: 40px;
  width: min(300px, calc(100vw - 24px));
}
.g-compose-win.is-minimized .g-compose-win-body { display: none; }
.g-compose-win.is-maximized {
  left: 50%;
  right: auto;
  bottom: auto;
  top: 50%;
  transform: translate(-50%, -50%);
  width: min(780px, calc(100vw - 48px));
  height: min(640px, calc(100vh - 64px));
}
.g-compose-win.is-maximized .icon-max { display: none; }
.g-compose-win.is-maximized .icon-restore { display: block !important; }
.g-compose-win:not(.is-maximized) .icon-restore { display: none !important; }

.g-compose-win-inner {
  display: flex;
  flex-direction: column;
  height: 100%;
  background: #fff;
  border-radius: 8px 8px 0 0;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.28);
  overflow: visible;
  border: 1px solid #dadce0;
}
.g-compose-win.is-maximized .g-compose-win-inner {
  border-radius: 8px;
}

.g-compose-win-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #404040;
  color: #fff;
  padding: 0 6px 0 14px;
  height: 40px;
  cursor: default;
  flex-shrink: 0;
  user-select: none;
  border-radius: 8px 8px 0 0;
}
.g-compose-win.is-maximized .g-compose-win-head {
  border-radius: 8px 8px 0 0;
}
.g-compose-win-title {
  font-size: 0.9rem;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.g-compose-win-controls {
  display: flex;
  align-items: center;
}
.g-compose-ctrl {
  width: 32px;
  height: 32px;
  border: none;
  background: transparent;
  color: #fff;
  border-radius: 4px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.g-compose-ctrl:hover { background: rgba(255, 255, 255, 0.12); }

.g-compose-win-body {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  background: #fff;
}
.g-compose-fields { flex-shrink: 0; position: relative; z-index: 6; }
.g-compose-field {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  border-bottom: 1px solid #eceff1;
  padding: 0 12px;
  min-height: 40px;
}
.g-compose-field input {
  flex: 1;
  border: none;
  outline: none;
  font: inherit;
  font-size: 0.9rem;
  padding: 0.55rem 0;
  background: transparent;
  min-width: 0;
}
.g-compose-field-label {
  color: #5f6368;
  font-size: 0.85rem;
  width: 28px;
  flex-shrink: 0;
}
.g-compose-to-row { position: relative; }
.g-compose-suggest-wrap { position: relative; overflow: visible; }
.g-compose-suggest {
  position: absolute;
  left: 0;
  right: 0;
  top: 100%;
  z-index: 40;
  margin: 0;
  padding: 4px 0;
  list-style: none;
  background: #fff;
  border: 1px solid #dadce0;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.14);
  max-height: 240px;
  overflow-y: auto;
}
.g-compose-suggest:not([hidden]) { display: block; }
.g-compose-suggest-item {
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding: 8px 12px;
  cursor: pointer;
  font-size: 0.875rem;
  color: #202124;
}
.g-compose-suggest-item:hover,
.g-compose-suggest-item.is-active {
  background: #e8f0ee;
}
.g-compose-suggest-name {
  font-weight: 500;
  line-height: 1.25;
}
.g-compose-suggest-email {
  color: #5f6368;
  font-size: 0.8rem;
  line-height: 1.25;
}
.g-compose-ccbcc-toggles {
  display: flex;
  gap: 0.65rem;
  flex-shrink: 0;
}
.g-link-btn {
  border: none;
  background: none;
  color: #5f6368;
  font: inherit;
  font-size: 0.85rem;
  cursor: pointer;
  padding: 0;
}
.g-link-btn:hover { color: var(--gus-green); text-decoration: underline; }

.g-compose-win-textarea {
  flex: 1;
  border: none;
  outline: none;
  resize: none;
  padding: 12px;
  font: inherit;
  font-size: 0.9rem;
  line-height: 1.5;
  min-height: 160px;
}
.g-compose-win-editor {
  flex: 1;
  border: none;
  outline: none;
  padding: 12px;
  font: inherit;
  font-size: 0.9rem;
  line-height: 1.5;
  min-height: 160px;
  overflow: auto;
  background: #fff;
  color: #202124;
}
.g-compose-win-editor:empty:before {
  content: attr(data-placeholder);
  color: #9aa0a6;
  pointer-events: none;
}
.g-compose-win-editor img {
  max-width: 100%;
  height: auto;
}

.g-compose-attach-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  padding: 0 12px 8px;
}
.g-compose-attach-list:not([hidden]) { display: flex; }
.g-attach-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  background: #f1f3f4;
  border-radius: 16px;
  padding: 0.25rem 0.55rem;
  font-size: 0.78rem;
  color: #3c4043;
  max-width: 100%;
}
.g-attach-chip span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 180px;
}
.g-attach-chip button {
  border: none;
  background: transparent;
  cursor: pointer;
  color: #5f6368;
  font-size: 1rem;
  line-height: 1;
  padding: 0 2px;
}

.g-compose-win-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px 12px;
  flex-shrink: 0;
  gap: 0.5rem;
}
.g-compose-foot-left {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}
.g-compose-send {
  background: var(--gus-green);
  color: #fff;
  border: none;
  border-radius: 20px;
  font: inherit;
  font-weight: 600;
  font-size: 0.9rem;
  padding: 0.55rem 1.35rem;
  cursor: pointer;
  margin-right: 0.35rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  min-width: 5.75rem;
}
.g-compose-send:hover { background: var(--gus-green-deep); }
.g-compose-send.is-busy,
.g-compose-send:disabled {
  opacity: 0.92;
  cursor: wait;
  pointer-events: none;
}
.g-compose-send.is-busy:hover { background: var(--gus-green); }
.g-compose-autosave {
  font-size: 0.75rem;
  color: #5f6368;
  margin-left: 4px;
  white-space: nowrap;
}
.g-compose-tool {
  width: 36px;
  height: 36px;
  border: none;
  background: transparent;
  border-radius: 50%;
  color: #5f6368;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.g-compose-tool:hover { background: rgba(60, 64, 67, 0.08); color: #202124; }

@media (max-width: 640px) {
  .g-compose-win,
  .g-compose-win.is-maximized {
    left: 0;
    right: 0;
    bottom: 0;
    top: auto;
    transform: none;
    width: 100%;
    height: min(92dvh, 92vh);
    max-height: calc(100dvh - env(safe-area-inset-top, 0px));
    border-radius: 12px 12px 0 0;
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }
  .g-compose-win.is-minimized {
    height: 44px;
    width: 100%;
    border-radius: 12px 12px 0 0;
  }
  .g-compose-win-editor {
    min-height: 140px;
    font-size: 16px; /* prevents iOS zoom on focus */
  }
  .g-compose-field input {
    font-size: 16px;
  }
}

@keyframes rise {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}
.fade-in { animation: rise 0.35s ease both; }
.slide-in { animation: rise 0.4s ease both; }

@media (max-width: 960px) {
  :root {
    --topbar-h: 64px;
  }
  .g-topbar {
    grid-template-columns: auto minmax(0, 1fr) auto;
    gap: 0.4rem;
    padding: 0 0.5rem 0 0.25rem;
    padding-top: env(safe-area-inset-top, 0px);
    height: calc(var(--topbar-h) + env(safe-area-inset-top, 0px));
  }
  .g-topbar-left {
    min-width: 0;
  }
  .g-topbar-right {
    min-width: 0;
  }
  .g-brand {
    padding: 0.1rem 0.2rem;
  }
  .g-brand-logo {
    max-width: 140px;
    height: 40px;
  }
  .g-icon-btn {
    width: 44px;
    height: 44px;
  }
  .g-search {
    height: 40px;
    padding: 0 0.35rem 0 0.65rem;
    gap: 0.35rem;
    border-radius: 22px;
  }
  .g-search-input {
    font-size: 16px; /* prevents iOS zoom on focus */
  }
  .g-search-submit {
    padding: 0.4rem 0.7rem;
    font-size: 0.8rem;
  }
  .g-avatar-profile {
    width: 36px;
    height: 36px;
  }
  .g-body,
  .g-body.is-sidebar-open,
  .g-body.is-sidebar-closed {
    grid-template-columns: 1fr;
  }
  .g-sidebar {
    position: fixed;
    left: 0;
    top: calc(var(--topbar-h) + env(safe-area-inset-top, 0px));
    bottom: 0;
    width: min(300px, 88vw);
    background: var(--canvas);
    z-index: 50;
    transform: translateX(-105%);
    opacity: 1;
    pointer-events: auto;
    transition: transform 0.22s ease;
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.12);
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }
  .g-body.is-sidebar-closed .g-sidebar {
    transform: translateX(-105%);
    opacity: 1;
  }
  .g-sidebar.is-open,
  .g-body.is-sidebar-open .g-sidebar {
    transform: translateX(0);
  }
  .g-compose {
    min-height: 48px;
    padding: 0.75rem 1.1rem;
    font-size: 0.95rem;
  }
  .g-nav-item {
    min-height: 48px;
    padding: 0.75rem 1rem;
    font-size: 0.95rem;
  }
  .g-mail-main {
    grid-template-columns: 1fr auto;
    grid-template-areas:
      "from date"
      "content content";
    gap: 0.2rem 0.5rem;
    padding: 0.7rem 0.75rem 0.7rem 0.15rem;
  }
  .g-mail-from { grid-area: from; font-size: 0.92rem; }
  .g-mail-date { grid-area: date; font-size: 0.75rem; }
  .g-mail-content { grid-area: content; font-size: 0.85rem; }
  .g-mail-snippet { display: none; }
  .g-main { border-radius: 0; }
  .g-toolbar {
    padding: 0.35rem 0.4rem;
    gap: 0.25rem;
    flex-wrap: wrap;
  }
  .g-toolbar-left {
    flex-wrap: wrap;
    gap: 0.15rem;
  }
  .g-text-btn {
    min-height: 40px;
    padding: 0.5rem 0.65rem;
  }
  .g-toolbar-selected .g-icon-btn {
    width: 44px;
    height: 44px;
  }
  .g-read {
    padding: 1rem 0.9rem 2rem;
  }
  .g-read-subject {
    font-size: 1.2rem;
  }
  .g-mail-frame {
    min-height: 220px;
  }
  .g-progress {
    top: env(safe-area-inset-top, 0px);
  }
  .toast-stack {
    top: calc(0.75rem + env(safe-area-inset-top, 0px));
    right: 0.75rem;
    left: 0.75rem;
    max-width: none;
  }
  .auth-shell {
    padding: 1.25rem 1rem;
    padding-bottom: calc(1.25rem + env(safe-area-inset-bottom, 0px));
    min-height: 100dvh;
  }
  .auth-card {
    padding: 1.75rem 1.25rem 1.5rem;
    border-radius: 16px;
  }
  .auth-logo {
    width: min(220px, 100%);
  }
  .field input {
    font-size: 16px;
  }
}

@media (max-width: 420px) {
  .g-search-submit {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
  }
  .g-search {
    position: relative;
  }
  .g-brand-logo {
    max-width: 112px;
    height: 34px;
  }
}
