/* =========================================================================
   NexT SysteM Mail — the inbox workspace, message reader and countdown timer.
   Inherits every theme token from styles.css (dark default, light opt-in).
   ========================================================================= */

.inbox-view {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
}

/* ---- Top bar --------------------------------------------------------- */
.topbar {
  flex: none;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px clamp(14px, 3vw, 28px);
  background: var(--glass);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--line);
  z-index: 30;
}
.icon-button {
  display: inline-grid;
  place-items: center;
  width: 42px;
  height: 42px;
  flex: none;
  border-radius: var(--r-pill);
  border: 1px solid var(--line-2);
  background: var(--surface-2);
  color: var(--text);
  transition: border-color var(--fast) var(--ease), background var(--fast) var(--ease), transform var(--fast) var(--ease);
}
.icon-button:hover {
  border-color: var(--green-line);
  transform: translateY(-1px);
}
.icon-button svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.rail-toggle { display: none; }

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  min-width: 0;
}
.brand-logo {
  width: 36px;
  height: 36px;
  flex: none;
}
.brand span {
  display: flex;
  flex-direction: column;
  line-height: 1.1;
  min-width: 0;
}
.brand strong {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 600;
}
.brand-mail { color: var(--green-ink); }
.brand small {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--text-3);
}

.topbar-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 10px;
}
.demo-badge--inbox { font-size: 11px; padding: 5px 10px; }

.connection-state {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-radius: var(--r-pill);
  background: var(--surface-2);
  border: 1px solid var(--line-2);
  font-size: 13px;
  font-weight: 700;
  color: var(--text-2);
}
.connection-state > span {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 0 4px var(--green-soft);
}
.connection-state.is-busy > span { background: var(--accent-ink); box-shadow: 0 0 0 4px var(--purple-soft); animation: pulse 1s infinite; }
.connection-state.is-error > span { background: var(--danger); box-shadow: 0 0 0 4px rgb(var(--danger-rgb) / .2); }

.account-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 14px 6px 6px;
  border-radius: var(--r-pill);
  background: var(--surface-2);
  border: 1px solid var(--line-2);
  max-width: 260px;
}
.account-avatar {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  flex: none;
  border-radius: 50%;
  background: var(--green);
  color: var(--on-green);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 14px;
}
.account-copy {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
  min-width: 0;
}
.account-copy strong {
  font-size: 13px;
  font-weight: 800;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 180px;
}
.account-copy small { font-size: 11px; color: var(--text-3); }

.logout-button {
  width: auto;
  gap: 7px;
  padding: 0 16px;
  font-weight: 700;
  font-size: 14px;
  color: var(--text-2);
}
.logout-button:hover { color: var(--text); }

/* ---- Workspace shell ------------------------------------------------- */
.workspace {
  position: relative;
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: 276px 1fr;
}
.rail-scrim {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 25;
  background: var(--scrim);
  backdrop-filter: blur(2px);
}

/* ---- Sidebar --------------------------------------------------------- */
.sidebar {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 20px 18px;
  border-right: 1px solid var(--line);
  overflow-y: auto;
  background: linear-gradient(var(--surface-1), var(--bg) 60%);
}
.sidebar-label {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: var(--track-caps);
  text-transform: uppercase;
  color: var(--text-3);
  padding: 0 6px;
}
.mail-nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 11px 14px;
  border: 1px solid transparent;
  border-radius: var(--r-md);
  background: transparent;
  color: var(--text-2);
  font-family: inherit;
  font-size: 14px;
  font-weight: 700;
  text-align: left;
  transition: background var(--fast) var(--ease), color var(--fast) var(--ease), border-color var(--fast) var(--ease);
}
.nav-item svg {
  width: 20px;
  height: 20px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.nav-item span { flex: 1; }
.nav-count {
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 700;
  min-width: 26px;
  text-align: center;
  padding: 2px 8px;
  border-radius: var(--r-pill);
  background: var(--surface-3);
  color: var(--text-2);
}
.nav-item:hover {
  background: var(--surface-2);
  color: var(--text);
}
.nav-item.is-active {
  background: var(--green-soft);
  border-color: var(--green-line);
  color: var(--green-ink);
}
.nav-item.is-active .nav-count {
  background: var(--green);
  color: var(--on-green);
}

.sidebar-spacer { flex: 1; min-height: 8px; }

.sidebar-store {
  display: block;
  padding: 16px;
  border-radius: var(--r-lg);
  background:
    radial-gradient(120% 120% at 100% 0, rgb(var(--purple-rgb) / .35), transparent 55%),
    var(--surface-2);
  border: 1px solid var(--purple-line);
  position: relative;
  overflow: hidden;
}
.sidebar-store img {
  width: 54px;
  margin-bottom: 8px;
  filter: drop-shadow(0 8px 14px rgb(0 0 0 / .35));
}
.sidebar-store strong { display: block; font-size: 15px; }
.sidebar-store span { font-size: 13px; color: var(--text-2); font-weight: 700; }

.shortcuts-card,
.security-card {
  padding: 15px 16px;
  border-radius: var(--r-lg);
  background: var(--surface-2);
  border: 1px solid var(--line);
}
.shortcuts-card > strong {
  display: block;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: var(--track-caps);
  text-transform: uppercase;
  color: var(--text-3);
  margin-bottom: 10px;
}
.shortcuts-card ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.shortcuts-card li {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text-2);
}
.shortcuts-card li span { margin-left: auto; color: var(--text-3); }
kbd {
  font-family: var(--font);
  font-size: 11px;
  font-weight: 800;
  min-width: 22px;
  text-align: center;
  padding: 3px 6px;
  border-radius: var(--r-xs);
  background: var(--surface-4);
  border: 1px solid var(--line-2);
  color: var(--text);
}

.security-card {
  display: flex;
  gap: 11px;
  align-items: flex-start;
}
.security-icon {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  flex: none;
  border-radius: var(--r-md);
  background: var(--green-soft);
}
.security-icon svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: var(--green-ink);
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.security-card strong { font-size: 13px; }
.security-card p { margin: 2px 0 0; font-size: 12px; color: var(--text-3); }
.sidebar-preferences {
  padding: 10px;
  border-radius: var(--r-sm);
  border: 1px solid var(--line);
  background: transparent;
  color: var(--text-3);
  font-weight: 700;
  font-size: 12px;
}
.sidebar-preferences:hover { color: var(--text); }

/* ---- Inbox main ------------------------------------------------------ */
.inbox-main {
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding: clamp(16px, 2.4vw, 26px) clamp(16px, 3vw, 30px);
  gap: 16px;
}
.inbox-heading {
  flex: none;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
}
.inbox-heading h1 {
  font-size: clamp(24px, 3vw, 34px);
  font-weight: 600;
  margin: 4px 0 2px;
}
#last-update { margin: 0; font-size: 13px; color: var(--text-3); }

/* ---- Countdown timer (styled on the Next green-glow language) -------- */
.refresh-dock {
  display: flex;
  align-items: center;
  gap: 12px;
}
.timer-ring {
  position: relative;
  width: 50px;
  height: 50px;
  flex: none;
  display: grid;
  place-items: center;
}
.timer-ring svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}
.timer-ring circle {
  fill: none;
  stroke-width: 5;
  stroke-linecap: round;
}
.timer-ring__track { stroke: var(--line-2); }
.timer-ring__value {
  stroke: var(--green);
  stroke-dasharray: 100;
  stroke-dashoffset: calc(100 - var(--timer-progress, 0) * 100);
  transition: stroke-dashoffset .9s linear;
  filter: drop-shadow(0 0 5px rgb(var(--green-rgb) / .5));
}
.timer-ring__count {
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}
.timer-ring.is-ready .timer-ring__value {
  stroke-dashoffset: 0;
  animation: ring-pulse 1.8s var(--ease) infinite;
}
.timer-ring.is-ready .timer-ring__count { color: var(--green-ink); }
.timer-ring.is-loading .timer-ring__value {
  animation: ring-spin 1s linear infinite;
  stroke-dasharray: 25 75;
}
@keyframes ring-pulse {
  0%, 100% { filter: drop-shadow(0 0 5px rgb(var(--green-rgb) / .5)); }
  50% { filter: drop-shadow(0 0 12px rgb(var(--green-rgb) / .9)); }
}
@keyframes ring-spin {
  to { transform: rotate(270deg); }
}

.refresh-button {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  height: 46px;
  padding: 0 18px;
  border-radius: var(--r-md);
  border: 1px solid var(--line-2);
  background: var(--surface-2);
  color: var(--text-2);
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 600;
  transition: all var(--fast) var(--ease);
}
.refresh-button:not(:disabled) {
  color: var(--on-green);
  background: var(--green);
  border-color: transparent;
  box-shadow: var(--glow);
}
.refresh-button:not(:disabled):hover {
  background: var(--green-hover);
  transform: translateY(-2px);
}
.refresh-button:disabled { cursor: not-allowed; }
.refresh-icon {
  width: 19px;
  height: 19px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.refresh-button.is-loading .refresh-icon { display: none; }
.refresh-button .button-spinner {
  border-color: var(--line-3);
  border-top-color: var(--text);
}
.refresh-button:not(:disabled) .button-spinner { border-top-color: var(--on-green); }

/* ---- Sync banner ----------------------------------------------------- */
.sync-banner {
  flex: none;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 15px;
  border-radius: var(--r-md);
  background: var(--purple-soft);
  border: 1px solid var(--purple-line);
  font-size: 14px;
  font-weight: 600;
}
.sync-banner svg {
  width: 20px;
  height: 20px;
  flex: none;
  fill: none;
  stroke: var(--accent-ink);
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.sync-banner span { flex: 1; }
.sync-banner button {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border: 0;
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--text-2);
}
.sync-banner button svg { width: 16px; height: 16px; stroke: currentColor; }

/* ---- Mail grid: list + reader --------------------------------------- */
.mail-grid {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(320px, 390px) 1fr;
  gap: 18px;
}

.message-column {
  display: flex;
  flex-direction: column;
  min-height: 0;
  border-radius: var(--r-xl);
  background: var(--surface-1);
  border: 1px solid var(--line);
  overflow: hidden;
}
.list-toolbar {
  flex: none;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px;
  border-bottom: 1px solid var(--line);
}
.list-toolbar-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}
.list-toolbar-title h2 {
  font-size: 16px;
  font-weight: 600;
  font-family: var(--font-display);
}
#visible-count { font-size: 12px; color: var(--text-3); font-weight: 700; }

.search-box {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 0 12px;
  height: 44px;
  border-radius: var(--r-md);
  background: var(--surface-2);
  border: 1.5px solid var(--line-2);
  transition: border-color var(--fast) var(--ease), box-shadow var(--fast) var(--ease);
}
.search-box:focus-within {
  border-color: var(--green);
  box-shadow: 0 0 0 4px var(--green-soft);
}
.search-box svg {
  width: 18px;
  height: 18px;
  flex: none;
  fill: none;
  stroke: var(--text-3);
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.search-box input {
  flex: 1;
  min-width: 0;
  border: 0;
  background: transparent;
  color: var(--text);
  font-family: inherit;
  font-size: 15px;
  font-weight: 600;
}
.search-box input:focus { outline: none; }
.search-box input::placeholder { color: var(--text-3); font-weight: 500; }
.search-kbd {
  font-size: 10px;
  letter-spacing: .04em;
}

.message-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.message-item {
  display: flex;
  gap: 12px;
  width: 100%;
  padding: 13px;
  border: 1px solid transparent;
  border-radius: var(--r-lg);
  background: transparent;
  text-align: left;
  color: var(--text);
  transition: background var(--fast) var(--ease), border-color var(--fast) var(--ease), transform var(--fast) var(--ease);
}
.message-item:hover {
  background: var(--surface-2);
}
.message-item.is-selected {
  background: var(--surface-2);
  border-color: var(--green-line);
  box-shadow: inset 3px 0 0 var(--green);
}
.message-item-avatar {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  flex: none;
  border-radius: var(--r-md);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 15px;
  background: var(--green);
  color: var(--on-green);
}
.message-item-avatar.is-blue { background: #3B82F6; color: #fff; }
.message-item-avatar.is-violet { background: var(--purple); color: #fff; }
.message-item-avatar.is-coral { background: #FF7A59; color: #231007; }
.message-item-copy {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.message-item-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}
.message-item-sender {
  font-size: 14px;
  font-weight: 800;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.message-item-time { font-size: 11px; color: var(--text-3); flex: none; font-weight: 700; }
.message-item-title {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.message-item-preview {
  font-size: 12.5px;
  color: var(--text-3);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.message-item-tags {
  display: flex;
  gap: 6px;
  margin-top: 4px;
}
.msg-tag {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .04em;
  text-transform: uppercase;
  padding: 3px 8px;
  border-radius: var(--r-pill);
}
.msg-tag--code { background: var(--green-soft); color: var(--green-ink); border: 1px solid var(--green-line); }
.msg-tag--link { background: var(--purple-soft); color: var(--accent-ink); border: 1px solid var(--purple-line); }

.list-empty {
  margin: auto;
  padding: 40px 24px;
  text-align: center;
}
.list-empty img { width: 92px; margin: 0 auto 14px; opacity: .9; }
.list-empty strong { display: block; font-size: 16px; font-family: var(--font-display); }
.list-empty p { margin: 6px 0 0; font-size: 13px; color: var(--text-3); max-width: 30ch; margin-inline: auto; }

/* ---- Reader ---------------------------------------------------------- */
.reader {
  min-height: 0;
  overflow-y: auto;
  border-radius: var(--r-xl);
  background: var(--surface-1);
  border: 1px solid var(--line);
}
.reader-placeholder {
  height: 100%;
  min-height: 340px;
  display: grid;
  place-content: center;
  justify-items: center;
  text-align: center;
  padding: 40px;
}
.reader-placeholder img { width: 120px; margin-bottom: 16px; opacity: .9; }
.reader-placeholder h2 { font-size: 20px; font-weight: 600; }
.reader-placeholder p { margin: 8px 0 0; color: var(--text-3); max-width: 32ch; }

.reader-content {
  padding: clamp(18px, 2.4vw, 30px);
}
.reader-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}
.back-button {
  display: none;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: var(--r-pill);
  border: 1px solid var(--line-2);
  background: var(--surface-2);
  color: var(--text);
  font-weight: 700;
  font-size: 14px;
}
.back-button svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.safe-content {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  margin-left: auto;
  padding: 7px 13px;
  border-radius: var(--r-pill);
  background: var(--green-soft);
  border: 1px solid var(--green-line);
  color: var(--green-ink);
  font-size: 12px;
  font-weight: 800;
}
.safe-content svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

.reader-header {
  display: flex;
  align-items: center;
  gap: 13px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
}
.reader-avatar {
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  flex: none;
  border-radius: var(--r-md);
  background: var(--green);
  color: var(--on-green);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 19px;
}
.reader-avatar.is-blue { background: #3B82F6; color: #fff; }
.reader-avatar.is-violet { background: var(--purple); color: #fff; }
.reader-avatar.is-coral { background: #FF7A59; color: #231007; }
.reader-sender { flex: 1; min-width: 0; }
.reader-sender strong { display: block; font-size: 17px; font-weight: 800; }
.reader-sender span { font-size: 13px; color: var(--text-3); word-break: break-word; }
.reader-header time { font-size: 13px; color: var(--text-3); font-weight: 700; white-space: nowrap; flex: none; }

.reader-title-label {
  display: block;
  margin: 18px 0 5px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: var(--track-caps);
  text-transform: uppercase;
  color: var(--text-3);
}
#reader-title {
  font-family: var(--font-display);
  font-size: clamp(20px, 2.4vw, 27px);
  font-weight: 600;
  margin-bottom: 20px;
}

/* ---- THE CODE HERO: the one bold moment ----------------------------- */
.code-tray {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 22px;
}
.copy-code {
  position: relative;
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-areas: 'label hint' 'value hint';
  align-items: center;
  gap: 2px 16px;
  width: 100%;
  padding: 20px 22px;
  border: 0;
  border-radius: var(--r-xl);
  background:
    radial-gradient(130% 160% at 0% 0%, rgb(var(--green-rgb) / .16), transparent 55%),
    var(--surface-2);
  box-shadow: inset 0 0 0 1.5px var(--green-line), var(--glow);
  text-align: left;
  overflow: hidden;
  transition: transform var(--fast) var(--ease), box-shadow var(--fast) var(--ease);
}
.copy-code::before {
  /* scanning sweep of light across the panel */
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(105deg, transparent 30%, rgb(var(--green-rgb) / .22) 48%, transparent 66%);
  transform: translateX(-120%);
  animation: code-scan 3.6s var(--ease) infinite;
  pointer-events: none;
}
.copy-code:hover {
  transform: translateY(-3px);
  box-shadow: inset 0 0 0 1.5px var(--green), var(--glow-lg);
}
.copy-code > span {
  grid-area: label;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: var(--track-caps);
  text-transform: uppercase;
  color: var(--green-ink);
}
.copy-code > strong {
  grid-area: value;
  font-family: var(--font-score);
  font-weight: 400;
  font-size: clamp(34px, 7vw, 52px);
  line-height: 1;
  letter-spacing: .14em;
  color: var(--text);
  text-shadow: 0 0 22px rgb(var(--green-rgb) / .35);
}
.copy-code > small {
  grid-area: hint;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 9px 16px;
  border-radius: var(--r-pill);
  background: var(--green);
  color: var(--on-green);
  font-size: 13px;
  font-weight: 800;
  white-space: nowrap;
}
@keyframes code-scan {
  0% { transform: translateX(-120%); }
  55%, 100% { transform: translateX(120%); }
}

/* ---- View switch + copy ---------------------------------------------- */
.html-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}
.view-switch {
  display: inline-flex;
  padding: 4px;
  border-radius: var(--r-pill);
  background: var(--surface-3);
  border: 1px solid var(--line);
}
.view-switch button {
  padding: 8px 18px;
  border: 0;
  border-radius: var(--r-pill);
  background: transparent;
  color: var(--text-2);
  font-family: inherit;
  font-size: 13px;
  font-weight: 800;
  transition: background var(--fast) var(--ease), color var(--fast) var(--ease);
}
.view-switch button[aria-pressed='true'] {
  background: var(--green);
  color: var(--on-green);
}
.view-switch button:disabled { opacity: .4; cursor: not-allowed; }

.ghost-button {
  padding: 9px 16px;
  border-radius: var(--r-pill);
  border: 1px solid var(--line-2);
  background: var(--surface-2);
  color: var(--text);
  font-family: inherit;
  font-size: 13px;
  font-weight: 700;
  transition: border-color var(--fast) var(--ease), color var(--fast) var(--ease);
}
.ghost-button:hover:not(:disabled) { border-color: var(--green-line); }
.ghost-button:disabled { opacity: .5; cursor: not-allowed; }
.ghost-button.is-loading { opacity: .7; }

.html-note { margin: 0 0 12px; font-size: 12px; color: var(--text-3); }

#html-reader {
  width: 100%;
  min-height: 360px;
  border: 1px solid var(--line-2);
  border-radius: var(--r-md);
  background: #fff;
}

.message-body {
  font-size: 15px;
  line-height: 1.7;
  color: var(--text);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
}

/* ---- Translation ----------------------------------------------------- */
.translation-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 22px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}
.translation-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 800;
  font-size: 14px;
}
.translation-label svg { width: 20px; height: 20px; fill: none; stroke: var(--accent-ink); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.translation-select { margin-left: auto; }
.translation-select select {
  padding: 9px 14px;
  border-radius: var(--r-pill);
  border: 1px solid var(--line-2);
  background: var(--surface-2);
  color: var(--text);
  font-family: inherit;
  font-size: 13px;
  font-weight: 700;
}
.translation-note { margin: 8px 0 0; font-size: 12px; color: var(--text-3); }
.translated-body {
  margin-top: 12px;
  padding: 16px;
  border-radius: var(--r-md);
  background: var(--purple-soft);
  border: 1px solid var(--purple-line);
  font-size: 15px;
  line-height: 1.7;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

/* ---- Email actions --------------------------------------------------- */
.email-actions {
  margin-top: 22px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}
.email-actions-heading { margin-bottom: 12px; }
.email-actions-heading strong { display: block; font-size: 15px; font-family: var(--font-display); font-weight: 600; }
.email-actions-heading span { font-size: 13px; color: var(--text-3); }
.email-actions > p { margin: 10px 0 0; font-size: 12px; color: var(--text-3); }
.email-actions-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.email-action {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border-radius: var(--r-md);
  background: var(--surface-2);
  border: 1px solid var(--line-2);
  transition: border-color var(--fast) var(--ease), transform var(--fast) var(--ease);
}
.email-action:hover { border-color: var(--green-line); transform: translateY(-1px); }
.email-action span { flex: 1; min-width: 0; }
.email-action strong { display: block; font-size: 14px; font-weight: 800; }
.email-action small { font-size: 12px; color: var(--text-3); word-break: break-all; }
.email-action svg {
  width: 20px;
  height: 20px;
  flex: none;
  fill: none;
  stroke: var(--text-3);
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.email-action.is-primary {
  background: var(--green-soft);
  border-color: var(--green-line);
}
.email-action.is-primary svg { stroke: var(--green-ink); }

/* ---- Reader prev/next (appended by JS) ------------------------------ */
.reader-navigation {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-top: 24px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}
.reader-navigation button {
  padding: 11px 18px;
  border-radius: var(--r-pill);
  border: 1px solid var(--line-2);
  background: var(--surface-2);
  color: var(--text);
  font-family: inherit;
  font-weight: 700;
  font-size: 14px;
  transition: border-color var(--fast) var(--ease), transform var(--fast) var(--ease);
}
.reader-navigation button:hover { border-color: var(--green-line); transform: translateY(-1px); }

/* ---- Responsive: tablet → single pane + drawer + overlay reader ----- */
@media (max-width: 1040px) {
  .workspace { grid-template-columns: 1fr; }
  .rail-toggle { display: inline-grid; }
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 26;
    width: min(84vw, 320px);
    height: 100%;
    padding-top: 82px;
    transform: translateX(-104%);
    transition: transform var(--mid) var(--ease);
    box-shadow: var(--shadow-pop);
  }
  .workspace.rail-open .sidebar { transform: none; }
  .workspace.rail-open .rail-scrim { display: block; }

  .mail-grid { grid-template-columns: 1fr; }
  .reader {
    position: fixed;
    inset: 0;
    z-index: 40;
    border-radius: 0;
    transform: translateX(104%);
    transition: transform var(--mid) var(--ease);
  }
  .reader.is-open { transform: none; }
  .back-button { display: inline-flex; }
}

@media (max-width: 720px) {
  .brand span,
  .connection-state,
  .account-copy,
  .logout-button span { display: none; }
  .account-chip { padding: 5px; }
  .inbox-heading { flex-wrap: wrap; align-items: flex-start; }
  .refresh-button { height: 44px; }
}
@media (max-width: 420px) {
  .topbar { gap: 8px; padding: 10px 12px; }
  .copy-code { padding: 16px 18px; }
  .reader-navigation { flex-direction: column; }
}
