/* Officer hub: contacts section (contacts-list.js, contacts-detail.js, contacts-dialogs.js).
   Tokens and shared pieces come from app.css and hub.css. Everything here starts with ct-. */

.hub-section-contacts { --ct-cols: minmax(0, 1fr) 150px 170px 150px; }

/* ---------- icons ---------- */

.ct-i {
  flex: none; width: 16px; height: 16px;
  fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
}
.ct-i-out { width: 12px; height: 12px; stroke-width: 2.4; opacity: 0.7; }
.ct-add .ct-i { width: 18px; height: 18px; stroke-width: 2.4; }

/* ---------- list: counts per status ---------- */

.ct-summary {
  display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 8px;
  margin: 0 0 14px;
}
.ct-tile {
  --c: var(--muted);
  position: relative; overflow: hidden;
  display: grid; align-content: start; gap: 3px;
  min-height: 70px; padding: 11px 12px 13px;
  text-align: left; font: inherit; color: var(--text); cursor: pointer;
  border-radius: 12px; border: 1px solid var(--line); background: var(--surface);
  transition: border-color 0.15s, background 0.15s;
}
.ct-tile:hover { border-color: var(--line-strong); }
.ct-tile-count { font-size: 23px; font-weight: 800; line-height: 1.1; font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }
.ct-tile-label {
  display: flex; align-items: center; gap: 6px; min-width: 0;
  font-size: 12.5px; font-weight: 650; color: var(--muted); line-height: 1.25;
}
.ct-tile-label::before { content: ""; flex: none; width: 7px; height: 7px; border-radius: 50%; background: var(--c); }
.ct-tile.is-all .ct-tile-label::before { display: none; }
.ct-tile-bar {
  position: absolute; left: 0; bottom: 0; height: 3px; width: var(--share, 0%);
  background: var(--c); opacity: 0.75; border-radius: 0 3px 0 0;
}
.ct-tile[aria-pressed="true"] {
  border-color: var(--c); box-shadow: inset 0 0 0 1px var(--c);
  background: color-mix(in srgb, var(--c) 9%, var(--surface));
}
.ct-tile[aria-pressed="true"] .ct-tile-label { color: var(--text); }
.ct-tile.is-all { --c: var(--accent); }
.ct-tile.contact-new { --c: var(--muted); }
.ct-tile.contact-reached, .ct-tile.contact-talking { --c: var(--accent); }
.ct-tile.contact-meeting { --c: var(--warn); }
.ct-tile.contact-partner { --c: var(--ok); }
.ct-tile.contact-no { --c: var(--muted); }
.ct-tile.contact-no .ct-tile-label::before { opacity: 0.5; }

/* ---------- list: search and filters ---------- */

.ct-toolbar {
  display: grid; grid-template-columns: minmax(240px, 1.35fr) minmax(0, 3fr); gap: 12px 14px; align-items: end;
  padding: 14px 16px; margin: 0 0 12px;
  border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface);
}
.ct-toolbar label, .ct-notes-fields label {
  font-size: 13px; font-weight: 650; color: var(--muted); margin-bottom: 5px;
}
.ct-search { display: grid; grid-template-columns: minmax(0, 1fr); column-gap: 8px; min-width: 0; }
.ct-search > label { grid-column: 1 / -1; }
.ct-search-box { position: relative; min-width: 0; }
.ct-search-box .ct-i { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); width: 17px; height: 17px; color: var(--muted); pointer-events: none; }
.hub input[type="search"].ct-search-input { padding-left: 38px; }
.ct-search-input::placeholder { color: var(--muted); opacity: 0.8; }
.ct-search-input::-webkit-search-cancel-button { cursor: pointer; }
.ct-filter-toggle { display: none; }
.ct-filters { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; min-width: 0; }
.ct-filters .hub-field { margin: 0; min-width: 0; }
.ct-filters select { text-overflow: ellipsis; }

.ct-count-row { display: flex; align-items: center; justify-content: space-between; gap: 8px 16px; flex-wrap: wrap; min-height: 34px; margin: 0 0 10px; padding: 0 4px; }
.ct-count { margin: 0; color: var(--muted); font-size: 14px; font-weight: 600; }
.ct-clear { min-height: 34px; font-size: 14px; }

/* ---------- list: rows ---------- */

.ct-list-head {
  display: grid; grid-template-columns: var(--ct-cols); gap: 18px;
  padding: 0 20px 8px;
  font-size: 11.5px; font-weight: 750; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted);
}
.ct-list {
  list-style: none; margin: 0; padding: 0;
  border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow);
  overflow: hidden;
}
.ct-row {
  position: relative;
  display: grid; grid-template-columns: var(--ct-cols); gap: 18px; align-items: start;
  padding: 15px 20px;
  border-top: 1px solid var(--line);
  transition: background 0.12s;
}
.ct-row:first-child { border-top: 0; }
.ct-row:hover { background: var(--surface-2); }
.ct-row-main { min-width: 0; }
.ct-row-title { display: flex; align-items: baseline; flex-wrap: wrap; gap: 4px 10px; margin: 0; }
.ct-name { color: var(--text); font-weight: 750; font-size: 16px; text-decoration: none; overflow-wrap: anywhere; }
/* The whole row opens the contact. */
.ct-name::after { content: ""; position: absolute; inset: 0; }
.ct-name:focus-visible { outline: none; }
.ct-row:has(.ct-name:focus-visible) { outline: 2px solid var(--accent); outline-offset: -2px; background: var(--surface-2); }
.ct-row:hover .ct-name { color: var(--accent); }
.ct-kind {
  font-size: 11.5px; font-weight: 700; color: var(--accent);
  padding: 1px 8px; border-radius: 999px; border: 1px solid color-mix(in srgb, var(--accent) 45%, transparent);
  white-space: nowrap;
}
.ct-sub { margin: 2px 0 0; color: var(--muted); font-size: 14px; overflow-wrap: anywhere; }
.ct-topic { margin: 3px 0 0; font-size: 14px; overflow-wrap: anywhere; }
.ct-preview {
  margin: 7px 0 0; font-size: 13.5px; color: var(--muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  padding-left: 10px; border-left: 2px solid var(--line-strong);
}
.ct-mark { color: var(--text); background: color-mix(in srgb, var(--accent) 28%, transparent); border-radius: 3px; padding: 0 2px; }
.ct-preview.is-empty { border-left-color: transparent; padding-left: 0; font-style: italic; opacity: 0.7; }
.ct-row-status, .ct-row-handler, .ct-row-updated { padding-top: 1px; min-width: 0; font-size: 14px; }
/* The handler fills its column (no wider), so a long first name ends in "..." instead of running
   into the Updated column. */
.ct-handler { display: flex; align-items: center; gap: 8px; min-width: 0; max-width: 100%; }
.ct-handler-name { min-width: 0; font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ct-nobody, .ct-never { color: var(--muted); font-size: 13.5px; }
.ct-updated-text { display: grid; }
.ct-updated-text time { font-weight: 600; }
.ct-updated-by { color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ct-row.is-muted .ct-name { color: var(--muted); }

.ct-credit { margin: 18px 4px 0; }
.ct-credit a { display: inline-flex; align-items: center; gap: 3px; font-weight: 600; }

/* ---------- detail: top ---------- */

.ct-topbar { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: -4px 0 14px; }
.ct-back {
  display: inline-flex; align-items: center; gap: 7px; min-height: 40px; padding: 0 12px 0 8px; margin-left: -8px;
  border-radius: 10px; color: var(--muted); font-weight: 650; font-size: 14px; text-decoration: none;
}
.ct-back:hover { color: var(--text); background: var(--surface-2); }
.ct-pager { display: flex; align-items: center; gap: 6px; }
.ct-pager-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 4px;
  min-height: 38px; min-width: 38px; padding: 0 12px;
  border-radius: 10px; border: 1px solid var(--line-strong); background: var(--surface);
  color: var(--text); font-weight: 650; font-size: 14px; text-decoration: none;
}
.ct-pager-btn.ct-prev { padding-left: 8px; }
.ct-pager-btn.ct-next { padding-right: 8px; }
.ct-pager-btn:hover { border-color: var(--accent); }
.ct-pager-btn.is-off { opacity: 0.35; }
.ct-pager-pos { padding: 0 6px; color: var(--muted); font-size: 13px; font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }

.ct-head { margin: 0 0 22px; }
.ct-head-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px 20px; }
.ct-head-text { min-width: 0; }
.ct-head .kicker { margin-bottom: 4px; }
.ct-head-name { margin: 0 0 4px; font-size: clamp(26px, 3.6vw, 34px); letter-spacing: -0.02em; overflow-wrap: anywhere; }
.ct-head-name:focus { outline: none; }
.ct-head-sub { margin: 0; color: var(--muted); font-size: 16px; }
.ct-head-topic { margin: 6px 0 0; font-size: 15px; }
.ct-head-actions { display: flex; flex-wrap: wrap; gap: 8px; flex: none; }
.ct-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.ct-chip {
  display: inline-flex; align-items: center; gap: 7px; max-width: 100%; min-width: 0;
  min-height: 36px; padding: 0 13px;
  border-radius: 999px; border: 1px solid var(--line-strong); background: var(--surface);
  color: var(--text); font-size: 14px; font-weight: 600; text-decoration: none;
}
.ct-chip > .ct-i:first-child { color: var(--accent); }
.ct-chip .ct-link-text { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
a.ct-chip:hover { border-color: var(--accent); }
.ct-chip.is-plain { color: var(--muted); }
.ct-caveat { margin: 14px 0 0; max-width: 760px; }
.ct-head-made { margin: 12px 0 0; }

/* ---------- detail: layout ---------- */

.ct-layout {
  display: grid; grid-template-columns: minmax(0, 1fr) 340px;
  grid-template-areas: "notes side" "extras side";
  gap: 20px 24px; align-items: start;
}
.ct-notes { grid-area: notes; min-width: 0; }
.ct-side { grid-area: side; display: grid; gap: 16px; min-width: 0; }
.ct-extras { grid-area: extras; display: grid; gap: 16px; min-width: 0; }
.ct-card-title { display: flex; align-items: center; gap: 8px; margin: 0; font-size: 18px; }
.ct-card-title .ct-i { width: 18px; height: 18px; color: var(--muted); }
.ct-card-head { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 6px 10px; margin-bottom: 12px; }
.ct-card-count { color: var(--muted); font-size: 13px; font-weight: 600; }

/* ---------- detail: the notes editor ---------- */

.card.ct-notes { padding: 20px 22px 0; }
.ct-notes.is-dirty { border-color: color-mix(in srgb, var(--warn) 45%, var(--line)); }
.ct-notes-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.ct-notes-last { margin: 3px 0 0; font-size: 13.5px; }
.ct-notes-last strong { color: var(--text); font-weight: 650; }
.ct-template { flex: none; }
.ct-notes-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-bottom: 14px; }
.ct-notes-fields .hub-field { margin: 0; min-width: 0; }

.hub textarea.ct-notes-text {
  display: block; width: 100%; min-height: 380px;
  padding: 16px 20px; resize: none; overflow-y: hidden;
  font-size: 16px; line-height: 1.7; letter-spacing: 0.003em;
  border-radius: 12px; background: var(--bg);
  tab-size: 4;
}
.hub textarea.ct-notes-text::placeholder { color: var(--muted); opacity: 0.85; }
.hub textarea.ct-notes-text[readonly] { opacity: 0.7; }
.ct-notes-help { margin: 8px 2px 0; font-size: 13px; }

.ct-notices:empty { display: none; }
.ct-notice {
  display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px 12px;
  margin: 0 0 12px; padding: 10px 12px 10px 14px;
  border-radius: 10px; border: 1px solid var(--line); border-left: 3px solid var(--accent);
  background: var(--surface-2); font-size: 14px;
}
.ct-notice.is-warn { border-left-color: var(--warn); }
.ct-notice p { margin: 0; flex: 1 1 280px; }
.ct-notice-actions { display: flex; flex-wrap: wrap; gap: 8px; }

.ct-savebar {
  position: sticky; bottom: 0; z-index: 3;
  display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px 16px;
  margin: 14px -22px 0; padding: 12px 22px;
  border-top: 1px solid var(--line); background: var(--surface);
  border-radius: 0 0 var(--radius) var(--radius);
}
.ct-savebar-text { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 16px; min-width: 0; }
.ct-save-state { display: inline-flex; align-items: center; gap: 8px; margin: 0; font-size: 14px; font-weight: 650; }
.ct-save-state::before { content: ""; flex: none; width: 8px; height: 8px; border-radius: 50%; background: var(--line-strong); }
.ct-save-state.is-saved::before { background: var(--ok); }
.ct-save-state.is-dirty::before { background: var(--warn); }
.ct-save-state.is-busy::before { background: var(--accent); }
.ct-save-state.is-error { color: var(--danger); }
.ct-save-state.is-error::before { background: var(--danger); }
.ct-count-chars { color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }
.ct-count-chars.is-near { color: var(--warn); font-weight: 650; }
.ct-count-chars.is-over { color: var(--danger); font-weight: 700; }
.ct-savebar-actions { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.ct-save { min-width: 108px; }
/* Off (nothing to save, or saving) but still focusable, so the keyboard stays on it after a save.
   Looks like app.css's .btn:disabled. */
.ct-save[aria-disabled="true"] { opacity: 0.55; cursor: default; }
.ct-save[aria-disabled="true"]:hover { filter: none; }
.ct-kbd {
  margin-left: 4px; padding: 1px 6px; border-radius: 6px;
  font: 650 11.5px/1.4 ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;
  background: color-mix(in srgb, currentColor 14%, transparent);
}
.ct-discard { font-size: 14px; }

/* ---------- detail: history ---------- */

.card.ct-history { padding: 18px 18px 16px; }
.ct-versions {
  list-style: none; margin: 0 -8px; padding: 0;
  display: grid; gap: 2px;
}
.ct-version-open, .ct-version.is-current {
  display: grid; gap: 3px; width: 100%;
  padding: 10px; border-radius: 10px; border: 1px solid transparent;
  text-align: left; font: inherit; color: var(--text); background: none;
}
.ct-version-open { cursor: pointer; }
.ct-version-open:hover { background: var(--surface-2); border-color: var(--line); }
.ct-version.is-current { background: var(--surface-2); border-color: var(--line); margin-bottom: 4px; }
.ct-version-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.ct-version-when { font-weight: 700; font-size: 14px; }
.ct-version.is-current .ct-version-when { color: var(--accent); }
.ct-version-meta { display: flex; flex-wrap: wrap; gap: 2px 10px; font-size: 13px; color: var(--muted); }
.ct-version-meta > span + span::before { content: ""; display: inline-block; width: 3px; height: 3px; margin: 0 8px 3px 0; border-radius: 50%; background: currentColor; opacity: 0.7; vertical-align: middle; }
.ct-version-meta > span + span { margin-left: -2px; }
.ct-version-date { font-size: 12px; color: var(--muted); opacity: 0.85; }
.ct-version .hub-badge { font-size: 11px; padding: 1px 7px; }
.ct-history-hint { margin: 10px 0 0; font-size: 13px; }
.ct-history-more { margin: 6px 0 0 -6px; min-height: 36px; font-size: 14px; }

/* ---------- detail: office hours and research ---------- */

.card.ct-extra { padding: 18px 22px 20px; }
.ct-tags { display: flex; flex-wrap: wrap; gap: 6px; }
.ct-tag {
  --c: var(--muted);
  padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 700; white-space: nowrap;
  color: var(--c); border: 1px solid var(--line-strong);
  border-color: color-mix(in srgb, var(--c) 40%, transparent);
  background: color-mix(in srgb, var(--c) 10%, transparent);
}
.ct-tag.tone-ok { --c: var(--ok); }
.ct-tag.tone-warn { --c: var(--warn); }
.ct-sessions { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.ct-sessions li { padding: 9px 12px; border-radius: 10px; background: var(--surface-2); font-size: 14.5px; }
.ct-extra-note { margin: 12px 0 0; color: var(--muted); font-size: 14px; }
.ct-research-topic { margin: 0 0 12px; font-weight: 650; }
.ct-works { list-style: none; margin: 0; padding: 0; display: grid; gap: 14px; }
.ct-work { padding-left: 12px; border-left: 2px solid var(--line-strong); min-width: 0; }
.ct-work-title { font-weight: 650; overflow-wrap: anywhere; }
a.ct-work-title { text-underline-offset: 3px; }
a.ct-work-title .ct-i-out { display: inline-block; margin-left: 4px; vertical-align: -1px; }
.ct-work-meta { margin: 2px 0 0; color: var(--muted); font-size: 12.5px; font-weight: 650; }
.ct-work-desc { margin: 4px 0 0; font-size: 14px; }
.ct-extras .ct-credit { margin: 2px 4px 0; }

/* ---------- dialogs ---------- */

.ct-form { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 14px; }
.ct-form-lede, .ct-form-name, .ct-form-link { grid-column: 1 / -1; }
.ct-form-lede { margin: 0 0 14px; }
.ct-form .hub-field { min-width: 0; }
.ct-form input[aria-invalid="true"] { border-color: var(--danger); }

.ct-compare-lede { margin: 0 0 10px; }
.ct-compare-diffs { margin: 0 0 12px; padding-left: 20px; font-size: 14px; }
.ct-compare-diffs li + li { margin-top: 2px; }
.ct-compare-panes { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.ct-compare-pane { display: flex; flex-direction: column; min-width: 0; }
.ct-compare-head { margin: 0 0 2px; font-size: 15px; }
.ct-compare-meta { margin: 0 0 8px; color: var(--muted); font-size: 13px; }
.ct-compare-text, .ct-version-text {
  flex: 1 1 auto; overflow: auto; overflow-wrap: anywhere; white-space: pre-wrap;
  padding: 12px 14px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg);
  font-size: 14.5px; line-height: 1.6;
}
.ct-compare-text { max-height: 46vh; min-height: 140px; }
.ct-version-text { max-height: 56vh; min-height: 160px; }
.ct-compare-text:focus-visible, .ct-version-text:focus-visible { outline-offset: 0; }
.ct-compare-empty { color: var(--muted); font-style: italic; }
.ct-compare-text { padding: 10px 0; }
.ct-line { min-height: 1.6em; padding: 0 14px; border-left: 3px solid transparent; }
.ct-line.is-changed { border-left-color: var(--warn); background: color-mix(in srgb, var(--warn) 13%, transparent); }
.ct-compare-text.is-mine .ct-line.is-changed { border-left-color: var(--accent); background: color-mix(in srgb, var(--accent) 13%, transparent); }
.ct-compare-key { font-weight: 700; }
.ct-compare-key.is-theirs { color: var(--warn); }
.ct-compare-key.is-mine { color: var(--accent); }
.ct-compare-text .ct-compare-empty { padding: 0 14px; }
.ct-vdialog-meta { margin: 0 0 10px; color: var(--muted); font-size: 14px; }
.ct-vdialog-hint { margin: 10px 0 0; }
.ct-vdialog-warn { margin: 12px 0 0; }
.ct-version-text .hub-loading { padding: 12px 0; }

/* ---------- screens between phone and desktop ---------- */

@media (max-width: 1080px) {
  .hub-section-contacts { --ct-cols: minmax(0, 1fr) 140px 150px 130px; }
  .ct-toolbar { grid-template-columns: minmax(0, 1fr); }
  .ct-layout { grid-template-columns: minmax(0, 1fr) 290px; }
}

@media (max-width: 899px) {
  .ct-summary { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .ct-layout { grid-template-columns: minmax(0, 1fr); grid-template-areas: "notes" "side" "extras"; }
}

/* ---------- phones ---------- */

@media (max-width: 759px) {
  /* One row of chips that scrolls sideways inside itself (the page never does). */
  .ct-summary {
    display: flex; flex-wrap: nowrap; gap: 6px; margin: 0 -16px 12px; padding: 2px 16px;
    overflow-x: auto; overscroll-behavior-x: contain; scrollbar-width: none; scroll-padding: 0 16px;
  }
  .ct-summary::-webkit-scrollbar { display: none; }
  .ct-tile {
    display: inline-flex; align-items: center; gap: 7px; flex: none; white-space: nowrap;
    min-height: 44px; padding: 0 12px; border-radius: 999px;
  }
  .ct-tile-count { order: 2; font-size: 14px; font-weight: 800; }
  .ct-tile-label { font-size: 13.5px; color: var(--text); }
  .ct-tile-bar { display: none; }

  .ct-toolbar { padding: 12px; gap: 10px; }
  .ct-search { grid-template-columns: minmax(0, 1fr) auto; }
  .ct-filter-toggle { display: inline-flex; min-height: 46px; padding: 0 14px; }
  .ct-filter-toggle.is-on { border-color: var(--accent); color: var(--accent); }
  .ct-filters { display: none; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .ct-filters.is-open { display: grid; }

  .ct-list-head { display: none; }
  /* Only the name shares its line with the status; the lines under it use the full width. */
  .ct-row { grid-template-columns: minmax(0, 1fr) auto; gap: 0 12px; padding: 14px 16px; }
  .ct-row-main { display: contents; }
  .ct-row-title { grid-column: 1; grid-row: 1; }
  .ct-row-status { grid-column: 2; grid-row: 1; }
  .ct-sub, .ct-topic, .ct-preview { grid-column: 1 / -1; }
  .ct-row-handler { grid-column: 1; align-self: center; margin-top: 10px; }
  .ct-row-updated { grid-column: 2; align-self: center; text-align: right; margin-top: 10px; }
  /* "2 min ago by Kimberly" on one line. The column is only as wide as its text, so a long name
     would push the handler aside: the cell stops at 45% of the screen and the name ends in "...". */
  .ct-row-updated { max-width: 45vw; }
  .ct-updated-text { display: flex; justify-content: flex-end; gap: 0.3em; min-width: 0; font-size: 13px; color: var(--muted); }
  .ct-updated-text time { flex: none; font-weight: 500; }
  .ct-updated-by { min-width: 0; font-size: 13px; }
  .ct-preview, .ct-sub { white-space: normal; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; overflow: hidden; }
  .ct-topic { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .ct-clear { min-height: 44px; }

  .ct-topbar { margin: -6px 0 10px; }
  .ct-back { min-height: 44px; }
  .ct-pager-btn { min-height: 44px; min-width: 44px; padding: 0; }
  .ct-pager-btn.ct-prev, .ct-pager-btn.ct-next { padding: 0; }
  .ct-pager-label { display: none; }
  .ct-head-top { flex-direction: column; }
  .ct-head-actions .btn { min-height: 44px; }
  .ct-chip { min-height: 44px; }
  .card.ct-notes { padding: 16px 16px 0; }
  .ct-savebar { flex-wrap: nowrap; margin: 12px -16px 0; padding: 10px 16px calc(10px + env(safe-area-inset-bottom)); }
  .ct-savebar-text { flex-direction: column; align-items: flex-start; gap: 2px; flex: 1 1 auto; }
  .ct-savebar-actions { flex: none; gap: 4px; }
  .ct-count-chars { font-size: 12.5px; }
  .ct-template { min-height: 44px; }
  .hub textarea.ct-notes-text { min-height: 300px; padding: 14px 14px; }
  .ct-save { min-height: 46px; }
  .ct-discard { min-height: 44px; }
  .ct-history-more { min-height: 44px; }
  .card.ct-history { padding: 16px 14px 14px; }
  .card.ct-extra { padding: 16px; }
  .ct-notice-actions .btn { min-height: 44px; }
  .ct-form { grid-template-columns: minmax(0, 1fr); }
  .ct-compare-panes { grid-template-columns: minmax(0, 1fr); }
  .ct-compare-text { max-height: 30vh; min-height: 96px; }
}

@media (max-width: 479px) {
  .ct-notes-fields { grid-template-columns: minmax(0, 1fr); gap: 10px; }
  /* The save bar keeps "Unsaved changes" on one line next to Discard and Save; a longer error
     wraps instead. */
  .ct-save-state:not(.is-error) { white-space: nowrap; }
  .ct-save-state.is-error { font-size: 13.5px; }
  .ct-save { min-width: 88px; }
  .ct-kbd { display: none; }
  .ct-count-unit {
    position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; border: 0;
    overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap;
  }
}

@media (hover: none) {
  .ct-kbd { display: none; }
}
