/*
 * ChatHub inbox v2: the desk (rail, list, thread, customer panel) and the phone.
 * Built on the tokens in application.css. Each block names the partial it styles.
 */

/* ── Shell (layouts/inbox) ───────────────────────────────────────── */

.shell {
  height: 100dvh;
  display: grid;
  grid-template-columns: var(--rail-w) minmax(0, 1fr);
  overflow: hidden;
}
.sheet {
  margin: var(--sheet-inset) var(--sheet-inset) var(--sheet-inset) 0;
  background: var(--sheet);
  border: 1px solid var(--border);
  border-radius: var(--radius-sheet);
  min-width: 0; min-height: 0;
  display: grid;
  grid-template-columns: var(--list-w) minmax(0, 1fr) var(--panel-w);
  grid-template-rows: auto minmax(0, 1fr);
  overflow: hidden;
  position: relative;
}
.sheet > .banner { grid-column: 1 / -1; grid-row: 1; }
.sheet > .list { grid-column: 1; grid-row: 2; }
/* The thread frame holds the thread and the customer panel (or a wide pane: new mail, the digest, an
   empty desk). It is a real box, not display: contents, so its lazy loading can see it. */
#thread { grid-column: 2 / -1; grid-row: 2; display: grid; grid-template-columns: minmax(0, 1fr) var(--panel-w); grid-template-rows: minmax(0, 1fr); min-width: 0; min-height: 0; position: relative; }
#thread > .thread, #thread > .panel, #thread > .compose-pane, #thread > .desk-empty { grid-row: 1; min-height: 0; }
#thread > .thread { grid-column: 1; }
#thread > .panel { grid-column: 2; }
#thread > .thread--wide, #thread > .compose-pane, #thread > .digest, #thread > .desk-empty { grid-column: 1 / -1; }
.sheet--page { grid-template-columns: 240px minmax(0, 1fr); }

/* ── Rail (inbox/_rail) ──────────────────────────────────────────── */

.rail {
  display: flex; flex-direction: column; gap: 18px;
  padding: 14px 10px 12px 12px;
  min-height: 0; overflow-y: auto;
}
.brand { display: flex; align-items: center; gap: 9px; padding: 2px 6px; font-weight: 650; font-size: 15px; letter-spacing: -.01em; text-decoration: none; }
.brand-mark { width: 22px; height: 22px; border-radius: 7px; background: var(--ink); color: var(--frame); display: grid; place-items: center; }
.brand-mark svg { width: 13px; height: 13px; stroke: currentColor; fill: none; stroke-width: 2; }
.rail-actions { display: grid; grid-template-columns: 1fr auto; gap: 6px; }
.nav-group { display: grid; gap: 1px; }
.nav-label { font-size: var(--fs-xs); color: var(--faint); padding: 0 8px 6px; }
.nav-item {
  display: flex; align-items: center; gap: 9px; width: 100%;
  height: 32px; padding: 0 8px; border-radius: var(--radius-control);
  color: var(--ink-2); text-decoration: none; font-size: var(--fs-md);
  border: 0; background: none; text-align: left;
}
.nav-item > span:not(.nav-count):not(.nav-quiet):not(.swatch) { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-item:hover { background: color-mix(in srgb, var(--active) 60%, transparent); color: var(--ink); }
.nav-item[aria-current="page"] { background: var(--active); color: var(--ink); font-weight: 550; }
.nav-item .icon { color: var(--muted); }
.nav-count { margin-left: auto; font-size: var(--fs-xs); color: var(--muted); font-weight: 550; }
.nav-count--hot { color: var(--ink); }
.nav-quiet { margin-left: auto; font-size: var(--fs-xs); color: var(--faint); }
.rail-foot { margin-top: auto; display: grid; gap: 1px; }
.me { display: flex; align-items: center; gap: 9px; padding: 8px; margin-top: 6px; font-size: var(--fs-sm); color: var(--muted); text-decoration: none; }
.me:hover { color: var(--ink); }

.search-trigger { justify-content: flex-start; color: var(--muted); background: var(--sheet); border-color: var(--border); font-weight: 400; }

/* ── Banner (offline) ─────────────────────────────────────────────── */

.banner {
  display: flex; align-items: center; gap: 10px;
  padding: 9px var(--pad); font-size: var(--fs-sm);
  background: var(--warning-soft); color: var(--ink);
  border-bottom: 1px solid var(--border);
}
.banner .icon { color: var(--warning); }
.banner .btn { margin-left: auto; height: 28px; }

/* ── List (inbox/conversations/_list, _row) ──────────────────────── */

.list { display: flex; flex-direction: column; border-right: 1px solid var(--border); min-width: 0; min-height: 0; }
.list-head { padding: 16px var(--pad) 10px; display: grid; gap: 8px; }
.list-title-row { display: flex; align-items: center; gap: 10px; min-height: 30px; }
.list-title { margin: 0; font-size: var(--fs-xl); font-weight: 600; letter-spacing: -.015em; }
.list-scope { display: inline-flex; align-items: center; gap: 6px; font-size: var(--fs-sm); color: var(--muted); }
.list-scope .linkish { margin-left: 4px; }
.list-title-row > .btn:last-child { margin-left: auto; }
.list-summary { margin: 0; font-size: var(--fs-sm); color: var(--muted); }
.list-summary strong { color: var(--ink); font-weight: 600; }
/* The summary line and, for Kunder and Mine, the sort menu at its end. */
.list-summary-row { display: flex; align-items: center; gap: 10px; min-height: 28px; }
.list-summary-row .list-summary { flex: 1; min-width: 0; }
.list-sort { margin-left: auto; flex: none; }
.list-sort-button {
  display: inline-flex; align-items: center; gap: 5px; height: 28px; padding: 0 8px 0 6px; margin-right: -6px;
  border-radius: var(--radius-control); font-size: var(--fs-xs); font-weight: 550; color: var(--muted); cursor: pointer; white-space: nowrap;
}
.list-sort-button .icon { width: 15px; height: 15px; }
.list-sort-button:hover, .list-sort[open] > .list-sort-button { background: var(--active); color: var(--ink); }
.list-sort-button:focus-visible { outline: none; box-shadow: 0 0 0 2px var(--accent); }
.list-sort-menu { min-width: 248px; }
.list-sort-choice { align-items: flex-start; }
.list-sort-choice:focus-visible { outline: none; box-shadow: inset 0 0 0 2px var(--accent); }
.list-sort-text { display: grid; gap: 1px; flex: 1; min-width: 0; }
.list-sort-text b { font-weight: 550; }
.list-sort-text span { font-size: var(--fs-xs); color: var(--muted); }
.list-sort-check { width: 16px; height: 16px; margin-top: 1px; color: var(--accent); flex: none; }
.list-digest { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-radius: var(--radius-card); background: var(--raised); text-decoration: none; font-size: var(--fs-sm); font-weight: 550; }
.list-digest span { margin-left: auto; color: var(--muted); font-weight: 400; }

.bulkbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 10px var(--pad); background: var(--raised); border-bottom: 1px solid var(--border); border-top: 1px solid var(--border); font-size: var(--fs-sm); }
.bulkbar strong { font-weight: 600; margin-right: auto; }
.bulk-form { display: contents; }
.bulkbar .btn { height: 30px; padding: 0 10px; }
input[type="search"]::-webkit-search-cancel-button { -webkit-appearance: none; appearance: none; }
.bulkbar select { height: var(--control-h); }

.rows { margin: 0; padding: 0 0 16px; overflow-y: auto; overscroll-behavior: contain; flex: 1; min-height: 0; }
.group-rows { list-style: none; margin: 0; padding: 0; }
.group-label { position: sticky; top: 0; z-index: 3; display: flex; gap: 6px; margin: 0; padding: 10px var(--pad) 6px; background: var(--sheet); font-size: var(--fs-xs); color: var(--muted); font-weight: 550; }
.group-note { color: var(--faint); font-weight: 400; }

.row { position: relative; }
.row + .row > .row-link::before { content: ""; position: absolute; top: 0; left: var(--pad); right: var(--pad); border-top: 1px solid var(--rule); }
.row-link {
  position: relative; display: grid; grid-template-columns: minmax(0, 1fr) auto; column-gap: 10px; row-gap: 2px;
  min-height: var(--row-h); padding: 11px var(--pad);
  text-decoration: none; color: inherit;
}
.row-link:hover { background: var(--raised); }
.row-link:focus-visible { border-radius: 0; box-shadow: inset 0 0 0 2px var(--accent); }
.row:hover > .row-link::before, .row[aria-current="true"] > .row-link::before, .row[aria-current="true"] + .row > .row-link::before { border-color: transparent; }
.row[aria-current="true"] > .row-link { background: var(--active); }
.row[aria-current="true"] > .row-link::after { content: ""; position: absolute; left: 0; top: 10px; bottom: 10px; width: 2px; border-radius: 2px; background: var(--ink); }
.row-who { display: flex; align-items: center; gap: 6px; min-width: 0; font-weight: 500; }
.row-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row--unread .row-name { font-weight: 650; }
.row-unread-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); flex: none; }
.row-time { font-size: var(--fs-xs); color: var(--muted); white-space: nowrap; text-align: right; align-self: center; }
.row-time--late { color: var(--warning); font-weight: 600; }
.row-text { grid-column: 1 / -1; font-size: var(--fs-sm); color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-text b { color: var(--ink); font-weight: 500; }
.row--unread .row-text b { font-weight: 600; }
.row-meta { grid-column: 1; display: flex; align-items: center; gap: 6px; min-width: 0; font-size: var(--fs-xs); color: var(--muted); white-space: nowrap; overflow: hidden; }
.row-meta > span { flex: none; }
.row-meta > .row-where { flex: 0 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.sep { color: var(--faint); }
.row-flag { color: var(--accent); font-weight: 550; }
.row-flag--bad { color: var(--negative); }
.row-side { grid-column: 2; grid-row: 3; display: flex; align-items: center; justify-content: flex-end; gap: 6px; }
.online { color: var(--positive); font-weight: 550; }
.row--closed .row-name { font-weight: 500; }
.row-check {
  position: absolute; left: 5px; top: 50%; translate: 0 -50%; width: 18px; height: 18px; margin: 0;
  accent-color: var(--ink); opacity: 0; z-index: 2; cursor: pointer;
}
.row:hover > .row-check, .is-selecting .row-check, .row-check:checked, .row-check:focus-visible { opacity: 1; }
.is-selecting .row-link { padding-left: 30px; }
.row--selected > .row-link { background: var(--accent-soft); }
.row--selected > .row-link:hover { background: color-mix(in srgb, var(--accent-soft) 70%, var(--active)); }

.skeleton { display: block; height: 12px; border-radius: 4px; background: var(--active); }
.skeleton-row { display: grid; grid-template-columns: 1fr 32px; gap: 8px 10px; padding: 14px var(--pad); min-height: var(--row-h); }
.skeleton-row .skeleton:nth-child(3) { grid-column: 1 / -1; }

.empty { padding: 48px var(--pad-lg); display: grid; gap: 6px; justify-items: start; }
.empty-title { margin: 0; font-size: var(--fs-lg); font-weight: 600; }
.empty-body { margin: 0; color: var(--muted); max-width: 40ch; }
.empty .btn { margin-top: 10px; }
.empty--center { margin: auto; justify-items: center; text-align: center; }
.list-error { margin: 0 var(--pad) 8px; padding: 12px; border-radius: var(--radius-card); background: var(--warning-soft); display: grid; gap: 4px; font-size: var(--fs-sm); }
.list-error .btn { justify-self: start; margin-top: 6px; }

/* ── Thread (inbox/conversations/_thread) ────────────────────────── */

.thread { display: flex; flex-direction: column; min-width: 0; position: relative; }
.thread-head { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 2px 10px; align-items: center; padding: 14px var(--pad-lg) 12px; border-bottom: 1px solid var(--border); }
.thread-head .back { display: none; }
.thread-title { grid-column: 2; margin: 0; font-size: var(--fs-xl); font-weight: 600; letter-spacing: -.015em; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.thread-title small { font-size: var(--fs-md); font-weight: 400; color: var(--muted); letter-spacing: 0; margin-left: 6px; }
.thread-actions { grid-column: 3; grid-row: 1; display: flex; gap: 6px; align-items: center; }
.thread-subject { grid-column: 2 / -1; margin: 0; font-size: var(--fs-lg); font-weight: 500; color: var(--ink); overflow-wrap: anywhere; }
.thread-meta { grid-column: 2 / -1; margin: 0; display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-size: var(--fs-sm); color: var(--muted); }
.assignee { display: inline-flex; align-items: center; gap: 6px; }
.pill-closed { font-size: var(--fs-xs); color: var(--muted); font-weight: 550; }

/* Menus (owner, Mere, message menu): native <details> */
.menu-wrap { position: relative; }
.menu-wrap > summary { list-style: none; }
.menu-wrap > summary::-webkit-details-marker { display: none; }
.menu {
  position: absolute; z-index: 20; min-width: 200px;
  background: var(--sheet); border: 1px solid var(--border); border-radius: var(--radius-card); box-shadow: var(--float); padding: 6px;
}
.menu--right { right: 0; top: calc(100% + 6px); }
.menu--up { right: 0; bottom: calc(100% + 4px); }
.menu-label { font-size: var(--fs-xs); color: var(--muted); padding: 6px 10px 4px; }
.menu-item, .menu .button_to button {
  display: flex; align-items: center; gap: 8px; width: 100%; text-align: left;
  padding: 8px 10px; border: 0; border-radius: var(--radius-control); background: none;
  font-size: var(--fs-sm); text-decoration: none; color: var(--ink);
}
.menu-item:hover, .menu-item[aria-selected="true"], .menu .button_to button:hover { background: var(--active); }
.menu-item--danger, .menu .button_to .menu-item--danger { color: var(--negative); }
.menu-item[aria-checked="true"]::after { content: "✓"; margin-left: auto; color: var(--muted); }
.menu hr { border: 0; border-top: 1px solid var(--rule); margin: 4px 0; }

.log { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 18px var(--pad-lg) 24px; }
.log-inner { max-width: 720px; margin: 0 auto; display: flex; flex-direction: column; gap: 10px; }
.messages { display: contents; }
.day { align-self: center; font-size: var(--fs-xs); color: var(--muted); font-weight: 550; padding: 10px 0 2px; }

.msg { position: relative; display: flex; flex-direction: column; max-width: min(80%, 560px); gap: 3px; }
.msg--in { align-self: flex-start; }
.msg--out { align-self: flex-end; align-items: flex-end; }
.bubble { padding: 9px 13px; border-radius: var(--radius-bubble); font-size: var(--fs-msg); white-space: pre-wrap; overflow-wrap: anywhere; }
.bubble a { color: inherit; text-underline-offset: 3px; }
.msg--in .bubble { background: var(--bubble-theirs); border-bottom-left-radius: 5px; }
.msg--out .bubble { background: var(--bubble-mine); color: var(--on-mine); border-bottom-right-radius: 5px; }
.msg-meta { font-size: var(--fs-xs); color: var(--muted); padding: 0 4px; display: flex; flex-wrap: wrap; align-items: center; gap: 0 6px; }
.msg-meta .bad { color: var(--negative); font-weight: 600; }
.msg--pending .bubble { opacity: .7; }
.msg--failed .bubble { box-shadow: 0 0 0 1.5px var(--negative); }
.receipt { align-self: flex-end; margin-top: -6px; font-size: var(--fs-xs); color: var(--muted); padding: 0 4px; }
.receipt:empty { display: none; }

/* The message menu: hover on the desk, always reachable on touch. */
.msg-menu { position: absolute; top: 2px; z-index: 4; }
.msg--out .msg-menu, .note .msg-menu, .mail .msg-menu { left: -34px; }
.msg-menu > summary { width: 28px; height: 28px; display: grid; place-items: center; border-radius: var(--radius-control); color: var(--muted); cursor: pointer; opacity: 0; }
.msg:hover .msg-menu > summary, .note:hover .msg-menu > summary, .mail:hover .msg-menu > summary, .msg-menu[open] > summary, .msg-menu > summary:focus-visible { opacity: 1; }
.msg-menu > summary:hover { background: var(--raised); }
.msg-menu .menu { left: 0; top: 30px; min-width: 140px; }
.mail .msg-menu { left: auto; right: 8px; top: 8px; }
@media (pointer: coarse) { .msg-menu > summary { opacity: .6; } }
/* A visitor's line: the menu (admins: »Slet«) sits to its right and opens over the bubble. */
.msg--in .msg-menu { left: auto; right: -34px; }
.msg--in .msg-menu .menu { left: auto; right: 0; }

/* »Redigeret« on a corrected reply or note: quiet, the time on hover and on a tap. */
.edited { display: inline-flex; gap: 4px; align-items: center; padding: 0; border: 0; background: none; font: inherit; color: inherit; cursor: default; border-radius: 4px; }
.edited-at { display: none; }
.edited[aria-expanded="true"] .edited-at { display: inline; }
.note-label .edited { font-weight: 500; color: var(--note-ink); opacity: .8; }
.note-label .edited::before { content: "·"; margin: 0 5px 0 4px; }

/* »Ret«: the text becomes an editor in place. */
.msg.is-editing { width: min(80%, 560px); }
.msg.is-editing .msg-menu, .note.is-editing .msg-menu { display: none; }
.msg-edit { display: flex; flex-direction: column; gap: 6px; width: 100%; }
.msg-edit-input {
  width: 100%; min-height: 44px; max-height: 320px; resize: none; padding: 9px 13px;
  border: 1px solid var(--border); border-radius: var(--radius-bubble); background: var(--sheet); color: var(--ink);
  font: inherit; font-size: var(--fs-msg); line-height: 1.45;
}
.msg-edit-input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 22%, transparent); }
.note .msg-edit-input { background: color-mix(in srgb, var(--sheet) 70%, var(--note)); border-color: var(--note-edge); }
.msg-edit-warn { display: flex; gap: 6px; align-items: flex-start; margin: 0; padding: 7px 10px; border-radius: var(--radius-control); background: var(--warning-soft); color: var(--ink); font-size: var(--fs-xs); }
.msg-edit-warn .icon { width: 14px; height: 14px; flex: none; margin-top: 1px; color: var(--warning); }
.msg-edit-error { margin: 0; font-size: var(--fs-xs); color: var(--negative); font-weight: 600; }
.msg-edit-bar { display: flex; align-items: center; justify-content: flex-end; gap: 6px; }
.msg-edit-keys { margin-right: auto; font-size: var(--fs-xs); color: var(--muted); }
@media (pointer: coarse) { .msg-edit-keys { visibility: hidden; } }

.note { position: relative; align-self: flex-end; width: min(100%, 600px); padding: 9px 13px; border-radius: var(--radius-card); background: var(--note); border: 1px solid var(--note-edge); font-size: var(--fs-msg); overflow-wrap: anywhere; }
.note-label { display: block; font-size: var(--fs-xs); font-weight: 600; color: var(--note-ink); margin-bottom: 2px; }
.note-body { white-space: pre-wrap; }

.event { display: flex; gap: 10px; align-items: baseline; padding: 8px 12px; border-radius: var(--radius-card); background: var(--raised); font-size: var(--fs-sm); color: var(--ink-2); }
.event .swatch { align-self: center; }
.event-text { min-width: 0; overflow-wrap: anywhere; }
.event b { font-weight: 600; color: var(--ink); }
.event time { margin-left: auto; color: var(--muted); font-size: var(--fs-xs); white-space: nowrap; }
.event--bad b { color: var(--negative); }

/* Mail card (inbox/messages/_mail) */
.mail { position: relative; align-self: stretch; border: 1px solid var(--border); border-radius: var(--radius-card); background: var(--sheet); overflow: visible; }
.mail--out { border-color: var(--control); }
.mail-head { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 0 10px; align-items: center; padding: 10px 44px 10px 14px; background: var(--raised); border-radius: var(--radius-card) var(--radius-card) 0 0; }
.mail-from { font-weight: 600; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mail-from span { font-weight: 400; color: var(--muted); }
.mail-head time { font-size: var(--fs-xs); color: var(--muted); white-space: nowrap; }
.mail-to { grid-column: 2 / -1; font-size: var(--fs-xs); color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mail-body { padding: 12px 14px 4px; font-size: var(--fs-msg); white-space: pre-wrap; overflow-wrap: anywhere; }
.mail-body:last-child { padding-bottom: 14px; }
/* »Vis citeret tekst«: the part of the mail the trimmer cut off, folded under the text. */
.mail-quoted { padding: 0 14px 10px; }
.mail-quoted:last-child { padding-bottom: 14px; }
.mail-quoted > summary { display: inline-flex; list-style: none; cursor: pointer; color: var(--accent); font-size: var(--fs-sm); font-weight: 550; min-height: 32px; align-items: center; }
.mail-quoted > summary::-webkit-details-marker { display: none; }
.mail-quoted > summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
.mail-quoted[open] .mail-quoted-show, .mail-quoted:not([open]) .mail-quoted-hide { display: none; }
.mail-quoted-body { margin-top: 4px; padding: 2px 0 2px 12px; border-left: 2px solid var(--border); color: var(--ink-2); font-size: var(--fs-sm); white-space: pre-wrap; overflow-wrap: anywhere; max-height: 480px; overflow: auto; }
.mail-quoted-more { margin-top: 6px; font-size: var(--fs-xs); color: var(--muted); }
.mail-foot { display: flex; flex-wrap: wrap; gap: 6px 14px; align-items: center; padding: 6px 14px 12px; }
.files { display: flex; flex-wrap: wrap; gap: 6px; padding: 6px 14px 8px; }
.file { display: inline-flex; align-items: center; gap: 8px; height: 36px; padding: 0 12px 0 10px; border: 1px solid var(--border); border-radius: var(--radius-control); background: var(--sheet); text-decoration: none; font-size: var(--fs-sm); max-width: 100%; }
.file:hover { background: var(--raised); }
.file .icon { color: var(--muted); }
.file-name { font-weight: 550; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-size { color: var(--muted); font-size: var(--fs-xs); white-space: nowrap; }
.file--uploading { color: var(--muted); }
.file--failed { border-color: var(--negative); color: var(--negative-ink); }
.file-remove { border: 0; background: none; color: var(--muted); padding: 0 0 0 4px; font-size: 16px; line-height: 1; }
.delivery { display: flex; align-items: center; gap: 6px; font-size: var(--fs-xs); color: var(--muted); padding: 0 14px 12px; }
.delivery .icon { width: 14px; height: 14px; }
.delivery-undo { display: inline-flex; align-items: center; gap: 6px; }
.delivery .linkish { font-size: var(--fs-xs); }
.delivery--failed { display: grid; grid-template-columns: auto 1fr; gap: 4px 10px; margin: 0 14px 14px; padding: 10px 12px; border-radius: var(--radius-control); background: var(--negative-soft); color: var(--ink); font-size: var(--fs-sm); }
.delivery--failed .icon { color: var(--negative); margin-top: 2px; }
.delivery--failed strong { color: var(--negative-ink); }
.delivery--failed .actions { grid-column: 2; display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }

/* Claude's draft (inbox/messages/_draft) */
.draft { align-self: stretch; border: 1px solid color-mix(in srgb, var(--accent) 45%, var(--border)); border-radius: var(--radius-card); background: var(--sheet); overflow: hidden; scroll-margin-top: 16px; }
.draft-head { display: flex; align-items: center; gap: 8px; padding: 9px 14px; background: var(--accent-soft); font-size: var(--fs-sm); color: var(--accent); font-weight: 600; }
.draft-head time { margin-left: auto; font-weight: 400; color: var(--muted); font-size: var(--fs-xs); }
.draft-body { padding: 12px 14px; font-size: var(--fs-msg); white-space: pre-wrap; overflow-wrap: anywhere; }
.draft-actions { display: flex; gap: 6px; padding: 0 14px 14px; flex-wrap: wrap; }
.draft-actions > :last-child { margin-left: auto; }
.draft .files { padding: 0 14px 10px; }

.typing { align-self: flex-start; display: flex; align-items: center; gap: 6px; font-size: var(--fs-xs); color: var(--muted); }
.typing-dots { display: inline-flex; gap: 3px; }
.typing-dots i { width: 5px; height: 5px; border-radius: 50%; background: var(--faint); }
@media (prefers-reduced-motion: no-preference) {
  .typing-dots i { animation: blink 1.2s infinite both; }
  .typing-dots i:nth-child(2) { animation-delay: .2s; }
  .typing-dots i:nth-child(3) { animation-delay: .4s; }
  @keyframes blink { 0%, 80%, 100% { opacity: .3; } 40% { opacity: 1; } }
}

/* ── Composer (inbox/conversations/_composer) ────────────────────── */

.composer { border-top: 1px solid var(--border); padding: 10px var(--pad-lg) 14px; background: var(--sheet); }
.composer-inner { position: relative; max-width: 720px; margin: 0 auto; display: grid; gap: 8px; }
.composer-top { display: flex; align-items: center; gap: 10px; min-width: 0; }
.mode { display: inline-flex; flex: none; padding: 2px; background: var(--raised); border-radius: var(--radius-control); border: 1px solid var(--border); }
.mode button { height: 26px; padding: 0 10px; border: 0; border-radius: 6px; background: none; font-size: var(--fs-sm); font-weight: 550; color: var(--muted); }
.mode button[aria-pressed="true"] { background: var(--sheet); color: var(--ink); box-shadow: 0 0 0 1px var(--border); }
.mode button[data-mode="note"][aria-pressed="true"] { background: var(--note); color: var(--note-ink); box-shadow: 0 0 0 1px var(--note-edge); }
.composer-to { font-size: var(--fs-sm); color: var(--muted); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.composer-to b { color: var(--ink); font-weight: 550; }
.box { border: 1px solid var(--field-edge); border-radius: var(--radius-card); background: var(--sheet); }
.box:focus-within { border-color: var(--ink); }
.composer--note .box { background: var(--note); border-color: var(--note-edge); }
.box-fields { display: grid; border-bottom: 1px solid var(--rule); }
.field-line { display: grid; grid-template-columns: 52px minmax(0, 1fr) auto; align-items: center; min-height: 36px; padding: 0 12px; font-size: var(--fs-sm); gap: 6px; }
.field-line + .field-line { border-top: 1px solid var(--rule); }
.field-line label { color: var(--muted); }
.field-line input, .field-line select, .field-line output { border: 0; background: transparent; min-width: 0; width: 100%; height: 34px; padding: 0; font-size: var(--fs-sm); }
.field-line output { display: flex; align-items: center; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.field-line input:focus, .field-line select:focus { outline: none; box-shadow: none; }
.box textarea { display: block; width: 100%; min-height: 76px; max-height: 280px; resize: none; border: 0; background: transparent; padding: 10px 12px; font-size: var(--fs-msg); line-height: 1.45; }
.box textarea:focus { outline: none; box-shadow: none; }
.box .files { padding: 0 12px 6px; }
.box-tools { display: flex; align-items: center; gap: 4px; padding: 6px 6px 6px 8px; }
.box-tools .spacer { flex: 1; }
.box-tools .hint { font-size: var(--fs-xs); color: var(--muted); margin-right: 6px; white-space: nowrap; }
/* An empty composer does not compete with »Godkend og send«: its button turns primary once there is text. */
.composer:not(.composer--open) [data-composer-target="send"] { background: var(--sheet); color: var(--ink-2); border-color: var(--control); }
.composer-error { font-size: var(--fs-sm); color: var(--negative-ink); background: var(--negative-soft); padding: 8px 12px; border-radius: var(--radius-control); }
.taken { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-radius: var(--radius-control); background: var(--warning-soft); font-size: var(--fs-sm); }
.taken .btn { margin-left: auto; height: 28px; }
.spambar { background: var(--raised); }

/* Saved replies menu (/) */
.snippet-menu { left: 0; right: 0; bottom: calc(100% + 6px); max-height: 320px; overflow-y: auto; }
.menu-filter { display: flex; align-items: center; gap: 8px; padding: 4px 8px 8px; border-bottom: 1px solid var(--rule); margin-bottom: 4px; font-size: var(--fs-sm); color: var(--muted); }
.menu-filter input { flex: 1; border: 0; background: none; height: 28px; font-size: var(--fs-sm); }
.menu-filter input:focus { outline: none; box-shadow: none; }
.snippet-menu .menu-item { display: grid; gap: 1px; }
.snippet-menu .menu-item b { font-weight: 600; font-size: var(--fs-sm); }
.snippet-menu .menu-item span { color: var(--muted); font-size: var(--fs-xs); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.menu-empty { padding: 10px; font-size: var(--fs-sm); color: var(--muted); }

/* ── Customer panel (inbox/conversations/_customer) ──────────────── */

.panel { border-left: 1px solid var(--border); overflow-y: auto; padding: 18px var(--pad) 24px; display: grid; align-content: start; gap: 22px; background: var(--sheet); }
.panel-close { display: none; }
.person { display: grid; gap: 4px; }
.person-name { margin: 0; font-size: var(--fs-lg); font-weight: 600; overflow-wrap: anywhere; }
.person-line { margin: 0; font-size: var(--fs-sm); color: var(--muted); overflow-wrap: anywhere; }
.person-line a { color: var(--ink); text-decoration-color: var(--control); text-underline-offset: 3px; }
.person-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.panel-section { display: grid; gap: 8px; }
.panel-title { margin: 0; font-size: var(--fs-sm); font-weight: 600; display: flex; align-items: baseline; gap: 6px; }
.panel-title > span { color: var(--muted); font-weight: 400; }
.panel-title a { margin-left: auto; }
.kv { list-style: none; margin: 0; padding: 0; display: grid; }
.kv li { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 10px; padding: 8px 0; border-top: 1px solid var(--rule); font-size: var(--fs-sm); }
.kv li:first-child { border-top: 0; padding-top: 0; }
.kv .k { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kv a.k { text-underline-offset: 3px; text-decoration-color: var(--control); }
.kv .v { text-align: right; white-space: nowrap; min-width: 0; overflow: hidden; text-overflow: ellipsis; max-width: 170px; }
.kv .sub { grid-column: 1 / -1; color: var(--muted); font-size: var(--fs-xs); }
.panel-empty { margin: 0; font-size: var(--fs-sm); color: var(--muted); }
.tech summary { cursor: pointer; font-size: var(--fs-sm); color: var(--muted); list-style: none; }
.tech summary::after { content: " ▾"; font-size: 11px; }
.tech[open] summary::after { content: " ▴"; }
.tech summary::-webkit-details-marker { display: none; }
.tech dl { margin: 8px 0 0; display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; font-size: var(--fs-xs); color: var(--muted); }
.tech dd { margin: 0; font-family: var(--font-mono); color: var(--ink-2); overflow-wrap: anywhere; }
.panel-loading { display: grid; gap: 10px; }

/* ── New mail (inbox/mails/new) ──────────────────────────────────── */

.compose-pane { display: flex; flex-direction: column; min-width: 0; }
.compose-body { flex: 1; overflow-y: auto; padding: 18px var(--pad-lg); }
.compose-body .box { max-width: 760px; }
.compose-body .box textarea { min-height: 260px; max-height: none; }
.compose-body .composer-error { max-width: 760px; margin-bottom: 10px; }

/* ── System digest (inbox/conversations/_digest) ─────────────────── */

.digest .log-inner { gap: 22px; }
.digest .kv a.k { font-weight: 550; }

/* ── Overlays: search palette, keyboard map, phone sheets ───────── */

dialog.overlay { padding: 0; border: 0; background: transparent; max-width: none; max-height: none; width: 100%; height: 100%; color: var(--ink); }
dialog.overlay:focus-visible { box-shadow: none; }
dialog.overlay::backdrop { background: rgb(10 11 12 / .32); }
.overlay-body { min-height: 100%; display: grid; place-items: start center; padding: 10vh 16px 16px; }
.palette { width: min(640px, 100%); background: var(--sheet); border: 1px solid var(--border); border-radius: var(--radius-sheet); box-shadow: var(--float); overflow: hidden; }
.palette-input { display: flex; align-items: center; gap: 10px; padding: 0 8px 0 16px; border-bottom: 1px solid var(--border); }
.palette-input .icon { color: var(--muted); }
.palette-input input { flex: 1; height: 52px; border: 0; background: none; font-size: var(--fs-lg); min-width: 0; }
.palette-input input:focus { outline: none; box-shadow: none; }
.palette-scope { display: flex; gap: 6px; padding: 10px 16px; border-bottom: 1px solid var(--rule); overflow-x: auto; }
.chip { display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 10px; border-radius: 999px; border: 1px solid var(--border); background: var(--sheet); font-size: var(--fs-sm); white-space: nowrap; }
.chip[aria-pressed="true"] { background: var(--ink); color: var(--sheet); border-color: var(--ink); }
.results { list-style: none; margin: 0; padding: 6px; max-height: 50vh; overflow-y: auto; }
.result { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 2px 10px; align-items: center; padding: 9px 10px; border-radius: var(--radius-control); text-decoration: none; }
.result[aria-selected="true"], .result:hover { background: var(--active); }
.result .k { font-weight: 550; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.result .sub { grid-column: 2 / -1; font-size: var(--fs-xs); color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.result mark { background: color-mix(in srgb, var(--accent) 22%, transparent); color: inherit; border-radius: 2px; }
.result time { font-size: var(--fs-xs); color: var(--muted); white-space: nowrap; }
.palette .empty { padding: 28px 20px; }
.keys { width: min(560px, 100%); background: var(--sheet); border: 1px solid var(--border); border-radius: var(--radius-sheet); box-shadow: var(--float); padding: 20px 22px; }
.keys-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.keys h2 { margin: 0; font-size: var(--fs-lg); }
.keys dl { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: 8px 16px; font-size: var(--fs-sm); }
.keys dt { display: flex; gap: 4px; justify-content: flex-end; align-items: center; }
.keys dd { margin: 0; color: var(--ink-2); }
.sheet-menu { width: min(420px, 100%); background: var(--sheet); border: 1px solid var(--border); border-radius: var(--radius-sheet); box-shadow: var(--float); padding: 8px; display: grid; gap: 1px; }
.sheet-menu h2 { margin: 6px 8px 8px; font-size: var(--fs-lg); }
.sheet-menu .nav-item { height: 48px; font-size: 16px; }

/* Dialog: the whole original mail */
.original { width: min(900px, 100%); height: min(86vh, 900px); display: flex; flex-direction: column; background: var(--sheet); border: 1px solid var(--border); border-radius: var(--radius-sheet); box-shadow: var(--float); overflow: hidden; }
.original-head { display: flex; align-items: center; gap: 10px; padding: 10px 10px 10px 18px; border-bottom: 1px solid var(--border); }
.original-head h2 { font-size: var(--fs-lg); margin-right: auto; }
.original iframe { flex: 1; width: 100%; border: 0; background: #fff; }

/* Toasts */
.toasts { position: fixed; z-index: 60; left: 50%; bottom: 24px; translate: -50% 0; display: grid; gap: 8px; justify-items: center; pointer-events: none; width: max-content; max-width: calc(100vw - 32px); }
.toast { pointer-events: auto; background: var(--primary); color: var(--on-primary); padding: 10px 14px; border-radius: var(--radius-control); font-size: var(--fs-sm); box-shadow: var(--float); display: flex; gap: 14px; align-items: center; }
.toast--alert { background: var(--negative); color: #fff; }
.toast button, .toast .button_to button { background: none; border: 0; color: inherit; font-weight: 600; text-decoration: underline; text-underline-offset: 3px; padding: 0; }

/* ── Phone bars (hidden on the desk) ─────────────────────────────── */

.tabbar, .phone-only, .site-filter { display: none; }

/* ── Desk without room for the customer panel ────────────────────── */

@media (max-width: 1279px) {
  .sheet { grid-template-columns: var(--list-w) minmax(0, 1fr); }
  #thread { grid-template-columns: minmax(0, 1fr); }
  #thread > .panel { position: absolute; z-index: 15; top: 0; right: 0; bottom: 0; width: var(--panel-w); box-shadow: var(--float); }
  #thread > .panel:not(.is-open) { display: none; }
  .panel-close { display: inline-flex; justify-self: end; }
}
@media (min-width: 1280px) { .panel-toggle { display: none; } }

/* ── Phone: one region at a time ─────────────────────────────────── */

@media (max-width: 760px) {
  :root { --pad: 16px; --pad-lg: 16px; --fs-md: 15px; --fs-sm: 14px; --row-h: 80px; }
  body { background: var(--sheet); }
  .shell { height: auto; min-height: 100dvh; grid-template-columns: 1fr; grid-template-rows: minmax(0, 1fr) auto; overflow: visible; }
  .rail { display: none; }
  .sheet { margin: 0; border: 0; border-radius: 0; grid-template-columns: 1fr; grid-template-rows: auto minmax(0, 1fr); overflow: visible; }
  .sheet > .list, #thread { grid-column: 1; }
  #thread > * { grid-column: 1 / -1 !important; }
  .has-thread .list, .has-compose .list { display: none; }
  body:not(.has-thread):not(.has-compose) #thread { display: none; }
  /* The list scrolls the page, so back from a thread returns to the same place (Turbo restores it). */
  .list { border-right: 0; }
  .rows { overflow: visible; padding-bottom: calc(80px + var(--safe-bottom)); }
  .list-head { padding: calc(10px + var(--safe-top)) var(--pad) 8px; position: sticky; top: 0; z-index: 4; background: var(--sheet); }
  .group-label { top: calc(48px + var(--safe-top)); }
  .desk-only { display: none !important; }
  .phone-only { display: inline-flex; }
  .list-title-row .phone-only:last-child { margin-left: auto; }
  .list-scope { display: none; }
  .list-sort-button { height: 32px; }
  .site-filter { display: inline-flex; align-items: center; line-height: 1; height: 32px; padding: 0 10px; gap: 6px; border-radius: 999px; border: 1px solid var(--border); background: var(--sheet); font-size: 14px; font-weight: 550; text-decoration: none; }

  .tabbar {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
    display: grid; grid-template-columns: repeat(5, 1fr);
    padding: 4px 4px calc(4px + var(--safe-bottom)); background: var(--sheet); border-top: 1px solid var(--border);
  }
  .has-thread .tabbar, .has-compose .tabbar { display: none; }
  .tab { position: relative; display: grid; justify-items: center; gap: 2px; padding: 6px 0 4px; min-height: 50px; border-radius: var(--radius-control); text-decoration: none; font-size: 11.5px; color: var(--muted); font-weight: 550; border: 0; background: none; }
  .tab .icon { width: 22px; height: 22px; stroke-width: 1.6; }
  .tab[aria-current="page"] { color: var(--ink); }
  .tab-count { position: absolute; top: 2px; left: calc(50% + 6px); min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--ink); color: var(--sheet); font-size: 11px; font-weight: 650; display: grid; place-items: center; }
  .tab-count:empty { display: none; }
  .row-check { display: none; }
  .is-selecting .row-link { padding-left: var(--pad); }

  /* Thread: a full screen with its own head; the composer sits at the bottom. */
  .has-thread .shell, .has-compose .shell { height: 100dvh; overflow: hidden; }
  .has-thread .sheet, .has-compose .sheet { overflow: hidden; }
  .thread-head { grid-template-columns: auto minmax(0, 1fr) auto; padding: calc(8px + var(--safe-top)) 8px 10px 4px; gap: 0 6px; }
  .thread-head .back { display: grid; place-items: center; width: var(--tap); height: var(--tap); grid-row: 1 / span 3; align-self: start; border: 0; background: none; color: var(--ink); }
  .thread-head .back .icon { width: 22px; height: 22px; }
  .thread-title { font-size: 17px; padding-top: 3px; }
  .thread-title small { display: none; }
  .thread-subject { font-size: 15px; }
  .thread-meta { font-size: 13px; flex-wrap: nowrap; white-space: nowrap; overflow: hidden; }
  .thread-meta > .thread-where { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
  .thread-actions .btn { height: 36px; }
  .thread-actions .btn--icon { width: 40px; }
  .log { padding: 12px 12px 16px; }
  .msg { max-width: 88%; }
  .msg.is-editing { width: 88%; }
  .msg-edit-input { font-size: 16px; }
  .msg-edit-keys { visibility: hidden; }
  .msg--out .msg-menu, .note .msg-menu { left: auto; right: 2px; top: -30px; }
  .mail-head { padding: 10px 44px 10px 12px; }
  .mail-body, .draft-body { padding: 12px; font-size: 16px; }
  .bubble, .note { font-size: 16px; }
  .draft-actions .btn { height: 40px; }
  .composer { padding: 8px 10px calc(8px + var(--safe-bottom)); }
  .box textarea { min-height: 44px; font-size: 16px; }
  /* At rest the phone composer is one line and its tools; the mode, the recipient and the From
     line open when you start writing. */
  .thread .composer:not(:focus-within):not(.composer--note):not(.composer--open) .composer-top,
  .thread .composer:not(:focus-within):not(.composer--open) .box-fields { display: none; }
  .thread .composer:not(:focus-within):not(.composer--open) .box textarea { min-height: 44px; height: 44px !important; }
  .thread .composer:focus-within .box textarea { min-height: 96px; }
  .box-tools .hint, .box-tools .kbd { display: none; }
  .composer .btn { height: var(--tap); }
  .field-line { grid-template-columns: 44px minmax(0, 1fr) auto; }
  .field-line input, .field-line select { font-size: 16px; }

  #thread > .panel { position: fixed; inset: 0; z-index: 30; width: auto; border: 0; box-shadow: none; padding: calc(12px + var(--safe-top)) 16px calc(24px + var(--safe-bottom)); }
  #thread > .panel:not(.is-open) { display: none; }
  .panel-close { display: inline-flex; justify-self: start; }
  .compose-body { padding: 12px; }
  .compose-body .box textarea { min-height: 220px; }
  .overlay-body { padding: 0; place-items: stretch; }
  .palette { border-radius: 0; border: 0; min-height: 100dvh; width: 100%; padding-top: var(--safe-top); }
  .palette-input input { font-size: 16px; }
  .results { max-height: none; }
  .original { height: 100dvh; border-radius: 0; border: 0; padding-top: var(--safe-top); }
  .overlay-body--sheet { place-items: end stretch; }
  .overlay-body--sheet .sheet-menu { width: 100%; border-radius: var(--radius-sheet) var(--radius-sheet) 0 0; padding: 8px 8px calc(16px + var(--safe-bottom)); }
  .keys { border-radius: 0; min-height: 100dvh; }
  .banner { padding: calc(8px + var(--safe-top)) 12px 8px; }
  .toasts { bottom: calc(76px + var(--safe-bottom)); }
  .has-thread .toasts, .has-compose .toasts { bottom: auto; top: calc(10px + var(--safe-top)); }
  .empty { padding: 32px var(--pad); }
}

@media (prefers-reduced-motion: no-preference) {
  .row-link, .nav-item, .menu-item, .result, .tab { transition: background-color .12s ease, color .12s ease; }
}

/* Loading frames: Turbo marks a frame busy while it fetches. */
turbo-frame[busy] .log-inner, turbo-frame[busy] .thread-head { opacity: .55; }
@media (prefers-reduced-motion: no-preference) {
  turbo-frame[busy] .log-inner { transition: opacity .2s ease .15s; }
}
/* A lane or site change: the old list dims while the new one is fetched (Turbo marks html busy). */
html[aria-busy="true"] .list .rows { opacity: .55; }
@media (prefers-reduced-motion: no-preference) {
  html[aria-busy="true"] .list .rows { transition: opacity .2s ease .15s; }
}
