/* The sections side by side: the switch, documents, letters inside talks, one search. */

:root { --rail: 5rem; }

/* --- The switch -------------------------------------------------------- */

.rail {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 2;
  width: var(--rail);
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  padding: 0.75rem 0.4rem;
  background: var(--surface-muted);
  border-right: 1px solid var(--border);
}
#app[hidden] ~ .rail, #app[hidden] ~ .write-fab { display: none; }
.rail button {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.2rem;
  min-height: 3.75rem;
  padding: 0.3rem 0.1rem;
  border-radius: 14px;
  color: var(--text-secondary);
  font-size: 0.7rem;
  font-weight: 500;
  -webkit-tap-highlight-color: transparent;
}
.rail button > span:not(.count, .box-face) { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rail button[aria-current='true'] { background: var(--selection); color: var(--accent); }
@media (hover: hover) { .rail button:not([aria-current='true']):hover { background: var(--surface-subtle); } }
.rail button .count {
  position: absolute;
  top: 0.3rem;
  left: calc(50% + 0.3rem);
  min-width: 1.1rem;
  margin: 0;
  padding: 0 0.25rem;
  border: 2px solid var(--surface-muted);
  border-radius: 1rem;
  background: var(--accent);
  color: var(--on-accent);
  font-size: 0.72rem;
  font-weight: 600;
  line-height: 1.1rem;
  text-align: center;
}
.rail .rail-find { margin-top: auto; }

/* --- Switching between mailboxes --------------------------------------- */

.switcher { display: none; }
.switcher[hidden] { display: none !important; }
.rail .switcher {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.35rem;
  min-height: 0;
  margin-top: 0.5rem;
  padding: 0.75rem 0;
  border-top: 1px solid var(--border);
  overflow-y: auto;
  scrollbar-width: none;
}
.switcher .switch,
.rail .switcher .switch {
  position: relative;
  flex: none;
  width: 2.9rem;
  height: 2.9rem;
  min-height: 0;
  display: grid;
  place-items: center;
  padding: 0;
  border-radius: 50%;
  background: none;
}
.switcher .box-face { grid-area: 1 / 1; width: 36px; height: 36px; border: 0; opacity: 0.8; }
.switcher .switch[aria-current='true'] { box-shadow: inset 0 0 0 2px var(--accent); }
.switcher .switch[aria-current='true'] .box-face,
.switcher .switch:hover .box-face { opacity: 1; }
.switcher .switch .count {
  position: absolute;
  top: -0.1rem;
  left: auto;
  right: -0.2rem;
  min-width: 1.1rem;
  padding: 0 0.25rem;
  border: 2px solid var(--surface-muted);
  border-radius: 1rem;
  background: var(--accent);
  color: var(--on-accent);
  font-size: 0.72rem;
  font-weight: 600;
  line-height: 1.1rem;
  text-align: center;
}

.app { padding-left: var(--rail); }
#chats.composer, .papers { left: var(--rail); }
#menu-settings .folder-icon { margin-inline: 3px; }
#chats-out { display: none; }
.side-head:has(#chats-out) { padding-left: 0.75rem; }
.write-fab { display: none; }
/* Windows lie over the switch, sections lie beside it. */
.composer:not(#chats) { z-index: 6; background: rgb(0 0 0 / 0.45); }
.composer#composer, .composer.finder { z-index: 7; }

/* --- Documents --------------------------------------------------------- */

.papers {
  position: fixed;
  inset: 0 0 0 var(--rail);
  display: flex;
  flex-direction: column;
  background: var(--surface);
}
.papers[hidden] { display: none; }
.papers-head { flex: none; display: flex; align-items: center; gap: 1rem; padding: 0.9rem 1.5rem 0.6rem; }
.papers-head h2 { margin: 0; font-size: 1.25rem; font-weight: 600; }
.papers-head .side-find { max-width: 30rem; margin-left: auto; }
.papers > .chats-tabs { padding-inline: 1.1rem; }
.papers-scroll { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; }
.papers-list { max-width: 64rem; margin: 0 auto; padding: 0.6rem 1rem 6rem; }
.papers-none { display: flex; flex-direction: column; align-items: center; gap: 1rem; padding: 4rem 1rem; text-align: center; color: var(--text-secondary); }
.papers-none p { margin: 0; }
.paper-row { display: flex; align-items: center; border-radius: 12px; }
@media (hover: hover) { .paper-row:hover { background: var(--surface-subtle); } }
.paper-go {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 0.85rem;
  min-height: 4rem;
  padding: 0.5rem 0.6rem;
  color: var(--text);
  text-align: left;
  text-decoration: none;
  -webkit-touch-callout: none;
}
.paper-text { background: #2f6fb2 !important; color: #fff !important; }
.paper-sheet { background: #2c8556 !important; color: #fff !important; }
.paper-pdf { background: #b8433a !important; color: #fff !important; }
.paper-other { background: #6d7876 !important; color: #fff !important; }
.sheet-row .file-mark { flex: none; }

.access-form { display: flex; flex-wrap: wrap; gap: 0.6rem; padding: 0 0.8rem 0.8rem; }
.access-form input, .access-form select { min-height: 2.75rem; padding: 0.5rem 0.8rem; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); color: var(--text); font: inherit; }
.access-form input { flex: 1 1 14rem; min-width: 0; }
.access-form button { min-height: 2.75rem; }

/* Three dots are drawn as points. */
.ci.icon-more { stroke-width: 3; }

/* --- In a talk --------------------------------------------------------- */

.paper-card { color: inherit; text-decoration: none; }
.talk-line > .paper-card { padding-right: 0.5rem; }
.thing-row.paper-card { width: 100%; }

.talk-letter, .letter-card { display: flex; flex-direction: column; gap: 0.15rem; min-width: 14rem; text-align: left; font: inherit; color: inherit; }
button.talk-letter { width: auto; max-width: min(30rem, 86%); padding: 0.55rem 0.8rem; border-left: 3px solid var(--accent); cursor: pointer; }
button.talk-letter:hover, button.talk-letter:active { background: var(--bubble); }
button.talk-letter.own:hover, button.talk-letter.own:active { background: var(--bubble-own); }
.talk-letter > b, .letter-card > b { font-weight: 600; overflow-wrap: anywhere; }
.talk-letter.unread > b { color: var(--accent); }
.letter-kind { display: flex; align-items: center; gap: 0.35rem; font-size: 0.87rem; font-weight: 500; color: var(--accent); }
.letter-kind .ci { width: 1rem; height: 1rem; }
.letter-kind .icon-clip { margin-left: auto; color: var(--text-tertiary); }
.letter-said {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
  font-size: 0.97rem;
  color: var(--text-secondary);
  overflow-wrap: anywhere;
}
.talk-letter .talk-time { align-self: flex-end; float: none; position: static; margin: 0; }
.letter-card { margin: 0.1rem 0 0.2rem; padding: 0.4rem 0.7rem; border-left: 3px solid var(--accent); border-radius: 8px; background: color-mix(in srgb, var(--accent) 10%, transparent); }
.chat-row-under .icon-mail, .chat-row > .icon-mail { display: inline-block; width: 1rem; height: 1rem; margin-right: 0.35rem; vertical-align: -0.15rem; color: var(--text-tertiary); }
.chat-row > .icon-mail { width: 1.25rem; height: 1.25rem; }

/* --- A letter over a talk ---------------------------------------------- */

.reader-card { width: min(48rem, 100%); height: min(54rem, 92dvh); background: var(--surface); }
.reader-card .pane-head { flex: none; background: var(--surface); }
.reader-scroll { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; }
.reader .thread-head .chat-face { width: 2.4rem; height: 2.4rem; font-size: 0.9rem; }

/* --- One search -------------------------------------------------------- */

.finder { align-items: flex-start; }
.finder-card { width: min(40rem, 100%); margin-top: min(8vh, 4rem); max-height: 84dvh; }
.finder-card .side-find input { padding: 0; border: 0; }
.finder-found { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding-bottom: 1rem; }
.finder .person .file-mark { width: 2.75rem; height: 2.75rem; flex: none; }

/* --- A phone: the switch is at the bottom -------------------------------- */

@media (max-width: 44rem) {
  :root { --rail: 0px; --bar: calc(3.4rem + env(safe-area-inset-bottom)); }
  .rail {
    inset: auto 0 0;
    width: auto;
    height: var(--bar);
    flex-direction: row;
    gap: 0;
    padding: 0 0.25rem env(safe-area-inset-bottom);
    border-right: 0;
    border-top: 1px solid var(--border);
    background: var(--surface);
  }
  .rail button { flex: 1; min-width: 0; min-height: 0; border-radius: 0; gap: 0.1rem; }
  .rail button[aria-current='true'] { background: none; }
  .rail button .count { top: 0.15rem; border-color: var(--surface); }
  .rail .rail-find { margin: 0; }
  .rail .switcher { display: none; }
  .switcher {
    flex: none;
    display: flex;
    gap: 0.35rem;
    padding: 0.5rem 0.75rem 0.3rem;
    overflow-x: auto;
    scrollbar-width: none;
  }
  .switcher .switch .count { border-color: var(--surface); }
  /* What is read, written or chosen takes the whole screen. */
  body:has(.app.reading, .app.folders-open) .rail,
  body:has(#chats:not([hidden]) .chats-panes.talking) .rail,
  body:has(#chats:not([hidden]) .chats-start:not([hidden])) .rail { display: none; }
  .app:not(.reading) .list-scroll { padding-bottom: calc(var(--bar) + 4.5rem); }
  .chats-side .side-scroll { padding-bottom: calc(var(--bar) + 5rem); }
  .chats-side > .fab, .papers > .fab, .write-fab { bottom: calc(var(--bar) + 1rem); }
  .chats-side .chats-start .fab { bottom: calc(1rem + env(safe-area-inset-bottom)); }
  .chats-start .side-scroll { padding-bottom: 5rem; }
  body:has(#chats[hidden]):has(#papers[hidden]):not(:has(.app.reading, .app.folders-open)) .write-fab { display: grid; position: fixed; z-index: 1; }
  .papers { inset: 0; }
  .papers-head { flex-wrap: wrap; gap: 0.5rem; padding: 0.6rem 0.75rem 0.3rem; }
  .papers-head h2 { flex: 1; }
  .papers-head .side-find { flex-basis: 100%; }
  #chats-close { display: none; }
  .side-head .menu-open { flex: none; }
  /* The menu stands in the same corner as over the letters. */
  .papers-head, .side-head { order: -1; }
  .papers-head { padding-top: 1rem; }
  #chats-head { padding: 1rem 0.75rem 0.8rem; }
  .side-head:has(#chats-out) { padding: 0.75rem 0.5rem 0.35rem 0.75rem; }
  .papers-head .side-find { max-width: none; }
  .papers > .chats-tabs { padding-inline: 0.4rem; }
  .papers-list { padding: 0.3rem 0.2rem calc(var(--bar) + 5.5rem); }
  .finder-card { margin: 0; max-height: none; }
  .reader-card { height: 100dvh; }
  .reader-card .pane-head { padding: 0.5rem; gap: 0.3rem; }
  .reader-card .pane-head .ghost:not(.icon) { padding-inline: 0.4rem; font-size: 0.92rem; white-space: nowrap; }
}

/* --- Chats over the letters -------------------------------------------- */

.strip {
  display: flex;
  gap: 0.15rem;
  padding: 0.6rem 0.5rem 0.5rem;
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  scrollbar-width: none;
}
.strip[hidden] { display: none; }
.strip::-webkit-scrollbar { display: none; }
.strip-one {
  flex: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.3rem;
  width: 4.35rem;
  padding: 0.35rem 0.2rem;
  border-radius: 12px;
  -webkit-tap-highlight-color: transparent;
}
@media (hover: hover) { .strip-one:hover { background: var(--surface-subtle); } }
.strip-face { position: relative; }
.strip-one .chat-face, .strip-sign { width: 2.9rem; height: 2.9rem; font-size: 1rem; }
.strip-sign {
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--selection);
  color: var(--accent);
}
.strip-sign svg { width: 1.35rem; height: 1.35rem; }
.strip-name {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text-secondary);
  font-size: 0.82rem;
}
.strip-face .count {
  position: absolute;
  top: -0.2rem;
  right: -0.35rem;
  min-width: 1.2rem;
  margin: 0;
  padding: 0 0.3rem;
  border: 2px solid var(--surface);
  border-radius: 1rem;
  background: var(--accent);
  color: var(--on-accent);
  font-size: 0.68rem;
  font-weight: 600;
  line-height: 1.1rem;
  text-align: center;
}
.strip-face .count.muted { background: var(--text-tertiary, var(--text-secondary)); }
.strip.offer { align-items: center; padding: 0.4rem 0.5rem; }
.strip-offer {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.4rem 0.5rem;
  border-radius: 12px;
  text-align: left;
}
.strip-offer > span:last-child { display: grid; min-width: 0; font-size: 0.92rem; color: var(--text-secondary); }
.strip-offer b { color: var(--text); font-size: 1rem; }
.strip-offer .strip-sign { flex: none; }
.chats-card:has(> .chats-panes:not([hidden])) > .switcher { display: none; }
