:root {
  --bg: #f6f5f2;
  --surface: #ffffff;
  --text: #1c1c1a;
  --muted: #6b6a65;
  --line: #e4e2dc;
  --accent: #2f5d50;
  --accent-soft: #e3ece8;
  --wait: #a4520f;
  --wait-soft: #f8eadb;
  --work: #285a8c;
  --work-soft: #e2ecf6;
  --danger: #b3261e;
  --user: #2f5d50;
  --user-text: #ffffff;
  --radius: 14px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #161615; --surface: #222220; --text: #ecebe7; --muted: #9c9a94; --line: #34332f;
    --accent: #7fb8a5; --accent-soft: #24332e; --wait: #f0a35e; --wait-soft: #3a2a1b;
    --work: #8db9e8; --work-soft: #1f2c3a; --danger: #f2827a; --user: #2f5d50; --user-text: #f6f5f2;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
}
main { max-width: 680px; margin: 0 auto; padding: env(safe-area-inset-top, 0) 16px calc(24px + var(--safe-b)); }
button, textarea, input { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--accent); }
[hidden] { display: none !important; }

/* ---------- header ---------- */
.bar { display: flex; align-items: center; gap: 8px; min-height: 56px; position: sticky; top: 0; z-index: 5; background: var(--bg); }
.bar h1 { flex: 1; font-size: 22px; margin: 0; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar h1.small { font-size: 17px; }
.icon-btn {
  width: 40px; height: 40px; border-radius: 20px; border: 0; background: transparent;
  display: grid; place-items: center; color: var(--muted); flex: none;
}
.icon-btn:active { background: var(--line); }
.icon-btn svg { width: 22px; height: 22px; }

/* ---------- capture ---------- */
.capture { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 10px 10px 14px; display: flex; gap: 8px; align-items: flex-end; }
.capture textarea { flex: 1; border: 0; background: transparent; resize: none; outline: none; min-height: 26px; max-height: 40vh; padding: 4px 0; }
.btn {
  border: 0; border-radius: 10px; padding: 8px 14px; background: var(--accent); color: var(--bg); font-weight: 600; flex: none;
}
.btn:disabled { opacity: .4; }
.btn.ghost { background: var(--accent-soft); color: var(--accent); }
.btn.danger { background: transparent; color: var(--danger); border: 1px solid var(--line); }
.hint { color: var(--muted); font-size: 13px; margin: 6px 2px 0; }

.warning { background: var(--wait-soft); color: var(--wait); border-radius: var(--radius); padding: 10px 14px; margin: 8px 0; font-size: 14px; }

details.fold { margin-top: 14px; }
details.fold summary { color: var(--muted); font-size: 14px; padding: 6px 2px; list-style: none; cursor: pointer; }
details.fold summary::-webkit-details-marker { display: none; }
details.fold summary::before { content: "▸ "; }
details.fold[open] summary::before { content: "▾ "; }
.capture-item { font-size: 14px; color: var(--muted); padding: 6px 2px; border-top: 1px solid var(--line); white-space: pre-wrap; overflow-wrap: anywhere; }
.capture-item.pending::after { content: " · čeká na odeslání"; color: var(--wait); }

/* ---------- list ---------- */
.list { list-style: none; padding: 0; margin: 14px 0 0; }
.row {
  position: relative; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  margin-bottom: 8px; overflow: hidden; touch-action: pan-y; user-select: none; -webkit-user-select: none;
}
.row .swipe-action {
  position: absolute; inset: 0 0 0 auto; width: 96px; border: 0; background: var(--danger); color: #fff; font-weight: 600;
}
.row .content { position: relative; display: flex; align-items: stretch; background: var(--surface); transition: transform .18s ease; }
.row.dragging { box-shadow: 0 8px 24px rgba(0,0,0,.18); z-index: 10; border-color: var(--accent); }
.row.dragging .content { transition: none; }
.handle { width: 40px; flex: none; display: grid; place-items: center; color: var(--muted); touch-action: none; cursor: grab; border: 0; background: transparent; }
.handle svg { width: 18px; height: 18px; }
.main { flex: 1; min-width: 0; padding: 12px 14px 12px 0; border: 0; background: transparent; text-align: left; }
.title { font-weight: 600; display: flex; gap: 6px; align-items: center; }
.title span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dot { width: 8px; height: 8px; border-radius: 4px; background: var(--wait); flex: none; }
.pin { width: 14px; height: 14px; color: var(--muted); flex: none; }
.meta { display: flex; gap: 8px; align-items: baseline; margin-top: 3px; font-size: 14px; color: var(--muted); min-width: 0; }
.meta .step { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.badge { font-size: 12px; font-weight: 600; padding: 1px 8px; border-radius: 999px; flex: none; white-space: nowrap; }
.badge.fronta { background: var(--line); color: var(--muted); }
.badge.pracuje { background: var(--work-soft); color: var(--work); }
.badge.ceka { background: var(--wait-soft); color: var(--wait); }
.badge.odlozeno { background: var(--line); color: var(--muted); }
.badge.uzavreno { background: transparent; color: var(--muted); border: 1px solid var(--line); }
.due { color: var(--wait); flex: none; }
.empty { color: var(--muted); text-align: center; padding: 32px 8px; }
.closed .row { opacity: .7; }
.snoozed .row { opacity: .85; }

/* ---------- item thread ---------- */
.thread { display: flex; flex-direction: column; gap: 10px; padding: 8px 0 16px; }
.bubble { max-width: 88%; border-radius: 16px; padding: 10px 14px; white-space: pre-wrap; overflow-wrap: anywhere; }
.bubble.user { align-self: flex-end; background: var(--user); color: var(--user-text); border-bottom-right-radius: 4px; }
.bubble.agent { align-self: flex-start; background: var(--surface); border: 1px solid var(--line); border-bottom-left-radius: 4px; }
.bubble.failed { align-self: flex-start; background: transparent; border: 1px dashed var(--line); color: var(--muted); font-size: 14px; }
.bubble .when { display: block; font-size: 12px; opacity: .7; margin-top: 4px; }
.bubble .label { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; opacity: .75; display: block; margin-bottom: 2px; }
.next { margin-top: 8px; padding: 8px 10px; border-radius: 10px; background: var(--wait-soft); color: var(--text); }
.next .label { color: var(--wait); opacity: 1; }
.files { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.files a { font-size: 14px; padding: 4px 10px; border-radius: 999px; background: var(--accent-soft); text-decoration: none; }
.files a .size { color: var(--muted); }
.bubble .warning.skipped { font-size: 13px; overflow-wrap: anywhere; }
.card.download { display: flex; flex-direction: column; align-items: flex-start; gap: 10px; }
.card.download p { margin: 0; }
.status-note { text-align: center; color: var(--muted); font-size: 14px; padding: 4px 0; }

.composer {
  position: sticky; bottom: 0; background: var(--bg); padding: 8px 0 calc(8px + var(--safe-b));
  border-top: 1px solid var(--line);
}
.chips { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 8px; scrollbar-width: none; }
.chip { border: 1px solid var(--accent); color: var(--accent); background: transparent; border-radius: 999px; padding: 6px 12px; white-space: nowrap; font-size: 15px; }
.composer .capture { border-radius: 22px; }
.item-actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; padding: 6px 0 12px; }

/* ---------- postponing ("Odložit") ---------- */
.bubble.reminder .label { color: var(--wait); opacity: 1; }
.sheet { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; margin: 0 0 12px; }
.sheet h2 { font-size: 16px; margin: 0 0 8px; }
.sheet input { display: block; width: 100%; min-height: 44px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); padding: 10px; margin-bottom: 8px; }
.sheet .chips { flex-wrap: wrap; overflow: visible; }
.chip.on { background: var(--accent); color: var(--bg); }
.sheet .hint { margin: 0 2px 10px; }
.sheet-actions { display: flex; gap: 8px; }

/* ---------- a change to the app (self-development) ---------- */
.bubble.change { max-width: 100%; align-self: stretch; min-width: 0; }
.bubble.handoff .label { color: var(--work); opacity: 1; }
.change-meta { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 8px; font-size: 13px; color: var(--muted); }
.ok { color: var(--accent); font-weight: 600; }
.bad { color: var(--danger); font-weight: 600; }
.bubble .warning { margin: 8px 0 0; }
pre.code {
  font: 12px/1.45 ui-monospace, Menlo, monospace; white-space: pre; overflow-x: auto; overflow-wrap: normal;
  background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; margin: 8px 0 0;
}
details.diff { margin-top: 8px; }
details.diff summary { color: var(--accent); font-size: 14px; cursor: pointer; }
details.diff pre.code { max-height: 70vh; overflow: auto; }
.change-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.step.deploying, .status-note.deploying { color: var(--work); }
.deploy-row .hint { margin: 0 0 6px; overflow-wrap: anywhere; }
.device .ok, .device .bad { flex: none; }

/* ---------- a delivered file: Markdown, text, image, prototype ---------- */
a.icon-btn { text-decoration: none; }
.md { padding: 4px 0 24px; overflow-wrap: anywhere; }
.md h1 { font-size: 22px; margin: 16px 0 8px; }
.md h2 { font-size: 19px; margin: 18px 0 6px; }
.md h3 { font-size: 17px; margin: 14px 0 4px; }
.md h4, .md h5, .md h6 { font-size: 16px; margin: 12px 0 4px; }
.md p { margin: 0 0 10px; }
.md ul, .md ol { margin: 0 0 10px; padding-left: 22px; }
.md li { margin: 2px 0; }
.md li > ul, .md li > ol { margin-bottom: 0; }
.md li.task { list-style: none; margin-left: -20px; }
.md li.task input { margin: 0 4px 0 0; vertical-align: -1px; accent-color: var(--accent); }
.md blockquote { margin: 0 0 10px; padding: 2px 12px; border-left: 3px solid var(--line); color: var(--muted); }
.md code { font: 13px/1.4 ui-monospace, Menlo, monospace; background: var(--surface); border: 1px solid var(--line); border-radius: 5px; padding: 1px 4px; }
.md pre.code { background: var(--surface); margin: 0 0 10px; }
.md pre.code code { background: none; border: 0; padding: 0; font-size: 12px; }
.md .table-wrap { overflow-x: auto; margin: 0 0 10px; -webkit-overflow-scrolling: touch; }
.md table { border-collapse: collapse; font-size: 14px; width: 100%; }
.md th, .md td { border: 1px solid var(--line); padding: 5px 8px; text-align: left; vertical-align: top; overflow-wrap: normal; }
.md th { background: var(--surface); }
.md .al-c { text-align: center; }
.md .al-r { text-align: right; }
.md hr { border: 0; border-top: 1px solid var(--line); margin: 14px 0; }
.md img { max-width: 100%; height: auto; border-radius: 10px; }
.md a[target] { word-break: break-all; }
.frame { position: fixed; top: calc(56px + env(safe-area-inset-top, 0px)); left: 0; right: 0; bottom: 0; overflow: auto; -webkit-overflow-scrolling: touch; background: #fff; }
.frame iframe { width: 100%; height: 100%; border: 0; display: block; }
.preview { display: block; max-width: 100%; height: auto; margin: 12px auto; border-radius: 10px; }

/* ---------- settings ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; margin: 12px 0; }
.card h2 { font-size: 16px; margin: 0 0 8px; }
.card p { margin: 0 0 10px; color: var(--muted); font-size: 14px; }
.card textarea { width: 100%; min-height: 120px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); padding: 10px; resize: vertical; }
.card input { width: 100%; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); padding: 10px; margin-bottom: 8px; }
.device { display: flex; align-items: center; gap: 8px; padding: 6px 0; border-top: 1px solid var(--line); font-size: 14px; }
.device span { flex: 1; }
.code { font: 600 24px/1.2 ui-monospace, Menlo, monospace; letter-spacing: .12em; text-align: center; padding: 8px; }
.audit-days a { display: block; padding: 8px 0; border-top: 1px solid var(--line); text-decoration: none; }
pre.audit { white-space: pre-wrap; overflow-wrap: anywhere; font: 13px/1.45 ui-monospace, Menlo, monospace; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; }

/* ---------- login ---------- */
.login { min-height: 80vh; display: flex; flex-direction: column; justify-content: center; gap: 12px; }
.login h1 { font-size: 28px; margin: 0; }
.login p { color: var(--muted); margin: 0; }
.login .btn { padding: 12px; font-size: 17px; }
.error { color: var(--danger); font-size: 14px; }

#toast {
  position: fixed; left: 50%; bottom: calc(24px + var(--safe-b)); transform: translateX(-50%);
  background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 12px; font-size: 14px; z-index: 50; max-width: calc(100vw - 32px);
}

/* ---------- published files ("Zveřejnit") ---------- */
.files .file { display: inline-flex; align-items: stretch; border-radius: 999px; background: var(--accent-soft); overflow: hidden; }
.files .file a { border-radius: 0; padding-right: 6px; }
.share-btn { display: inline-flex; align-items: center; gap: 4px; border: 0; border-left: 1px solid var(--line); background: transparent; color: var(--accent); font-size: 13px; padding: 4px 10px 4px 8px; }
.share-btn svg { width: 15px; height: 15px; }
.files .file.public { background: var(--accent); }
.files .file.public a, .files .file.public .share-btn { color: var(--bg); background: transparent; }
.shares { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; white-space: normal; }
.share { border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; background: var(--bg); font-size: 14px; }
.share-title { display: flex; align-items: center; gap: 6px; font-weight: 600; overflow-wrap: anywhere; }
.share-title svg { width: 16px; height: 16px; flex: none; color: var(--accent); }
.share-url { font: 13px/1.4 ui-monospace, Menlo, monospace; word-break: break-all; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px; margin: 6px 0 0; user-select: all; -webkit-user-select: all; }
.share .hint { margin: 6px 0 0; }
.share-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.share-row { flex: 1; min-width: 0; text-decoration: none; color: var(--text); overflow-wrap: anywhere; }
.share-row span, .share-row small { display: block; }
.share-row small { color: var(--muted); font-size: 13px; }
