/* Connected accounts component. Shared by the portal and the cockpit; uses only the shared design tokens
   (--panel, --line, --text, --accent, --ok/--warn/--err, --r*, --serif/--sans/--mono). */
.ac { display: flex; flex-direction: column; gap: 28px; }
.ac-section { display: flex; flex-direction: column; gap: 14px; }
.ac-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.ac-title { font-family: var(--serif); font-weight: 400; font-size: 28px; line-height: 1.1; letter-spacing: -0.005em; margin: 0; }
.ac-sub { color: var(--text-2); margin: 4px 0 0; max-width: 62ch; }
.ac-lede { color: var(--text-2); margin: 0 0 14px; max-width: 64ch; line-height: 1.55; }
.ac-mono { font-family: var(--mono); font-size: 0.84em; color: var(--muted); }
.ac .ic { width: 16px; height: 16px; }

/* banner */
.ac-banner { display: flex; align-items: flex-start; gap: 12px; padding: 14px 16px; border-radius: var(--r); background: var(--ok-soft); border: 1px solid color-mix(in srgb, var(--ok) 40%, transparent); color: var(--text); }
.ac-banner > .ic { color: var(--ok); width: 20px; height: 20px; margin-top: 1px; }
.ac-banner div { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.ac-banner span { color: var(--text-2); }
.ac-x { border: 0; background: transparent; color: var(--muted); cursor: pointer; padding: 4px; border-radius: var(--r-sm); display: inline-flex; }
.ac-x:hover { color: var(--text); background: var(--sunk); }

/* logos */
.ac-logo { display: inline-grid; place-items: center; flex: none; border-radius: 12px; background: var(--panel); border: 1px solid var(--line); }
.ac-logo svg { width: 55%; height: 55%; }
.ac-logo-md { width: 44px; height: 44px; }
.ac-logo-lg { width: 52px; height: 52px; border-radius: 14px; }
.ac-logo-imap { color: var(--accent); background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 30%, transparent); }

/* account list */
.ac-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 12px; }
.ac-acc { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 16px 18px; display: flex; flex-direction: column; gap: 12px; transition: border-color .3s, box-shadow .3s; }
.ac-acc.is-off { background: var(--panel-2); }
.ac-acc.is-off .ac-logo { filter: grayscale(1); opacity: .6; }
.ac-acc.is-new { border-color: var(--ok); box-shadow: 0 0 0 3px var(--ok-soft); }
.ac-acc-top { display: flex; gap: 14px; align-items: center; min-width: 0; }
.ac-acc-id { min-width: 0; flex: 1; display: flex; flex-direction: column; gap: 3px; }
.ac-acc-name { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.ac-acc-name b { font-size: 16px; font-weight: 600; overflow-wrap: anywhere; }
.ac-acc-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; color: var(--muted); font-size: 13.5px; }
.ac-ctx { display: inline-flex; align-items: center; padding: 1px 9px; border-radius: 999px; background: var(--accent-soft); color: var(--text); font-size: 12.5px; font-weight: 500; }
.ac-status { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 600; padding: 2px 9px 2px 8px; border-radius: 999px; }
.ac-dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.ac-tone-ok { color: var(--ok); background: var(--ok-soft); }
.ac-tone-warn { color: var(--warn); background: var(--warn-soft); }
.ac-tone-err { color: var(--err); background: var(--err-soft); }
.ac-tone-idle { color: var(--muted); background: var(--sunk); }
.ac-caps { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.ac-cap { font-size: 12.5px; padding: 2px 9px; border-radius: 999px; border: 1px solid var(--line-2); color: var(--text-2); }
.ac-sync { margin-left: auto; color: var(--muted); font-size: 13px; }
.ac-problem { display: flex; gap: 10px; align-items: center; padding: 10px 12px; border-radius: var(--r); background: var(--warn-soft); flex-wrap: wrap; }
.ac-problem > .ic { flex: none; width: 18px; height: 18px; }
.ac-problem.ac-tone-err { background: var(--err-soft); }
.ac-problem div { flex: 1; min-width: 200px; display: flex; flex-direction: column; gap: 2px; color: var(--text); }
.ac-problem div span { color: var(--text-2); font-size: 13.5px; }
.ac-result { display: flex; align-items: center; gap: 8px; padding: 8px 12px; border-radius: var(--r); font-size: 14px; font-weight: 500; animation: ac-in .25s ease-out; }
.ac-result span:last-child { color: var(--text); font-weight: 500; }
.ac-actions { display: flex; flex-wrap: wrap; gap: 6px; padding-top: 2px; border-top: 1px dashed var(--line); padding-top: 12px; }
.ac-actions .btn { gap: 6px; }
.ac-danger { color: var(--err) !important; }
.ac-empty { display: flex; gap: 14px; align-items: flex-start; padding: 22px; border: 1px dashed var(--line-2); border-radius: var(--r-lg); color: var(--text-2); }
.ac-empty > .ic { width: 22px; height: 22px; color: var(--accent); flex: none; margin-top: 2px; }
.ac-empty b { color: var(--text); font-size: 16px; }
.ac-empty p { margin: 4px 0 0; max-width: 56ch; }

/* connect cards */
.ac-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.ac-card { display: flex; flex-direction: column; border-radius: var(--r-lg); background: var(--panel); border: 1px solid var(--line); transition: border-color .15s, box-shadow .15s; }
.ac-card.is-open { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.ac-card:not(.is-disabled):hover { border-color: var(--line-2); }
.ac-card-btn { all: unset; box-sizing: border-box; cursor: pointer; display: flex; flex-direction: column; gap: 12px; padding: 18px; flex: 1; border-radius: var(--r-lg); }
.ac-card-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.ac-card.is-disabled .ac-card-btn { cursor: default; }
.ac-card.is-disabled .ac-card-btn:focus-visible { outline: none; }
.ac-card.is-disabled .ac-logo { filter: grayscale(1); opacity: .55; }
.ac-card.is-disabled .ac-card-text b { color: var(--text-2); }
.ac-card-text { display: flex; flex-direction: column; gap: 3px; }
.ac-card-text b { font-size: 15.5px; font-weight: 600; color: var(--text); }
.ac-card-text small { color: var(--muted); font-size: 13.5px; line-height: 1.4; }
.ac-card-go { margin-top: auto; display: inline-flex; align-items: center; gap: 4px; color: var(--accent); font-weight: 600; font-size: 14px; }
.ac-card-note { margin-top: auto; display: inline-flex; align-items: flex-start; gap: 6px; color: var(--muted); font-size: 13px; line-height: 1.4; }
a.ac-card-note { color: var(--accent); }
.ac-card-note .ic { width: 15px; height: 15px; margin-top: 1px; }
.ac-alt { all: unset; cursor: pointer; margin: -4px 18px 16px; font-size: 13px; color: var(--accent); font-weight: 500; text-decoration: underline; text-underline-offset: 3px; text-decoration-color: color-mix(in srgb, var(--accent) 40%, transparent); }
.ac-alt:hover { text-decoration-color: currentColor; }
.ac-alt:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 3px; }

/* panel + form */
.ac-panel-host:empty { display: none; }
.ac-panel { background: var(--panel); border: 1px solid var(--line-2); border-radius: var(--r-lg); padding: 20px 22px 22px; display: flex; flex-direction: column; gap: 14px; animation: ac-in .22s ease-out; }
.ac-panel-head { display: flex; align-items: center; gap: 12px; }
.ac-panel-head h3 { font-size: 18px; font-weight: 600; margin: 0; flex: 1; }
.ac-panel-foot { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; padding-top: 4px; }
.ac-row { display: grid; gap: 12px; }
.ac-row-2 { grid-template-columns: 1fr 1fr; }
.ac-row-3 { grid-template-columns: 1fr 110px 140px; }
.ac-field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.ac-field > span { font-size: 13.5px; font-weight: 600; color: var(--text-2); }
.ac-field > span em { font-style: normal; font-weight: 400; color: var(--muted); }
.ac-field small { color: var(--muted); font-size: 12.5px; }
.ac-field input, .ac-field select, .ac-pw input {
  font: 400 15px var(--sans); color: var(--text); background: var(--sunk); border: 1px solid var(--line-2); border-radius: var(--r-sm);
  height: 42px; padding: 0 12px; width: 100%; min-width: 0; box-sizing: border-box;
}
.ac-field input:focus, .ac-field select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.ac-field input:disabled, .ac-field select:disabled { opacity: .6; }
.ac-pw { position: relative; display: block; }
.ac-pw input { padding-right: 42px; }
.ac-pw-eye { position: absolute; right: 4px; top: 4px; height: 34px; width: 34px; border: 0; background: transparent; color: var(--muted); border-radius: var(--r-sm); cursor: pointer; display: grid; place-items: center; }
.ac-pw-eye:hover { color: var(--text); }
.ac-newctx { display: grid; grid-template-columns: 1fr 180px; gap: 12px; padding: 12px; border-radius: var(--r); background: var(--sunk); border: 1px dashed var(--line-2); }
.ac-presets { border: 0; margin: 0; padding: 0; min-width: 0; }
.ac-presets legend { font-size: 13.5px; font-weight: 600; color: var(--text-2); padding: 0; margin-bottom: 8px; }
.ac-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.ac-chip { position: relative; cursor: pointer; }
.ac-chip input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.ac-chip span { display: inline-flex; align-items: center; height: 36px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--line-2); background: var(--panel); font-weight: 500; font-size: 14px; color: var(--text-2); transition: background .12s, border-color .12s, color .12s; }
.ac-chip input:checked + span { background: var(--text); color: var(--panel); border-color: var(--text); }
.ac-chip input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.ac-note { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border-radius: var(--r); background: var(--accent-soft); color: var(--text); font-size: 14px; line-height: 1.5; }
.ac-note .ic { color: var(--accent); margin-top: 2px; flex: none; }
.ac-adv { border-top: 1px solid var(--line); padding-top: 10px; }
.ac-adv summary { cursor: pointer; list-style: none; display: inline-flex; align-items: center; gap: 6px; color: var(--text-2); font-weight: 500; font-size: 14px; padding: 4px 0; }
.ac-adv summary::-webkit-details-marker { display: none; }
.ac-adv summary .ic { transition: transform .15s; }
.ac-adv[open] summary .ic { transform: rotate(90deg); }
.ac-adv-body { display: flex; flex-direction: column; gap: 12px; padding-top: 12px; }
.ac-form-err { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: var(--r); background: var(--err-soft); border: 1px solid color-mix(in srgb, var(--err) 35%, transparent); }
.ac-form-err > .ic { color: var(--err); width: 18px; height: 18px; flex: none; margin-top: 1px; }
.ac-form-err div { display: flex; flex-direction: column; gap: 2px; }
.ac-form-err b { color: var(--err); }
.ac-form-err span { color: var(--text); overflow-wrap: anywhere; }
.ac-progress { display: inline-flex; align-items: center; gap: 10px; color: var(--text-2); font-size: 14px; }
.ac-spin { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--line-2); border-top-color: var(--accent); animation: ac-spin .8s linear infinite; flex: none; }
.ac-modal { display: flex; flex-direction: column; gap: 12px; }
.ac-modal .ac-newctx { grid-template-columns: 1fr; }


/* ---------- v0.3: files and drives ---------- */
.ac-drives { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.ac-drive { display: flex; flex-direction: column; gap: 14px; padding: 18px; border-radius: var(--r-lg); background: var(--panel); border: 1px solid var(--line); min-width: 0; }
.ac-drive.is-disabled .ac-drive-logo { filter: grayscale(1); opacity: .55; }
.ac-drive-top { display: flex; gap: 14px; align-items: flex-start; }
.ac-drive-foot { margin-top: auto; display: flex; flex-direction: column; align-items: flex-start; gap: 10px; }
.ac-drive-list { list-style: none; margin: 0; padding: 0; width: 100%; display: flex; flex-direction: column; }
.ac-drive-list li { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; align-items: center; gap: 10px; padding: 9px 0; border-top: 1px solid var(--line); }
.ac-drive-list li:first-child { border-top: 0; padding-top: 0; }
.ac-drive-who { display: flex; flex-direction: column; min-width: 0; }
.ac-drive-who b { font-weight: 600; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ac-drive-who small { color: var(--muted); font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ac-drive-note { color: var(--muted); font-size: 12.5px; white-space: nowrap; }
.ac-drive-add { align-self: flex-start; }
@media (max-width: 520px) { .ac-drive-list li { grid-template-columns: minmax(0, 1fr) auto; } .ac-drive-note { display: none; } }
.ac-drive-state { display: flex; gap: 8px; align-items: flex-start; font-size: 13.5px; line-height: 1.45; padding: 8px 10px; border-radius: var(--r); background: var(--ok-soft); color: var(--text); }
.ac-drive-state .ic { color: var(--ok); margin-top: 2px; flex: none; }
.ac-upload { grid-column: 1 / -1; }
.ac-drop { position: relative; display: flex; align-items: center; gap: 14px; padding: 18px; border-radius: var(--r); border: 1.5px dashed var(--line-2); background: var(--sunk); cursor: pointer; transition: border-color .15s, background .15s; }
.ac-drop:hover, .ac-drop.is-over { border-color: var(--accent); background: var(--accent-soft); }
.ac-drop:focus-within { outline: 2px solid var(--accent); outline-offset: 2px; }
.ac-drop.has-files { border-style: solid; border-color: color-mix(in srgb, var(--accent) 55%, var(--line-2)); }
.ac-drop input { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; }
.ac-drop > .ic { width: 22px; height: 22px; color: var(--accent); flex: none; }
.ac-drop span { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.ac-drop b { color: var(--text); overflow-wrap: anywhere; }
.ac-drop small { color: var(--muted); font-size: 13px; }
.ac-upload-row { align-items: end; }
.ac-upload-go { display: flex; justify-content: flex-end; }
.ac-upres { border-top: 1px dashed var(--line); padding-top: 12px; display: flex; flex-direction: column; gap: 8px; animation: ac-in .25s ease-out; }
.ac-upres-sum { display: flex; gap: 8px; align-items: flex-start; }
.ac-upres-sum .ic { margin-top: 3px; color: var(--ok); }
.ac-upres-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; max-height: 320px; overflow: auto; }
.ac-upres-list li { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 10px; align-items: baseline; padding: 7px 2px; font-size: 14px; }
.ac-upres-list li + li { border-top: 1px solid var(--line); }
.ac-upres-list li > .ic { width: 14px; height: 14px; align-self: center; }
.ac-upres-list li.is-ok > .ic { color: var(--ok); }
.ac-upres-list li.is-bad > .ic { color: var(--err); }
.ac-upres-t { display: flex; flex-direction: column; min-width: 0; overflow-wrap: anywhere; color: var(--text); }
.ac-upres-t small { color: var(--muted); font-family: var(--mono); font-size: 11.5px; }
.ac-upres-d { color: var(--muted); font-size: 13px; text-align: right; }
.ac-upres-list li.is-bad .ac-upres-d { color: var(--err); }

/* per-account Files panel */
.btn.is-on { border-color: var(--accent); background: var(--accent-soft); }
.ac-files { margin-top: -2px; padding: 14px; border-radius: var(--r); background: var(--panel-2); border: 1px solid var(--line); display: flex; flex-direction: column; gap: 12px; }
.ac-files.is-entering { animation: ac-in .22s ease-out; }
@media (prefers-reduced-motion: reduce) { .ac-files.is-entering, .ac-upres { animation: none; } }
.ac-files-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.ac-switch { display: flex; align-items: flex-start; gap: 12px; cursor: pointer; position: relative; min-width: 0; flex: 1 1 260px; }
.ac-switch input { position: absolute; opacity: 0; width: 40px; height: 24px; margin: 0; cursor: pointer; }
.ac-switch-ui { width: 40px; height: 24px; border-radius: 999px; background: var(--line-2); position: relative; flex: none; transition: background .15s; margin-top: 1px; }
.ac-switch-ui::after { content: ''; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.25); transition: transform .15s; }
.ac-switch input:checked + .ac-switch-ui { background: var(--ok); }
.ac-switch input:checked + .ac-switch-ui::after { transform: translateX(16px); }
.ac-switch input:focus-visible + .ac-switch-ui { outline: 2px solid var(--accent); outline-offset: 2px; }
.ac-switch input:disabled + .ac-switch-ui { opacity: .5; }
.ac-switch > span:last-child { display: flex; flex-direction: column; gap: 1px; }
.ac-switch small { color: var(--muted); font-size: 12.5px; }
.ac-files-msg { display: flex; gap: 8px; align-items: flex-start; font-size: 14px; color: var(--text-2); padding: 8px 10px; border-radius: var(--r); background: var(--sunk); }
.ac-files-msg .ic { margin-top: 2px; flex: none; }
.ac-files-msg.ac-tone-ok { background: var(--ok-soft); color: var(--text); }
.ac-files-msg.ac-tone-ok .ic { color: var(--ok); }
.ac-files-msg.ac-tone-err { background: var(--err-soft); color: var(--text); }
.ac-files-msg.ac-tone-err .ic { color: var(--err); }
.ac-files-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.ac-files-list li { display: grid; grid-template-columns: 52px minmax(0, 1fr) auto; gap: 10px; align-items: baseline; padding: 8px 0; font-size: 14px; }
.ac-files-list li + li { border-top: 1px solid var(--line); }
.ac-file-kind { font-size: 11.5px; font-weight: 600; color: var(--text-2); background: var(--sunk); border: 1px solid var(--line); border-radius: 5px; padding: 1px 6px; text-align: center; }
.ac-file-a { display: inline-flex; align-items: center; gap: 6px; min-width: 0; color: var(--text); }
.ac-file-a .ic { width: 13px; height: 13px; color: var(--muted); flex: none; }
.ac-file-a:hover { color: var(--accent); }
.ac-file-t { overflow-wrap: anywhere; }
.ac-file-meta { color: var(--muted); font-size: 12.5px; white-space: nowrap; }
.ac-files-all { margin: 0; align-self: flex-start; }
@media (max-width: 640px) {
  .ac-drives { grid-template-columns: 1fr; }
  .ac-files-list li { grid-template-columns: 46px minmax(0, 1fr); }
  .ac-file-meta { grid-column: 2; white-space: normal; }
  .ac-upres-list li { grid-template-columns: auto minmax(0, 1fr); }
  .ac-upres-d { grid-column: 2; text-align: left; }
  .ac-upload-go .btn { width: 100%; }
}

@keyframes ac-spin { to { transform: rotate(360deg); } }
@keyframes ac-in { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .ac-panel, .ac-result { animation: none; } .ac-spin { animation-duration: 2s; } }

@media (max-width: 640px) {
  .ac-row-2, .ac-newctx { grid-template-columns: 1fr; }
  .ac-row-3 { grid-template-columns: 1fr 1fr; }
  .ac-row-3 .ac-field:first-child { grid-column: 1 / -1; }
  .ac-sync { margin-left: 0; width: 100%; }
  .ac-acc { padding: 14px; }
  .ac-panel { padding: 16px; }
  .ac-cards { grid-template-columns: 1fr 1fr; gap: 10px; }
  .ac-card-btn { padding: 14px; gap: 10px; }
  .ac-alt { margin: -4px 14px 14px; }
  .ac-actions .btn { flex: 1 1 auto; }
  .ac-head .btn { width: 100%; }
}
@media (max-width: 380px) { .ac-cards { grid-template-columns: 1fr; } }

/* Short fields (ports, security, context kind) sit beside a wider one */
.ac-field-sm { flex: 0 0 150px; max-width: 150px; }
@media (max-width: 560px) { .ac-field-sm { flex-basis: 100%; max-width: none; } }
