:root {
  --bg: #f4f1ea;
  --surface: #ffffff;
  --text: #1f2933;
  --muted: #6b7280;
  --accent: #0f766e;
  --mine: #0f766e;
  --mine-text: #ffffff;
  --theirs: #ffffff;
  --theirs-text: #1f2933;
  --border: #e5e1d8;
  --online: #22c55e;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d1117;
    --surface: #161b22;
    --text: #e6edf3;
    --muted: #8b949e;
    --accent: #2dd4bf;
    --mine: #0f766e;
    --theirs: #21262d;
    --theirs-text: #e6edf3;
    --border: #30363d;
  }
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font: 16px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-tap-highlight-color: transparent;
}
[hidden] { display: none !important; }
button {
  font: inherit; border: 0; border-radius: 999px; padding: 10px 18px;
  background: var(--accent); color: #fff; cursor: pointer;
}
button.secondary { background: transparent; color: var(--text); border: 1px solid var(--border); }
input, textarea {
  font: inherit; color: var(--text); background: var(--surface);
  border: 1px solid var(--border); border-radius: 12px; padding: 10px 12px; width: 100%;
}

.screen { height: 100dvh; display: flex; flex-direction: column; }

/* login */
#login { align-items: center; justify-content: center; padding: 16px; }
.card {
  width: 100%; max-width: 340px; background: var(--surface); padding: 28px 24px;
  border-radius: 20px; display: flex; flex-direction: column; gap: 14px;
  box-shadow: 0 10px 30px rgba(0,0,0,.08);
}
.card h1 { margin: 0 0 6px; text-align: center; font-size: 22px; }
.card label { display: flex; flex-direction: column; gap: 6px; font-size: 14px; color: var(--muted); }
.logo { font-size: 44px; text-align: center; }
.error { color: #dc2626; min-height: 1.2em; margin: 0; font-size: 14px; text-align: center; }

/* chat */
.bar {
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(env(safe-area-inset-top) + 10px) 16px 10px;
  background: var(--surface); border-bottom: 1px solid var(--border);
}
.who { display: flex; align-items: center; gap: 10px; }
.peer-name { font-weight: 600; }
.peer-status { font-size: 13px; color: var(--muted); }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--border); }
.dot.on { background: var(--online); }
.icon-btn { background: transparent; color: var(--text); font-size: 22px; padding: 4px 10px; }

.banner {
  display: flex; gap: 10px; align-items: center; justify-content: space-between;
  padding: 10px 16px; background: #fef3c7; color: #78350f; font-size: 14px;
}
.banner button { padding: 6px 14px; flex-shrink: 0; }

#messages {
  flex: 1; overflow-y: auto; padding: 12px 12px 4px;
  display: flex; flex-direction: column; gap: 3px; overscroll-behavior: contain;
}
.day { align-self: center; font-size: 12px; color: var(--muted); margin: 12px 0 6px; }
.msg {
  max-width: 78%; padding: 8px 12px; border-radius: 18px; white-space: pre-wrap;
  word-wrap: break-word; position: relative;
}
.msg.theirs { align-self: flex-start; background: var(--theirs); color: var(--theirs-text); border-bottom-left-radius: 6px; }
.msg.mine { align-self: flex-end; background: var(--mine); color: var(--mine-text); border-bottom-right-radius: 6px; }
.msg.pending { opacity: .6; }
.msg .time { font-size: 11px; opacity: .7; margin-left: 8px; float: right; margin-top: 6px; }
.msg + .msg.gap { margin-top: 8px; }
.seen { align-self: flex-end; font-size: 12px; color: var(--muted); margin: 2px 4px 4px; }

.typing {
  display: flex; align-items: center; gap: 8px; padding: 4px 16px 6px;
  font-size: 13px; color: var(--muted);
}
.typing-text-live { font-style: italic; color: var(--text); }
.typing-dots { display: inline-flex; gap: 3px; }
.typing-dots i {
  width: 6px; height: 6px; border-radius: 50%; background: var(--muted);
  animation: blink 1.2s infinite;
}
.typing-dots i:nth-child(2) { animation-delay: .2s; }
.typing-dots i:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%, 80%, 100% { opacity: .25; } 40% { opacity: 1; } }

.composer {
  display: flex; gap: 8px; align-items: flex-end;
  padding: 8px 10px;
  background: var(--surface); border-top: 1px solid var(--border);
}
.composer textarea { resize: none; max-height: 140px; border-radius: 20px; }
.composer button { width: 44px; height: 44px; padding: 0; flex-shrink: 0; font-size: 18px; }

dialog {
  border: 0; border-radius: 18px; padding: 20px; width: min(92vw, 380px);
  background: var(--surface); color: var(--text);
}
dialog::backdrop { background: rgba(0,0,0,.4); }
dialog h2 { margin: 0 0 14px; font-size: 18px; }
.row { display: flex; gap: 10px; align-items: center; margin: 10px 0; }
.row input { width: auto; }
.help { font-size: 13px; color: var(--muted); }
.actions { display: flex; justify-content: space-between; margin-top: 18px; }

/* views and tabs */
.view { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.list-view { overflow-y: auto; padding: 12px 14px 20px; gap: 12px; }
.view-head { display: flex; align-items: center; justify-content: space-between; }
.view-head h2 { margin: 0; font-size: 20px; }
.view-head button { padding: 8px 14px; font-size: 14px; }
.tabs {
  display: flex; background: var(--surface); border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom);
}
.tab {
  flex: 1; background: transparent; color: var(--muted); border-radius: 0;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 8px 0 6px; font-size: 20px; position: relative;
}
.tab span { font-size: 11px; }
.tab.active { color: var(--accent); }
.tab.active span { font-weight: 600; }
.badge {
  position: absolute; top: 4px; left: calc(50% + 6px); min-width: 16px; height: 16px; padding: 0 4px;
  border-radius: 8px; background: #ef4444; color: #fff; font: 600 10px/16px sans-serif;
}
#badge-chat:empty { width: 10px; min-width: 10px; height: 10px; top: 6px; padding: 0; }
.empty { color: var(--muted); text-align: center; padding: 24px 8px; list-style: none; }
.danger { color: #dc2626 !important; border-color: #fca5a5 !important; }

/* photos and Claude in the chat */
.icon-btn.round { width: 44px; height: 44px; padding: 0; font-size: 20px; flex-shrink: 0; }
.msg.has-photo { padding: 4px; }
.msg img {
  display: block; max-width: 100%; max-height: 360px; border-radius: 14px; cursor: zoom-in;
  margin-bottom: 2px; min-width: 120px; background: var(--border);
}
.msg.has-photo .time { margin: 2px 8px 4px; }
.msg.bot { background: #ede9fe; color: #3b0764; }
@media (prefers-color-scheme: dark) { .msg.bot { background: #2e1065; color: #ede9fe; } }
.sender { font-size: 12px; font-weight: 700; margin-bottom: 2px; opacity: .8; }
.photo-viewer { padding: 0; background: transparent; max-width: 100vw; max-height: 100vh; }
.photo-viewer img { display: block; max-width: 96vw; max-height: 90vh; border-radius: 12px; }
.photo-viewer::backdrop { background: rgba(0,0,0,.85); }

/* notes */
.cards { display: flex; flex-direction: column; gap: 10px; }
.card-item {
  display: block; text-align: left; width: 100%; background: var(--surface); color: var(--text);
  border: 1px solid var(--border); border-radius: 14px; padding: 12px 14px; position: relative;
}
.card-item strong { display: block; margin-bottom: 4px; }
.card-item p { margin: 0 0 6px; color: var(--muted); white-space: pre-wrap; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; }
.card-item small { color: var(--muted); font-size: 12px; }
.note-dialog { width: min(96vw, 560px); }
.note-dialog form { display: flex; flex-direction: column; gap: 10px; }
.note-dialog #note-title { font-weight: 600; font-size: 17px; }
.note-dialog textarea { resize: vertical; min-height: 40vh; }
.note-dialog .actions { align-items: center; margin-top: 4px; }
.note-dialog .actions span { display: flex; gap: 8px; }

/* to-dos */
.todo-add { display: flex; gap: 8px; align-items: flex-end; }
.todo-add button { flex-shrink: 0; }
.todos { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.todos li:not(.empty) {
  display: flex; align-items: center; gap: 10px; background: var(--surface);
  border: 1px solid var(--border); border-radius: 12px; padding: 8px 6px 8px 12px;
}
.todos input[type=checkbox] { width: 22px; height: 22px; flex-shrink: 0; accent-color: var(--accent); }
.todo-text { flex: 1; word-break: break-word; }
.todos li.done .todo-text { text-decoration: line-through; color: var(--muted); }
.who-chip {
  font-size: 11px; color: var(--muted); border: 1px solid var(--border); border-radius: 999px;
  padding: 1px 7px; flex-shrink: 0;
}
.icon-btn.del { font-size: 20px; color: var(--muted); padding: 2px 8px; }
.done-wrap summary { color: var(--muted); padding: 8px 2px; cursor: pointer; }

/* private */
.vault-gate { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 16px; }
.vault-gate p:first-child { margin-top: 0; color: var(--muted); font-size: 14px; }
.vault-gate form { display: flex; flex-direction: column; gap: 10px; }
#vault-open { display: flex; flex-direction: column; gap: 12px; }
#vault-open[hidden] { display: none; }
.vault-item p { color: var(--text); -webkit-line-clamp: unset; display: block; padding-right: 24px; }
.vault-item .del { position: absolute; top: 4px; right: 4px; }
