/* Session-specific viewer controls and compact reading state. */

@media (max-width: 520px), (max-height: 480px) {
  /* Work inspection must not move a tap target by expanding the composer. */
  body[data-reading] .dock:is(:not(:focus-within), :has(#background-work:focus-within)) { padding-top: .9rem; }
  body[data-reading] .dock:is(:not(:focus-within), :has(#background-work:focus-within)) :is(#session-box, #artifacts,
    #own-queue, .disclosure, .skill-chips, .composer-scope, .attachments,
    .queue-state, .composer-identity, .composer-label, #attach-button, #send-button,
    .composer-spacer) {
    display: none;
  }
  body[data-reading] .dock:is(:not(:focus-within), :has(#background-work:focus-within)) .composer {
    flex-direction: row;
    align-items: center;
    padding: .35rem .5rem;
  }
  body[data-reading] .dock:is(:not(:focus-within), :has(#background-work:focus-within)) .composer textarea {
    flex: 1;
    min-width: 0;
    min-height: 0;
    height: 1.8rem;
    resize: none;
    white-space: nowrap;
    overflow: hidden;
  }
  body[data-reading] .dock:is(:not(:focus-within), :has(#background-work:focus-within)) .composer-row {
    flex: 0 0 auto;
    flex-wrap: nowrap;
  }
}

/* An owner's model and mode open the settings that change them. */
.modeline .ml-link,
.modeline .settings-button {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
}

.modeline .ml-link:hover,
.modeline .ml-link:focus-visible {
  color: var(--accent);
  text-decoration: underline;
}

.modeline .settings-button {
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: var(--control-radius);
  padding: .1rem .55rem;
}

.modeline .settings-button:hover,
.modeline .settings-button:focus-visible {
  border-color: var(--accent);
  color: var(--accent);
}

.modeline .settings-button.attention {
  color: var(--failed);
  border-color: var(--failed);
  font-weight: 600;
}

/* Session settings: an owner's choices, each with its own explanation,
   since a phone has no hover to show a tooltip. */
.settings-group { padding: .9rem 0; }
.settings-group + .settings-group { border-top: 1px solid var(--line); }
.settings-heading {
  display: block;
  margin: 0 0 .45rem;
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--muted);
}
.settings-help {
  margin: .45rem 0 0;
  font-size: .8rem;
  line-height: 1.5;
  color: var(--muted);
}
.settings-row,
.settings-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .5rem;
}
.settings-row .sheet-input { flex: 1 1 12rem; width: auto; min-width: 0; }
.settings-actions .sheet-input { width: auto; }
.settings-attention {
  margin: .4rem 0 .3rem;
  padding: .8rem .9rem;
  border: 1px solid color-mix(in srgb, var(--failed) 45%, transparent);
  border-radius: .5rem;
  background: color-mix(in srgb, var(--failed) 6%, transparent);
}
.settings-attention .settings-heading { color: var(--failed); }
.settings-issue, .settings-input { margin: 0 0 .5rem; font-size: .85rem; }
.settings-input { flex-basis: 100%; overflow-wrap: anywhere; }
#recovery-auth p { margin: .5rem 0 0; font-size: .85rem; }
#recovery-auth input { max-width: 100%; }

/* The sheets wear the panel idiom rather than inventing a second one:
   the same accent title, muted note, hairline, and rem sizes
   the rest of the dock uses. */
.sheet {
  width: min(30rem, calc(100vw - 2rem));
  padding: 0;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: .7rem;
  box-shadow: var(--shadow);
}

.sheet::backdrop {
  background: color-mix(in srgb, #0C1412 46%, transparent);
  backdrop-filter: blur(2px);
}

.sheet-form {
  display: flex;
  flex-direction: column;
  gap: .35rem;
  padding: 1.1rem;
}

.sheet-title {
  margin: 0;
  font-family: var(--font-ui);
  font-size: .85rem;
  font-weight: 700;
  color: var(--accent);
}

.sheet-note {
  margin: 0 0 .5rem;
  color: var(--muted);
  font-size: .8rem;
}

.sheet-label {
  margin-top: .5rem;
  font-size: .74rem;
  font-weight: 700;
}

.sheet-hint {
  margin-left: .4rem;
  color: var(--muted);
  font-weight: 400;
}

.sheet-input {
  font: inherit;
  font-size: .8rem;
  width: 100%;
  padding: .45rem .6rem;
  color: var(--ink);
  background: var(--ground);
  border: 1px solid var(--line);
  border-radius: .5rem;
}

.sheet-input:focus {
  outline: none;
  border-color: var(--accent);
}

.sheet-area { resize: vertical; }

.sheet-actions {
  display: flex;
  justify-content: flex-end;
  gap: .5rem;
  margin: .9rem 0 0;
  padding: 0;
}

/* Inviting is not composing: a read-only guest never sees the composer
   and still has its own link to hand on, so the control sits in the
   dock rather than in the composer row. */
.dock-actions {
  display: flex;
  justify-content: flex-end;
  width: 100%;
  max-width: 44rem;
}

.dock-actions:not(:has(button:not([hidden]))) { display: none; }

/* One row per tier the holder may hand on -- never one above it. */
.invite-tiers {
  display: flex;
  flex-direction: column;
  gap: .4rem;
}

.invite-tier {
  display: flex;
  align-items: center;
  gap: .6rem;
  padding: .45rem .6rem;
  background: var(--ground);
  border: 1px solid var(--line);
  border-radius: .5rem;
}

.invite-tier .invite-name {
  font-size: .78rem;
  font-weight: 700;
}

.invite-tier .invite-what {
  flex: 1 1 auto;
  min-width: 0;
  font-size: .72rem;
  color: var(--muted);
}

/* A requested session outlives the sheet that asked for it, so several
   can stack in the dock instead of overwriting one another. */
.invite-entry .invite-actions {
  display: flex;
  flex-wrap: wrap;
  gap: .4rem;
  padding: 0 .9rem .5rem;
}

.invite-entry .invite-open { text-decoration: none; }

.invite-tier .room-actions {
  grid-column: 2;
  grid-row: 1 / span 2;
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: .4rem;
}
.invite-tier.room-entry .invite-open { text-decoration: none; }
/* A tier's QR code: dark on white in either theme, for any camera. */
.invite-qr { margin: .4rem 0 0; display: grid; justify-items: center; gap: .5rem; }
.invite-qr-code { width: min(240px, 70vw); aspect-ratio: 1; }
.invite-qr-code svg { display: block; width: 100%; height: 100%; }
.invite-qr figcaption { font-size: .78rem; color: var(--muted); text-align: center; }
/* Room names are the host's and keep their case; tier names are capitalized. */
.invite-tier.room-entry .invite-name { text-transform: none; }
/* On a phone the actions take their own line, leaving the name its width. */

/* A lobby link opens the project's session list instead of a room: the
   conversation, composer and room menu have nothing to show. */
body[data-lobby] :is(.skip-link, #filter, #history, #transcript, #empty-state,
  #notify-button, #session-box, #requests, #own-queue, #assistant-working,
  #composer, .live-controls) {
  display: none;
}

.lobby { width: 100%; max-width: 51rem; margin: 0 auto; padding: 1.5rem 1rem 2rem; }
.lobby[hidden] { display: none; }

.lobby-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .5rem;
  margin-bottom: 1rem;
}

.lobby-head h2 {
  flex: 1 1 12rem;
  min-width: 0;
  margin: 0;
  font-size: 1.35rem;
  letter-spacing: -.02em;
  overflow-wrap: anywhere;
}
.lobby-actions { display: flex; flex-wrap: wrap; gap: .5rem; margin-left: auto; }
/* The artifacts tab's create buttons join the head's action row. */
.lobby-create { display: contents; }
.lobby-create[hidden] { display: none; }

.lobby-list { list-style: none; margin: 0; padding: 0; }

.lobby-row {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .8rem 0;
  border-top: 1px solid var(--line);
}

.lobby-row:last-child { border-bottom: 1px solid var(--line); }

.lobby-main { flex: 1; min-width: 0; display: grid; gap: .15rem; }
.lobby-name { font-weight: 600; overflow-wrap: anywhere; }
.lobby-meta { color: var(--muted); font-size: .85rem; }

.lobby-preview {
  margin: 0;
  color: var(--muted);
  font-size: .9rem;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  overflow-wrap: anywhere;
}

.lobby-row .btn { flex: 0 0 auto; }

/* An artifact row shows Open and keeps its other actions in a menu, so it
   stays one line down to phone width.  The menu is a popover placed by
   script beside its trigger. */
.store-more { padding-inline: .7rem; }
.store-menu {
  position: fixed;
  inset: auto;
  margin: 0;
  min-width: 11rem;
  padding: .3rem;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--rule-strong);
  box-shadow: var(--shadow);
}
.store-menu:popover-open { display: grid; }
.store-menu:not([data-placed]) { visibility: hidden; }
.store-menu .btn { background: none; border: 0; text-align: left; font-weight: 500; }
.store-menu .btn:hover, .store-menu .btn:focus-visible { background: var(--accent-soft); filter: none; }
.lobby-row .store-menu .btn.danger { color: var(--failed); border: 0; }
.store-versions { list-style: none; margin: .4rem 0 0; padding: 0; display: grid; gap: .25rem; }
.store-version { display: flex; align-items: center; gap: .5rem; }
/* An owner's artifact links: one compact line per tier in shared columns,
   the link selectable in a read-only field that shrinks before its Copy
   button, so the row's Open and menu keep their place down to phone width. */
.store-links {
  margin: .4rem 0 0;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: .3rem .5rem;
}
.store-link { display: contents; }
.store-links .btn { padding: .15rem .55rem; font-size: .78rem; }
.store-links > .btn { grid-column: 1; justify-self: start; }
.store-link-field {
  min-width: 0;
  width: 100%;
  box-sizing: border-box;
  font: .75rem var(--mono, monospace);
  padding: .2rem .4rem;
  color: var(--ink);
  background: var(--ground);
  border: 1px solid var(--line);
  border-radius: .375rem;
  text-overflow: ellipsis;
}
.store-link-field:focus { outline: none; border-color: var(--accent); }
.lobby-empty { color: var(--muted); margin: 1rem 0 0; }
.lobby-empty[hidden] { display: none; }

/* A full link's lobby has two tabs: the session list and the project's
   files. The tabs head the page in place of the title, and the shown tab's
   actions share their row above one rule. On a narrow screen the actions
   wrap onto a row above the tabs, so the tabs stay on the rule. */
.lobby-head:has(> .lobby-tabs:not([hidden])) {
  flex-wrap: wrap-reverse;
  align-items: flex-start;
  border-bottom: 1px solid var(--line);
}
.lobby-head:has(> .lobby-tabs:not([hidden])) h2 {
  position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%);
}
.lobby-head:has(> .lobby-tabs:not([hidden])) .lobby-actions {
  align-self: center;
  padding: .35rem 0;
}
.lobby-tabs { display: flex; gap: .25rem; }
.lobby-tabs[hidden] { display: none; }
.lobby-tab {
  font: inherit;
  color: var(--muted);
  background: none;
  border: 0;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  padding: .45rem .8rem;
  cursor: pointer;
}
.lobby-tab[aria-selected="true"] {
  color: var(--ink);
  border-bottom-color: var(--accent);
  font-weight: 600;
}
.lobby-tab:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
#lobby-sessions[hidden], .lobby-files[hidden] { display: none; }

.lobby-files { border-radius: var(--panel-radius); min-height: 50vh; }
.files-drop-hint { color: var(--muted); font-size: .85rem; margin: 0 0 .75rem; }
.files-path {
  margin-bottom: .6rem;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: .15rem;
  overflow-wrap: anywhere;
}
.files-crumb {
  font: inherit;
  color: var(--accent);
  background: none;
  border: 0;
  padding: .1rem .2rem;
  cursor: pointer;
}
.files-crumb:last-child { color: var(--ink); font-weight: 600; }
.files-sep { color: var(--muted); }
.files-row { padding: .45rem 0; gap: .6rem; flex-wrap: wrap; }
.files-row .btn { flex: 0 0 auto; }
.files-name {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: baseline;
  gap: .45rem;
  font: inherit;
  text-align: left;
  color: var(--ink);
  background: none;
  border: 0;
  padding: .2rem 0;
  cursor: pointer;
  overflow-wrap: anywhere;
}
.files-name:hover { color: var(--accent); }
.files-icon { color: var(--muted); width: .8rem; flex: 0 0 auto; }
.files-row .lobby-meta { flex: 0 0 auto; }
@media (max-width: 480px) {
  .files-name { flex-basis: calc(100% - 5rem); }
}
/* A lobby list carries a Remove or Delete per row; a solid danger block on
   every row would shout, so it reads as a quiet control until pointed at. */
.lobby-row .btn.danger {
  background: none;
  color: var(--failed);
  border: 1px solid var(--line);
  flex: 0 0 auto;
}
.lobby-row .btn.danger:hover,
.lobby-row .btn.danger:focus-visible { border-color: var(--failed); }
