/* Light and dark follow the device (prefers-color-scheme). */

:root {
  --bg: #f6f7f7; --surface: #ffffff; --fg: #1a1a1a; --muted: #5f6368; --border: #cfd3d4;
  --accent: #0f766e; --accent-fg: #ffffff; --link: #0f5f99; --error: #b3261e; --ok: #1b6e36; --focus: #1a73e8;
  --mine: #e3f3f1;
  --tap: 2.75rem; --max: 40rem;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1c1c1e; --surface: #2a2a2d; --fg: #ececee; --muted: #a3a3ab; --border: #48484e;
    --accent: #2dd4bf; --accent-fg: #06201d; --link: #8ab4f8; --error: #ff8a80; --ok: #7ee0a0; --focus: #8ab4f8;
    --mine: #17332f;
    color-scheme: dark;
  }
}

html { font-family: system-ui, -apple-system, sans-serif; line-height: 1.45; }
body {
  margin: 0 auto; max-width: var(--max); box-sizing: border-box; background: var(--bg); color: var(--fg);
  padding: 0 max(1rem, env(safe-area-inset-right)) env(safe-area-inset-bottom) max(1rem, env(safe-area-inset-left));
}
a { color: var(--link); }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* iOS zooms into inputs below 16px, so controls keep 16px. */
input, button, select, textarea, .button { font: inherit; font-size: 16px; color: var(--fg); background: var(--surface);
  border: 1px solid var(--border); border-radius: .5rem; padding: .3rem .8rem; box-sizing: border-box; max-width: 100%; }
button, .button { min-height: var(--tap); cursor: pointer; display: inline-flex; align-items: center; justify-content: center;
  text-decoration: none; }
input[type=text], input:not([type]), input[type=password] { min-height: var(--tap); width: 100%; }
textarea { width: 100%; resize: vertical; }
label { display: block; font-size: .9rem; margin-bottom: .15rem; }
button.primary { background: var(--accent); color: var(--accent-fg); border-color: var(--accent); font-weight: 600; }
button.quiet { border-color: transparent; background: none; color: var(--muted); }

header { display: flex; justify-content: space-between; align-items: center;
  padding: .75rem 0; padding-top: max(.75rem, env(safe-area-inset-top)); border-bottom: 1px solid var(--border); }
.brand { font-weight: bold; font-size: 1.15rem; text-decoration: none; color: var(--fg); letter-spacing: .02em; }
h1 { font-size: 1.4rem; margin: 1rem 0 .5rem; }
h2 { font-size: 1rem; margin: 1.25rem 0 .25rem; color: var(--muted); }
.error { color: var(--error); }
.ok { color: var(--ok); }
.note, .hint, .empty { color: var(--muted); }
.hint { font-size: .85rem; margin: .25rem 0 0; min-height: 1.2em; }
.empty { padding: 1rem 0; list-style: none; }

/* home: the list of people */
.people { list-style: none; margin: 0; padding: 0; }
.people li { border-bottom: 1px solid var(--border); }
.people a { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; padding: 1rem .25rem;
  text-decoration: none; color: var(--fg); min-height: var(--tap); }
.people .name { font-size: 1.15rem; font-weight: 600; }
.people .hint { margin: 0; }

/* chat */
.chathead { display: flex; align-items: center; gap: .75rem; }
.chathead h1 { flex: 1; margin: .75rem 0; }
.back { font-size: 2rem; line-height: 1; text-decoration: none; padding: 0 .5rem 0 0; color: var(--fg); }
.refresh { font-size: .9rem; }
.items { list-style: none; margin: 0; padding: 0 0 1rem; display: flex; flex-direction: column; gap: .6rem; }
.item { background: var(--surface); border: 1px solid var(--border); border-radius: .75rem; padding: .5rem .75rem; }
.item.mine { background: var(--mine); }
.meta { display: flex; flex-wrap: wrap; gap: 0 .6rem; font-size: .75rem; color: var(--muted); }
.meta .who { font-weight: 600; color: var(--fg); }
.text { white-space: pre-wrap; overflow-wrap: anywhere; margin: .3rem 0; }
.file { margin: .3rem 0; overflow-wrap: anywhere; }
.file .size { color: var(--muted); font-size: .85rem; margin-left: .4rem; }
.thumb img { display: block; max-width: 100%; max-height: 16rem; border-radius: .4rem; margin-top: .3rem; }
.acts { display: flex; gap: .5rem; align-items: center; }
.acts form { margin: 0; }
.acts button, .acts .button { min-height: 2.25rem; padding: .1rem .8rem; font-size: 15px; }

/* composer: stays at the bottom of the screen */
#composer { position: sticky; bottom: 0; background: var(--bg); border-top: 1px solid var(--border);
  padding: .6rem 0 max(.6rem, env(safe-area-inset-bottom)); }
.compose .row { display: grid; grid-template-columns: repeat(4, 1fr); gap: .4rem; margin-top: .4rem; }
.compose .row button { padding: .3rem .4rem; }
body.dragging #composer { outline: 3px dashed var(--accent); outline-offset: -3px; }

.uploads { list-style: none; margin: 0 0 .5rem; padding: 0; display: flex; flex-direction: column; gap: .4rem; }
.up { display: grid; grid-template-columns: 1fr auto; gap: .1rem .5rem; align-items: center; background: var(--surface);
  border: 1px solid var(--border); border-radius: .5rem; padding: .4rem .6rem; font-size: .9rem; }
.up .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.up progress { grid-column: 1; width: 100%; height: .6rem; accent-color: var(--accent); }
.up .state { grid-column: 1; font-size: .8rem; color: var(--muted); }
.up.failed .state { color: var(--error); }
.up .btns { grid-column: 2; grid-row: 1 / span 3; display: flex; gap: .3rem; }
.up .btns button { min-height: 2.25rem; padding: .1rem .7rem; }

/* profile menu */
.profile { position: relative; }
.profile summary { list-style: none; cursor: pointer; display: flex; align-items: center; justify-content: center;
  width: var(--tap); height: var(--tap); border: 1px solid var(--border); border-radius: 50%; background: var(--surface); color: var(--fg); }
.profile summary::-webkit-details-marker { display: none; }
.profile summary svg { width: 1.3rem; height: 1.3rem; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; }
.profile[open] summary, .profile.current summary { border-color: var(--fg); }
.profile .menu { position: absolute; right: 0; top: calc(100% + .35rem); z-index: 10; min-width: 11rem; display: flex; flex-direction: column;
  background: var(--surface); border: 1px solid var(--border); border-radius: .5rem; padding: .3rem; }
.profile .who { margin: 0; padding: .3rem .7rem; font-size: .85rem; color: var(--muted); }
.profile .menu form { margin: 0; }
.profile .menu a, .profile .menu button { display: block; width: 100%; box-sizing: border-box; text-align: left; min-height: 0;
  padding: .5rem .7rem; border: 0; border-radius: .35rem; background: none; color: var(--fg); text-decoration: none; }
.profile .menu a:hover, .profile .menu button:hover { background: var(--bg); }

/* find a person */
.find .row { display: flex; gap: .5rem; }
.find .row button { flex: none; }
