/* PalM Style tokens — docs/Palmer_PalM_Style_Solution_Architecture.md
   Radii, padding, hairlines, accent focus. Layout IA unchanged. */

:root {
  --radius-window: 12px;
  --radius-field: 9px;
  --radius-button: 8px;
  --radius-list: 8px;
  --focus-ring: 2px;
  --pad-field: 0.55rem 0.8rem;
  --pad-button: 0.5rem 0.95rem;

  --page: #1b2433;
  --window: #1b2433;
  --header: #1b2433;
  --panel: #232d3d;
  --card: #1f2836;
  --base: #1f2836;
  --text: #e8eef6;
  --muted: #9aa8bc;
  --line: rgba(232, 238, 246, 0.12);
  --accent: #6b5cff;
  --accent-text: #f4f2ff;
  --danger: #e07a7a;
}

html.theme-palms-wm-dark {
  --page: #1b2433;
  --window: #1b2433;
  --header: #1b2433;
  --panel: #232d3d;
  --card: #1f2836;
  --base: #1f2836;
  --text: #e8eef6;
  --muted: #9aa8bc;
  --line: rgba(232, 238, 246, 0.12);
  --accent: #6b5cff;
  --accent-text: #f4f2ff;
  --danger: #e07a7a;
}

html.theme-dark {
  --page: #1c1c1c;
  --window: #1c1c1c;
  --header: #1c1c1c;
  --panel: #2a2a2a;
  --card: #333333;
  --base: #242424;
  --text: #ececec;
  --muted: #9a9a9a;
  --line: rgba(255, 255, 255, 0.12);
  --accent: #6b5cff;
  --accent-text: #f4f2ff;
  --danger: #e07a7a;
}

html.theme-light {
  --page: #f3f5f8;
  --window: #f3f5f8;
  --header: #ffffff;
  --panel: #ffffff;
  --card: #ffffff;
  --base: #e7ebf1;
  --text: #1b2433;
  --muted: #5c6b80;
  --line: rgba(27, 36, 51, 0.14);
  --accent: #6b5cff;
  --accent-text: #f4f2ff;
  --danger: #b42318;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  height: 100%;
  background: var(--page);
  color: var(--text);
  font: 16px/1.45 "DejaVu Sans", "Noto Sans", sans-serif;
}

html {
  --muted: color-mix(in srgb, var(--text) 70%, var(--page));
  /* Text on the accent: WM's --accent-text on --accent measures 4.13:1, under WCAG AA (4.5:1) for
     body-size text. Anything that puts text ON the accent uses this deeper fill: 5.09:1. */
  --accent-fill: color-mix(in srgb, var(--accent) 88%, #000);
  --line: color-mix(in srgb, var(--text) 22%, transparent);
}

a { color: var(--text); }

.shell {
  max-width: none;
  width: 100%;
  min-height: 100vh;
  margin: 0;
  background: var(--page);
  border: 0;
  border-radius: 0;
  overflow: auto;
  box-shadow: none;
}

header {
  display: grid;
  grid-template-columns: 88px 240px minmax(0,1fr);
  gap: 1rem;
  align-items: center;
  padding: 0.65rem 1.25rem;
  border-bottom: 1px solid var(--line);
  background: var(--page);
  color: var(--text);
}

main, .auth {
  padding: 1.15rem 1.25rem 1.4rem;
}

h1, h2 { font-weight: 600; margin: 0 0 0.6rem; }
.brand {
  letter-spacing: 0.02em;
  display: flex;
  align-items: center;
  gap: 0.55rem;
  grid-column: 1 / 3;
  margin: 0;
}
.brand-envelope {
  width: 100%;
  height: auto;
  min-height: 72px;
  display: block;
}
.brand-envelope .env-face { fill: var(--panel); stroke: var(--line); stroke-width: 2; }
.brand-envelope .env-window { fill: var(--base); stroke: var(--line); stroke-width: 1.5; }
.brand-envelope .env-return, .brand-envelope .env-hello { fill: var(--text); }
/* The PalMS logo as the envelope's postage stamp (ruled by Cevin 2026-10-14): drawn INSIDE the envelope's SVG
   (templates/_brand.html, a foreignObject at x 560-622, y 18-80 of the 640 x 180 viewBox), so it stays on the
   envelope's upper right at every width, the letterboxed narrow header included. The logo alone: no box, border or
   padding. 1x and 2x copies, served by WM. */
.brand-stamp { display: block; width: 100%; height: 100%; pointer-events: none; }

header form {
  grid-column: 3;
  justify-self: end;
  display: flex;
  align-items: center;
  gap: 0.55rem;
  margin: 0;
}
.brand-mark {
  width: 1.35rem;
  height: 1.35rem;
  border-radius: 6px;
  background: var(--accent-fill);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  color: var(--accent-text);
}

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-list);
  padding: 1.2rem;
}

label { display: block; margin: 0.75rem 0 0.3rem; color: var(--muted); }

input, textarea {
  width: 100%;
  background: var(--base);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: var(--radius-field);
  padding: var(--pad-field);
  font: inherit;
}
textarea { min-height: 12rem; }

input:focus, textarea:focus, button:focus-visible, .btn:focus-visible, a:focus-visible {
  outline: var(--focus-ring) solid var(--accent);
  outline-offset: 2px;
}

button, .btn {
  display: inline-block;
  background: var(--accent-fill);
  color: var(--accent-text);
  border: 0;
  border-radius: var(--radius-button);
  padding: var(--pad-button);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
}
button.ghost, .btn.ghost {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--line);
}

.error { color: var(--danger); margin: 0.6rem 0; }
.hint { color: var(--muted); font-size: 0.9rem; }

.layout {
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
  gap: 1.25rem;
  align-items: start;
}


table {
  width: 100%;
  table-layout: fixed;
  border-collapse: separate;
  border-spacing: 0;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-list);
  overflow: hidden;
}
th, td {
  text-align: left;
  padding: 0.55rem 0.7rem;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}
th { color: var(--muted); font-weight: 600; }
tr:last-child td { border-bottom: 0; }
tr.unseen td { font-weight: 700; }
tr:hover td { background: rgba(107, 92, 255, 0.08); }
th:nth-child(1), td:nth-child(1) { width: 22%; }
th:nth-child(2), td:nth-child(2) { width: auto; }
th:nth-child(3), td:nth-child(3) { width: 11.5rem; white-space: nowrap; }
th:nth-child(4), td:nth-child(4) { width: 5.6rem; white-space: nowrap; text-align: right; }
td:nth-child(1), td:nth-child(2) {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.meta { color: var(--muted); margin-bottom: 1rem; }

iframe.body {
  width: 100%;
  min-height: 18rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-list);
  background: #fff;
}
pre.body {
  white-space: pre-wrap;
  background: var(--base);
  padding: 0.9rem 1rem;
  border-radius: var(--radius-list);
  border: 1px solid var(--line);
}

.actions { display: flex; gap: 0.55rem; flex-wrap: wrap; margin: 0.8rem 0; }

@media (max-width: 720px) {
  .shell { margin: 0; border-radius: 0; }
  .layout { grid-template-columns: 1fr; }
}

.folder {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-list);
  padding: 0.45rem 0.35rem 0.55rem;
  max-height: 100%;
  min-height: 0;
  overflow: auto;
}
.folder-heading {
  margin: 0.15rem 0.55rem 0.4rem;
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}
.folder-row {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.38rem 0.55rem;
  margin-left: calc(var(--depth, 0) * 1.15rem);
  text-decoration: none;
  border-radius: var(--radius-field);
  color: var(--muted);
}
.folder-row.tree-hide { display: none; }
.folder-twist {
  width: 16px;
  min-width: 16px;
  height: 16px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--text);
  font-size: 16px;
  line-height: 16px;
  cursor: pointer;
}
.folder-twist.spacer { visibility: hidden; pointer-events: none; }

.folder-row.active, .folder-row:hover {
  background: var(--base);
  color: var(--text);
}
.folder-row.active {
  box-shadow: inset 3px 0 0 var(--accent);
}
.folder-icon {
  width: 16px;
  height: 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 16px;
  color: var(--muted);
}
.folder-icon svg {
  width: 16px;
  height: 16px;
  max-width: 16px;
  max-height: 16px;
  display: block;
}
.folder-row.active .folder-icon,
.folder-row:hover .folder-icon {
  color: var(--text);
}
.folder-label { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.compose-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 240px;
  grid-template-areas:
    "to-label to-label"
    "to to"
    "subject-label attach"
    "subject attach"
    "body-label attach"
    "body attach"
    "actions actions";
  column-gap: 1rem;
  row-gap: 0.25rem;
  align-items: stretch;
}
.compose-to { grid-area: to-label; }
.compose-to-field { grid-area: to; }
.compose-subject { grid-area: subject-label; }
.compose-subject-field { grid-area: subject; }
.compose-body { grid-area: body-label; }
.compose-body-field { grid-area: body; min-height: 16rem; }
.compose-attach {
  grid-area: attach;
  background: var(--base);
  border: 1px solid var(--line);
  border-radius: var(--radius-list);
  padding: 0.75rem;
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.compose-actions { grid-area: actions; }
.attach-list {
  list-style: none;
  margin: 0.6rem 0;
  padding: 0;
  flex: 1;
}
.attach-list li {
  padding: 0.3rem 0;
  border-bottom: 1px solid var(--line);
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
@media (max-width: 720px) {
  .compose-form {
    grid-template-columns: 1fr;
    grid-template-areas:
      "to-label"
      "to"
      "subject-label"
      "subject"
      "body-label"
      "body"
      "attach"
      "actions";
  }
}

.search-clear:hover { color: var(--text); background: var(--panel); }

.search {
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  align-items: center;
  gap: 0.5rem;
  margin: 0 0 0.8rem;
}
.search input[type="search"] {
  flex: 1 1 auto;
  min-width: 0;
  width: auto;
}
.search-clear {
  flex: 0 0 2rem;
  width: 2rem;
  height: 2rem;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  color: var(--muted);
  border: 1px solid var(--line);
  background: var(--base);
  line-height: 1;
  font-size: 1.25rem;
}
.search-clear:hover { color: var(--text); background: var(--panel); }
.search button { flex: 0 0 auto; }


.inline-action { display: inline; margin: 0; }
.inline-action button { padding: 0.25rem 0.6rem; font-weight: 600; }

.folder-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin: 0.1rem 0.25rem 0.45rem;
}
.folder-toolbar {
  background: var(--header);
  color: var(--text);
  border-radius: 8px;
  padding: 0.25rem 0.35rem;
}
.folder-toolbar .folder-heading { margin: 0; color: var(--text); }
.compose-in-panel { padding: 0.28rem 0.7rem; font-size: 0.9rem; }

.app-nav { display: flex; gap: 0.75rem; align-items: center; }
.app-nav a { color: var(--muted); text-decoration: none; font-weight: 650; }
.app-nav a.current, .app-nav a:hover { color: var(--text); }
header { display: flex; align-items: center; gap: 1rem; }
header form { margin-left: auto; }

.workspace {
  display: grid;
  grid-template-columns: 72px 240px minmax(0, 1fr);
  gap: 1rem;
  align-items: start;
}
.rail {
  background: var(--panel);
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.55rem;
  padding: 0.35rem 0.25rem;
}
.rail-settings {
  position: fixed !important;
  left: 0.55rem !important;
  bottom: 0.65rem !important;
  width: 4.6rem !important;
  margin: 0 !important;
  z-index: 40 !important;
  background: var(--window);
}
.rail-help {
  position: fixed !important;
  left: 0.55rem !important;
  bottom: 5.5rem !important;
  width: 4.6rem !important;
  margin: 0 !important;
  z-index: 40 !important;
  background: var(--window);
}
.rail-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.25rem;
  min-height: 4.4rem;
  padding: 0.45rem 0.2rem;
  border-radius: 14px;
  color: var(--muted);
  text-decoration: none;
  font-size: 0.78rem;
  font-weight: 700;
  border: 1px solid transparent;
  background: transparent;
}
.rail-item.current {
  color: var(--text);
  background: rgba(232, 238, 246, 0.14);
  border-color: rgba(232, 238, 246, 0.08);
}
.rail-item:hover { color: var(--text); }
.rail-icon { display: flex; width: 22px; height: 22px; }
.rail-label { line-height: 1; }
.workspace {
  grid-template-columns: 88px 240px minmax(0, 1fr);
}
.workspace:has(.cal-board) {
  grid-template-columns: 88px minmax(0, 1fr) 22rem;
}
.ctx-menu {
  position: absolute;
  z-index: 20;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  min-width: 10rem;
  padding: 0.25rem;
}
.ctx-menu button {
  display: block;
  width: 100%;
  text-align: left;
  background: transparent;
  color: var(--text);
}
dialog {
  background: var(--window);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 1rem;
}
.month { width: 100%; table-layout: fixed; border-collapse: separate; border-spacing: 0; }
.month th, .month td { border: 1px solid var(--line); vertical-align: top; height: 7rem; padding: 0.35rem; }
.month .empty { background: transparent; }
.month .today { outline: 1px solid var(--accent); }
.day-num { color: var(--muted); font-size: 0.8rem; }
.cal-chip { margin: 0.15rem 0; }
.cal-chip button {
  width: 100%;
  text-align: left;
  padding: 0.15rem 0.3rem;
  font-size: 0.75rem;
  background: rgba(107,92,255,0.2);
}
.cal-board { min-width: 0; }
.cal-form { max-width: 22rem; }
.workspace:has(.cal-board) {
  grid-template-columns: 72px minmax(0, 1fr) 22rem;
}
.body-frame table, .message table { width: 100%; border-collapse: collapse; }
.body-frame td, .body-frame th, .message td, .message th { border: 1px solid var(--line); padding: 0.25rem 0.4rem; }

#palms-toast { position: fixed; right: 1rem; bottom: 1rem; z-index: 120; display: flex; flex-direction: column; gap: 0.45rem; max-width: 18rem; }
.palms-toast-card { background: #f0f0f0; color: #111; border: 1px solid #b0b6c0; border-radius: 10px; padding: 0.65rem 0.75rem; box-shadow: 0 8px 24px rgba(0,0,0,0.25); }
.palms-toast-card strong { display: block; margin-bottom: 0.2rem; }
.palms-toast-card p { margin: 0.15rem 0 0; }



.suggest-box {
  position: fixed !important;
  z-index: 4000 !important;
  display: flex !important;
  flex-direction: column !important;
  flex-wrap: nowrap !important;
  align-items: stretch !important;
  background: #dcdfe4 !important;
  border: 1px solid #b7bcc4 !important;
  border-radius: 8px;
  padding: 0.15rem 0;
  max-height: 16rem;
  overflow: auto;
  color: #111 !important;
}
.suggest-box.hidden { display: none !important; }
.suggest-box .suggest-item {
  display: block !important;
  width: 100% !important;
  box-sizing: border-box !important;
  background: #dcdfe4 !important;
  color: #111 !important;
  border: 0 !important;
  border-radius: 0 !important;
  padding: 0.4rem 0.7rem !important;
  font-weight: 400 !important;
  font-size: 0.9rem !important;
  line-height: 1.35 !important;
  cursor: pointer;
}
.suggest-box .suggest-item strong,
.suggest-box .suggest-item span,
.suggest-box .suggest-item em {
  font-weight: 400 !important;
  font-style: normal !important;
  color: #111 !important;
  background: none !important;
}
.suggest-box .suggest-item span { margin: 0 0.7rem; }
.suggest-box .suggest-item:hover { background: #dcdfe4 !important; }

.rail-item { position: relative; }
.meet-badge { animation: none !important; }
.chat-badge {
  position: absolute;
  top: 0.15rem;
  right: 0.15rem;
  min-width: 1.15rem;
  height: 1.15rem;
  padding: 0 0.28rem;
  border-radius: 999px;
  border: 1px solid #fff;
  background: #c62828;
  color: #fff;
  font-weight: 700;
  font-size: 0.72rem;
  line-height: 1.15rem;
  text-align: center;
  box-sizing: border-box;
}
.chat-head {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  flex-wrap: wrap;
}
.chat-toast {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.78rem;
  font-weight: 650;
  color: #d7dcff;
  background: rgba(107,92,255,.28);
  border-radius: 999px;
  padding: 0.12rem 0.45rem 0.12rem 0.55rem;
}
.chat-toast.hidden, .chat-badge.hidden { display: none; }
#meet-toast { text-decoration: none; color: inherit; cursor: pointer; }
.chat-toast-close {
  border: 0;
  background: transparent;
  color: inherit;
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  padding: 0 0.15rem;
}


/* Theme surfaces: Application header = page; other headers = --header; panels = --panel; cards = --card */
.msg-row, .peek-agenda a, .peek-agenda button, .chat-list a {
  background: var(--card);
}
.head-cell, .peek-toggle, .folder-heading {
  background: var(--header);
  color: var(--text);
}
.mail-peek, .compose-peek, .folder, .mail-col {
  background: var(--panel);
}
