/* contacts.css -- owned by the contacts room builder. Use tokens only; reuse base.css components. */

.ct-room { display: grid; grid-template-columns: 264px minmax(0, 1fr); min-height: 100%; }

/* ------------------------------------------------------------ rail */
.ct-rail { display: flex; flex-direction: column; min-height: 0; background: var(--bg-pane); border-right: 1px solid var(--line); padding: var(--rail-pad); position: sticky; top: 0; align-self: start; max-height: 100%; height: 100%; }
.ct-find { display: flex; align-items: center; gap: 6px; height: var(--control-h); padding: 0 8px; border-radius: var(--r-control); background: var(--bg-app); box-shadow: inset 0 0 0 1px var(--line-subtle); color: var(--text-placeholder); margin: 0 0 10px; }
.ct-find:focus-within { box-shadow: inset 0 0 0 1px var(--accent), 0 0 0 3px var(--accent-soft); }
.ct-findinput { flex: 1 1 auto; min-width: 0; border: 0; background: transparent; color: var(--text); font: inherit; outline: none; }
.ct-findinput::placeholder { color: var(--text-placeholder); }
/* round 7 (S18.1): the label sits where the magnifier did, so the row keeps its height */
.ct-findlbl { flex: none; }
.ct-find kbd { font-size: var(--fs-micro); }
.ct-scope { padding: 0 6px 8px; display: flex; gap: 8px; align-items: baseline; }
.ct-groups { flex: 1 1 auto; overflow: auto; min-height: 0; }
.ct-group + .ct-group { margin-top: 2px; }
.ct-ghead { display: flex; align-items: center; gap: 2px; height: 30px; }
/* round 7 (S16.12): 24 px, the compact-control minimum */
.ct-gtoggle { display: inline-grid; place-items: center; width: 24px; height: 24px; border: 0; border-radius: 4px; background: none; color: var(--text-secondary); }
.ct-gtoggle:hover { background: var(--bg-hover); color: var(--text); }
.ct-gtoggle .ico { transition: transform var(--t-press) var(--ease); }
.ct-group.open .ct-gtoggle .ico { transform: rotate(90deg); }
.ct-glabel { flex: 1 1 auto; font-size: var(--fs-meta); font-weight: 600; color: var(--text); padding: 4px 4px; border-radius: 4px; }
.ct-glabel:hover { background: var(--bg-hover); text-decoration: none; }
.ct-glist { margin: 0 0 6px; }
.ct-prow { display: grid; grid-template-columns: minmax(0, 1fr) auto 18px; gap: 8px; align-items: center; height: 30px; padding: 0 8px 0 24px; border-radius: var(--r-control); color: var(--text); font-size: var(--fs-meta); }
.ct-prow:hover { background: var(--bg-hover); text-decoration: none; }
.ct-prow.active { background: var(--accent-soft); color: var(--accent-text); }
.ct-pname { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ct-porg { font-size: var(--fs-caption); letter-spacing: 0.02em; }
.ct-pn { text-align: right; font-size: var(--fs-caption); }
.ct-duphit { padding: 8px 8px 0; }
.ct-duprow { flex: none; display: flex; align-items: center; justify-content: space-between; height: 34px; margin-top: 8px; padding: 0 10px; border-radius: var(--r-control); color: var(--text); font-size: var(--fs-meta); font-weight: 500; background: var(--bg-hover); }
.ct-duprow:hover { text-decoration: none; background: var(--line-subtle); }
.ct-duprow.active { background: var(--accent-soft); color: var(--accent-text); }
.ct-empty { padding: 8px; }

/* ------------------------------------------------------------ main */
.ct-main { min-width: 0; padding: var(--s3) var(--gutter, 24px) 48px; }
.ct-dir, .ct-dedupe, .ct-person { max-width: 1040px; }
.ct-dirhead { display: flex; align-items: baseline; gap: 12px; margin: 20px 0 8px; flex-wrap: wrap; }
.ct-dirhead:first-child { margin-top: 0; }
.ct-dirnote { margin-left: auto; }
.ct-tbl td { height: 36px; }
.ct-tname { color: var(--text); font-weight: 500; }
.ct-torg { color: var(--text-secondary); max-width: 280px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ct-peekcell { text-align: right; width: 64px; }
.ct-peek { height: 26px; opacity: 0; }
.ct-tbl tr:hover .ct-peek, .ct-peek:focus-visible { opacity: 1; }
.ct-tbl tbody tr:hover td { background: var(--bg-pane); }

/* quick add */
.ct-add { padding: 10px 14px 6px; background: var(--bg-pane); border-radius: var(--r-card); display: grid; gap: 8px; }
.ct-addrow { display: grid; grid-template-columns: 150px minmax(120px, 1fr) minmax(140px, 1fr) minmax(120px, 1fr) auto; gap: 8px; align-items: end; }
/* round 7 (S18.1, S18.2): label over field, so the name stays visible while the field is filled in */
.ct-addfield { display: grid; gap: 2px; min-width: 0; }
.ct-addrow .input { min-width: 0; }
.ct-exists { min-height: 18px; font-size: var(--fs-meta); color: var(--text-secondary); display: flex; flex-wrap: wrap; gap: 4px 6px; align-items: baseline; }
.ct-exists[data-hit="hard"] { color: var(--urgency-1); }
.ct-exists[data-hit] a { font-weight: 500; }

/* ------------------------------------------------------------ person header */
.ct-head { display: grid; gap: 8px; padding-bottom: 16px; }
.ct-name { font-size: var(--fs-h1); line-height: var(--lh-h1); font-weight: 600; letter-spacing: -0.015em; }
.ct-chips { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.ct-org { color: var(--text-secondary); font-size: var(--fs-meta); margin-left: 2px; }
.ct-reach { display: flex; flex-wrap: wrap; gap: 4px 16px; font-size: var(--fs-meta); }
.ct-email { color: var(--text-secondary); overflow-wrap: anywhere; }
.ct-actions { display: flex; flex-wrap: wrap; gap: 6px; }
/* round 7 (S18.6): the reason line takes its own row under the reach buttons */
.ct-why { flex: 1 0 100%; text-align: left; }
/* on the person page the reach buttons are right-aligned in their own grid column, so the reason line
   under them is right-aligned too -- left-aligned it started a third of the screen away from the
   controls it is about. The narrow layout puts the buttons back on the left and the line with them. */
.ct-head-page .ct-why { text-align: right; }
.ct-facts { display: grid; grid-template-columns: 88px 1fr; gap: 4px 12px; font-size: var(--fs-meta); margin-top: 4px; }
.ct-facts dt { color: var(--text-secondary); }
.ct-head-page { grid-template-columns: minmax(0, 1fr) auto; column-gap: 24px; align-items: start; }
.ct-head-page .ct-chips, .ct-head-page .ct-reach, .ct-head-page .ct-facts { grid-column: 1; }
.ct-head-page .ct-actions { grid-column: 2; grid-row: 1 / span 2; justify-content: flex-end; }
.ct-head-page .ct-facts { grid-template-columns: 88px 1fr; }

/* ------------------------------------------------------------ tiles */
.ct-tiles { display: grid; grid-template-columns: repeat(var(--ct-cols, 3), minmax(0, 1fr)); gap: 2px; }
.ct-tile { background: var(--bg-pane); border-radius: var(--r-control); padding: 12px 14px 12px; display: grid; gap: 3px; align-content: start; min-width: 0; }
.ct-tile-wide { grid-column: 1 / -1; }
.ct-tile-label { font-size: var(--fs-caption); font-weight: 500; color: var(--text-secondary); display: flex; align-items: center; gap: 6px; }
.ct-small { white-space: nowrap; font-size: var(--fs-micro); font-weight: 500; color: var(--text-secondary); padding: 0 5px; border-radius: 4px; box-shadow: inset 0 0 0 1px var(--line); cursor: help; }
.ct-tile-value { font-size: 20px; line-height: 28px; font-weight: 600; letter-spacing: -0.01em; font-variant-numeric: tabular-nums; }
.ct-unit { font-size: var(--fs-meta); font-weight: 400; color: var(--text-secondary); letter-spacing: 0; }
.ct-tile-note { font-size: var(--fs-meta); line-height: var(--lh-meta); color: var(--text); }
.ct-tile-n { font-size: var(--fs-caption); line-height: var(--lh-caption); color: var(--text-secondary); display: flex; flex-wrap: wrap; gap: 0 8px; }
.ct-base:empty { display: none; }
.ct-base { color: var(--text-placeholder); }
.ct-tile-link { justify-self: start; margin-top: 2px; font-size: var(--fs-caption); }
.ct-refresh { margin: 8px 2px 0; font-size: var(--fs-caption); }

/* ------------------------------------------------------------ tabs */
.ct-tabs { display: flex; gap: 2px; margin-top: 20px; border-bottom: 1px solid var(--line-subtle); }
.ct-tab { position: relative; height: 34px; padding: 0 10px; border: 0; background: none; color: var(--text-secondary); font: inherit; font-size: var(--fs-meta); font-weight: 500; display: inline-flex; align-items: center; gap: 4px; }
a.ct-tab:hover, .ct-tab:hover { color: var(--text); text-decoration: none; }
.ct-tab.active { color: var(--text); }
.ct-tab.active::after { content: ""; position: absolute; left: 10px; right: 10px; bottom: -1px; height: 2px; background: var(--text); border-radius: 2px 2px 0 0; }
.ct-tabbody { padding-top: 4px; }

.ct-matters > li + li { border-top: 1px solid var(--line-subtle); }
.ct-mrow { display: grid; grid-template-columns: minmax(140px, 1.3fr) minmax(120px, 1fr) 100px 90px auto; gap: 12px; align-items: center; min-height: 38px; padding: 0 8px; margin: 0 -8px; border-radius: var(--r-control); color: var(--text); font-size: var(--fs-meta); }
.ct-mrow:hover { background: var(--bg-hover); text-decoration: none; }
.ct-mname { font-weight: 500; font-size: var(--fs-body); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ct-mref { color: var(--text-secondary); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ct-mstage { color: var(--text-secondary); }
.ct-mgo { display: inline-flex; align-items: center; gap: 4px; justify-self: end; opacity: 0.7; }
.ct-mrow:hover .ct-mgo, .ct-mrow:focus-visible .ct-mgo { opacity: 1; color: var(--accent-text); }

.ct-timeline > li { display: grid; grid-template-columns: 44px 18px minmax(0, 1fr) auto; gap: 10px; align-items: baseline; padding: 8px 0; font-size: var(--fs-meta); }
.ct-timeline > li + li { border-top: 1px solid var(--line-subtle); }
.ct-tdate { color: var(--text-secondary); font-size: 12px; }
.ct-tsrc { color: var(--text-secondary); align-self: center; display: inline-flex; }
.ct-tmeta { white-space: nowrap; }
.ct-tmeta a { color: var(--text-secondary); }
.ct-next { font-size: var(--fs-caption); font-weight: 600; color: var(--text-secondary); }
.ct-timeline .is-next .ct-twhat { color: var(--text); }

.ct-noteform { display: grid; grid-template-columns: 1fr auto; gap: 8px; align-items: end; padding: 12px 0; }
.ct-notearea { height: auto; min-height: 56px; padding: 8px 10px; resize: vertical; font: inherit; line-height: var(--lh-body); }
.ct-notelist > li { padding: 10px 0; border-top: 1px solid var(--line-subtle); display: grid; gap: 2px; }
.ct-notetext { white-space: pre-wrap; max-width: 72ch; }

/* ------------------------------------------------------------ dedupe */
.ct-dedupe-intro { max-width: 72ch; margin-bottom: 8px; }
.ct-tier { margin-top: 20px; display: grid; gap: 10px; }
.ct-tierhead { display: flex; align-items: baseline; gap: 6px; flex-wrap: wrap; padding-bottom: 6px; border-bottom: 1px solid var(--line-subtle); }
.ct-tiername { font-weight: 600; }
.ct-tierrule { margin-left: 8px; }
.ct-tier[data-tier="possible"] .pcard { opacity: 0.92; }

/* ------------------------------------------------------------ side panel */
@media (min-width: 721px) { .layer-panel { width: 400px; } }
.ct-panel .ct-head { padding-bottom: 14px; }
.ct-panel .ct-tiles { grid-template-columns: 1fr; }
.ct-panel .ct-tile { padding: 8px 12px; grid-template-columns: minmax(0, 1fr) auto; column-gap: 12px; row-gap: 2px; }
.ct-panel .ct-tile > * { grid-column: 1 / -1; }
.ct-panel .ct-tile > .ct-tile-label { grid-column: 1; grid-row: 1; align-self: center; }
.ct-panel .ct-tile > .ct-tile-value { grid-column: 2; grid-row: 1; font-size: 16px; line-height: 22px; text-align: right; }
.ct-panel .ct-tabs { margin-top: 16px; }
.ct-panel .ct-mrow { grid-template-columns: minmax(0, 1fr) auto; gap: 2px 10px; padding: 6px 8px; }
.ct-panel .ct-mname { grid-column: 1; }
.ct-panel .ct-mref { grid-column: 1; grid-row: 2; }
.ct-panel .ct-mtouch { grid-column: 2; grid-row: 1; justify-self: end; }
.ct-panel .ct-mgo { grid-column: 2; grid-row: 2; }
.ct-full { padding-top: 12px; }

/* ------------------------------------------------------------ narrow */
@media (max-width: 1100px) {
  .ct-tiles { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
  .ct-addrow { grid-template-columns: 1fr 1fr; }
  .ct-mrow { grid-template-columns: minmax(0, 1fr) auto; }
  .ct-mstage, .ct-mtouch { display: none; }
}
@media (max-width: 720px) {
  .ct-room { grid-template-columns: minmax(0, 1fr); }
  .ct-main, .ct-dir { min-width: 0; }
  .ct-rail { position: static; height: auto; border-right: 0; border-bottom: 1px solid var(--line); }
  .ct-groups { max-height: 280px; }
  .ct-main { padding: 16px; }
  .ct-head-page { grid-template-columns: 1fr; }
  .ct-head-page .ct-actions { grid-column: 1; grid-row: auto; justify-content: flex-start; }
  .ct-head-page .ct-why { text-align: left; }
  .ct-addrow { grid-template-columns: 1fr; }
  .ct-torg, .ct-tbl th:nth-child(3), .ct-tbl td:nth-child(3) { display: none; }
  .ct-timeline > li { grid-template-columns: 44px 18px minmax(0, 1fr); }
  .ct-tmeta { grid-column: 3; white-space: normal; }
}

/* ------------------------------------------------------------ round 2: Ask link, backlinks (3.4) */
.ct-namerow { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 4px 12px; }
.ct-ask { white-space: nowrap; }
.ct-blink { font-size: var(--fs-meta); }
.ct-blink-none { margin: 0; }
.ct-blinks { margin: 6px 0 0; display: grid; gap: 0; }
.ct-blinks > li + li { border-top: 1px solid var(--line-subtle); }
.ct-blrow { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: 10px; align-items: baseline; padding: 6px 8px; margin: 0 -8px; border-radius: var(--r-control); color: var(--text); font-size: var(--fs-meta); }
.ct-blrow:hover { background: var(--bg-hover); text-decoration: none; }
.ct-bltitle { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.ct-head-page .ct-blink-slot { grid-column: 1; }
.ct-head-page .ct-blinks { max-width: 560px; }

/* ------------------------------------------------------------ round 3: referral strip, lead contacts */
.ct-referral { display: grid; gap: 6px; padding: 12px 14px; margin-bottom: 16px; background: var(--bg-pane); border-radius: var(--r-card); }
.ct-ref-open { max-width: 72ch; }
.ct-ref-facts { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px 20px; font-size: var(--fs-meta); }
.ct-ref-facts dt { color: var(--text-secondary); font-size: var(--fs-caption); }
.ct-ref-facts dd { margin: 0; min-width: 0; overflow-wrap: break-word; }
.ct-leaddir .ct-dirhead { margin-top: 0; }
@media (max-width: 1100px) { .ct-ref-facts { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 720px) { .ct-ref-facts { grid-template-columns: minmax(0, 1fr); } }
