/* webmail only; common/base.css holds tokens, layout, controls, dialogs and menus */
.search {
  display: flex; align-items: center;
  flex: 0 1 720px; min-width: 0; height: 48px; margin-left: 8px; padding: 0 4px;
  border-radius: 24px; background: var(--surface-3);
  transition: background-color .15s, box-shadow .15s;
}
.search:focus-within { background: var(--surface); box-shadow: var(--shadow-1); }
.search-input { flex: 1; min-width: 0; height: 100%; border: 0; background: transparent; outline: none; font-size: 16px; }
.search-input::-webkit-search-cancel-button { display: none; }
.search-clear { visibility: hidden; }
.search.has-q .search-clear, .search:focus-within .search-clear { visibility: visible; }
.compose-btn {
  display: inline-flex; align-items: center; gap: 12px;
  height: 56px; margin: 4px 0 16px 8px; padding: 0 24px 0 18px;
  border: 0; border-radius: var(--radius);
  background: var(--compose); color: var(--compose-text);
  font-weight: 500;
  transition: box-shadow .15s;
}
.compose-btn:hover { box-shadow: var(--shadow-3); }
.compose-btn .icon { width: 22px; height: 22px; }
.fab { display: none; }
.list-view, .reader-view { display: flex; flex-direction: column; height: 100%; }
.range { margin: 0 8px; font-size: 12px; color: var(--muted); white-space: nowrap; }
.sel-count { margin-left: 8px; font-size: 13px; color: var(--muted); white-space: nowrap; }
.select-box { display: flex; align-items: center; margin-right: 6px; border-radius: 4px; }
.select-box .cell-check { width: 32px; }
.search-header { display: flex; align-items: center; gap: 10px; padding: 4px 20px 10px; color: var(--text-2); flex: none; }

/* ---------- message rows ---------- */
.rows { flex: 1; overflow-y: auto; border-top: 1px solid var(--border); scrollbar-width: thin; }
.row {
  position: relative;
  display: grid;
  grid-template-columns: 32px 32px minmax(120px, 200px) minmax(0, 1fr) 22px 84px;
  align-items: center;
  height: var(--row-h);
  padding: 0 12px 0 10px;
  border-bottom: 1px solid var(--border);
  background: var(--row-read);
  cursor: pointer;
  user-select: none;
  overflow: hidden;
}
.row.unread { background: var(--row-unread); font-weight: 700; }
.row.unread .preview { font-weight: 400; }
.row:hover { box-shadow: var(--row-shadow); z-index: 1; }
.row.selected { background: var(--row-selected); }
.row.focused::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--accent); }
.cell-check { display: grid; place-items: center; width: 32px; height: 32px; cursor: pointer; }
.star-btn { display: grid; place-items: center; width: 32px; height: 32px; padding: 0; border: 0; border-radius: 50%; background: none; color: var(--muted); }
.star-btn:hover { background: var(--hover); color: var(--text); }
.star-btn .icon { width: 18px; height: 18px; }
.star-btn.on { color: var(--star); }
.star-btn.on .icon { fill: var(--star); stroke: var(--star); }
.cell-from { display: flex; gap: 6px; min-width: 0; padding-right: 24px; overflow: hidden; white-space: nowrap; }
.from-text { overflow: hidden; text-overflow: ellipsis; }
.draft-tag { color: var(--danger); font-weight: 400; }
.cell-main { min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.preview { color: var(--muted); }
.cell-att { display: grid; place-items: center; color: var(--muted); }
.cell-att .icon { width: 16px; height: 16px; }
.cell-date { justify-self: end; font-size: 12px; white-space: nowrap; color: var(--text-2); }
.row.unread .cell-date { color: var(--text); }
.row-actions { position: absolute; right: 8px; top: 0; bottom: 0; display: none; align-items: center; gap: 0; padding-left: 8px; background: inherit; }
.row:hover .row-actions { display: flex; }
.row:hover .cell-date { visibility: hidden; }
.row-actions .icon-btn { width: 34px; height: 34px; }
.row.skeleton { cursor: default; background: var(--surface); grid-template-columns: 200px 1fr 60px; gap: 24px; padding: 0 24px; }
.row.skeleton span { height: 10px; border-radius: 5px; background: var(--surface-3); animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .45; } }
.empty { display: grid; justify-items: center; gap: 12px; padding: 64px 24px; text-align: center; color: var(--muted); }
.empty p { max-width: 420px; margin: 0; }
.empty-icon { width: 56px; height: 56px; stroke-width: 1.2; opacity: .6; }

/* ---------- reader ---------- */
.reader-scroll { flex: 1; overflow-y: auto; border-top: 1px solid var(--border); scrollbar-width: thin; }
.reader { max-width: 1100px; padding: 16px 24px 40px 72px; }
.reader-head { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; margin: 4px 0 16px; }
.reader-subject { margin: 0; font-size: 22px; font-weight: 400; line-height: 1.3; word-break: break-word; }
.chip { padding: 1px 8px; border-radius: 4px; background: var(--chip); font-size: 12px; color: var(--text-2); }
.msg-head { display: grid; grid-template-columns: 40px minmax(0, 1fr) auto auto; gap: 0 12px; align-items: start; margin-left: -56px; }
.msg-head .avatar { width: 40px; height: 40px; font-size: 18px; }
.who-line { display: flex; flex-wrap: wrap; gap: 4px 6px; align-items: baseline; padding-top: 2px; }
.who-line .addr { font-size: 12px; color: var(--muted); }
.to-line { display: inline-flex; align-items: center; gap: 2px; max-width: 100%; padding: 0; border: 0; background: none; font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.when { padding-top: 4px; font-size: 12px; color: var(--muted); white-space: nowrap; }
.msg-actions { display: flex; align-items: center; margin-top: -6px; }
.msg-details { margin: 8px 0 4px; padding: 8px 12px; border: 1px solid var(--border); border-radius: 8px; font-size: 12px; box-shadow: var(--shadow-1); border-collapse: separate; }
.msg-details th { padding: 2px 12px 2px 0; text-align: right; font-weight: 400; color: var(--muted); vertical-align: top; white-space: nowrap; }
.msg-details td { padding: 2px 0; word-break: break-all; }
.images-banner { display: flex; align-items: center; gap: 10px; margin: 14px 0 0; padding: 6px 8px 6px 14px; border-radius: 8px; background: var(--surface-3); font-size: 13px; color: var(--text-2); }
.images-banner span { flex: 1; }
.msg-body { display: block; width: 100%; min-height: 60px; margin-top: 16px; border: 0; border-radius: 8px; background: #fff; color-scheme: light; }
.attachments { margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--border); }
.att-title { margin-bottom: 10px; font-weight: 500; color: var(--text-2); }
.att-list { display: flex; flex-wrap: wrap; gap: 12px; }
.att { width: 180px; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; background: var(--surface); transition: box-shadow .15s; }
.att:hover { box-shadow: var(--shadow-1); }
.att-preview { display: grid; place-items: center; height: 100px; background: var(--surface-2); color: var(--muted); overflow: hidden; text-decoration: none; }
.att-preview img { width: 100%; height: 100%; object-fit: cover; }
.att-icon { display: grid; justify-items: center; gap: 4px; font-size: 11px; font-weight: 700; color: var(--danger); }
.att-icon .icon { width: 34px; height: 34px; stroke-width: 1.3; color: var(--muted); }
.att-meta { display: grid; grid-template-columns: 1fr auto; grid-template-rows: auto auto; align-items: center; padding: 6px 4px 6px 10px; }
.att-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; font-weight: 500; }
.att-size { grid-row: 2; font-size: 12px; color: var(--muted); }
.att-meta .icon-btn { grid-row: 1 / 3; grid-column: 2; }
.reply-actions { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 28px; }
.reader-skeleton { display: grid; gap: 14px; padding-top: 8px; }
.reader-skeleton span { height: 14px; border-radius: 7px; background: var(--surface-3); animation: pulse 1.2s ease-in-out infinite; }
.reader-skeleton span:nth-child(1) { width: 40%; height: 22px; }
.reader-skeleton span:nth-child(2) { width: 25%; }
.reader-skeleton span:nth-child(3) { width: 70%; height: 120px; }

/* ---------- compose ---------- */
.compose-dock { position: fixed; right: 16px; bottom: 0; z-index: 40; display: flex; flex-direction: row-reverse; align-items: flex-end; gap: 16px; pointer-events: none; }
.compose {
  display: flex; flex-direction: column;
  width: 560px; height: min(620px, calc(100vh - 80px));
  border-radius: 12px 12px 0 0;
  background: var(--surface);
  box-shadow: var(--shadow-3), 0 0 0 1px var(--border);
  overflow: hidden;
  pointer-events: auto;
}
.compose.dropping { box-shadow: var(--shadow-3), inset 0 0 0 3px var(--accent); }
.compose.min { height: auto; width: 300px; }
.compose.min > :not(.c-head) { display: none; }
.compose.max { position: fixed; inset: 6vh 8vw; width: auto; height: auto; border-radius: 12px; z-index: 50; }
body.compose-max::after { content: ""; position: fixed; inset: 0; background: rgba(0, 0, 0, .4); z-index: 39; }
.c-head { display: flex; align-items: center; gap: 8px; height: 40px; padding: 0 6px 0 16px; background: var(--compose-head); cursor: default; flex: none; }
.compose.min .c-head { cursor: pointer; }
.c-title { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; font-size: 14px; }
.c-status { font-size: 12px; color: var(--muted); white-space: nowrap; }
.c-head-btns { display: flex; }
.c-body { display: flex; flex-direction: column; flex: 1; min-height: 0; padding: 0 16px; overflow-y: auto; }
.cf-row { position: relative; display: flex; align-items: center; min-height: 40px; border-bottom: 1px solid var(--border); flex: none; }
.cf-label { width: 34px; flex: none; color: var(--muted); }
.cf-toggles { display: flex; gap: 6px; margin-left: 8px; color: var(--muted); flex: none; }
.cf-subject { flex: 1; height: 40px; border: 0; background: transparent; outline: none; }
.rcpt-wrap { position: relative; flex: 1; min-width: 0; }
.rcpt-box { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; padding: 4px 0; min-height: 40px; cursor: text; }
.rcpt-input { flex: 1; min-width: 120px; height: 28px; border: 0; background: transparent; outline: none; }
.chip-rcpt { display: inline-flex; align-items: center; gap: 2px; height: 26px; padding: 0 2px 0 10px; border-radius: 13px; border: 1px solid var(--border-2); background: var(--surface); font-size: 13px; max-width: 100%; }
.chip-rcpt.invalid { border-color: var(--danger); color: var(--danger); }
.chip-x { display: grid; place-items: center; width: 20px; height: 20px; padding: 0; border: 0; border-radius: 50%; background: none; color: var(--muted); }
.chip-x:hover { background: var(--hover); }
.chip-x .icon { width: 13px; height: 13px; }
.suggest { position: absolute; left: 0; top: 100%; z-index: 5; min-width: 280px; max-width: 100%; padding: 6px 0; border-radius: 8px; background: var(--surface); box-shadow: var(--shadow-3); }
.suggest-item { display: flex; flex-direction: column; padding: 6px 14px; cursor: pointer; }
.suggest-item span { font-size: 12px; color: var(--muted); }
.suggest-item.active, .suggest-item:hover { background: var(--hover); }
.editor-wrap { flex: 1; display: flex; padding: 12px 0; min-height: 120px; }
.editor { flex: 1; outline: none; overflow-wrap: anywhere; line-height: 1.5; }
.editor blockquote, .sac-quote blockquote { margin: 0 0 0 .8ex; padding-left: 1ex; border-left: 1px solid var(--border-2); }
.editor .sac-quote { color: var(--text-2); }
.editor img { max-width: 100%; }
.editor .sac-signature { color: var(--muted); }
.c-atts { display: flex; flex-wrap: wrap; gap: 6px; padding-bottom: 10px; flex: none; }
.c-att { display: flex; align-items: center; gap: 6px; max-width: 100%; padding: 2px 2px 2px 10px; border-radius: 6px; background: var(--surface-2); font-size: 13px; }
.c-att .att-name { font-weight: 500; max-width: 260px; }
.c-att .att-size { color: var(--muted); }
.fmt-bar { display: flex; align-items: center; gap: 2px; margin: 0 16px; padding: 2px 6px; border-radius: 8px; box-shadow: var(--shadow-1); flex: none; }
.fmt { width: 32px; height: 32px; border: 0; border-radius: 6px; background: none; font-size: 15px; }
.fmt:hover { background: var(--hover); }
.fmt.b { font-weight: 800; }
.fmt.i { font-style: italic; font-family: Georgia, serif; }
.fmt.u { text-decoration: underline; }
.c-foot { display: flex; align-items: center; gap: 4px; padding: 10px 12px 12px 16px; flex: none; }
.send-btn { margin-right: 8px; padding: 0 24px; }
.shortcuts { width: 100%; border-collapse: collapse; }
.shortcuts td { padding: 6px 4px; border-bottom: 1px solid var(--border); }
.shortcuts td:first-child { width: 45%; }

@media (max-width: 1100px) {
  .row { grid-template-columns: 32px 32px minmax(100px, 160px) minmax(0, 1fr) 22px 64px; }
}

@media (max-width: 800px) {
  .search { margin-left: 0; height: 44px; }
  .topbar .icon-btn[aria-label="Settings"] { display: none; }
  .nav-collapsed .sidebar .nav-label, .nav-collapsed .sidebar .nav-count, .nav-collapsed .compose-btn span { display: initial; }
  .row { grid-template-columns: 30px minmax(0, 1fr) auto; grid-template-rows: auto auto; height: auto; padding: 8px 12px 8px 6px; gap: 0 8px; }
  .row .cell-check { grid-row: 1 / 3; }
  .row .star-btn { grid-column: 3; grid-row: 2; justify-self: end; width: 28px; height: 28px; }
  .row .cell-from { grid-column: 2; grid-row: 1; padding-right: 0; }
  .row .cell-main { grid-column: 2; grid-row: 2; }
  .row .cell-att { display: none; }
  .row .cell-date { grid-column: 3; grid-row: 1; }
  .row:hover .row-actions { display: none; }
  .row:hover .cell-date { visibility: visible; }
  .reader { padding: 12px 16px 32px; }
  .msg-head { margin-left: 0; grid-template-columns: 40px minmax(0, 1fr) auto; }
  .msg-head .when { grid-column: 2; grid-row: 2; }
  .msg-head .msg-actions { grid-column: 3; grid-row: 1 / 3; }
  .compose-dock { right: 0; left: 0; }
  .compose, .compose.max { position: fixed; inset: 0; width: auto; height: auto; border-radius: 0; }
  .compose.min { inset: auto 0 0 0; }
  .range { display: none; }
  .fab {
    position: fixed; right: 16px; bottom: 20px; z-index: 30;
    display: inline-flex; align-items: center; gap: 10px;
    height: 56px; padding: 0 20px 0 16px; border: 0; border-radius: 16px;
    background: var(--compose); color: var(--compose-text); font-weight: 500;
    box-shadow: var(--shadow-3);
  }
  body:has(.compose:not([hidden])) .fab, body:has(.reader-view) .fab { display: none; }
}
