/* ==========================================================================
   Offline workspace: the sync chip in the top bar, the Sync panel, the "keep available offline" control and the
   "waiting to sync" marks on rows. Brand tokens come from app.css. No shadows; ground and 1px rules only.
   ========================================================================== */

/* ---------- Chip in the top bar ---------- */
.sync-chip {
    display: inline-flex; align-items: center; gap: .4rem;
    min-height: 44px; padding: 0 .85rem;
    font: inherit; font-size: .875rem; font-weight: 600; line-height: 1.2;
    color: var(--chalk); background: transparent;
    border: 1px solid rgba(247, 244, 238, .35); border-radius: var(--radius, 4px);
    cursor: pointer; white-space: nowrap;
}
.sync-chip::before { content: ""; width: .6rem; height: .6rem; border-radius: 50%; background: var(--harvest-gold); flex: none; }
.sync-chip[data-state="saved"]::before { background: #9CC48E; }
.sync-chip[data-state="syncing"]::before { background: #9CC48E; animation: sync-pulse 1s ease-in-out infinite; }
.sync-chip[data-state="attention"] { border-color: var(--harvest-gold); }
.sync-chip[data-state="attention"]::before { background: #E8A59A; }
.sync-chip:hover { background: rgba(247, 244, 238, .1); }
.sync-chip:focus-visible { outline: 2px solid var(--harvest-gold); outline-offset: 2px; }
@keyframes sync-pulse { 50% { opacity: .35; } }
@media (prefers-reduced-motion: reduce) { .sync-chip[data-state="syncing"]::before { animation: none; } }
@media (max-width: 1180px) { .sync-chip { margin-left: auto; margin-right: .5rem; } }

/* ---------- Sync panel ---------- */
.sync-panel {
    position: fixed; z-index: 70; top: calc(var(--sticky-top, 56px) + 8px); right: max(12px, env(safe-area-inset-right));
    width: min(440px, calc(100vw - 24px)); max-height: calc(100vh - var(--sticky-top, 56px) - 24px); max-height: calc(100dvh - var(--sticky-top, 56px) - 24px);
    overflow: auto; overscroll-behavior: contain;
    background: var(--paper); color: var(--ink);
    border: 1px solid var(--stone); border-radius: var(--radius, 4px); padding: 1rem 1.1rem 1.25rem;
}
.sync-panel[hidden] { display: none; }
.sync-panel:focus { outline: none; }
.sync-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.sync-head h2 { margin: 0; font-size: 1.25rem; }
.sync-state { margin: .5rem 0 .75rem; }
.sync-note { margin: 0 0 .75rem; padding: .6rem .75rem; background: var(--warn-bg); border-radius: var(--radius, 4px); font-size: .9375rem; }
.sync-note a { color: var(--acorn-cap-deep); font-weight: 600; }
.sync-list { list-style: none; margin: 1rem 0 0; padding: 0; border-top: 1px solid var(--limestone); }
.sync-op { padding: .75rem 0; border-bottom: 1px solid var(--limestone); }
.sync-op-main { display: flex; flex-wrap: wrap; align-items: baseline; gap: .25rem .6rem; }
.sync-op[data-status="failed"] .sync-chip-status, .sync-op[data-status="conflict"] .sync-chip-status { background: var(--danger-bg); color: var(--danger); }
.sync-op[data-status="inflight"] .sync-chip-status { background: var(--ok-bg); color: var(--forest); }
.sync-op[data-status="pending"] .sync-chip-status { background: var(--warn-bg); color: var(--acorn-cap-deep); }
.sync-op-error { margin: .35rem 0 0; font-size: .9375rem; color: var(--danger); }
.sync-op-actions { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: .6rem; }
.sync-projects { margin-top: 1.25rem; padding-top: .75rem; border-top: 1px solid var(--stone); }
.sync-projects h3 { margin: 0 0 .5rem; }
.sync-proj { display: flex; flex-wrap: wrap; align-items: center; gap: .25rem .75rem; padding: .35rem 0; }
.sync-usage { margin: .75rem 0 0; font-size: .875rem; }
@media (max-width: 700px) {
    .sync-panel { left: 12px; right: 12px; width: auto; }
}

/* ---------- Keep available offline ---------- */
.offline-toggle-host { display: flex; flex-wrap: wrap; align-items: center; gap: .35rem .75rem; margin-top: .5rem; }
.offline-toggle-host[hidden] { display: none; }
.offline-toggle { min-height: 44px; }
.offline-toggle.is-on { background: var(--ok-bg); border-color: var(--moss); color: var(--forest); }
.offline-toggle-note { font-size: .875rem; }
.offline-toggle-note.is-error { color: var(--danger); font-weight: 600; }
@media (max-height: 779px) { .offline-toggle-host { margin-top: 0; } }

/* ---------- Marks on things that have not synced yet ---------- */
.is-waiting-sync { position: relative; }
.waiting-chip {
    display: inline-block; margin-left: .4rem; padding: .1rem .45rem; border-radius: var(--radius, 4px);
    background: var(--warn-bg); color: var(--acorn-cap-deep); font-size: .75rem; font-weight: 700; letter-spacing: .02em; vertical-align: middle;
}
.waiting-chip.is-failed { background: var(--danger-bg); color: var(--danger); }

/* ---------- Plan editor notices that come from the outbox ---------- */
.plan-estimate { margin: 0 0 .5rem; padding: .35rem .6rem; background: var(--warn-bg); border-radius: var(--radius, 4px); font-size: .875rem; }

@media print { .sync-chip, .sync-panel, .offline-toggle-host { display: none !important; } }
