.sync-settings { padding: 16px 0; border-bottom: 1px solid var(--line); }
.sync-device-row, .sync-actions, .sync-dialog-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.sync-device-row input { width: 180px; max-width: 100%; }
.sync-device-row { margin-bottom: 12px; }
#syncLastSaved { font-size: 12px; color: var(--muted); overflow-wrap: anywhere; }
.sync-actions button { min-height: 36px; width: auto; }
.sync-settings h3 { font-size: 14px; margin: 16px 0 8px; }
#syncHistoryList { list-style: none; padding: 0; margin: 0; }
#syncHistoryList li { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--line); }
#syncHistoryList li span { min-width: 0; flex: 1; overflow-wrap: anywhere; }
#syncHistoryList button { flex: 0 0 auto; width: auto; min-width: 64px; }
.sync-compact { border: 0; background: transparent; color: var(--muted); padding: 3px 0; min-height: 26px; max-width: 100%; font-size: 12px; text-align: left; }
.sync-compact span { white-space: normal; overflow-wrap: anywhere; }
.sync-dialog { width: min(520px, calc(100% - 32px)); padding: 24px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--ink); max-height: calc(100dvh - 32px); overflow: auto; }
.sync-dialog::backdrop { background: rgb(0 0 0 / 45%); }
.sync-dialog h2, .sync-stale-notice h2 { font-size: 18px; margin: 0 0 12px; }
.sync-dialog p, .sync-stale-notice p { line-height: 1.7; font-size: 14px; color: var(--muted); overflow-wrap: anywhere; margin-bottom: 20px; }
.sync-dialog-actions { justify-content: flex-end; }
.sync-dialog-actions button { width: auto; }
.sync-stale-notice { position: fixed; inset: 0; z-index: 11000; background: rgb(0 0 0 / 55%); display: grid; place-items: center; padding: 16px; }
.sync-stale-notice section { width: min(460px, 100%); border-radius: 8px; padding: 24px; background: var(--surface); color: var(--ink); }
.sync-settings [hidden], .sync-compact[hidden], .sync-stale-notice[hidden] { display: none !important; }
@media (max-width: 600px) {
  .sync-actions { gap: 8px; }
  .sync-actions button { flex: 1 1 140px; white-space: normal; }
  .sync-dialog { padding: 18px; }
  .sync-dialog-actions button { flex: 1 1 140px; white-space: normal; }
  .sync-device-row input { flex: 1; min-width: 0; }
  #syncLastSaved { width: 100%; }
}

/* Whole teaching document control, next to the account in the upper right. */
.header-account { display: flex; align-items: center; gap: 10px; }
.header-account .sync-compact { display: inline-flex; align-items: center; justify-content: center; gap: 7px; min-height: 40px; padding: 7px 10px; border: 1px solid var(--line, #d8d8dc); border-radius: 8px; background: var(--surface); white-space: nowrap; }
.sync-status-icon { width: 20px; height: 20px; flex: 0 0 20px; }
.sync-compact.is-syncing .sync-status-icon { animation: teacher-sync-spin 1s linear infinite; }
.sync-compact[data-state="saved"] { color: #217249; }
.sync-compact[data-state="pending"], .sync-compact[data-state="conflict"], .sync-compact[data-state="error"] { color: #a25700; }
.sync-document-scope { color: var(--muted); font-size: 13px; line-height: 1.6; margin: 0 0 14px; }
@keyframes teacher-sync-spin { to { transform: rotate(-360deg); } }
@media (max-width: 600px) { .header-account { gap: 6px; } .header-account .sync-compact { font-size: 11px; gap: 4px; padding: 6px; } }
@media (prefers-reduced-motion: reduce) { .sync-compact.is-syncing .sync-status-icon { animation-duration: 3s; } }

/* V1.1 settings: frequent actions first, backup tools on demand. */
#settingsWorkspace .sync-settings { padding: 4px 0 18px; }
.sync-primary-row { display:flex; align-items:center; justify-content:space-between; gap:12px; flex-wrap:wrap; }
.sync-more { margin-top:14px; border:1px solid var(--line); border-radius:12px; padding:0 14px; }
.sync-more summary { display:flex; justify-content:space-between; align-items:center; cursor:pointer; min-height:44px; font-size:13px; color:var(--muted); list-style:none; }
.sync-more summary::-webkit-details-marker { display:none; }
.sync-more[open] { padding-bottom:14px; }
.sync-more[open] summary span { transform:rotate(180deg); }
.sync-recovery-actions:has(button:not([hidden])) { margin-top:12px; }
@media(max-width:600px) { .sync-primary-row { align-items:stretch; } .sync-primary-row>.sync-actions { width:100%; display:grid; grid-template-columns:1fr 1fr; } .sync-primary-row>.sync-actions button { min-width:0; } .sync-more .sync-actions { display:grid; grid-template-columns:1fr 1fr; } }

.header-account .sync-compact{color:#c4383e}.header-account .sync-compact[data-state="saved"]{color:#218657}.header-account .sync-compact.is-syncing{color:#c4383e}.sync-result-toast{position:fixed;z-index:100000;top:calc(env(safe-area-inset-top,0px) + 20px);left:50%;transform:translateX(-50%);padding:11px 25px;border:1px solid #b8dcc6;border-radius:12px;background:#edf9f1;color:#187548;box-shadow:0 8px 30px #102a2420;font-size:15px;font-weight:700;pointer-events:none}.sync-result-toast[data-success="false"]{background:#fff0f0;border-color:#efc1c3;color:#bd3037}.sync-result-toast[hidden]{display:none!important}
