/**
 * Roundcube-inspired light skin (classic webmail layout).
 */
:root {
  --rc-bg-page: #dfe4ef;
  --rc-bg-panel: #f4f6fb;
  --rc-bg-sidebar: #d4dbe8;
  --rc-bg-toolbar: #ebeff5;
  --rc-bg-hover: #ecf1f8;
  --rc-bg-row: #ffffff;
  --rc-border: #bcc4d3;
  --rc-border-soft: #c9d0dc;
  --rc-text: #333333;
  --rc-text-muted: #5e6673;
  --rc-link: #3760a0;
  --rc-link-hover: #1f4e8c;
  --rc-primary: #4a6ea9;
  --rc-primary-hover: #3d5f95;
  --rc-primary-text: #ffffff;
  --rc-danger-bg: #fde8e8;
  --rc-danger-border: #e8b4b4;
  --rc-danger-text: #8b1a1a;
  --rc-ok-bg: #e8f5e9;
  --rc-ok-border: #a5d6a7;
  --rc-ok-text: #1b5e20;
  --rc-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
  --rc-topbar-h: 52px;
  --rc-sidebar-w: 212px;
}

* {
  box-sizing: border-box;
}

html {
  font-size: 15px;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  /* keeps wide mail tables scrolling inside wrappers, not the whole viewport */
  overflow-x: hidden;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--rc-text);
  background: var(--rc-bg-page);
  line-height: 1.45;
  display: flex;
  flex-direction: column;
}

a {
  color: var(--rc-link);
}

a:hover {
  color: var(--rc-link-hover);
  text-decoration: underline;
}

.rc-topbar {
  height: var(--rc-topbar-h);
  min-height: var(--rc-topbar-h);
  background: linear-gradient(180deg, #fafbfd 0%, #e8ecf4 100%);
  border-bottom: 1px solid var(--rc-border);
  box-shadow: var(--rc-shadow);
  z-index: 20;
}

.rc-topbar-inner {
  max-width: 100%;
  height: 100%;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  row-gap: 0.25rem;
  padding: 0.35rem calc(0.75rem + env(safe-area-inset-right, 0)) 0.35rem calc(1rem + env(safe-area-inset-left, 0));
  gap: 0.75rem;
}

.rc-logo {
  font-weight: 700;
  font-size: 1.15rem;
  color: var(--rc-text);
  text-decoration: none;
  letter-spacing: 0.03em;
}

.rc-logo:hover {
  text-decoration: none;
  color: var(--rc-link);
}

.rc-topbar-center {
  flex: 1;
}

.rc-userbar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.9rem;
  color: var(--rc-text-muted);
}

.rc-user-id {
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rc-link-logout {
  color: var(--rc-link);
  font-weight: 500;
}

.rc-workspace {
  flex: 1;
  display: flex;
  min-height: 0;
}

.rc-sidebar {
  width: var(--rc-sidebar-w);
  min-width: var(--rc-sidebar-w);
  background: var(--rc-bg-sidebar);
  border-right: 1px solid var(--rc-border);
  display: flex;
  flex-direction: column;
}

.rc-sidebar-head {
  padding: 0.65rem 1rem;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--rc-text-muted);
  border-bottom: 1px solid var(--rc-border-soft);
}

.rc-sidebar-subhead {
  padding: 0.45rem 0.95rem 0.35rem;
  font-size: 0.67rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--rc-text-muted);
}

.rc-folder-divider-wrap {
  list-style: none;
  padding: 0.25rem 0.85rem 0.05rem;
  margin: 0;
}

.rc-folder-divider {
  display: block;
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--rc-text-muted);
  letter-spacing: 0.12em;
  border-bottom: 1px solid var(--rc-border-soft);
  padding-bottom: 0.2rem;
  margin-bottom: 0.2rem;
}

.rc-folders {
  list-style: none;
  margin: 0;
  padding: 0.35rem 0;
}

.rc-folder {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.52rem 0.85rem;
  margin: 0 0.4rem;
  border-radius: 4px;
  color: var(--rc-text);
  text-decoration: none;
  font-size: 0.95rem;
  border: 1px solid transparent;
}

.rc-folder:hover {
  background: rgba(255, 255, 255, 0.45);
  text-decoration: none;
  border-color: var(--rc-border-soft);
}

.rc-folder.is-active {
  background: #eef2fa;
  border-color: var(--rc-border);
  font-weight: 600;
}

.rc-folder-ico {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  opacity: 0.85;
}

.rc-ico-inbox {
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%233760a0'%3E%3Cpath d='M20 4H4c-1.1 0-2 .9-2 2v12c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V6c0-1.1-.9-2-2-2zm0 4l-8 5-8-5V6l8 5 8-5v2z'/%3E%3C/svg%3E")
    center / contain no-repeat;
}

.rc-ico-compose {
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%235e6673'%3E%3Cpath d='M3 17.25V21h3.75L17.81 9.94l-3.75-3.75L3 17.25zM20.71 7.04c.39-.39.39-1.02 0-1.41l-2.34-2.34c-.39-.39-1.02-.39-1.41 0l-1.83 1.83 3.75 3.75 1.83-1.83z'/%3E%3C/svg%3E")
    center / contain no-repeat;
}

.rc-ico-drafts {
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%235e6673'%3E%3Cpath d='M14 2H6c-1.1 0-1.99.9-1.99 2L4 20c0 1.1.89 2 1.99 2H18c1.1 0 2-.9 2-2V8l-6-6zm2 16H8v-2h8v2zm0-4H8v-2h8v2zm-3-5V3.5L18.5 9H13z'/%3E%3C/svg%3E")
    center / contain no-repeat;
}

.rc-ico-sent {
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%233760a0'%3E%3Cpath d='M2.01 21L23 12 2.01 3 2 10l15 2-15 2z'/%3E%3C/svg%3E")
    center / contain no-repeat;
}

.rc-ico-junk {
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%23a85a2a'%3E%3Cpath d='M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm1 15h-2v-2h2v2zm0-4h-2V7h2v6z'/%3E%3C/svg%3E")
    center / contain no-repeat;
}

.rc-ico-trash {
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%235e6673'%3E%3Cpath d='M6 19c0 1.1.9 2 2 2h8c1.1 0 2-.9 2-2V7H6v12zM19 4h-3.5l-1-1h-5l-1 1H5v2h14V4z'/%3E%3C/svg%3E")
    center / contain no-repeat;
}

.rc-ico-folder {
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%235e6673'%3E%3Cpath d='M10 4H4c-1.1 0-1.99.9-1.99 2L2 18c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V8c0-1.1-.9-2-2-2h-8l-2-2z'/%3E%3C/svg%3E")
    center / contain no-repeat;
}

.rc-sidebar-foot {
  margin-top: auto;
  padding: 0.6rem 0.95rem;
  font-size: 0.72rem;
  color: var(--rc-text-muted);
  word-break: break-all;
  border-top: 1px solid var(--rc-border-soft);
}

.rc-page {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: var(--rc-bg-panel);
}

.rc-main {
  flex: 1;
  padding: 0;
  padding-bottom: env(safe-area-inset-bottom, 0);
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.rc-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2.625rem;
  padding: 0.42rem 0.85rem;
  border-radius: 4px;
  border: 1px solid var(--rc-border);
  background: linear-gradient(180deg, #fff 0%, #ebeff7 100%);
  color: var(--rc-text);
  font-size: 0.87rem;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.8);
}

.rc-btn:hover {
  border-color: #9aa9be;
  text-decoration: none;
  background: linear-gradient(180deg, #fff 0%, #dfe6f4 100%);
}

.rc-btn-primary {
  background: linear-gradient(180deg, #5f84c9 0%, var(--rc-primary) 100%);
  border-color: #3f5f99;
  color: var(--rc-primary-text);
  text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.12);
}

.rc-btn-primary:hover {
  background: linear-gradient(180deg, #6d93d6 0%, var(--rc-primary-hover) 100%);
  color: #fff;
  border-color: #355887;
}

.rc-btn-danger {
  background: linear-gradient(180deg, #e88 0%, #c44 100%);
  border-color: #a33;
  color: #fff;
  text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.15);
}

.rc-btn-danger:hover {
  background: linear-gradient(180deg, #ea5555 0%, #b33 100%);
  color: #fff;
  border-color: #822;
}

button.rc-btn {
  font-family: inherit;
}

.rc-toolbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.35rem;
  padding: 0.45rem 0.85rem;
  background: var(--rc-bg-toolbar);
  border-bottom: 1px solid var(--rc-border-soft);
}

.rc-toolbar-gap {
  flex: 1;
}

.rc-toolbar-meta {
  font-size: 0.85rem;
  color: var(--rc-text-muted);
}

.rc-toolbar-folder {
  font-weight: 600;
  color: var(--rc-text);
  padding: 0 0.25rem;
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rc-panel {
  margin: 0.75rem;
  background: var(--rc-bg-row);
  border: 1px solid var(--rc-border);
  border-radius: 6px;
  box-shadow: var(--rc-shadow);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.rc-panel-flat {
  margin: 0.75rem;
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.rc-mail-frame {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  border-radius: 6px;
  border: 1px solid var(--rc-border);
  background: var(--rc-bg-row);
  overflow: hidden;
}

.rc-table-wrap {
  flex: 1;
  overflow: auto;
  min-height: 120px;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;
}

.rc-mail-table {
  width: 100%;
  min-width: 560px;
  border-collapse: collapse;
  font-size: 0.92rem;
}

.rc-mail-table thead th {
  text-align: left;
  padding: 0.45rem 0.65rem;
  background: linear-gradient(180deg, #f6f8fc 0%, #dfe5ef 100%);
  border-bottom: 1px solid var(--rc-border);
  font-weight: 600;
  color: var(--rc-text-muted);
  font-size: 0.8rem;
  white-space: nowrap;
}

.rc-mail-table thead th.cell-check {
  width: 64px;
  text-align: center;
}

.rc-mail-table thead th.cell-from {
  width: 26%;
}

.rc-mail-table thead th.cell-subj {
  width: auto;
}

.rc-mail-table thead th.cell-date {
  width: 190px;
  text-align: right;
}

.rc-mail-table tbody td {
  padding: 0.45rem 0.65rem;
  border-bottom: 1px solid #dde3ea;
  vertical-align: middle;
}

.rc-mail-table tbody tr {
  background: #fff;
}

.rc-mail-table tbody tr:nth-child(even) {
  background: #f9fafc;
}

.rc-mail-table tbody tr:hover {
  background: var(--rc-bg-hover);
}

.rc-mail-table tbody tr.is-unread {
  font-weight: 600;
  background: #dce8fb;
}

.rc-mail-table tbody tr.is-unread:nth-child(even) {
  background: #cdddf7;
}

.rc-mail-row-link {
  color: inherit;
  text-decoration: none;
}

.rc-mail-row-link:hover {
  text-decoration: underline;
}

.cell-status {
  text-align: center;
}

.rc-msg-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--rc-primary);
  vertical-align: middle;
}

.rc-msg-dot-read {
  background: transparent;
  border: 2px solid #b0bccf;
}

.wm-check-wrap {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  vertical-align: middle;
}

.cell-check[data-stop-row-nav="1"] {
  text-align: center;
}

.rc-mail-table tbody td.cell-check {
  white-space: nowrap;
}

.wm-inbox-bulk-form {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

.rc-inbox-bulkbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
  padding: 0.45rem 0.85rem;
  background: linear-gradient(180deg, #f2f5fa 0%, #e5eaf3 100%);
  border-bottom: 1px solid var(--rc-border-soft);
}

.rc-bulkbar-hint {
  font-size: 0.8rem;
  color: var(--rc-text-muted);
}

.rc-cell-from,
.rc-cell-subj {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 1px;
}

.rc-cell-from {
  color: var(--rc-text-muted);
}

.rc-cell-date {
  text-align: right;
  color: var(--rc-text-muted);
  font-size: 0.86rem;
  white-space: nowrap;
}

.rc-empty {
  padding: 2.5rem 1rem;
  text-align: center;
  color: var(--rc-text-muted);
}

.rc-message-card {
  margin: 0.75rem;
  background: #fff;
  border: 1px solid var(--rc-border);
  border-radius: 6px;
  box-shadow: var(--rc-shadow);
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.rc-msg-toolbar {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.45rem 0.85rem;
  background: var(--rc-bg-toolbar);
  border-bottom: 1px solid var(--rc-border-soft);
}

.rc-msg-toolbar-msg {
  flex-wrap: wrap;
  gap: 0.5rem 0.65rem;
}

.rc-msg-actions {
  margin-left: auto;
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  justify-content: flex-end;
  align-items: center;
}

.rc-msg-delete-form {
  margin: 0;
  display: inline-flex;
  align-items: center;
}

.rc-msg-delete-form button.rc-btn {
  padding: 0.38rem 0.72rem;
  font-size: 0.84rem;
}

.rc-message-meta-chips {
  margin-top: 0.75rem;
  font-size: 0.82rem;
  color: var(--rc-text-muted);
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.rc-meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 0.5rem;
}

.rc-meta-k {
  min-width: 2rem;
  font-weight: 600;
  color: var(--rc-text-muted);
}

.rc-meta-v {
  color: var(--rc-text);
  word-break: break-word;
}

.rc-attach-strip {
  margin-top: 0.85rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.rc-attach-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.35rem 0.65rem;
  border: 1px solid var(--rc-border-soft);
  border-radius: 4px;
  background: var(--rc-bg-row);
  text-decoration: none;
  font-size: 0.82rem;
  color: var(--rc-text);
  max-width: 100%;
}

.rc-attach-chip:hover {
  border-color: var(--rc-primary);
  background: var(--rc-bg-panel);
}

.rc-attach-ico {
  width: 14px;
  height: 14px;
  border-radius: 2px;
  background: linear-gradient(145deg, #8aa4d8, var(--rc-primary));
  opacity: 0.85;
  flex-shrink: 0;
}

.rc-attach-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 220px;
}

.rc-attach-mime {
  flex-shrink: 0;
  color: var(--rc-text-muted);
  font-size: 0.75rem;
}

.wm-compose-stack {
  border: 1px solid var(--rc-border-soft);
  border-radius: 4px;
  background: #fff;
  margin-bottom: 0.85rem;
  overflow: hidden;
}

.wm-compose-row {
  display: grid;
  grid-template-columns: 86px minmax(0, 1fr);
  gap: 0.5rem;
  align-items: center;
  border-bottom: 1px solid var(--rc-border-soft);
  padding: 0.35rem 0.65rem;
  min-height: 2.4rem;
}

.wm-compose-row.wm-compose-row-grow {
  align-items: stretch;
  padding-top: 0.55rem;
  padding-bottom: 0.55rem;
}

.wm-compose-row-grow > .wm-compose-label {
  align-self: start;
  padding-top: 0.5rem;
}

.wm-compose-label {
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--rc-text-muted);
  padding-right: 0.25rem;
}

.wm-compose-input {
  min-width: 0;
}

.wm-compose-ident {
  font-size: 0.92rem;
  color: var(--rc-text);
  word-break: break-all;
}

.wm-compose-input input[type="text"] {
  width: 100%;
  border: none;
  outline: none;
  padding: 0.35rem 0.15rem;
  background: transparent;
  border-radius: 0;
}

.wm-compose-input input[type="text"]:focus {
  box-shadow: none;
}

.wm-editor-shell {
  border: 1px solid var(--rc-border);
  border-radius: 4px;
  background: #fff;
}

#wm-rich-zone .wm-editor-mount {
  min-height: 300px;
}

.wm-editor-shell .wm-editor-mount {
  min-height: 300px;
}

.wm-editor-shell .ql-toolbar.ql-snow {
  border: none;
  border-bottom: 1px solid var(--rc-border-soft);
  border-radius: 4px 4px 0 0;
}

.wm-editor-shell .ql-container.ql-snow {
  border: none;
  border-radius: 0 0 4px 4px;
  font-family: inherit;
  font-size: 0.92rem;
}

.wm-editor-fallback {
  padding: 0.35rem;
}

.wm-body-fallback-ta {
  display: block;
  width: 100%;
  min-height: 300px;
  padding: 0.55rem 0.65rem;
  font-size: 0.92rem;
  font-family: inherit;
  line-height: 1.45;
  border: 1px solid var(--rc-border-soft);
  border-radius: 4px;
  resize: vertical;
  box-sizing: border-box;
  background: #fff;
}

.wm-body-fallback-ta:focus {
  outline: none;
  border-color: var(--rc-primary);
  box-shadow: 0 0 0 1px rgba(74, 110, 169, 0.25);
}

.wm-fallback-note {
  margin: 0.4rem 0 0;
  font-size: 0.8rem;
  color: var(--rc-text-muted);
}

.wm-compose-form .rc-file-hint {
  display: inline-block;
  margin-left: 0.65rem;
  font-size: 0.82rem;
  color: var(--rc-text-muted);
  vertical-align: middle;
}

.wm-file-input {
  font-size: 0.86rem;
  max-width: 100%;
}

.rc-message-head {
  padding: 1rem 1.2rem;
  border-bottom: 1px solid var(--rc-border-soft);
}

.rc-message-head h1 {
  margin: 0 0 0.35rem;
  font-size: 1.15rem;
  font-weight: 600;
}

.rc-message-head .sub {
  font-size: 0.88rem;
  color: var(--rc-text-muted);
}

.rc-message-body {
  padding: 1rem 1.2rem;
  flex: 1;
  overflow: auto;
}

.body-plain {
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 0.92rem;
}

.mail-html-wrap {
  border: 1px solid var(--rc-border);
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 1rem;
}

.mail-html {
  width: 100%;
  min-height: 320px;
  border: none;
  background: #fff;
}

/* Gmail-inspired message reader */
.gm-msg-view {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: #f6f8fc;
}

.gm-msg-toolbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
  padding: 0.5rem calc(1rem + env(safe-area-inset-right, 0)) 0.5rem calc(1rem + env(safe-area-inset-left, 0));
  background: linear-gradient(180deg, #fafbfd 0%, #eef2f7 100%);
  border-bottom: 1px solid var(--rc-border-soft);
  flex-shrink: 0;
}

.gm-msg-toolbar--foot {
  border-bottom: none;
  border-top: 1px solid var(--rc-border-soft);
  margin-top: 1rem;
  padding-top: 0.75rem;
}

.gm-msg-back {
  font-weight: 600;
}

.gm-msg-actions-strip {
  margin-left: auto;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
  justify-content: flex-end;
}

.gm-act-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.45rem 0.85rem;
  min-height: 2.625rem;
  border-radius: 999px;
  border: 1px solid #dadce0;
  background: #fff;
  color: #444746;
  font-size: 0.84rem;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  font-family: inherit;
}

.gm-act-btn:hover {
  background: #f1f3f4;
  text-decoration: none;
  border-color: #c4c7c5;
}

.gm-act-primary {
  background: #c2e7ff;
  border-color: #a8d8f8;
  color: #001d35;
}

.gm-act-primary:hover {
  background: #aecbfa;
}

.gm-act-primary .gm-act-ico::before {
  content: "";
  display: inline-block;
  width: 0;
  height: 0;
  border: 6px solid transparent;
  border-right: none;
  border-left: 10px solid #001d35;
}

.gm-act-btn-danger {
  color: var(--rc-danger-text, #822);
  border-color: #eab4b4;
  background: #fff5f5;
}

.gm-act-btn-danger:hover {
  background: #fdecef;
}

.gm-msg-delete-form.rc-msg-delete-form {
  margin: 0;
}

.gm-msg-delete-form.rc-msg-delete-form button {
  appearance: none;
}

.gm-msg-sheet {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  max-width: 960px;
  width: 100%;
  margin: 0 auto;
  padding: 0 clamp(0.65rem, 3vw, 1rem) max(2rem, env(safe-area-inset-bottom)) clamp(0.65rem, 3vw, 1rem);
  box-sizing: border-box;
}

.gm-msg-subject-row {
  padding: 0.85rem 0 1rem;
  border-bottom: 1px solid #e8eaed;
}

.gm-unread-chip {
  display: inline-block;
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 0.15rem 0.45rem;
  border-radius: 4px;
  background: #fef7e0;
  border: 1px solid #f9e4a8;
  color: #764d00;
  margin-right: 0.5rem;
  vertical-align: middle;
}

.gm-msg-subject {
  margin: 0;
  padding: 0.35rem 0 0;
  font-size: 1.4rem;
  font-weight: 400;
  line-height: 1.35;
  color: #202124;
  word-break: break-word;
}

@media (max-width: 640px) {
  .gm-msg-subject {
    font-size: 1.2rem;
  }
}

.gm-msg-sender-card {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr) auto;
  gap: 0.85rem;
  align-items: start;
  padding: 1rem 0;
  border-bottom: 1px solid #e8eaed;
}

@media (max-width: 620px) {
  .gm-msg-sender-card {
    grid-template-columns: 44px minmax(0, 1fr);
  }

  .gm-msg-date-pill {
    grid-column: span 2;
    justify-self: start;
    margin-top: 0.35rem;
  }
}

.gm-msg-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: linear-gradient(135deg, #5f84c9, #8badde);
  color: #fff;
  font-weight: 700;
  font-size: 0.92rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.gm-msg-sender-meta {
  min-width: 0;
}

.gm-msg-from-name {
  font-weight: 600;
  color: #202124;
  font-size: 0.94rem;
  margin-right: 0.25rem;
}

.gm-msg-from-addr {
  font-size: 0.82rem;
  color: var(--rc-text-muted);
  word-break: break-all;
}

.gm-msg-details {
  margin-top: 0.35rem;
  font-size: 0.8rem;
  color: #5f6368;
}

.gm-msg-details-sum {
  cursor: pointer;
  list-style: none;
}

.gm-msg-details-sum::-webkit-details-marker {
  display: none;
}

.gm-msg-details-sum:hover .gm-details-label {
  color: var(--rc-link);
}

.gm-to-me,
.gm-details-label {
  display: inline;
}

.gm-msg-dl {
  margin: 0.6rem 0 0;
  padding: 0.65rem 0.75rem;
  background: #f8fafc;
  border: 1px solid #eef0f4;
  border-radius: 6px;
}

.gm-msg-dl-row {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  gap: 0.5rem;
  font-size: 0.82rem;
  padding: 0.2rem 0;
}

.gm-msg-dl-row dt {
  margin: 0;
  font-weight: 600;
  color: #757b85;
}

.gm-msg-dl-row dd {
  margin: 0;
  word-break: break-word;
}

.gm-msg-date-pill {
  font-size: 0.8rem;
  color: var(--rc-text-muted);
  white-space: nowrap;
  justify-self: end;
  align-self: start;
  padding-top: 0.15rem;
}

.gm-msg-attach-panel {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  padding: 0.85rem 0;
  border-bottom: 1px solid #eceff3;
}

.gm-attach-tile {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  min-width: 200px;
  max-width: 100%;
  padding: 0.55rem 0.85rem;
  border: 1px solid #dadce0;
  border-radius: 8px;
  background: #fff;
  color: inherit;
  text-decoration: none;
  box-shadow: 0 1px 2px rgba(60, 64, 67, 0.1);
}

.gm-attach-tile:hover {
  border-color: #aecbfa;
  background: #f8fafc;
  text-decoration: none;
}

.gm-attach-svg {
  width: 44px;
  height: 48px;
  flex-shrink: 0;
  background: repeating-linear-gradient(-45deg, #eaeef5 0px, #eaeef5 4px, #fff 4px, #fff 8px);
  border-radius: 4px;
  border: 1px solid #e0e3e8;
}

.gm-attach-info {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.gm-attach-name {
  font-size: 0.86rem;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.gm-attach-mime {
  font-size: 0.75rem;
  color: #5f6368;
}

.gm-attach-save {
  flex-shrink: 0;
  font-size: 0.76rem;
  font-weight: 600;
  color: var(--rc-link);
  margin-left: auto;
}

.gm-msg-body {
  padding: 1rem 0 2rem;
  background: transparent;
}

.gm-html-frame {
  border: none;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(60, 64, 67, 0.12), 0 1px 1px rgba(60, 64, 67, 0.08);
  background: #fff;
}

.gm-html-iframe {
  display: block;
  width: 100%;
  min-height: clamp(260px, 55vh, 720px);
  border: none;
  background: #fff;
}

.gm-plain-collapse {
  margin-top: 0.85rem;
  font-size: 0.82rem;
  color: #5f6368;
}

.gm-plain-collapse summary {
  cursor: pointer;
  font-weight: 600;
  padding: 0.35rem 0;
}

.gm-plain-inner.body-plain {
  margin-top: 0.35rem;
  padding: 0.75rem 1rem;
  background: #fff;
  border: 1px solid #ebeff5;
  border-radius: 6px;
  font-size: 0.86rem;
  color: #3c4043;
}

.gm-plain-main.body-plain {
  padding: 0.85rem 1rem;
  background: #fff;
  border-radius: 8px;
  border: 1px solid #eceff3;
  font-size: 0.9rem;
  line-height: 1.56;
}

.rc-compose-card {
  margin: 0.75rem;
  background: #fff;
  border: 1px solid var(--rc-border);
  border-radius: 6px;
  box-shadow: var(--rc-shadow);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.rc-compose-head {
  padding: 0.65rem 1rem;
  font-weight: 700;
  font-size: 1rem;
  border-bottom: 1px solid var(--rc-border-soft);
  background: linear-gradient(180deg, #f6f8fc 0%, #eef2f7 100%);
}

.rc-compose-body {
  padding: 1rem;
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.rc-form-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 0.75rem;
}

.rc-form-table th {
  width: 88px;
  padding: 0.4rem 0.5rem 0.4rem 0;
  text-align: right;
  vertical-align: top;
  font-weight: 600;
  font-size: 0.88rem;
  color: var(--rc-text-muted);
}

.rc-form-table td {
  padding: 0.35rem 0;
  vertical-align: middle;
}

label {
  font-size: 0.88rem;
  color: var(--rc-text-muted);
}

input[type="text"],
input[type="password"],
input[type="email"],
textarea {
  width: 100%;
  padding: 0.45rem 0.55rem;
  border: 1px solid var(--rc-border);
  border-radius: 3px;
  background: #fff;
  color: var(--rc-text);
  font-size: 0.92rem;
  font-family: inherit;
}

input:focus,
textarea:focus {
  outline: none;
  border-color: var(--rc-primary);
  box-shadow: 0 0 0 1px rgba(74, 110, 169, 0.25);
}

textarea {
  min-height: 280px;
  resize: vertical;
}

.rc-form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  padding-top: 0.5rem;
  border-top: 1px solid var(--rc-border-soft);
  margin-top: auto;
}

.rc-foot {
  padding: 0.45rem 1rem;
  padding-bottom: max(0.45rem, env(safe-area-inset-bottom));
  font-size: 0.75rem;
  color: var(--rc-text-muted);
  text-align: center;
  border-top: 1px solid var(--rc-border);
  background: #d2d9e6;
}

.rc-login {
  background: var(--rc-bg-page);
}

.rc-login-frame {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding-top: max(1.35rem, env(safe-area-inset-top));
  padding-left: max(1rem, env(safe-area-inset-left));
  padding-right: max(1rem, env(safe-area-inset-right));
  padding-bottom: max(2rem, env(safe-area-inset-bottom));
}

.rc-login-box {
  width: 100%;
  max-width: 420px;
  background: #fff;
  border: 1px solid var(--rc-border);
  border-radius: 8px;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.08);
  overflow: hidden;
}

.rc-login-head {
  background: linear-gradient(180deg, #5f84c9 0%, var(--rc-primary) 100%);
  color: #fff;
  padding: 0.85rem 1.25rem;
  font-weight: 700;
  font-size: 1.05rem;
  text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.15);
  border-bottom: 1px solid #355887;
}

.rc-login-body {
  padding: 1.25rem 1.35rem 1.5rem;
}

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

.alert {
  padding: 0.55rem 0.7rem;
  border-radius: 4px;
  margin-bottom: 1rem;
  font-size: 0.88rem;
}

.alert.error {
  background: var(--rc-danger-bg);
  border: 1px solid var(--rc-danger-border);
  color: var(--rc-danger-text);
}

.alert.ok {
  background: var(--rc-ok-bg);
  border: 1px solid var(--rc-ok-border);
  color: var(--rc-ok-text);
}

.form-row {
  margin-bottom: 0.85rem;
}

.form-row label {
  display: block;
  margin-bottom: 0.25rem;
  font-weight: 600;
  color: var(--rc-text);
}

.rc-login-hint {
  margin-top: 1rem;
  font-size: 0.85rem;
  color: var(--rc-text-muted);
  line-height: 1.5;
}

@media (max-width: 820px) {
  :root {
    --rc-sidebar-w: 180px;
  }
}

@media (max-width: 640px) {
  .rc-workspace {
    flex-direction: column;
  }

  .rc-msg-actions {
    margin-left: 0;
    width: 100%;
    justify-content: flex-start;
  }

  .gm-msg-actions-strip {
    margin-left: 0;
    width: 100%;
    justify-content: flex-start;
  }

  .rc-sidebar {
    width: 100%;
    min-width: 0;
    max-height: min(280px, 42vh);
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-y: contain;
    flex-shrink: 0;
    flex-direction: column;
    align-items: stretch;
    border-right: none;
    border-bottom: 1px solid var(--rc-border);
  }

  .rc-sidebar-head {
    width: auto;
    flex-shrink: 0;
  }

  .rc-sidebar-subhead {
    flex-shrink: 0;
  }

  .rc-folders {
    display: block;
    padding: 0.25rem 0.35rem 0.5rem;
    flex: 0 auto;
    min-height: 0;
  }

  .rc-folders li {
    flex: none;
  }

  .rc-folder {
    margin: 0.1rem 0.35rem;
    justify-content: flex-start;
    min-height: 2.625rem;
  }

  .rc-sidebar-foot {
    display: none;
  }

  .rc-compose-card,
  .rc-panel,
  .rc-panel-flat {
    margin: 0.5rem clamp(0.35rem, 3vw, 0.85rem);
  }

  .rc-toolbar {
    padding: 0.45rem clamp(0.5rem, 3vw, 0.85rem);
  }

  .rc-toolbar-meta {
    width: 100%;
    flex-basis: 100%;
    padding-top: 0.25rem;
  }

  .rc-toolbar-gap {
    display: none;
  }

  .rc-mail-table thead th.cell-from {
    width: 34%;
  }

  .rc-mail-table thead th.cell-date {
    width: 118px;
  }

  /* Stack compose-like header labels */
  .wm-compose-row:not(.wm-compose-row-grow) {
    grid-template-columns: minmax(0, 4.75rem) minmax(0, 1fr);
    gap: 0.35rem;
  }

  .wm-compose-label {
    font-size: 0.72rem;
  }
}

@media (max-width: 520px) {
  .wm-compose-row {
    grid-template-columns: 1fr;
    align-items: stretch;
    min-height: 0;
  }

  .wm-compose-row .wm-compose-label {
    align-self: start;
    padding-top: 0.15rem;
    padding-bottom: 0;
  }

  .wm-compose-row-grow > .wm-compose-label {
    padding-top: 0;
  }

  .wm-compose-input input[type="text"] {
    padding-left: 0.25rem;
  }

  .gm-attach-tile {
    flex: 1 1 100%;
    min-width: 0;
  }

  .rc-topbar {
    height: auto;
    min-height: calc(var(--rc-topbar-h) - 10px);
  }

  .rc-user-id {
    max-width: min(140px, 38vw);
  }
}

@media (max-width: 400px) {
  .rc-mail-table thead th.cell-date,
  .rc-mail-table td.rc-cell-date {
    display: none;
  }

  .rc-logo {
    font-size: 1.05rem;
  }

  .rc-btn-compose {
    padding-inline: 0.6rem;
    font-size: 0.82rem;
  }

  .rc-inbox-bulkbar {
    flex-direction: column;
    align-items: stretch;
    gap: 0.35rem;
  }

  .rc-bulkbar-hint {
    margin-left: 0;
    display: block;
  }

  .gm-msg-from-name,
  .gm-msg-from-addr {
    display: block;
  }

  .gm-msg-from-addr {
    margin-top: 0.18rem;
  }
}

@media (max-height: 520px) and (orientation: landscape) {
  .rc-sidebar {
    max-height: 38vh !important;
  }

  .gm-html-iframe {
    min-height: min(260px, 45vh);
  }
}
