/* ===================================================================
   iCloud Tools - Contacts group (VCF viewer, VCF to CSV, CSV to VCF,
   duplicate cleaner, merge and split). Builds on icloud-tools.css and
   backlink-maker.css; scoped under .icc so nothing leaks.
   =================================================================== */

.icc { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.icc > * { min-width: 0; }
.icc [hidden] { display: none !important; }
.icc .icc-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; }
.icc-result { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.icc-result > * { min-width: 0; }
.icc-start { display: flex; flex-direction: column; gap: 14px; }
.icc-msg:empty { display: none; }
.icc-notices { display: flex; flex-direction: column; gap: 10px; }
.icc-notices:empty { display: none; }
.icc-hint { font-weight: 400; color: var(--bm-ink-3); }
.icc-subhead { margin: 6px 0 0; font-size: 1.02rem; color: var(--bm-ink); }
.icc-pre { white-space: pre-wrap; overflow-wrap: anywhere; }

/* Paste box (CSV to VCF) */
.icc-paste { padding: 14px; border: 1px solid var(--bm-line); border-radius: 14px; background: var(--bm-bg); }
.icc-paste textarea { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: .85rem; resize: vertical; }
.icc-paste .ic-toolbar { margin-top: 10px; }

/* How-to (server rendered in each partial) */
.icc-howto { border: 1px solid var(--bm-line); border-radius: 14px; background: var(--bm-bg); padding: 0 14px; }
.icc-howto summary { cursor: pointer; padding: 12px 0; font-weight: 800; color: var(--bm-ink); list-style-position: inside; }
.icc-howto ol { margin: 0 0 12px; padding-left: 20px; color: var(--bm-ink-2); font-size: .92rem; }
.icc-howto li { margin: 4px 0; }
.icc-howto p { font-size: .88rem; color: var(--bm-ink-3); }

/* Toolbar with a search box and actions */
.icc-toolbar { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; justify-content: space-between; padding: 12px; border: 1px solid var(--bm-line); border-radius: 14px; background: var(--bm-bg); }
.icc-toolbar .icc-search { flex: 1 1 240px; }
.icc-toolbar-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.icc-export-label { font-size: .8rem; text-transform: uppercase; letter-spacing: .05em; color: var(--bm-ink-3); }
.icc-segfield { display: flex; flex-direction: column; gap: 6px; }
.icc-segfield .ic-label { font-weight: 700; font-size: .88rem; color: var(--bm-ink); }
.icc-count { margin: 0; font-size: .9rem; color: var(--bm-ink-3); }

/* Contact cards */
.icc-cards { grid-template-columns: repeat(auto-fill, minmax(min(260px, 100%), 1fr)); }
.icc-contact { display: flex; flex-direction: column; gap: 8px; transition: transform .16s var(--bm-ease), box-shadow .16s var(--bm-ease), border-color .16s; }
.icc-contact:hover { transform: translateY(-2px); box-shadow: var(--bm-shadow-lg); border-color: color-mix(in srgb, var(--bm-accent) 45%, var(--bm-line)); }
.icc-contact-head, .icc-detail-head { display: flex; gap: 12px; align-items: center; min-width: 0; }
.icc-contact-title { min-width: 0; flex: 1 1 auto; }
.icc-contact-title h4, .icc-contact-title h3 { margin: 0; overflow-wrap: anywhere; }
.icc-contact-title .ic-meta { margin: 2px 0 0; }
.icc-avatar {
    display: grid; place-items: center; flex: 0 0 44px; width: 44px; height: 44px; border-radius: 50%;
    color: #fff; font-weight: 800; font-size: .95rem; letter-spacing: .02em; box-shadow: inset 0 0 0 2px rgba(255, 255, 255, .35);
}
.icc-avatar.is-group { border-radius: 14px; }
.icc-lines { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 4px; font-size: .86rem; color: var(--bm-ink-2); }
.icc-lines li { display: flex; gap: 8px; align-items: baseline; min-width: 0; overflow-wrap: anywhere; }
.icc-lines i { color: var(--bm-accent-strong); width: 14px; flex: 0 0 14px; }
.icc-badges { display: flex; flex-wrap: wrap; gap: 6px; margin: 0; }
.icc-open { align-self: flex-start; margin-top: auto; min-height: 36px; }
.icc-rowno { margin: 0; font-size: .74rem; font-weight: 800; text-transform: uppercase; letter-spacing: .05em; color: var(--bm-ink-3); }
.icc-vcardtext summary { cursor: pointer; font-size: .85rem; font-weight: 700; color: var(--bm-accent-strong); }
.icc-vcardtext pre { margin: 8px 0 0; padding: 10px; max-height: 240px; overflow: auto; border-radius: 10px; background: var(--bm-bg); font-size: .76rem; white-space: pre-wrap; overflow-wrap: anywhere; }
.icc-more { align-self: center; margin: 12px auto 0; display: flex; }
.icc-paged { display: flex; flex-direction: column; }

/* Detail panel */
.icc-detail-host:empty { display: none; }
.icc-detail {
    padding: 18px; border: 1px solid color-mix(in srgb, var(--bm-accent) 40%, var(--bm-line)); border-radius: 18px;
    background: var(--bm-surface); box-shadow: 0 0 0 4px var(--bm-accent-soft), var(--bm-shadow-lg);
}
.icc-detail-head { margin-bottom: 14px; }
.icc-detail-head .icc-avatar { flex-basis: 56px; width: 56px; height: 56px; font-size: 1.15rem; }
.icc-detail h3:focus { outline: none; }
.icc-detail h3:focus-visible { outline: 3px solid var(--bm-accent-ring); outline-offset: 4px; border-radius: 6px; }
.icc-kv { grid-template-columns: minmax(110px, max-content) minmax(0, 1fr); gap: 8px 16px; }
.icc-kv dt { padding-top: 1px; }
.icc-ddlist { margin: 0; padding: 0; list-style: none; }
.icc-ddlist li { white-space: pre-wrap; overflow-wrap: anywhere; }
.icc-ddlist li + li { margin-top: 3px; }
.icc-rawbox { margin-top: 14px; }
.icc-rawbox summary { cursor: pointer; font-weight: 700; color: var(--bm-accent-strong); padding: 6px 0; }
.icc-raw td, .icc-raw th { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: .78rem; }
@media (max-width: 575px) { .icc-kv { grid-template-columns: minmax(0, 1fr); gap: 2px; } .icc-kv dd { margin-bottom: 8px; } }

/* Column chooser */
.icc-fieldgrid { display: grid; gap: 8px 16px; grid-template-columns: repeat(auto-fill, minmax(min(210px, 100%), 1fr)); margin: 8px 0 10px; }
.icc-fieldgrid .is-empty { opacity: .65; }
.icc-modebox { display: flex; flex-direction: column; gap: 6px; }
.icc-modehelp { margin: 0; }

/* Mapping table */
.icc-settings { align-items: end; }
.icc-headerfield { justify-content: flex-end; padding-bottom: 8px; }
.icc-delimnote { margin: -6px 0 0; }
.icc-map select { width: 100%; min-width: 150px; min-height: 40px; padding: 6px 10px; border: 1px solid var(--bm-line); border-radius: 10px; background: var(--bm-surface); color: var(--bm-ink); font: inherit; font-size: .88rem; }
.icc-map select:focus { border-color: var(--bm-accent); outline: 3px solid var(--bm-accent-ring); }
.icc-map tr.is-mapped th { color: var(--bm-accent-strong); }
.icc-map tr.is-mapped th::before { content: "\2713  "; color: var(--ic-ok); }
.icc-sample { color: var(--bm-ink-3); font-style: italic; }
.icc-map .icc-hint { display: block; margin-top: 4px; font-size: .76rem; }
.icc-issues { border: 1px solid var(--bm-line); border-radius: 12px; padding: 0 12px; background: var(--bm-surface); }
.icc-issues summary { cursor: pointer; padding: 10px 0; font-weight: 700; color: var(--ic-warn); }
.icc-issues[open] { padding-bottom: 12px; }
.icc-out { display: flex; flex-direction: column; gap: 14px; }

/* Duplicate groups */
.icc-groups, .icc-suggest { display: flex; flex-direction: column; gap: 12px; }
.icc-groups:empty, .icc-suggest:empty { display: none; }
.icc-grouplist { display: flex; flex-direction: column; gap: 14px; }
.icc-dgroup { border-left: 4px solid var(--ic-t4); background: var(--bm-surface); }
.icc-dgroup.is-kept { border-left-color: var(--ic-t7); }
.icc-dgroup h4 { margin: 0; font-size: 1rem; }
.icc-dgroup .ic-group-head { align-items: flex-start; }
.icc-members { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(min(240px, 100%), 1fr)); margin: 0 0 10px; padding: 0; list-style: none; }
.icc-members li { display: flex; gap: 10px; align-items: flex-start; padding: 10px; border-radius: 12px; background: var(--bm-bg); min-width: 0; overflow-wrap: anywhere; }
.icc-members .icc-avatar { flex-basis: 36px; width: 36px; height: 36px; font-size: .8rem; }
.icc-members .icc-lines { margin-top: 4px; font-size: .8rem; }
.icc-reasons { margin: 0 0 12px; padding: 10px 12px; list-style: none; border-radius: 12px; background: var(--ic-warn-soft); color: var(--ic-warn); font-size: .86rem; }
.icc-reasons li { overflow-wrap: anywhere; }
.icc-reasons li + li { margin-top: 4px; }
.icc-mergebox { display: flex; flex-direction: column; gap: 12px; padding-top: 10px; border-top: 1px dashed var(--bm-line); }
.icc-singles { display: flex; flex-direction: column; gap: 10px; }
.icc-same { margin: 0; font-size: .9rem; overflow-wrap: anywhere; }
.icc-choice { margin: 0; padding: 10px 12px; border: 1px solid var(--bm-line); border-radius: 12px; min-width: 0; }
.icc-choice legend { float: none; width: auto; margin: 0; padding: 0 6px; font-size: .88rem; font-weight: 800; color: var(--bm-ink); }
.icc-choice .ic-check { padding: 4px 0; overflow-wrap: anywhere; }
.icc-choice .ic-check span { min-width: 0; }
.icc-outbox { display: flex; flex-direction: column; gap: 12px; padding: 16px; border-radius: 16px; background: var(--bm-accent-soft); border: 1px solid color-mix(in srgb, var(--bm-accent) 30%, var(--bm-line)); }
.icc-outbox .ic-help { margin: 0; }
.icc-actions .bm-btn-primary { min-height: 46px; }

/* Merge & split pick list */
.icc-picklist { margin: 0; padding: 0; list-style: none; border: 1px solid var(--bm-line); border-radius: 14px; overflow: hidden; background: var(--bm-surface); }
.icc-picklist li + li { border-top: 1px solid var(--bm-line-2); }
.icc-pick { display: flex; gap: 12px; align-items: center; padding: 10px 14px; margin: 0; cursor: pointer; min-width: 0; }
.icc-pick:hover { background: var(--bm-accent-soft); }
.icc-pick input { width: 20px; height: 20px; flex: 0 0 auto; accent-color: var(--bm-accent); }
.icc-pick .icc-avatar { flex-basis: 34px; width: 34px; height: 34px; font-size: .78rem; }
.icc-pick-text { display: flex; flex-direction: column; min-width: 0; overflow-wrap: anywhere; }
.icc-pick-text .ic-meta { font-size: .8rem; color: var(--bm-ink-3); }
.icc-picklist li.is-off .icc-pick-text { opacity: .55; }
.icc-picklist li.is-off .icc-avatar { filter: grayscale(1); opacity: .6; }

@media (max-width: 575px) {
    .icc-toolbar { padding: 10px; }
    .icc-toolbar-actions { width: 100%; }
    .icc-actions .bm-btn { flex: 1 1 100%; justify-content: center; }
    .icc-detail { padding: 14px; }
}
@media (pointer: coarse) {
    .icc .icc-open, .icc .icc-pick, .icc .icc-map select, .icc summary { min-height: 44px; }
    .icc .icc-pick input, .icc .ic-check input { width: 24px; height: 24px; }
    .icc .ic-check { min-height: 44px; align-items: center; }
    .icc .ic-check input { margin-top: 0; }
}
@media print {
    .icc-toolbar, .icc-outbox, .icc-more, .icc-open, .icc-paste { display: none !important; }
}
