/* Bundles: black and white, rounded. Two panes on wide screens, one at a time on phones. */
:root {
  --bg: #efefef;
  --surface: #ffffff;
  --soft: #f3f3f3;
  --hover: #ebebeb;
  --line: #e2e2e2;
  --text: #0b0b0b;
  --muted: #6e6e6e;
  --ink: #0b0b0b;        /* filled buttons, active row */
  --on-ink: #ffffff;
  --radius-xl: 24px;
  --radius-l: 18px;
  --radius-m: 14px;
  --radius-s: 10px;
  --side: 360px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #000000;
    --surface: #0e0e0e;
    --soft: #1a1a1a;
    --hover: #202020;
    --line: #262626;
    --text: #f4f4f4;
    --muted: #9b9b9b;
    --ink: #f4f4f4;
    --on-ink: #000000;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; }
h1, h2 { margin: 0; line-height: 1.25; }
h2 { font-size: 1rem; font-weight: 650; }
p { margin: 0; }
button { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--text); outline-offset: 2px; }

.js-only { display: none !important; }
.js .js-only { display: inline-flex !important; }
.hint { color: var(--muted); font-size: .875rem; font-weight: 400; }
.error { font-weight: 600; padding: 10px 14px; border: 2px solid var(--text); border-radius: var(--radius-m); }
.flash { padding: 10px 14px; border-radius: var(--radius-m); background: var(--soft); font-weight: 500; }

/* ---- buttons ---- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 42px; padding: 0 18px; border-radius: 999px;
  border: 1.5px solid var(--line); background: var(--surface);
  font-weight: 600; text-decoration: none; cursor: pointer; white-space: nowrap;
}
.btn:hover { background: var(--hover); }
.btn.primary { background: var(--ink); color: var(--on-ink); border-color: var(--ink); }
.btn.primary:hover { opacity: .88; }
.btn.outline-strong { border-color: var(--text); }
.btn.wide { width: 100%; }
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center; flex: none;
  width: 40px; height: 40px; border-radius: 50%; color: var(--text); text-decoration: none;
}
.icon-btn:hover { background: var(--hover); }
.text-btn { background: none; border: 0; padding: 0; cursor: pointer; font-weight: 600; text-decoration: underline; text-underline-offset: 3px; }

/* ---- avatars: a photo or a letter ---- */
.avatar {
  flex: none; width: 46px; height: 46px; border-radius: 16px; object-fit: cover;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--ink); color: var(--on-ink); font-weight: 700; font-size: 1.15rem; letter-spacing: -.02em;
}
.avatar.small { width: 32px; height: 32px; border-radius: 50%; font-size: .9rem; }
.big-icon .avatar { width: 96px; height: 96px; border-radius: 30px; font-size: 2.4rem; }

/* ---- login and error ---- */
.solo { min-height: 100%; display: grid; place-items: center; padding: 16px; }
.solo-card {
  width: 100%; max-width: 440px; padding: 40px 28px; text-align: center;
  background: var(--surface); border-radius: var(--radius-xl); border: 1px solid var(--line);
  display: grid; gap: 16px; justify-items: center;
}
.solo-card h1 { font-size: 1.6rem; letter-spacing: -.02em; }
.lead { color: var(--muted); font-size: 1.05rem; }
.mark {
  width: 64px; height: 64px; border-radius: 22px; background: var(--ink); color: var(--on-ink);
  display: grid; place-items: center; font-weight: 800; font-size: 1.8rem;
}

/* ---- app shell ---- */
.shell {
  height: 100vh; height: 100dvh;
  display: grid; grid-template-columns: var(--side) minmax(0, 1fr); gap: 12px; padding: 12px;
}
.sidebar, .pane {
  min-height: 0; display: flex; flex-direction: column;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-xl); overflow: hidden;
}
.mobile-only { display: none; }

/* sidebar */
.side-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 14px 8px 20px; }
.brand { font-weight: 800; font-size: 1.35rem; letter-spacing: -.03em; text-decoration: none; }
.list { flex: 1; overflow-y: auto; padding: 4px 8px 8px; display: grid; align-content: start; gap: 2px; }
.row {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: var(--radius-l);
  text-decoration: none; min-width: 0;
}
.row:hover { background: var(--hover); }
.row.active { background: var(--ink); color: var(--on-ink); }
.row.active .avatar.letter { background: var(--on-ink); color: var(--ink); }
.row.active .row-sub, .row.active .row-time { color: inherit; opacity: .7; }
.row-text { flex: 1; min-width: 0; display: grid; gap: 1px; }
.row-top { display: flex; align-items: baseline; gap: 8px; }
.row-title { flex: 1; font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-time { flex: none; font-size: .78rem; color: var(--muted); }
.row-sub { color: var(--muted); font-size: .875rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-empty { padding: 16px 12px; color: var(--muted); }

.side-foot { border-top: 1px solid var(--line); padding: 14px 16px 14px; display: grid; gap: 14px; }
.me { display: flex; align-items: center; gap: 10px; min-width: 0; }
.me-text { flex: 1; min-width: 0; display: grid; }
.me-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.me-plan { color: var(--muted); font-size: .8rem; }
.me form { margin: 0; }
.me .text-btn { font-size: .85rem; }

/* storage meter */
.storage { display: grid; gap: 6px; }
.storage-line { display: flex; justify-content: space-between; font-size: .85rem; font-weight: 600; }
.storage-nums { color: var(--muted); font-size: .8rem; }
.storage progress {
  -webkit-appearance: none; appearance: none; width: 100%; height: 8px; border: 0;
  border-radius: 999px; overflow: hidden; background: var(--soft);
}
.storage progress::-webkit-progress-bar { background: var(--soft); border-radius: 999px; }
.storage progress::-webkit-progress-value { background: var(--ink); border-radius: 999px; }
.storage progress::-moz-progress-bar { background: var(--ink); border-radius: 999px; }
.storage-msg { font-size: .85rem; font-weight: 600; padding: 10px 12px; border-radius: var(--radius-m); border: 2px solid var(--text); }
.storage.full .storage-msg { background: var(--ink); color: var(--on-ink); border-color: var(--ink); }

/* pane */
.pane-head {
  display: flex; align-items: center; gap: 8px; min-height: 68px; padding: 10px 12px 10px 14px;
  border-bottom: 1px solid var(--line);
}
.pane-title { font-size: 1.05rem; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.head-link { flex: 1; min-width: 0; display: flex; align-items: center; gap: 12px; text-decoration: none; padding: 4px 8px 4px 4px; border-radius: var(--radius-l); }
.head-link:hover { background: var(--hover); }
.head-link .avatar { width: 42px; height: 42px; border-radius: 14px; font-size: 1.05rem; }
.head-text { min-width: 0; display: grid; }
.head-sub { color: var(--muted); font-size: .85rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pane-body { flex: 1; overflow-y: auto; padding: 20px; display: grid; align-content: start; gap: 14px; max-width: 760px; width: 100%; margin: 0 auto; }
.pane-empty { flex: 1; display: grid; place-content: center; justify-items: center; gap: 16px; padding: 24px; text-align: center; color: var(--muted); }

/* cards and forms */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-l); padding: 18px; display: grid; gap: 12px; }
.form label { display: grid; gap: 6px; font-weight: 600; font-size: .9rem; }
input, textarea {
  font: inherit; color: var(--text); background: var(--soft); width: 100%;
  border: 1.5px solid transparent; border-radius: var(--radius-m); padding: 11px 14px;
}
input:focus, textarea:focus { outline: none; border-color: var(--text); background: var(--surface); }
input.short { width: 6em; text-align: center; font-weight: 700; }
textarea { resize: vertical; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.actions form { margin: 0; }
.notice p { font-weight: 500; }
.icon-card { grid-template-columns: auto 1fr; align-items: center; gap: 18px; }
.icon-actions { display: grid; gap: 8px; }
.file-btn { position: relative; overflow: hidden; }
.file-btn input[type=file] { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.people { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.people li { display: flex; align-items: center; gap: 10px; }
.person { display: grid; }
.confirm { justify-items: center; text-align: center; padding: 28px 20px; }
.confirm p { max-width: 30em; }

/* timeline */
.timeline {
  flex: 1; overflow-y: auto; padding: 20px 20px 8px;
  display: flex; flex-direction: column; gap: 10px;
}
.timeline > :first-child { margin-top: auto; }  /* newest at the bottom, like a chat */
.timeline-empty { align-self: center; max-width: 26em; text-align: center; color: var(--muted); padding: 24px; }
.item {
  align-self: flex-end; max-width: min(78%, 620px); display: grid; gap: 4px;
  background: var(--soft); border-radius: var(--radius-l) var(--radius-l) 6px var(--radius-l); padding: 10px 14px 8px;
}
.item-text { white-space: pre-wrap; overflow-wrap: anywhere; }
.item-text a { text-underline-offset: 2px; }
.item-meta { display: flex; justify-content: flex-end; align-items: center; gap: 12px; font-size: .75rem; color: var(--muted); }
.item-meta .copy { font-size: .75rem; color: var(--muted); }
.item-link { padding: 6px; }
.link-card {
  display: grid; gap: 3px; padding: 12px 14px; text-decoration: none;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-m); overflow-wrap: anywhere;
}
.link-card:hover { border-color: var(--text); }
.link-site { font-size: .75rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.link-title { font-weight: 650; }
.link-desc { font-size: .9rem; color: var(--muted); display: -webkit-box; -webkit-line-clamp: 3; line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.link-loading { font-size: .85rem; color: var(--muted); }
.link-url { font-size: .82rem; text-decoration: underline; text-underline-offset: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item-link .item-meta { padding: 0 8px 2px; }

/* composer */
.composer { padding: 10px 14px 14px; display: grid; gap: 8px; }
.composer-row {
  display: flex; align-items: flex-end; gap: 8px; padding: 6px 6px 6px 16px;
  background: var(--soft); border-radius: 26px; border: 1.5px solid transparent;
}
.composer-row:focus-within { border-color: var(--text); background: var(--surface); }
.composer textarea {
  flex: 1; background: transparent; border: 0; padding: 9px 0; resize: none; max-height: 200px; line-height: 1.4;
}
.composer textarea:focus { background: transparent; }
.send {
  flex: none; width: 40px; height: 40px; border-radius: 50%; border: 0; cursor: pointer;
  background: var(--ink); color: var(--on-ink); display: grid; place-items: center;
}
.send:disabled { opacity: .5; cursor: default; }
.composer-error { font-size: .85rem; font-weight: 600; padding: 0 6px; }
.composer-full {
  margin: 10px 14px 14px; padding: 14px 16px; border-radius: var(--radius-l);
  background: var(--ink); color: var(--on-ink); font-weight: 600;
}

/* ---- phones: one screen at a time ---- */
@media (max-width: 800px) {
  .shell { grid-template-columns: minmax(0, 1fr); padding: 0; gap: 0; }
  .sidebar, .pane { border: 0; border-radius: 0; }
  .shell.is-open .sidebar { display: none; }
  .shell:not(.is-open) .pane { display: none; }
  .mobile-only { display: inline-flex; }
  .pane-head { padding-left: 6px; min-height: 60px; }
  .timeline { padding: 14px 12px 6px; }
  .item { max-width: 88%; }
  .pane-body { padding: 14px 12px 24px; }
  .composer { padding: 8px 10px calc(10px + env(safe-area-inset-bottom)); }
  .side-foot { padding-bottom: calc(14px + env(safe-area-inset-bottom)); }
  .icon-card { grid-template-columns: 1fr; justify-items: center; text-align: center; }
  .icon-card .actions { justify-content: center; }
}

/* ---- photos, videos, files ---- */
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.item-photo, .item-video { padding: 5px 5px 6px; }
.media { display: block; border-radius: calc(var(--radius-l) - 4px); overflow: hidden; background: var(--line); }
.media img, video.media { display: block; max-width: 100%; height: auto; max-height: 420px; width: auto; object-fit: contain; }
video.media { width: 100%; background: #000; }
.item-photo .item-meta, .item-video .item-meta { padding: 0 8px; }
.media-note { padding: 4px 8px 0; }
.item-meta a.text-btn { font-size: .75rem; color: var(--muted); }
.file-card {
  display: flex; align-items: center; gap: 12px; min-width: 220px; padding: 10px 12px; text-decoration: none;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-m);
}
.file-card:hover { border-color: var(--text); }
.file-ext {
  flex: none; width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center;
  background: var(--ink); color: var(--on-ink); font-size: .7rem; font-weight: 800; letter-spacing: .02em;
}
.file-text { min-width: 0; display: grid; }
.file-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 40ch; }
.file-size { font-size: .8rem; color: var(--muted); }
.item-file { padding: 6px; }
.item-file .item-meta { padding: 0 8px 2px; }

/* upload in progress */
.item-upload { min-width: 240px; }
.upload-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 40ch; }
.upload-bar { height: 6px; border-radius: 999px; background: var(--line); overflow: hidden; }
.upload-bar > span { display: block; height: 100%; width: 0; background: var(--ink); border-radius: 999px; transition: width .2s; }
.upload-status { display: flex; justify-content: space-between; gap: 12px; font-size: .78rem; color: var(--muted); }
.item-upload.failed { border: 2px solid var(--text); }
.item-upload.failed .upload-status { color: var(--text); font-weight: 600; }

/* composer additions */
.attach {
  position: relative; flex: none; width: 40px; height: 40px; border-radius: 50%; cursor: pointer;
  align-items: center; justify-content: center; color: var(--text); margin-left: -10px;
}
.attach:hover { background: var(--hover); }
.attach input { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; }
.compress, .compress-note { font-size: .8rem; color: var(--muted); padding: 0 10px; gap: 6px; align-items: center; }
.compress input { width: auto; accent-color: var(--ink); }
.pane { position: relative; }
.drop-overlay {
  position: absolute; inset: 0; z-index: 5; display: grid; place-items: center; padding: 24px;
  background: color-mix(in srgb, var(--surface) 88%, transparent); border: 3px dashed var(--text); border-radius: var(--radius-xl);
  font-weight: 700; font-size: 1.1rem; pointer-events: none;
}
.drop-overlay[hidden] { display: none; }
