/* ===================================================================
   iCloud Tools - Calendars group (ICS Viewer, ICS Merger, Calendar
   Duplicate Cleaner, ICS to CSV). Builds on icloud-tools.css; every
   selector is scoped under .icc so nothing leaks into other tools.
   =================================================================== */

.icc { --icc-tone: var(--ic-t0); min-width: 0; }
.icc > * + * { margin-top: 16px; }
.icc [hidden] { display: none !important; }
.icc-tone-0 { --icc-tone: var(--ic-t0); } .icc-tone-1 { --icc-tone: var(--ic-t1); } .icc-tone-2 { --icc-tone: var(--ic-t2); } .icc-tone-3 { --icc-tone: var(--ic-t3); }
.icc-tone-4 { --icc-tone: var(--ic-t4); } .icc-tone-5 { --icc-tone: var(--ic-t5); } .icc-tone-6 { --icc-tone: var(--ic-t6); } .icc-tone-7 { --icc-tone: var(--ic-t7); }

.icc-loader > * + * { margin-top: 12px; }
.icc-status > * + * { margin-top: 8px; }
.icc-status:empty { display: none; }
.icc-sub { margin: 14px 0 6px; font-size: .95rem; font-weight: 800; color: var(--bm-ink); }
.icc-plain-list { margin: 0; padding-left: 18px; }
.icc-plain-list li + li { margin-top: 2px; }
.icc-code { display: inline-block; font-size: .8rem; padding: 1px 6px; border-radius: 6px; background: var(--bm-line-2); color: var(--bm-ink-2); overflow-wrap: anywhere; word-break: break-all; }
.icc-rule { display: block; font-weight: 700; margin-bottom: 4px; }
.icc-note { margin: 0; font-size: .85rem; color: var(--bm-ink-3); }
.icc-linkish { padding: 0; border: 0; background: none; color: var(--bm-accent-strong); font: inherit; font-weight: 700; text-align: left; cursor: pointer; text-decoration: underline; text-underline-offset: 2px; }
.icc-badges { display: flex; flex-wrap: wrap; gap: 6px; }
.icc-badges:empty { display: none; }
.icc-warnings summary { cursor: pointer; font-weight: 700; }
.icc-warnings ul { margin: 6px 0 0; padding-left: 18px; max-height: 220px; overflow: auto; }

/* ---------- Calendar header card ---------- */
.icc-head {
    display: flex; flex-wrap: wrap; gap: 14px; align-items: center; justify-content: space-between;
    padding: 16px; border: 1px solid var(--bm-line); border-radius: 16px;
    background: linear-gradient(135deg, var(--bm-accent-soft), var(--bm-surface) 60%);
}
.icc-head-main { display: flex; gap: 14px; align-items: center; min-width: 0; flex: 1 1 260px; }
.icc-head-icon { position: relative; display: grid; place-items: center; flex: 0 0 56px; height: 56px; border-radius: 16px; background: var(--bm-surface); box-shadow: var(--bm-shadow); color: var(--bm-accent-strong); font-size: 1.5rem; overflow: hidden; }
.icc-head-icon::before { content: ""; position: absolute; left: 0; right: 0; top: 0; height: 12px; background: var(--icc-cal, var(--bm-accent)); }
.icc-head-icon i { margin-top: 8px; }
.icc-head h3 { margin: 0; font-size: 1.15rem; overflow-wrap: anywhere; }
.icc-head-meta { margin: 2px 0 0; font-size: .85rem; color: var(--bm-ink-3); overflow-wrap: anywhere; }
.icc-head .ic-toolbar { flex: 0 1 auto; }

/* ---------- Filters ---------- */
.icc-filters { display: grid; gap: 10px; grid-template-columns: minmax(0, 2fr) repeat(2, minmax(0, 1fr)) auto; align-items: end; }
.icc-filters .ic-field { margin: 0; }
.icc-count { margin: 0; font-size: .88rem; font-weight: 700; color: var(--bm-ink-2); }
@media (max-width: 760px) { .icc-filters { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); } .icc-filters .icc-search { grid-column: 1 / -1; } }

/* ---------- Tabs ---------- */
.icc-tabs .ic-tab i { margin-right: 6px; }
.icc-panel { padding-top: 14px; }

/* ---------- Agenda ---------- */
.icc-agenda { display: grid; gap: 14px; }
.icc-day { display: grid; grid-template-columns: 64px minmax(0, 1fr); gap: 12px; align-items: start; }
.icc-day-date { position: sticky; top: 70px; display: flex; flex-direction: column; align-items: center; padding: 8px 4px; border-radius: 14px; background: var(--bm-bg); border: 1px solid var(--bm-line); line-height: 1.1; }
.icc-day-date .wd { font-size: .72rem; font-weight: 800; text-transform: uppercase; letter-spacing: .05em; color: var(--bm-ink-3); }
.icc-day-date .dn { font-size: 1.5rem; font-weight: 800; color: var(--bm-ink); }
.icc-day-date .mo { font-size: .72rem; font-weight: 700; color: var(--bm-ink-3); }
.icc-day h4 { margin: 0 0 6px; font-size: .9rem; color: var(--bm-ink-2); }
.icc-day-list { display: grid; gap: 6px; margin: 0; padding: 0; list-style: none; }
.icc-event {
    display: grid; grid-template-columns: 4px minmax(0, 1fr); gap: 10px; width: 100%; padding: 9px 12px; text-align: left;
    border: 1px solid var(--bm-line); border-radius: 12px; background: var(--bm-surface); color: var(--bm-ink); font: inherit; cursor: pointer;
    transition: border-color .15s, transform .15s var(--bm-ease), box-shadow .15s;
}
.icc-event:hover { border-color: var(--icc-tone); box-shadow: var(--bm-shadow); transform: translateY(-1px); }
.icc-event[aria-expanded="true"] { border-color: var(--icc-tone); box-shadow: 0 0 0 3px color-mix(in srgb, var(--icc-tone) 25%, transparent); }
.icc-event-bar { border-radius: 4px; background: var(--icc-tone); }
.icc-event-body { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.icc-event-time { font-size: .8rem; font-weight: 700; color: var(--bm-ink-3); font-variant-numeric: tabular-nums; }
.icc-event-title { font-weight: 800; overflow-wrap: anywhere; }
.icc-event-meta { font-size: .82rem; color: var(--bm-ink-3); overflow-wrap: anywhere; }
.icc-event .icc-badges { margin-top: 3px; }
.icc-more { justify-self: center; }
@media (max-width: 480px) { .icc-day { grid-template-columns: minmax(0, 1fr); gap: 6px; } .icc-day-date { position: static; flex-direction: row; gap: 6px; justify-content: flex-start; padding: 6px 10px; } .icc-day-date .dn { font-size: 1rem; } }

/* ---------- Month grid ---------- */
.icc-month-head { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.icc-month-label { margin: 0; font-size: 1.15rem; font-weight: 800; min-width: 10ch; text-align: center; flex: 1 1 auto; }
.icc-month-nav { display: flex; gap: 6px; }
.icc-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); border: 1px solid var(--bm-line); border-radius: 14px; overflow: hidden; background: var(--bm-line); gap: 1px; }
.icc-wd { padding: 6px 4px; text-align: center; font-size: .72rem; font-weight: 800; letter-spacing: .04em; text-transform: uppercase; color: var(--bm-ink-3); background: var(--bm-bg); }
.icc-cell { display: flex; flex-direction: column; gap: 3px; min-width: 0; min-height: 104px; padding: 4px; background: var(--bm-surface); }
.icc-cell.is-out { background: var(--bm-bg); }
.icc-cell.is-out .icc-daybtn { color: var(--bm-ink-3); font-weight: 600; }
.icc-cell.is-selected { box-shadow: inset 0 0 0 2px var(--bm-accent); }
.icc-daybtn {
    display: flex; align-items: center; justify-content: space-between; gap: 4px; width: 100%; min-height: 28px; padding: 2px 6px;
    border: 0; border-radius: 8px; background: none; color: var(--bm-ink); font: inherit; font-size: .85rem; font-weight: 800; cursor: pointer;
}
.icc-daybtn:hover { background: var(--bm-accent-soft); }
.icc-cell.is-today .icc-daynum { display: inline-grid; place-items: center; min-width: 24px; height: 24px; padding: 0 4px; border-radius: 999px; background: var(--bm-accent); color: #fff; }
.icc-dots { display: none; gap: 2px; }
.icc-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--icc-tone); }
.icc-chip {
    display: block; width: 100%; min-width: 0; padding: 2px 6px; border: 0; border-left: 3px solid var(--icc-tone); border-radius: 6px;
    background: color-mix(in srgb, var(--icc-tone) 13%, var(--bm-surface)); color: var(--bm-ink); font: inherit; font-size: .74rem; font-weight: 700;
    text-align: left; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: pointer;
}
.icc-chip:hover { background: color-mix(in srgb, var(--icc-tone) 24%, var(--bm-surface)); }
.icc-chip.is-cont { border-left-style: dashed; opacity: .85; }
.icc-chip-more { padding: 0 6px; border: 0; background: none; color: var(--bm-accent-strong); font: inherit; font-size: .74rem; font-weight: 800; text-align: left; cursor: pointer; }
.icc-dayview { margin-top: 14px; padding: 14px; border: 1px solid var(--bm-line); border-radius: 14px; background: var(--bm-bg); }
.icc-dayview h4 { margin: 0 0 8px; font-size: 1rem; }
@media (max-width: 640px) {
    .icc-cell { min-height: 52px; padding: 2px; align-items: center; }
    .icc-chip, .icc-chip-more { display: none; }
    .icc-dots { display: flex; flex-wrap: wrap; justify-content: center; }
    .icc-daybtn { flex-direction: column; justify-content: center; min-height: 44px; padding: 2px; font-size: .8rem; }
    .icc-wd { font-size: .62rem; letter-spacing: 0; padding: 4px 0; }
}

/* ---------- Details ---------- */
.icc-detail { position: relative; margin-top: 14px; padding: 16px; border: 1px solid var(--bm-line); border-radius: 16px; background: var(--bm-surface); box-shadow: var(--bm-shadow-lg); }
.icc-detail > * + * { margin-top: 10px; }
.icc-detail-head { display: flex; gap: 10px; align-items: flex-start; }
.icc-detail-bar { flex: 0 0 6px; align-self: stretch; border-radius: 6px; background: var(--icc-tone); }
.icc-detail-title { flex: 1 1 auto; min-width: 0; margin: 0; font-size: 1.15rem; overflow-wrap: anywhere; }
/* The heading receives focus programmatically when the panel opens; the
   panel border shows where focus is instead of a box around the text. */
.ic .icc-detail-title:focus, .ic .icc-detail-title:focus-visible { outline: none; }
.icc-detail:focus-within { border-color: var(--bm-accent); }
.icc-kv { grid-template-columns: minmax(96px, max-content) minmax(0, 1fr); }
.icc-desc { margin: 0; padding: 12px; border-radius: 12px; background: var(--bm-bg); white-space: pre-wrap; overflow-wrap: anywhere; font-size: .9rem; color: var(--bm-ink); max-height: 360px; overflow: auto; }
@media (max-width: 420px) { .icc-kv { grid-template-columns: minmax(0, 1fr); } .icc-kv dd { margin-bottom: 6px; } }

/* ---------- Merger ---------- */
.icc-files { display: grid; gap: 10px; margin: 0; padding: 0; list-style: none; grid-template-columns: repeat(auto-fill, minmax(min(280px, 100%), 1fr)); }
.icc-file { position: relative; display: flex; flex-direction: column; gap: 6px; padding: 14px 14px 12px 18px; border: 1px solid var(--bm-line); border-radius: 14px; background: var(--bm-surface); min-width: 0; overflow: hidden; }
.icc-file::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 5px; background: var(--icc-cal, var(--bm-accent)); }
.icc-file-top { display: flex; gap: 8px; align-items: flex-start; justify-content: space-between; }
.icc-file h4 { margin: 0; font-size: .98rem; overflow-wrap: anywhere; min-width: 0; }
.icc-file .ic-kv { font-size: .82rem; grid-template-columns: minmax(80px, max-content) minmax(0, 1fr); }
.icc-order { display: inline-grid; place-items: center; min-width: 24px; height: 24px; margin-right: 6px; border-radius: 999px; background: var(--bm-accent-soft); color: var(--bm-accent-strong); font-size: .75rem; font-weight: 800; }
.icc-icon-btn { display: inline-grid; place-items: center; min-width: 36px; min-height: 36px; border: 1px solid var(--bm-line); border-radius: 10px; background: var(--bm-surface); color: var(--bm-ink-2); cursor: pointer; }
.icc-icon-btn:hover { border-color: var(--bm-accent); color: var(--bm-accent-strong); }
.icc-icon-btn:disabled { opacity: .45; cursor: not-allowed; }
.icc-options { display: flex; flex-wrap: wrap; gap: 12px 20px; align-items: center; }
.icc-flow { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(150px, 100%), 1fr)); gap: 10px; }
.icc-conflict { padding: 10px 12px; border: 1px solid var(--bm-line); border-radius: 12px; background: var(--bm-surface); }
.icc-conflict + .icc-conflict { margin-top: 8px; }
.icc-conflict p { margin: 0; overflow-wrap: anywhere; }

/* ---------- Duplicate cleaner ---------- */
.icc-group-list > * + * { margin-top: 12px; }
.icc-dup-grid { display: grid; gap: 8px; }
.icc-dup {
    display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 10px; align-items: start; padding: 10px 12px;
    border: 1px solid var(--bm-line); border-radius: 12px; background: var(--bm-surface);
}
.icc-dup.is-keep { border-color: color-mix(in srgb, var(--ic-ok) 45%, var(--bm-line)); background: color-mix(in srgb, var(--ic-ok-soft) 60%, var(--bm-surface)); }
.icc-dup.is-remove { border-color: color-mix(in srgb, var(--ic-bad) 35%, var(--bm-line)); }
.icc-dup.is-remove.is-kept-by-user { border-color: var(--bm-line); opacity: .8; }
.icc-dup-mark { display: grid; place-items: center; width: 28px; height: 28px; border-radius: 999px; background: var(--ic-ok); color: #fff; font-size: .8rem; }
.icc-dup input[type="checkbox"] { width: 22px; height: 22px; margin: 3px; accent-color: var(--ic-bad); }
.icc-dup label { display: flex; flex-direction: column; gap: 2px; min-width: 0; cursor: pointer; }
.icc-dup-title { font-weight: 800; overflow-wrap: anywhere; }
.icc-dup-meta { font-size: .82rem; color: var(--bm-ink-3); overflow-wrap: anywhere; }
.icc-dup-action { font-size: .78rem; font-weight: 800; text-transform: uppercase; letter-spacing: .04em; }
.icc-dup.is-keep .icc-dup-action { color: var(--ic-ok); }
.icc-dup.is-remove .icc-dup-action { color: var(--ic-bad); }
.icc-dup.is-kept-by-user .icc-dup-action { color: var(--bm-ink-3); }
.icc-sticky { position: sticky; bottom: 0; z-index: 2; padding: 10px 12px; border: 1px solid var(--bm-line); border-radius: 14px; background: color-mix(in srgb, var(--bm-surface) 94%, transparent); box-shadow: var(--bm-shadow-lg); backdrop-filter: blur(6px); }
.icc-sticky p { margin: 0; font-weight: 700; }

/* ---------- ICS to CSV ---------- */
.icc-csv-layout { display: grid; gap: 16px; grid-template-columns: minmax(0, 320px) minmax(0, 1fr); align-items: start; }
@media (max-width: 900px) { .icc-csv-layout { grid-template-columns: minmax(0, 1fr); } }
.icc-cols { display: grid; gap: 6px; margin: 8px 0 0; padding: 0; list-style: none; }
.icc-col { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: 6px; align-items: center; padding: 6px 8px; border: 1px solid var(--bm-line); border-radius: 10px; background: var(--bm-surface); }
.icc-col.is-off { background: var(--bm-bg); }
.icc-col.is-off .icc-col-name { color: var(--bm-ink-3); }
.icc-col label { display: flex; gap: 8px; align-items: center; min-width: 0; margin: 0; font-size: .88rem; font-weight: 700; cursor: pointer; }
.icc-col input[type="checkbox"] { width: 18px; height: 18px; accent-color: var(--bm-accent); flex: 0 0 auto; }
.icc-col-name { overflow-wrap: anywhere; }
.icc-settings > * + * { margin-top: 14px; }
.icc-settings .ic-seg { display: flex; }
.icc-preview-head { display: flex; flex-wrap: wrap; gap: 8px; align-items: baseline; justify-content: space-between; }
.icc-preview-head h4 { margin: 0; font-size: 1rem; }

/* ---------- Polish ---------- */
.icc h3, .icc h4, .icc .icc-detail-title, .icc .ic-results-head h3 { font-weight: 800; color: var(--bm-ink); }
.icc .ic-stat dd { font-size: 1.2rem; }
.icc-dup-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.icc-file-top .ic-toolbar { flex-wrap: nowrap; flex: 0 0 auto; gap: 4px; }
.icc-file-top h4 { flex: 1 1 auto; }
.icc-preview .ic-table th, .icc-preview .ic-table td { white-space: nowrap; max-width: 28ch; overflow: hidden; text-overflow: ellipsis; }
.icc-preview .ic-table-wrap { max-height: 520px; }
.icc-rules summary { cursor: pointer; font-weight: 700; }
.icc-rules ul { margin-top: 6px; }

@media (pointer: coarse) {
    .icc .icc-daybtn, .icc .icc-chip, .icc .icc-event, .icc .icc-icon-btn, .icc .icc-linkish { min-height: 44px; }
    .icc .icc-icon-btn { min-width: 44px; }
    .icc .icc-col input[type="checkbox"] { width: 24px; height: 24px; }
}
@media (prefers-reduced-motion: reduce) { .icc *, .icc *::before { transition: none !important; } }
@media print {
    .icc .ic-toolbar, .icc-filters, .icc-tabs, .icc-month-nav, .icc-loader { display: none !important; }
}
