/* Inbox: list pane, conversation view, timeline, composer, project and task columns. */

.inbox-module .module-main { background: var(--surface-2); }
.inbox-panes { display: flex; height: 100%; min-height: 0; min-width: 0; overflow: hidden; }
.inbox-list-pane {
  width: clamp(320px, 27vw, 420px); flex: none; display: flex; flex-direction: column; min-height: 0;
  background: var(--surface); border-right: 1px solid var(--border);
}
.inbox-detail-pane { flex: 1; min-width: 0; display: flex; flex-direction: column; min-height: 0; position: relative; }
@media (max-width: 760px) {
  .inbox-list-pane { width: 100%; border-right: 0; }
  .inbox-panes.has-detail .inbox-list-pane { display: none; }
  .inbox-panes:not(.has-detail) .inbox-detail-pane { display: none; }
}

/* -- sidebar extras ------------------------------------------------------------------ */

.sidebar-tree { display: flex; flex-direction: column; gap: 1px; }
.sidebar-expand { display: flex; color: var(--text-3); padding: 2px; border-radius: 4px; margin-right: -2px; }
.sidebar-expand:hover { color: var(--text); background: var(--hover); }
.sidebar-empty { padding: 4px 12px 6px; font-size: 12px; color: var(--text-3); }
.sidebar-more { color: var(--text-3); font-size: 12.5px; }

/* -- list ------------------------------------------------------------------------------ */

.list-header { padding: 10px 12px 8px; border-bottom: 1px solid var(--border); display: flex; flex-direction: column; gap: 8px; flex: none; }
.list-header-top { display: flex; align-items: center; gap: 8px; min-height: 30px; }
.list-title { font-size: 16px; font-weight: 700; letter-spacing: -0.015em; min-width: 0; }
.list-count { font-size: 12px; font-weight: 650; color: var(--text-3); background: var(--surface-3); padding: 1px 7px; border-radius: 9px; }
.list-search { display: flex; align-items: center; gap: 4px; }
.list-search .search-input { flex: 1; }
.list-tabs { display: flex; align-items: center; }
.search-empty { padding: 28px 20px; color: var(--text-3); font-size: 13px; text-align: center; }
.search-help { padding: 12px 14px; font-size: 12.5px; }
.search-help-title { font-weight: 650; margin-bottom: 8px; }
.search-help-row { display: grid; grid-template-columns: 130px 1fr; gap: 10px; padding: 3px 0; color: var(--text-2); }
.search-help code, .search-help-foot code { font-family: var(--mono); font-size: 11.5px; color: var(--accent-text); }
.search-help-foot { margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--divider); color: var(--text-3); }

.bulk-bar {
  display: flex; align-items: center; gap: 4px; padding: 0 8px 0 14px; min-height: 52px; flex: none;
  background: var(--accent-soft); border-bottom: 1px solid var(--border);
}
.bulk-count { font-weight: 650; font-size: 13px; color: var(--accent-text); margin-left: 6px; }

.conv-list { flex: 1; overflow-y: auto; min-height: 0; }
.conv-list-section { border-bottom: 1px solid var(--border); }
.conv-list-section-title { padding: 10px 14px 4px; font-size: 11px; font-weight: 650; color: var(--text-3); text-transform: uppercase; letter-spacing: 0.05em; }
.conv-list-more { display: flex; justify-content: center; padding: 10px; }

.conv-row {
  position: relative; display: flex; gap: 10px; padding: 10px 12px 10px 10px; cursor: pointer;
  border-bottom: 1px solid var(--divider); color: var(--text); user-select: none;
}
.conv-row:hover { background: var(--hover); text-decoration: none; }
.conv-row.is-active { background: var(--selected); }
.conv-row.is-active::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--accent); }
.conv-row.is-selected { background: color-mix(in srgb, var(--accent-soft) 80%, transparent); }
.conv-row.is-closed { opacity: 0.78; }
.conv-row-lead { position: relative; flex: none; width: 34px; height: 34px; }
.conv-row-avatar { position: relative; display: block; }
.conv-row-icon { width: 32px; height: 32px; border-radius: 50%; background: var(--surface-3); color: var(--text-2); display: flex; align-items: center; justify-content: center; }
.conv-row-channel {
  position: absolute; right: -3px; bottom: -3px; width: 15px; height: 15px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center; color: #fff; background: var(--gray); box-shadow: 0 0 0 2px var(--surface);
}
.conv-row-channel.ch-email { background: var(--blue); }
.conv-row-channel.ch-sms { background: var(--green); }
.conv-row-channel.ch-whatsapp { background: #25a366; }
.conv-row-channel.ch-chat { background: var(--purple); }
.conv-row-channel.ch-api { background: var(--orange); }
.conv-row-check { position: absolute; inset: 0; display: none; align-items: center; justify-content: center; background: var(--surface); border-radius: 50%; }
.conv-row.is-selected .conv-row-check, .conv-row-lead:hover .conv-row-check { display: flex; }
.conv-row.is-active .conv-row-check { background: var(--selected); }
.conv-row-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.conv-row-top { display: flex; align-items: center; gap: 6px; min-width: 0; }
.unread-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); flex: none; }
.conv-row-from { font-size: 13.5px; color: var(--text); flex: 1; min-width: 0; }
.conv-row.is-unread .conv-row-from, .conv-row.is-unread .conv-row-subject-text { font-weight: 700; }
.conv-row-n { font-size: 11.5px; color: var(--text-3); font-weight: 500; margin-left: 5px; }
.conv-row-icons { display: flex; align-items: center; gap: 4px; color: var(--text-3); flex: none; }
.conv-row-comments { display: inline-flex; align-items: center; gap: 2px; font-size: 11.5px; }
.ic-urgent { color: var(--red); }
.ic-high { color: var(--orange); }
.ic-draft { color: var(--red-text); }
.ic-scheduled { color: var(--purple); }
.ic-failed { color: var(--red); }
.ic-star { color: var(--yellow); fill: var(--yellow); }
.conv-row-time { font-size: 12px; color: var(--text-3); flex: none; font-variant-numeric: tabular-nums; }
.conv-row.is-unread .conv-row-time { color: var(--accent-text); font-weight: 650; }
.conv-row-subject { font-size: 13px; color: var(--text-2); }
.conv-row-subject-text { color: var(--text); margin-right: 6px; }
.conv-row-subject-text:empty { display: none; }
.conv-row-preview { color: var(--text-3); }
.conv-row-meta { display: flex; align-items: center; flex-wrap: wrap; gap: 4px; min-height: 0; }
.conv-row-meta:empty { display: none; }
.row-presence { display: inline-flex; align-items: center; gap: 3px; padding: 1px 5px 1px 4px; border-radius: 10px; background: var(--surface-3); color: var(--text-2); }
.row-presence.is-replying { background: var(--yellow-soft); color: var(--yellow-text); }
.draft-row { align-items: center; }

/* -- conversation placeholder ---------------------------------------------------------- */

.conv-placeholder { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; color: var(--text-3); padding: 24px; }
.conv-placeholder-art { width: 76px; height: 76px; border-radius: 22px; background: var(--surface); border: 1px solid var(--border); display: flex; align-items: center; justify-content: center; color: var(--text-3); box-shadow: var(--shadow-1); }
.conv-placeholder-title { font-size: 15px; font-weight: 650; color: var(--text-2); }
.conv-placeholder-keys { font-size: 12.5px; display: flex; align-items: center; gap: 4px; flex-wrap: wrap; justify-content: center; }
.conv-empty { padding: 24px; display: flex; flex-direction: column; gap: 12px; align-items: flex-start; }

/* -- conversation view ---------------------------------------------------------------- */

.conv-view { flex: 1; display: flex; min-height: 0; min-width: 0; position: relative; }
.conv-main { flex: 1; min-width: 0; display: flex; flex-direction: column; min-height: 0; background: var(--surface-2); }
.conv-header {
  display: flex; align-items: center; gap: 10px; padding: 8px 12px 8px 18px; min-height: 52px; flex: none;
  background: var(--surface); border-bottom: 1px solid var(--border);
}
.conv-back { margin-left: -8px; }
.conv-source { flex: 1; min-width: 0; display: flex; align-items: center; gap: 12px; font-size: 13px; }
.conv-contact-link { font-weight: 600; color: var(--text-2) !important; }
.conv-meta { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font-size: 12.5px; color: var(--text-3); }
.conv-meta-item { display: inline-flex; align-items: center; gap: 5px; color: var(--text-3); min-width: 0; }
a.conv-meta-item:hover { color: var(--accent-text) !important; }
.conv-actions { display: flex; align-items: center; gap: 2px; flex: none; }
.conv-assign {
  display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 8px; border-radius: var(--radius-sm);
  color: var(--text-2); font-size: 13px; font-weight: 550; margin-right: 2px;
}
.conv-assign:hover { background: var(--hover); color: var(--text); }
.conv-close-btn { margin: 0 4px; }
.conv-hero { display: flex; flex-direction: column; gap: 8px; padding: 2px 2px 6px; }
.conv-subject { font-size: 20px; font-weight: 700; letter-spacing: -0.02em; line-height: 1.25; cursor: text; border-radius: 4px; overflow-wrap: anywhere; }
.conv-subject:hover { background: var(--hover); box-shadow: 0 0 0 4px var(--hover); }
.conv-subject-input { font-size: 20px; font-weight: 700; border: 1px solid var(--accent); border-radius: 5px; padding: 1px 6px; margin: -2px -7px; outline: none; background: var(--surface); box-shadow: 0 0 0 3px var(--focus); width: calc(100% + 14px); }
.conv-add-label { display: inline-flex; align-items: center; gap: 3px; height: 22px; padding: 0 8px; border-radius: 11px; border: 1px dashed var(--border-strong); color: var(--text-3); font-size: 12px; }
.conv-add-label:hover { color: var(--text); border-color: var(--text-3); }
@media (max-width: 1280px) { .hide-narrow { display: none; } }
@media (max-width: 760px) {
  .conv-header { padding: 6px 6px 6px 12px; }
  .conv-source { display: none; }
  .conv-subject { font-size: 17px; }
}

.presence-bar {
  display: flex; align-items: center; gap: 8px; padding: 6px 20px; font-size: 12.5px; color: var(--text-2); flex: none;
  background: var(--surface); border-bottom: 1px solid var(--divider);
}
.presence-bar.is-replying { background: var(--yellow-soft); color: var(--yellow-text); }
.typing-dots { display: inline-flex; gap: 3px; }
.typing-dots i { width: 5px; height: 5px; border-radius: 50%; background: currentColor; opacity: 0.4; animation: typing 1.2s infinite ease-in-out; }
.typing-dots i:nth-child(2) { animation-delay: 0.15s; }
.typing-dots i:nth-child(3) { animation-delay: 0.3s; }
@keyframes typing { 30% { opacity: 1; transform: translateY(-2px); } 60% { opacity: 0.4; transform: none; } }

.conv-scroll { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; }
.timeline { max-width: 920px; margin: 0 auto; padding: 18px 20px 28px; display: flex; flex-direction: column; gap: 10px; }
@media (max-width: 760px) { .timeline { padding: 12px 10px 20px; } }
.day-separator { display: flex; align-items: center; gap: 10px; margin: 8px 0 2px; color: var(--text-3); font-size: 11.5px; font-weight: 650; text-transform: uppercase; letter-spacing: 0.05em; }
.day-separator::before, .day-separator::after { content: ""; flex: 1; height: 1px; background: var(--border); }

.new-below {
  position: absolute; left: 50%; bottom: 150px; transform: translateX(-50%); z-index: 5;
  display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 16px;
  background: var(--accent); color: #fff; font-size: 12.5px; font-weight: 650; box-shadow: var(--shadow-2);
}

/* email cards */
.msg-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-1); min-width: 0; container-type: inline-size; }
.msg-card.is-outbound { border-left: 3px solid var(--accent); }
.msg-card.is-failed { border-color: var(--red); }
.msg-card.is-collapsed { display: flex; align-items: center; gap: 10px; padding: 8px 14px; cursor: pointer; }
.msg-card.is-collapsed:hover { background: var(--surface-2); }
.msg-collapsed-from { font-weight: 650; font-size: 13px; flex: none; max-width: 30%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.msg-collapsed-snippet { flex: 1; color: var(--text-3); font-size: 13px; }
.msg-header { display: flex; align-items: flex-start; gap: 10px; padding: 12px 12px 6px 14px; cursor: pointer; }
.msg-head-text { flex: 1; min-width: 0; }
.msg-from { display: flex; align-items: baseline; gap: 6px; min-width: 0; }
.msg-from > * { flex: none; }
/* Long names and addresses end in "…" rather than pushing the time and buttons out;
   the address gives way first. */
.msg-from-name { font-weight: 650; font-size: 14px; flex: 0 1 auto; min-width: 0; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.msg-from-handle { font-size: 12.5px; color: var(--text-3); flex: 0 100 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.msg-to { font-size: 12.5px; color: var(--text-3); }
/* A narrow message (phone, or a conversation squeezed by its project columns): the
   address goes on its own line and only the "…" button stays (reply and comment are in
   it, and in the right-click / press-and-hold menu). */
@container (max-width: 480px) {
  .msg-from { flex-wrap: wrap; row-gap: 0; }
  .msg-from .msg-from-handle { flex: 1 1 100%; order: 3; }
  .msg-actions > :not(:last-child) { display: none; }
  .msg-body, .msg-attachments, .msg-subject { padding-left: 14px; }
}
/* Narrower still: the time drops under the sender so the name keeps its room. */
@container (max-width: 360px) {
  .msg-header { flex-wrap: wrap; row-gap: 2px; }
  .msg-header .msg-head-text { order: 1; }
  .msg-header .msg-actions { order: 2; }
  .msg-header .msg-time { order: 3; flex: 0 0 100%; padding: 0 0 0 42px; }
}
.msg-time { font-size: 12px; color: var(--text-3); white-space: nowrap; flex: none; padding-top: 2px; }
.msg-status { display: inline-flex; align-items: center; gap: 6px; flex: none; }
.msg-actions { display: flex; gap: 0; flex: none; opacity: 0.6; }
.msg-card:hover .msg-actions { opacity: 1; }
.msg-subject { padding: 0 14px 4px 56px; font-weight: 650; font-size: 13.5px; color: var(--text-2); }
.msg-body { padding: 4px 16px 14px 56px; }
.msg-attachments { padding: 0 16px 14px 56px; }
.msg-text { white-space: pre-wrap; overflow-wrap: anywhere; font-size: 14px; line-height: 1.5; }
.ic-opened, .ic-delivered { color: var(--green); }
@media (max-width: 760px) { .msg-body, .msg-attachments, .msg-subject { padding-left: 14px; } }
.email-body { background: #fff; border-radius: var(--radius-sm); }
:root[data-theme="dark"] .email-body { padding: 10px 12px; }
.email-frame { display: block; width: 100%; height: 60px; border: 0; background: #fff; }
.email-images-blocked { display: flex; align-items: center; gap: 6px; padding: 6px 10px; margin-bottom: 8px; border-radius: var(--radius-sm); background: var(--surface-3); color: var(--text-2); font-size: 12.5px; }

/* text & chat bubbles */
.bubble-row { display: flex; align-items: flex-end; gap: 8px; max-width: 78%; }
.bubble-row.is-outbound { align-self: flex-end; }
.bubble-wrap { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.bubble-row.is-outbound .bubble-wrap { align-items: flex-end; }
.bubble-meta { font-size: 11.5px; color: var(--text-3); display: flex; align-items: center; gap: 4px; padding: 0 4px; }
.bubble { padding: 9px 13px; border-radius: 16px 16px 16px 4px; background: var(--surface); border: 1px solid var(--border); font-size: 14px; line-height: 1.45; overflow-wrap: anywhere; box-shadow: var(--shadow-1); }
.bubble-row.is-outbound .bubble { border-radius: 16px 16px 4px 16px; background: var(--accent); color: #fff; border-color: transparent; }
.bubble-row.is-outbound .bubble a { color: #fff; text-decoration: underline; }

/* internal comments */
.comment { display: flex; gap: 10px; align-items: flex-start; position: relative; padding: 2px 0; }
.comment-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; align-items: flex-start; }
.comment-head { display: flex; align-items: baseline; gap: 6px; font-size: 12.5px; }
.comment-author { font-weight: 650; }
.comment-time, .comment-edited { color: var(--text-3); font-size: 11.5px; }
.comment-bubble {
  max-width: 100%; padding: 8px 12px; border-radius: 4px 14px 14px 14px; font-size: 13.5px;
  background: var(--yellow-soft); border: 1px solid color-mix(in srgb, var(--yellow) 30%, transparent);
}
.comment-edit { width: 100%; display: flex; flex-direction: column; gap: 6px; background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius); padding: 4px; }
.comment-actions { position: absolute; top: -6px; right: 0; display: none; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); box-shadow: var(--shadow-1); }
.comment:hover .comment-actions { display: flex; }
/* Touch screens: reply, react, edit and delete are in the press-and-hold menu. */
@media (hover: none) { .comment-actions { display: none !important; } }
.reactions { display: flex; flex-wrap: wrap; gap: 4px; }
.reaction { display: inline-flex; align-items: center; gap: 4px; height: 24px; padding: 0 8px; border-radius: 12px; border: 1px solid var(--border); background: var(--surface); font-size: 13px; }
.reaction:hover { border-color: var(--border-strong); }
.reaction.is-mine { border-color: var(--accent); background: var(--accent-soft); }
.reaction-count { font-size: 11.5px; font-weight: 650; color: var(--text-2); }

/* events */
.event-line { display: flex; align-items: center; justify-content: center; gap: 6px; flex-wrap: wrap; font-size: 12px; color: var(--text-3); padding: 2px 0; }
.event-text b { color: var(--text-2); font-weight: 600; }
.event-time { color: var(--text-3); }

/* drafts in timeline */
.draft-card { border: 1px dashed var(--border-strong); border-radius: var(--radius-lg); background: var(--surface); padding: 10px 12px; }
.draft-card-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 13px; color: var(--text-2); }
.draft-card-body { margin-top: 6px; color: var(--text-2); font-size: 13px; padding-left: 21px; }

/* reply bar & comment box */
.reply-bar { display: flex; align-items: center; gap: 6px; padding: 8px 16px 0; flex: none; max-width: 920px; width: 100%; margin: 0 auto; }
.conv-composer { flex: none; padding: 8px 16px 0; max-width: 952px; width: 100%; margin: 0 auto; }
.comment-box { flex: none; padding: 8px 16px 12px; max-width: 952px; width: 100%; margin: 0 auto; }
.comment-box-row {
  display: flex; align-items: flex-end; gap: 2px; padding: 3px 4px 3px 2px;
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius-lg);
  transition: border-color 0.12s, box-shadow 0.12s;
}
.comment-box-row:focus-within { border-color: color-mix(in srgb, var(--yellow) 60%, var(--border-strong)); box-shadow: 0 0 0 3px color-mix(in srgb, var(--yellow) 22%, transparent); }
.comment-editor { flex: 1; min-width: 0; }
.comment-editor .rich-editor-content { padding: 7px 10px; min-height: 36px; }
.comment-box-files { margin-bottom: 6px; }
.comment-box-hint { font-size: 11px; color: var(--text-3); padding: 4px 6px 0; }
@media (max-width: 760px) { .comment-box-hint { display: none; } .comment-box { padding-bottom: 8px; } }

/* -- composer --------------------------------------------------------------------------- */

.composer {
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-2); display: flex; flex-direction: column; min-width: 0;
}
.composer-page { border-radius: 0; border: 0; box-shadow: none; flex: 1; min-height: 0; }
.compose-page { flex: 1; display: flex; flex-direction: column; min-height: 0; background: var(--surface); }
.composer-head { display: flex; align-items: center; gap: 10px; padding: 8px 10px 6px 14px; border-bottom: 1px solid var(--divider); min-height: 42px; }
.composer-mode { display: inline-flex; align-items: center; gap: 6px; font-weight: 650; font-size: 13px; }
.composer-from { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--text-3); min-width: 0; }
.composer-from .select { max-width: 280px; }
.composer-coeditor { display: flex; }
.composer-save { font-size: 11.5px; color: var(--text-3); min-width: 40px; text-align: right; }
.composer-save.is-error { color: var(--red-text); }
.composer-remote { display: flex; align-items: center; gap: 8px; padding: 6px 14px; background: var(--yellow-soft); color: var(--yellow-text); font-size: 12.5px; }
.composer-fields { display: flex; flex-direction: column; border-bottom: 1px solid var(--divider); position: relative; }
.recipients { position: relative; display: flex; align-items: flex-start; gap: 8px; padding: 5px 14px; border-bottom: 1px solid var(--divider); cursor: text; }
.recipients:last-of-type { border-bottom: 0; }
.recipients-label { font-size: 12.5px; color: var(--text-3); padding-top: 4px; min-width: 26px; }
.recipients-chips { display: flex; flex-wrap: wrap; gap: 4px; flex: 1; min-width: 0; align-items: center; min-height: 26px; }
.recipients-input { flex: 1; min-width: 140px; border: 0; outline: none; background: transparent; font-size: 13.5px; height: 24px; }
.recipients-suggest {
  position: absolute; left: 44px; top: 100%; z-index: 30; min-width: 280px; max-width: 420px; padding: 4px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-3);
}
.recipients-option { display: flex; flex-direction: column; align-items: flex-start; width: 100%; padding: 6px 10px; border-radius: 5px; text-align: left; font-size: 13px; }
.recipients-option.is-active, .recipients-option:hover { background: var(--hover); }
.composer-cc-toggle { position: absolute; right: 12px; top: 8px; font-size: 12px; color: var(--text-3); padding: 2px 6px; border-radius: 4px; }
.composer-cc-toggle + .composer-cc-toggle { right: 64px; }
.composer-cc-toggle:hover { color: var(--text); background: var(--hover); }
.composer-subject { padding: 4px 14px; border-top: 1px solid var(--divider); }
.composer-subject-input { width: 100%; border: 0; outline: none; background: transparent; font-size: 14px; font-weight: 600; height: 28px; }
.composer-editor .editor-toolbar { border-bottom: 1px solid var(--divider); }
.composer-editor .rich-editor-content { padding: 10px 14px; }
.composer-page .composer-editor { flex: 1; min-height: 0; }
.composer-signature { margin: 0 14px 8px; padding-top: 6px; border-top: 1px dashed var(--border); color: var(--text-3); font-size: 12.5px; max-height: 90px; overflow: hidden; }
.composer-attachments { padding: 0 14px 8px; display: flex; flex-direction: column; gap: 6px; }
.composer-foot { display: flex; align-items: center; gap: 4px; padding: 8px 10px; border-top: 1px solid var(--divider); flex-wrap: wrap; }
.composer-sig-toggle { margin-left: 8px; font-size: 12.5px; }
.composer-sig-toggle .toggle-track { transform: scale(0.85); }
.sms-count { font-size: 12px; color: var(--text-3); margin-left: 8px; }
.sms-count.is-multi { color: var(--yellow-text); }

/* -- levels: Inbox > Conversation > Project > Task --------------------------------------- */
/* Each level opens a column on the right; the columns before it narrow but stay in view. */

.level-col {
  flex: none; display: flex; flex-direction: column; min-height: 0; min-width: 0;
  background: var(--surface); border-left: 1px solid var(--border);
}
.level-projects { width: 280px; }
/* Collapsed to a slim strip that brings it back. */
.level-projects.is-collapsed { width: 44px; }
.level-expand {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 14px 0;
  color: var(--text-3); background: none; border: 0; cursor: pointer;
}
.level-expand:hover { color: var(--text); background: var(--hover); }
.level-expand-label { writing-mode: vertical-rl; font-size: 12px; font-weight: 650; letter-spacing: 0.04em; text-transform: uppercase; }
.level-expand-count { font-size: 11.5px; font-weight: 650; color: var(--accent-text); background: var(--accent-soft); border-radius: 999px; padding: 1px 7px; }
.level-project { width: 380px; }
.level-task { width: 380px; }
.level-head { display: flex; align-items: center; gap: 6px; min-height: var(--header-h); padding: 0 8px 0 14px; border-bottom: 1px solid var(--divider); }
.level-icon { color: var(--text-3); flex: none; }
.level-title { margin: 0; font-size: 14px; font-weight: 650; }
.level-body { flex: 1; overflow-y: auto; padding: 10px; display: flex; flex-direction: column; gap: 6px; }
.level-row {
  display: block; width: 100%; text-align: left; padding: 9px 10px; border-radius: var(--radius);
  border: 1px solid var(--divider); background: var(--surface); color: var(--text);
}
.level-row:hover { border-color: var(--border-strong); }
.level-row.is-active { border-color: var(--accent); background: var(--accent-soft); }
.level-row.is-done { opacity: 0.65; }
.level-subhead { margin: 10px 2px 2px; font-size: 11.5px; font-weight: 650; letter-spacing: 0.04em; text-transform: uppercase; color: var(--text-3); }
.level-empty { margin: 4px 2px; }
.project-hero { display: flex; flex-direction: column; gap: 6px; padding: 4px 2px 6px; }
.project-title { margin: 0; font-size: 16px; font-weight: 650; letter-spacing: -0.01em; overflow-wrap: anywhere; }
.project-desc { margin: 0; font-size: 13px; color: var(--text-2); white-space: pre-wrap; overflow-wrap: anywhere; }
.project-alone .level-project { width: 100%; max-width: 640px; margin: 0 auto; border-right: 1px solid var(--border); }
.level-task .task-drawer-head { min-height: var(--header-h); padding: 0 8px 0 14px; }
.level-task .task-drawer-body { padding: 14px 14px 24px; }

/* Going deeper narrows what came before. */
@media (min-width: 761px) {
  /* The mailbox list as icons: when you collapse it, and on its own at the Project and
     Task levels. Counts stay, as badges on the icons, and each name shows on hover. */
  .inbox-module:is(.depth-3, .depth-4, .sidebar-collapsed) .module-sidebar { width: 60px; }
  .inbox-module:is(.depth-3, .depth-4, .sidebar-collapsed) .module-sidebar :is(.sidebar-header, .sidebar-section-header, .sidebar-label, .btn-label) { display: none; }
  .inbox-module:is(.depth-3, .depth-4, .sidebar-collapsed) .module-sidebar .sidebar-item { justify-content: center; position: relative; padding: 0; }
  .inbox-module:is(.depth-3, .depth-4, .sidebar-collapsed) .module-sidebar .sidebar-count {
    position: absolute; top: 1px; right: 4px; min-width: 16px; height: 16px; padding: 0 4px; border-radius: 8px;
    display: inline-flex; align-items: center; justify-content: center; font-size: 10px; line-height: 1;
    background: var(--surface-3); color: var(--text-2); box-shadow: 0 0 0 2px var(--surface-2);
  }
  .inbox-module:is(.depth-3, .depth-4, .sidebar-collapsed) .module-sidebar .sidebar-count:is(.tone-accent, .tone-danger) { color: #fff; }
  .inbox-module:is(.depth-3, .depth-4, .sidebar-collapsed) .module-sidebar .sidebar-count.tone-accent { background: var(--accent); }
  .inbox-module:is(.depth-3, .depth-4, .sidebar-collapsed) .module-sidebar .sidebar-count.tone-danger { background: var(--red); }
  .inbox-module:is(.depth-3, .depth-4, .sidebar-collapsed) .module-sidebar .sidebar-section + .sidebar-section { border-top: 1px solid var(--divider); }
  .inbox-module:is(.depth-3, .depth-4, .sidebar-collapsed) .sidebar-compose { padding-left: 8px; padding-right: 8px; }
  .inbox-module:is(.depth-3, .depth-4, .sidebar-collapsed) .sidebar-compose .btn-group > :last-child { display: none; }
  .sidebar-expand-btn {
    display: flex; align-items: center; justify-content: center; width: 36px; height: 32px; margin: 10px auto 2px;
    border-radius: 6px; color: var(--text-3);
  }
  .sidebar-expand-btn:hover { background: var(--hover); color: var(--text); }
  .inbox-panes.depth-3 .inbox-list-pane { width: 260px; }
  .inbox-panes.depth-4 .inbox-list-pane { width: 210px; }
  .inbox-panes.depth-3 .inbox-detail-pane { min-width: 360px; }
  .inbox-panes.depth-4 .inbox-detail-pane { min-width: 300px; }
  .inbox-panes.depth-4 .level-project { width: 300px; }
}
@media (min-width: 761px) and (max-width: 1280px) {
  .inbox-panes.depth-2 .inbox-list-pane { width: 300px; }
  .level-projects:not(.is-collapsed) { width: 240px; }
  .inbox-panes.depth-4 .inbox-list-pane { width: 180px; }
  .level-task { width: 340px; }
}
/* Tablets (portrait iPad is 1024 wide): four columns don't fit beside a task, so the
   conversation list steps aside at the Task level and the rest share what's left. */
@media (min-width: 761px) and (max-width: 1180px) {
  /* Even at the Conversation level the mailbox list goes down to icons, or the open
     conversation would be squeezed to a sliver between the list and Projects. */
  .inbox-module.depth-2 .module-sidebar { width: 60px; }
  .inbox-module.depth-2 .module-sidebar :is(.sidebar-header, .sidebar-section-header, .sidebar-label, .btn-label) { display: none; }
  .inbox-module.depth-2 .module-sidebar .sidebar-item { justify-content: center; position: relative; padding: 0; }
  .inbox-module.depth-2 .module-sidebar .sidebar-count {
    position: absolute; top: 1px; right: 4px; min-width: 16px; height: 16px; padding: 0 4px; border-radius: 8px;
    display: inline-flex; align-items: center; justify-content: center; font-size: 10px; line-height: 1;
    background: var(--surface-3); color: var(--text-2); box-shadow: 0 0 0 2px var(--surface-2);
  }
  .inbox-module.depth-2 .module-sidebar .sidebar-count.tone-accent { background: var(--accent); color: #fff; }
  .inbox-module.depth-2 .sidebar-compose { padding-left: 8px; padding-right: 8px; }
  .inbox-module.depth-2 .sidebar-compose .btn-group > :last-child { display: none; }
  .inbox-panes.depth-2 .inbox-list-pane { width: 280px; }
  .inbox-panes.depth-2 .inbox-detail-pane { min-width: 340px; }
  .inbox-panes.depth-3 .inbox-list-pane { width: 220px; }
  .inbox-panes.depth-3 .inbox-detail-pane { min-width: 300px; }
  .inbox-panes.depth-3 .level-project { width: 320px; }
  .inbox-panes.depth-4 .inbox-list-pane { display: none; }
  .inbox-panes.depth-4 .inbox-detail-pane { min-width: 260px; }
  .inbox-panes.depth-4 .level-project { width: 280px; }
  .inbox-panes.depth-4 .level-task { width: 320px; }
}
@media (max-width: 760px) {
  /* Phones show only the deepest level; its X steps back up. */
  .level-col { width: 100%; border-left: 0; }
  .inbox-panes.depth-2 .level-projects { display: none; }
  .inbox-panes:is(.depth-3, .depth-4) .inbox-detail-pane, .inbox-panes.depth-4 .level-project { display: none; }
}

.text-danger { color: var(--red-text); }

/* -- widgets & settings ------------------------------------------------------------------- */

.inbox-widget-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 12px; }
.inbox-widget-stat { display: flex; flex-direction: column; padding: 10px; border-radius: var(--radius); background: var(--surface-2); border: 1px solid var(--divider); color: var(--text-3); font-size: 12px; }
.inbox-widget-stat:hover { text-decoration: none; border-color: var(--border-strong); }
.inbox-widget-num { font-size: 22px; font-weight: 700; color: var(--text); letter-spacing: -0.02em; }
.widget-list { display: flex; flex-direction: column; }
.widget-row { display: flex; align-items: center; gap: 8px; padding: 7px 4px; border-bottom: 1px solid var(--divider); color: var(--text); font-size: 13px; min-width: 0; }
.widget-row:last-child { border-bottom: 0; }
.widget-row:hover { background: var(--hover); text-decoration: none; }
.widget-row.is-unread b { color: var(--accent-text); }
.vars-help { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.var-chip { font-family: var(--mono); font-size: 11.5px; padding: 2px 6px; border-radius: 4px; background: var(--surface-3); color: var(--text-2); }
.var-chip:hover { background: var(--accent-soft); color: var(--accent-text); }

/* -- print a conversation ----------------------------------------------------------------- */

@media print {
  .rail, .module-sidebar, .inbox-list-pane, .conv-actions, .level-col, .comment-box, .reply-bar, .conv-composer,
  .presence-bar, .msg-actions, .comment-actions, .desktop-prompt, .connection-banner, .toast-stack, .new-below { display: none !important; }
  .app, .app-main, .app-outlet, .module, .module-main, .inbox-panes, .inbox-detail-pane, .conv-view, .conv-main, .conv-scroll { display: block !important; height: auto !important; overflow: visible !important; }
  body, .conv-main { background: #fff !important; }
  .msg-card { break-inside: avoid; box-shadow: none; }
}

/* Comments that answer another comment or discuss one message */
.comment-avatar, .comment-author { padding: 0; border: 0; background: none; color: inherit; font: inherit; cursor: pointer; }
.comment-author { font-weight: 650; }
.comment-author:hover { text-decoration: underline; }
.reply-quote { display: flex; align-items: center; gap: 4px; max-width: 100%; margin: 2px 0 4px; }
.reply-quote-main { display: flex; align-items: center; gap: 6px; min-width: 0; padding: 3px 8px; border: 0;
  border-left: 3px solid var(--border-strong); border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  background: var(--surface-2); color: var(--text-2); font-size: 12.5px; text-align: left; cursor: pointer; }
.reply-quote.is-message .reply-quote-main { border-left-color: var(--accent); }
.reply-quote-main:hover { color: var(--text); }
.reply-quote-who { font-weight: 600; flex: none; }
.reply-quote-text { min-width: 0; }
.comment-box > .reply-quote { padding: 0 2px 6px; }
.is-flash { animation: sb-flash 1.6s ease-out; }
@keyframes sb-flash { 0%, 30% { box-shadow: 0 0 0 3px var(--accent-soft); background-color: var(--accent-soft); } 100% { box-shadow: none; } }

/* -- press and hold (touch) ----------------------------------------------------------- */
/* Holding a finger on these opens their menu (lib/longpress.js), not the phone's own
   text-selection or link callout. */
@media (pointer: coarse) {
  .conv-row, .msg-header, .msg-card.is-collapsed, .bubble-row, .comment, .level-row, .task-row, .conv-hero {
    -webkit-touch-callout: none; -webkit-user-select: none; user-select: none;
  }
  .conv-row, .conv-row *, .msg-card img, .comment img, .bubble-row img { -webkit-user-drag: none; }
}

/* Tasks in a project column: the name gets the width (up to two lines) and the due date
   sits under it, so a narrow column doesn't cut names to a few letters. */
.level-project .task-row.is-compact { flex-wrap: wrap; align-items: flex-start; row-gap: 2px; }
.level-project .task-row.is-compact .task-title {
  white-space: normal; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2;
}
.level-project .task-row.is-compact .task-due { order: 5; flex-basis: 100%; padding-left: 28px; }

/* -- reading tools: find in this conversation, and All / Messages / Comments ------------ */
.conv-tools {
  position: sticky; top: 0; z-index: 4; display: flex; align-items: center; justify-content: flex-end; gap: 8px;
  max-width: 920px; margin: 0 auto; padding: 8px 20px 0; pointer-events: none;
}
.conv-tools > * { pointer-events: auto; }
.conv-tools > .icon-btn { background: var(--surface); box-shadow: var(--shadow-1); }
.conv-tools .segmented { box-shadow: var(--shadow-1); }
.conv-find {
  flex: 1 1 auto; max-width: 440px; min-width: 0; display: flex; align-items: center; gap: 4px; height: 32px;
  padding: 0 4px 0 10px; border: 1px solid var(--border-strong); border-radius: 8px; background: var(--surface); box-shadow: var(--shadow-2);
}
.conv-find:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--focus); }
.conv-find-input { flex: 1; min-width: 0; border: 0; outline: 0; background: none; font: inherit; font-size: 13.5px; color: var(--text); }
.conv-find-input::-webkit-search-cancel-button { display: none; }
.conv-find-count { font-size: 12px; color: var(--text-3); white-space: nowrap; font-variant-numeric: tabular-nums; }
@media (max-width: 760px) { .conv-tools { padding: 8px 10px 0; } .conv-tools.is-finding .segmented { display: none; } }
::highlight(sb-find) { background: #ffe58a; color: inherit; }
::highlight(sb-find-current) { background: #ff9f43; color: #111; }
.is-find-current.msg-card, .is-find-current .comment-bubble, .is-find-current.bubble-row .bubble { box-shadow: 0 0 0 2px #ff9f43; }
.conv-filter-empty { text-align: center; padding: 28px 0; }

/* Dragging conversations over another row: it's where they'll merge. */
.conv-row.is-merge-target { position: relative; background: var(--accent-soft); box-shadow: inset 0 0 0 2px var(--accent); }
/* Touch drag: the held row lifts, then a chip follows the finger. */
.conv-row.is-lifted { position: relative; z-index: 2; background: var(--surface); box-shadow: var(--shadow-3), inset 0 0 0 2px var(--accent); transform: scale(1.015); transition: transform 0.12s, box-shadow 0.12s; }
.is-conv-dragging .conv-row.is-lifted { opacity: 0.45; transform: none; box-shadow: none; }
.is-conv-dragging, .is-conv-dragging * { user-select: none !important; -webkit-user-select: none !important; }
.conv-drag-ghost {
  position: fixed; left: 0; top: 0; z-index: 1000; pointer-events: none; display: flex; align-items: center; gap: 8px;
  max-width: min(280px, 70vw); padding: 6px 12px 6px 6px; border-radius: 999px; background: var(--surface);
  box-shadow: var(--shadow-3), 0 0 0 2px var(--accent); font-size: 13px; font-weight: 600; color: var(--text);
}
.conv-drag-ghost .conv-row-avatar { position: relative; flex: none; }
.conv-drag-ghost-label { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conv-row.is-merge-target::after {
  content: attr(data-merge-hint); position: absolute; right: 10px; bottom: 6px; max-width: calc(100% - 20px);
  padding: 2px 8px; border-radius: 999px; background: var(--accent); color: #fff; font-size: 11.5px; font-weight: 650;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; pointer-events: none;
}

/* Comment box in "direct message to a teammate" mode. */
.comment-dm {
  display: flex; align-items: center; gap: 6px; margin-bottom: 6px; padding: 3px 4px 3px 10px; border-radius: var(--radius);
  background: var(--accent-soft); color: var(--accent-text); font-size: 12.5px; min-width: 0;
}
.comment-dm .truncate { flex: 1; }

/* -- conversation list folded to a strip of avatars ------------------------------------ */
@media (min-width: 761px) {
  .inbox-panes.list-collapsed > .inbox-list-pane { width: 64px; }
  .list-collapsed > .inbox-list-pane :is(.list-header, .bulk-bar, .search-empty, .conv-list-section, .conv-list-more, .conv-row-main, .conv-row-check, .empty) { display: none; }
  .list-collapsed > .inbox-list-pane .conv-row { justify-content: center; padding: 8px 0; }
  .list-collapsed > .inbox-list-pane .conv-row .conv-row-lead { pointer-events: none; }
  /* Unread shows as a dot on the avatar. */
  .list-collapsed > .inbox-list-pane .conv-row.is-unread .conv-row-avatar::after {
    content: ""; position: absolute; top: -2px; left: -2px; width: 9px; height: 9px; border-radius: 50%;
    background: var(--accent); box-shadow: 0 0 0 2px var(--surface);
  }
  .list-collapsed-head {
    display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 10px 0 8px;
    border-bottom: 1px solid var(--border); flex: none;
  }
  .list-expand { display: flex; align-items: center; justify-content: center; width: 36px; height: 32px; border-radius: 6px; color: var(--text-3); }
  .list-expand:hover { background: var(--hover); color: var(--text); }
  .list-collapsed-count { font-size: 11px; font-weight: 650; color: var(--text-3); font-variant-numeric: tabular-nums; }
}

/* -- a project's steps (the Scheduler's tasks), in the project and task columns -------- */
.project-dates { display: flex; flex-wrap: wrap; gap: 4px 14px; margin: 2px 0 0; font-size: 12.5px; }
.project-dates div { display: flex; gap: 5px; }
.project-dates dt { color: var(--text-3); }
.project-dates dd { margin: 0; font-weight: 600; }
.project-progress { height: 5px; border-radius: 3px; background: var(--surface-3); overflow: hidden; margin-top: 4px; }
.project-progress span { display: block; height: 100%; background: var(--green); border-radius: 3px; }
.step-list { display: flex; flex-direction: column; gap: 2px; }
.step-row {
  display: grid; grid-template-columns: auto auto minmax(0, 1fr) auto; align-items: center; gap: 8px;
  padding: 6px 6px 6px 4px; border-radius: 6px; cursor: pointer; font-size: 13px; min-width: 0;
}
.step-row:hover { background: var(--hover); }
.step-row.is-active { background: var(--selected); }
.step-row.is-done .step-value { color: var(--text-3); text-decoration: line-through; }
.step-status { display: flex; align-items: center; justify-content: center; width: 22px; height: 22px; border-radius: 50%; flex: none; }
.step-status:hover { background: var(--surface-3); }
.step-status .sch-status-dot { width: 11px; height: 11px; }
.step-value { min-width: 0; overflow-wrap: anywhere; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; overflow: hidden; }
.step-day { font-size: 12px; color: var(--text-3); white-space: nowrap; }
.step-day.is-unplaced { font-style: italic; }
.step-add { display: flex; gap: 6px; align-items: center; margin-top: 6px; min-width: 0; }
.step-add .input { min-width: 0; }
.step-add select { width: auto; flex: none; }
.step-detail { display: flex; flex-direction: column; gap: 14px; padding: 4px 4px 20px; }
.step-value-input {
  width: 100%; resize: vertical; border: 1px solid transparent; border-radius: 6px; padding: 4px 6px; margin: -4px -6px 0;
  font: 650 16px/1.35 var(--font); color: var(--text); background: transparent;
}
.step-value-input:hover { border-color: var(--border); }
.step-value-input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--focus); background: var(--surface); }
.step-value-static { margin: 0; font-size: 16px; font-weight: 650; overflow-wrap: anywhere; }

/* -- tools: the bar beside a conversation and the window it opens ----------------------- */
/* Draft of the "Inbox view with tool active" wireframe: rail, the conversation list as
   avatars, the open conversation, the tool bar, then the tool window taking the rest. */
.tool-bar {
  flex: none; width: 58px; display: flex; flex-direction: column; gap: 2px; padding: 8px 5px;
  background: var(--surface); border-left: 1px solid var(--border); overflow-y: auto;
}
.tool-bar-item {
  display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 8px 0 6px; border-radius: 8px;
  color: var(--text-3); font-size: 10.5px; font-weight: 650; letter-spacing: 0.01em;
}
.tool-bar-item:hover { background: var(--hover); color: var(--text); }
.tool-bar-item.is-active { background: #2a2c32; color: #fff; }
.tool-window {
  flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; min-height: 0;
  background: var(--surface-2); color: var(--text); border-left: 1px solid var(--border);
}
.tool-head { display: flex; align-items: center; gap: 8px; min-height: var(--header-h); padding: 0 8px 0 16px; border-bottom: 1px solid var(--divider); flex: none; }
.tool-head-icon { color: var(--accent-text); }
.tool-title { margin: 0; font-size: 14px; font-weight: 650; }
.tool-sub { color: var(--text-3); font-size: 12.5px; min-width: 0; }
.tool-body { flex: 1; min-height: 0; display: flex; flex-direction: column; overflow: auto; }
.tool-note { color: var(--text-3); font-size: 12.5px; margin: 0; }
.tool-empty { margin: auto; text-align: center; color: var(--text-3); font-size: 13px; padding: 24px; display: flex; flex-direction: column; align-items: center; gap: 10px; }
.tool-split { flex: 1; min-height: 0; display: flex; }

@media (min-width: 761px) {
  /* The conversation keeps about a third, the tool takes the rest (as in the wireframe). */
  .inbox-panes.tool-open .inbox-detail-pane { flex: 0 1 clamp(380px, 31vw, 600px); min-width: 340px; }
}
@media (min-width: 761px) and (max-width: 1180px) {
  .inbox-panes.tool-open .inbox-detail-pane { flex-basis: 400px; min-width: 300px; }
}

/* Projects inside the tool window: the levels side by side. */
.tool-levels { flex: 1; min-height: 0; display: flex; overflow-x: auto; }
.tool-window .level-col { background: var(--surface); }
.tool-window .level-col:first-child { border-left: 0; }
/* Panels sized with a divider still give way (flex-shrink) when the tool narrows. */
.tool-window .level-projects { flex: 0 1 var(--pane-w, 280px); min-width: 200px; }
.tool-window .level-project[style*="--pane-w"] { flex: 0 1 var(--pane-w); min-width: 240px; }
.tool-window .level-project, .tool-window .level-task { flex: 1 1 380px; min-width: 300px; }
.tool-window .project-progress { background: var(--surface-3); }

/* Files */
.tool-files {
  flex: 0 1 var(--pane-w, 300px); min-width: 160px; overflow-y: auto; padding: 10px; display: grid; grid-template-columns: repeat(auto-fill, minmax(124px, 1fr));
  gap: 8px; align-content: start; border-right: 1px solid var(--divider);
}
.tool-file { display: flex; flex-direction: column; gap: 4px; padding: 6px; border-radius: 8px; text-align: left; color: var(--text); min-width: 0; }
.tool-file:hover { background: var(--hover); }
.tool-file.is-active { background: var(--selected); box-shadow: inset 0 0 0 1px var(--accent); }
.tool-file-thumb { aspect-ratio: 4 / 3; border-radius: 6px; background: var(--surface-3); display: flex; align-items: center; justify-content: center; overflow: hidden; color: var(--text-3); }
.tool-file-thumb img { width: 100%; height: 100%; object-fit: cover; }
.tool-file-name { font-size: 12.5px; font-weight: 600; }
.tool-file-meta { font-size: 11.5px; color: var(--text-3); }
.tool-preview { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.tool-preview-stage { flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; padding: 16px; overflow: auto; }
.tool-preview-stage img { max-width: 100%; max-height: 100%; object-fit: contain; border-radius: 4px; box-shadow: var(--shadow-2); background: #fff; }
.tool-preview-stage iframe { width: 100%; height: 100%; border: 0; border-radius: 4px; background: #fff; }
.tool-preview-bar { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-top: 1px solid var(--divider); font-size: 12.5px; color: var(--text-2); min-width: 0; }

/* Imposition */
.tool-form { flex: 0 1 var(--pane-w, 260px); min-width: 200px; overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 16px; border-right: 1px solid var(--divider); }
.tool-form-group { display: flex; flex-direction: column; gap: 8px; }
.tool-form-title { font-size: 11.5px; font-weight: 650; letter-spacing: 0.04em; text-transform: uppercase; color: var(--text-3); }
.tool-field { display: flex; flex-direction: column; gap: 3px; font-size: 12px; color: var(--text-2); min-width: 0; }
.tool-field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.tool-impose-out { flex: 1; min-width: 0; padding: 16px; display: flex; flex-direction: column; gap: 14px; overflow: auto; }
.tool-impose-result { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 8px; }
.tool-impose-result div { padding: 10px 12px; border-radius: 8px; background: var(--surface); border: 1px solid var(--border); display: flex; flex-direction: column; gap: 2px; }
.tool-impose-result b { font-size: 20px; font-weight: 700; letter-spacing: -0.01em; }
.tool-impose-result span { font-size: 12px; color: var(--text-3); }
.tool-impose-sheet { width: 100%; max-height: 460px; }
.tool-impose-sheet .sheet { fill: #fff; stroke: #9aa3b2; }
.tool-impose-sheet .margin { fill: none; stroke: #c9ced8; stroke-dasharray: 4 3; }
.tool-impose-sheet .bleed { fill: rgba(109, 140, 255, 0.18); }
.tool-impose-sheet .piece { fill: rgba(109, 140, 255, 0.42); stroke: #3b5bdb; stroke-width: 1; }

/* AI */
.tool-ai { padding: 14px 16px; display: flex; flex-direction: column; gap: 12px; max-width: 760px; }
.tool-ai-out { padding: 12px 14px; border-radius: 8px; background: var(--surface); border: 1px solid var(--border); font-size: 13.5px; }
.tool-kv { display: grid; grid-template-columns: 120px 1fr; gap: 6px 12px; margin: 0; }
.tool-kv dt { color: var(--text-3); text-transform: capitalize; }
.tool-kv dd { margin: 0; overflow-wrap: anywhere; }

/* Design */
.tool-design { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.tool-design-bar { display: flex; align-items: center; gap: 6px; padding: 8px 12px; border-bottom: 1px solid var(--divider); }
.tool-design-bar select { max-width: 320px; }
.tool-zoom { font-size: 12px; color: var(--text-2); min-width: 40px; text-align: center; font-variant-numeric: tabular-nums; }
.tool-design-canvas {
  flex: 1; min-height: 0; overflow: auto; display: flex; align-items: flex-start; justify-content: center; padding: 24px;
  background-color: #1b1c20; background-image: linear-gradient(45deg, #222327 25%, transparent 25%), linear-gradient(-45deg, #222327 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #222327 75%), linear-gradient(-45deg, transparent 75%, #222327 75%);
  background-size: 20px 20px; background-position: 0 0, 0 10px, 10px -10px, -10px 0;
}
.tool-design-canvas img { max-width: none; box-shadow: var(--shadow-3); background: #fff; }
.tool-design-canvas iframe { width: 100%; height: 100%; min-height: 480px; border: 0; background: #fff; }

/* Phones: the tool takes the screen; within Projects only the deepest level shows. */
@media (max-width: 760px) {
  .inbox-panes.tool-open .inbox-detail-pane { display: none; }
  .tool-bar { width: 52px; padding: 6px 3px; }
  .tool-split { flex-direction: column; }
  .tool-files, .tool-form { flex: none; max-height: 45%; border-right: 0; border-bottom: 1px solid var(--divider); }
  .inbox-panes.tool-open .tool-window .level-projects { display: flex; flex: 1 1 auto; width: 100%; }
  .inbox-panes.tool-open:is(.depth-3, .depth-4) .tool-window .level-projects,
  .inbox-panes.tool-open.depth-4 .tool-window .level-project { display: none; }
  .tool-window .level-project, .tool-window .level-task { min-width: 0; }
}

/* Tools beside the Scheduler: module | tool bar | tool window (the app shell places them). */
.app-outlet > .tool-bar { flex: none; }
.app-outlet.tool-open > .tool-window { flex: 1 1 0; min-width: 420px; }
.app-outlet.tool-open > .module { flex: 1.25 1 0; min-width: 640px; }
/* With no conversation open, the Inbox's empty reading pane gives way to the tool. */
.inbox-panes.tool-open:not(.has-detail) .inbox-detail-pane { display: none; }
@media (max-width: 760px) {
  .app-outlet.tool-open > .module { display: none; }
  .inbox-panes.tool-open:not(.has-detail) .inbox-list-pane { display: none; }
}

/* -- resizable sidebar and conversation list ------------------------------------------- */
/* The dividers replace the panes' own right borders. A chosen width applies only while
   the pane is open: folded to icons or avatars, or at Project/Task depth, it stays slim. */
.sidebar-split, .list-split { display: none; }
@media (min-width: 761px) {
  /* The list divider shows whenever the list is open; the sidebar one whenever the
     sidebar shows its names (tablets fold it to icons on their own at depth 2). */
  .inbox-panes:not(.list-collapsed):not(.depth-4):not(.tool-open) > .list-split,
  .inbox-panes.tool-open.has-detail:not(.list-collapsed):not(.depth-4) > .list-split { display: block; }
  .inbox-panes:not(.list-collapsed):not(.depth-4):not(.tool-open) > .inbox-list-pane,
  .inbox-panes.tool-open.has-detail:not(.list-collapsed):not(.depth-4) > .inbox-list-pane { border-right: 0; }
  .inbox-panes:not(.list-collapsed):not(.depth-4) > .inbox-list-pane[style*="--pane-w"] { width: var(--pane-w); }
}
@media (min-width: 1181px) {
  .inbox-module:not(.depth-3):not(.depth-4):not(.sidebar-collapsed) > .sidebar-split { display: block; }
  .inbox-module:not(.depth-3):not(.depth-4):not(.sidebar-collapsed) > .module-sidebar { border-right: 0; }
  .inbox-module:not(.depth-3):not(.depth-4):not(.sidebar-collapsed) > .module-sidebar[style*="--pane-w"] { width: var(--pane-w); }
}
@media (min-width: 761px) and (max-width: 1180px) {
  .inbox-module:not(.depth-2):not(.depth-3):not(.depth-4):not(.sidebar-collapsed) > .sidebar-split { display: block; }
  .inbox-module:not(.depth-2):not(.depth-3):not(.depth-4):not(.sidebar-collapsed) > .module-sidebar { border-right: 0; }
  .inbox-module:not(.depth-2):not(.depth-3):not(.depth-4):not(.sidebar-collapsed) > .module-sidebar[style*="--pane-w"] { width: var(--pane-w); }
}

/* -- tool window size: drag its left edge, presets, fill ------------------------------------ */
.tool-window { position: relative; container: tool / inline-size; }
.tool-resizer {
  position: absolute; z-index: 5; top: 0; bottom: 0; left: -4px; width: 9px; cursor: col-resize; touch-action: none;
}
.tool-resizer::after {
  content: ''; position: absolute; top: 0; bottom: 0; left: 3px; width: 3px; border-radius: 2px;
  background: var(--accent); opacity: 0; transition: opacity 0.12s;
}
.tool-resizer:hover::after, .tool-resizer.is-live::after, .tool-resizer:focus-visible::after { opacity: 0.85; }
.tool-resizer:focus-visible { outline: none; }
@media (pointer: coarse) {
  /* A wider grab area for fingers. */
  .tool-resizer { left: -10px; width: 20px; }
}
@media (min-width: 761px) {
  /* A chosen width is the tool's preferred width: the conversation takes what's left and
     the tool gives way first when the window narrows. */
  .inbox-panes.tool-open.has-detail > .tool-window.is-sized,
  .app-outlet.tool-open > .tool-window.is-sized { flex: 0 1 var(--tool-w); min-width: 320px; }
  .inbox-panes.tool-open.has-detail:has(> .tool-window.is-sized) .inbox-detail-pane { flex: 1 1 0; min-width: 300px; }
  .app-outlet.tool-open:has(> .tool-window.is-sized) > .module { flex: 1 1 0; min-width: 360px; }
  /* Fill the space: the conversation (or the Scheduler) steps aside; the list strip stays. */
  .inbox-panes.tool-open.has-detail > .tool-window.is-max, .app-outlet.tool-open > .tool-window.is-max { flex: 1 1 auto; min-width: 0; }
  .inbox-panes.tool-open:has(> .tool-window.is-max) .inbox-detail-pane,
  .app-outlet.tool-open:has(> .tool-window.is-max) > .module { display: none; }
  .tool-window.is-max .tool-resizer { display: none; }
}
/* With no conversation open the tool shares the room with the conversation list instead:
   a chosen width lets the list take the rest, and Fill the space hides the list. When
   the list is folded to its strip the tool already has everything, so there is nothing
   to size. */
@media (min-width: 761px) {
  .inbox-panes.tool-open:not(.has-detail):not(.list-collapsed) > .tool-window.is-sized { flex: 0 1 var(--tool-w); min-width: 320px; }
  .inbox-panes.tool-open:not(.has-detail):not(.list-collapsed):has(> .tool-window.is-sized) .inbox-list-pane { flex: 1 1 0; width: auto; min-width: 300px; }
  .inbox-panes.tool-open:not(.has-detail):has(> .tool-window.is-max) .inbox-list-pane { display: none; }
}
.inbox-panes.tool-open.list-collapsed:not(.has-detail) .tool-window :is(.tool-resizer, .tool-size-btn) { display: none; }
@media (max-width: 760px) { .tool-size-btn { display: none; } }
@media (max-width: 760px) { .tool-resizer { display: none; } }

/* The divider is the line between the panels, so they drop their own borders. */
.tool-files:has(+ .pane-split), .tool-form:has(+ .pane-split) { border-right: 0; }
.tool-levels > .pane-split + .level-col { border-left: 0; }

/* Tucked (optional, while filling): the rest slides off screen; pull tabs bring it back
   over the tool. Each panel on the left slides out by its own width plus what's left of it. */
@media (min-width: 761px) {
  .tool-tucked :is(.rail, .inbox-module > .module-sidebar, .inbox-panes > .inbox-list-pane, .tool-bar) {
    position: fixed; top: 0; bottom: 0; z-index: 70; transition: transform 0.2s var(--ease), box-shadow 0.2s;
  }
  .tool-tucked .rail { left: 0; transform: translateX(-100%); }
  .tool-tucked .inbox-module > .module-sidebar { left: var(--rail-w); transform: translateX(calc(-100% - var(--rail-w))); }
  .tool-tucked .inbox-panes > .inbox-list-pane { left: calc(var(--rail-w) + 60px); transform: translateX(calc(-100% - var(--rail-w) - 60px)); }
  .tool-tucked .tool-bar { right: 0; transform: translateX(100%); }
  .tool-peek-left :is(.rail, .inbox-module > .module-sidebar, .inbox-panes > .inbox-list-pane) { transform: none; }
  .tool-peek-left :is(.rail, .inbox-module > .module-sidebar, .inbox-panes > .inbox-list-pane) { box-shadow: 6px 0 18px rgba(0, 0, 0, 0.18); }
  .tool-peek-right .tool-bar { transform: none; box-shadow: var(--shadow-3); }
  .tool-tucked .tool-window.is-max { border-left: 0; }
}
.tuck-tab {
  position: fixed; z-index: 71; top: 50%; width: 14px; height: 64px; margin-top: -32px; padding: 0;
  display: flex; align-items: center; justify-content: center; border: 1px solid var(--border-strong);
  background: var(--surface-3); color: var(--text-2); box-shadow: var(--shadow-2); cursor: pointer;
  transition: width 0.12s, background 0.12s, opacity 0.2s;
}
.tuck-tab:hover, .tuck-tab:focus-visible { width: 20px; background: var(--accent); border-color: var(--accent); color: #fff; outline: none; }
.tuck-tab-left { left: 0; border-left: 0; border-radius: 0 8px 8px 0; }
.tuck-tab-right { right: 0; border-right: 0; border-radius: 8px 0 0 8px; }
.tool-peek-left .tuck-tab-left, .tool-peek-right .tuck-tab-right { opacity: 0; pointer-events: none; }
/* While peeking, iframes (a PDF preview) mustn't swallow the pointer, or leaving the panels
   over one would never be noticed. */
:is(.tool-peek-left, .tool-peek-right) iframe { pointer-events: none; }
@media (max-width: 760px) { .tuck-tab { display: none; } }

/* Inside the tool, layouts follow the tool's own width, not the screen's. */
@container tool (max-width: 640px) {
  .tool-split { flex-direction: column; }
  .tool-files, .tool-form { flex: none; max-height: 45%; border-right: 0; border-bottom: 1px solid var(--divider); }
  .tool-levels > .level-col { flex: 1 1 auto; width: 100%; min-width: 0; border-left: 0; }
  .tool-levels:has(> .level-project) > .level-projects,
  .tool-levels:has(> .level-task) > .level-project { display: none; }
  .tool-head .tool-sub { display: none; }
  .pane-split { display: none; }
  .tool-levels > .level-col[style] { flex: 1 1 auto; }
}
@container tool (min-width: 641px) and (max-width: 980px) {
  /* Room for two levels: the project and its step, or the list and the project. */
  .tool-levels:has(> .level-task) > .level-projects { display: none; }
  .tool-levels > .level-project, .tool-levels > .level-task { min-width: 0; }
  .tool-files:not([style*="--pane-w"]), .tool-form:not([style*="--pane-w"]) { flex-basis: 220px; }
  .tool-levels:has(> .level-task) > .level-projects + .pane-split { display: none; }
}

/* -- a project's files: Proof and Print-ready slots, then the rest ----------------------- */
.file-slots { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 8px; }
.file-slot {
  display: flex; flex-direction: column; gap: 4px; padding: 8px; border-radius: 8px; min-width: 0;
  border: 1.5px dashed var(--border-strong); background: var(--surface-2);
}
.file-slot.is-filled { border-style: solid; border-color: var(--border); background: var(--surface); }
.file-slot.is-drop, .project-files.is-drop { border-color: var(--accent); background: var(--accent-soft); }
.file-slot-head { display: flex; align-items: center; gap: 6px; color: var(--text-2); min-width: 0; }
.file-slot-title { font-size: 12.5px; font-weight: 650; color: var(--text); }
.file-slot-status { font-size: 11.5px; font-weight: 600; color: var(--text-3); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-slot-status.is-ok { color: var(--green-text); }
.file-slot-status.is-warn { color: var(--orange-text); }
.file-slot-empty { font-size: 12px; color: var(--text-3); padding: 2px 2px 4px; }
.pfile { display: flex; align-items: center; gap: 2px; min-width: 0; border-radius: 6px; }
.pfile:hover { background: var(--hover); }
.pfile-main { flex: 1; min-width: 0; display: flex; align-items: center; gap: 8px; padding: 4px 6px; color: var(--text); text-decoration: none; }
.pfile-main:hover { text-decoration: none; }
.pfile-thumb { width: 28px; height: 28px; flex: none; border-radius: 4px; background: var(--surface-3); display: flex; align-items: center; justify-content: center; overflow: hidden; color: var(--text-3); }
.pfile-thumb img { width: 100%; height: 100%; object-fit: cover; }
.pfile-name { font-size: 13px; }
.pfile-size { font-size: 11.5px; color: var(--text-3); white-space: nowrap; }
.project-files { display: flex; flex-direction: column; gap: 2px; margin-top: 6px; padding: 4px; border-radius: 8px; border: 1.5px solid transparent; }
.project-files-add { display: flex; align-items: center; gap: 6px; padding: 6px; border-radius: 6px; color: var(--text-3); font-size: 12.5px; }
.project-files-add:hover { background: var(--hover); color: var(--text); }
