# Offline state

> How Kwark says work is kept on this device: a tag on the project, a word at the corner, and a banner only when a choice is needed.

Source: https://kwark.space/designSystem/components/offline-state

## Usage

### What it is
Kwark keeps work on the device first and sends it to the cloud when it can. So "offline" is not an error; it is where the work is. Four real pieces say so:

| Where | Words | When |
|---|---|---|
| Project card or row tag | *Only on this device* | a guest story, kept here until sign-in |
| Project card or row tag | *Not synced yet* | changes on this device not yet in the cloud; its title gives the count |
| Corner word | *Saved on this device* | the screenplay saved while offline |
| Toast | *Kept on this device; it will sync when you are back online.* | Cmd+S while offline |
| Banner | *This screenplay has not downloaded to this device…* **Try again** | the copy here is incomplete, so nothing is saved |

The account panel adds *Safe on this device (offline by choice)* when someone switches to working offline.

### When to use
- Whenever the place the work lives is not the cloud.

### When not to use
- To warn about a slow network. If the save happens, say *Saved*.

### Writing
Name the place: *on this device*. Say what is safe before what is not (Decision 0013). Tooltips give the detail: *2 changes are saved on this device and not in the cloud yet. Keep this device online, or open the story here, before working on it elsewhere.*

## Style

### Anatomy

1. **Tag**: 2px 8px, 999px corners, 1px border `color-mix(--k-accent-soft 45%)`, `--k-accent-soft` text, 12px Poppins, cloud-off glyph 14px, 4px gap (`.home-project__tag`).
2. **Banner**: full width, sticky to the top of the editor, 10px 16px, 1px bottom border `color-mix(tone 35%)`, background `color-mix(tone 12%, --k-bg)`, 12px Poppins 500, the lead sentence in bold tone colour, actions at the end (`ScriptSyncStatus`).

### Tokens

| Token | Light | Dark |
|---|---|---|
| `--k-accent-soft` | #e8b58b | #e8b58b |
| `--k-warn` | #8a5a00 | #d8a44a |
| `--k-text` | #0f172a | #e3e3e3 |
| `--k-line` | #e2e8f0 | rgba(255, 255, 255, .1) |
| `--k-bg` | #f8fafc | #191919 |
| `--k-radius-pill` | 999px |  |
| `--k-fs-meta` | 12px |  |

## Code

### React

Use the HTML below with `kwark.css`. The example shows the markup and styling. Supply any application behavior described on this page.

### HTML and CSS

Works anywhere with `kwark.css`.

```html
<div class="kw-offline-demo">
  <span class="kw-offline-tag"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="m2 2 20 20M5.8 5.8A7 7 0 0 0 9 19h8.5a4.5 4.5 0 0 0 1.3-.2M21.5 15.5A4.5 4.5 0 0 0 17.5 10h-1.8A7 7 0 0 0 9.9 5.1"/></svg>Only on this device</span>
  <span class="kw-offline-tag"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="m2 2 20 20M5.8 5.8A7 7 0 0 0 9 19h8.5a4.5 4.5 0 0 0 1.3-.2M21.5 15.5A4.5 4.5 0 0 0 17.5 10h-1.8A7 7 0 0 0 9.9 5.1"/></svg>Not synced yet</span>
  <div class="kw-sync-banner" role="status"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="m2 2 20 20M5.8 5.8A7 7 0 0 0 9 19h8.5a4.5 4.5 0 0 0 1.3-.2M21.5 15.5A4.5 4.5 0 0 0 17.5 10h-1.8A7 7 0 0 0 9.9 5.1"/></svg><span><strong>This screenplay has not downloaded to this device.</strong> Nothing will be saved until it does, so the copy elsewhere stays exactly as it is.</span><button class="kw-button kw-button--sm" type="button">Try again</button></div>
</div>
```

## Accessibility

### Keyboard
| Key | Does |
|---|---|
| Tab | Reaches the banner’s Try again. Tags are not focusable; their detail is also in the project’s own page. |

### ARIA
- The banner is `role="status"`. The tag’s `title` must not be the only place the count lives on touch screens; repeat it where the story opens.

## For agents

### Rules

- **Must** say where the work is (*on this device*), never just *Offline*.
- **Never** call keeping work locally a failure.
- **Must** stop saving and say so when the local copy is incomplete (*Not downloaded*), so the cloud copy stays intact.
- **Always** offer Try again on the banner.

### AI readiness test

**Task:** Show that Mira's character edits are waiting to reach the cloud.

**Give the agent:** This page, Decision 0013, the Sync status page.

**Constraint:** Three edits are queued; the cloud is unreachable.

**A reliable answer:**
- Uses Saved on this device at the corner
- Adds a Not synced yet tag with "3 changes" in its detail
- Never uses failed or error
- Offers no banner unless a decision is needed
