select {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  background: var(--bg);
  color: var(--text);
  padding: 0.8rem 0.9rem;
}

select:focus {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.optional-label {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 400;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.rooms-heading-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-right: 0.8rem;
}

.icon-button {
  display: inline-grid;
  width: 2rem;
  height: 2rem;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 0.6rem;
  background: var(--surface-2);
  color: var(--text);
  place-items: center;
  font-size: 1.25rem;
  line-height: 1;
}

.presence-panel {
  margin: 0.5rem 0.65rem 1rem;
  border: 1px solid var(--border);
  border-radius: 1rem;
  background: var(--surface);
  padding-bottom: 0.75rem;
}

.presence-list {
  display: grid;
  gap: 0.65rem;
  margin: 0;
  padding: 0 1rem;
  list-style: none;
}

.presence-user {
  display: flex;
  min-width: 0;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  color: var(--text);
  font-size: 0.86rem;
}

.presence-user::before {
  width: 0.5rem;
  height: 0.5rem;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--success);
  content: "";
}

.presence-name {
  min-width: 0;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.presence-idle {
  color: var(--muted);
  font-size: 0.72rem;
  white-space: nowrap;
}

.room-header {
  grid-row: 1;
  grid-column: 1;
}

.empty-state,
.message-list {
  grid-row: 2;
  grid-column: 1;
}

.composer-wrap {
  grid-row: 3;
  grid-column: 1;
}

.room-dialog {
  width: min(32rem, calc(100vw - 2rem));
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 1.5rem;
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow);
}

.room-dialog::backdrop {
  background: rgb(0 0 0 / 0.68);
  backdrop-filter: blur(3px);
}

.room-dialog form {
  padding: 1.5rem;
}

.dialog-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.dialog-header h2 {
  margin: 0;
}

code {
  border-radius: 0.25rem;
  background: var(--surface-2);
  padding: 0.08rem 0.3rem;
}

#load-older-button {
  align-self: center;
}

/* The attach control is a paperclip inside the message field. */
.composer-field {
  position: relative;
  display: grid;
  min-width: 0;
}

.composer-field textarea {
  padding-right: 2.9rem;
  padding-left: 2.9rem;
}

/* The emoji button mirrors the attach button in the field's right corner. */
.emoji-button {
  position: absolute;
  right: 0.4rem;
  bottom: 0.4rem;
  display: grid;
  width: 2.25rem;
  height: 2.25rem;
  padding: 0;
  border: 0;
  border-radius: 0.55rem;
  background: transparent;
  color: var(--muted);
  place-items: center;
}

.emoji-button:hover,
.emoji-button[aria-expanded="true"] {
  background: var(--surface-2);
  color: var(--text);
}

.emoji-picker {
  position: absolute;
  right: 0;
  bottom: calc(100% + 0.5rem);
  z-index: 30;
  display: grid;
  width: min(22rem, calc(100vw - 2rem));
  gap: 0.5rem;
  padding: 0.6rem;
  border: 1px solid var(--border);
  border-radius: 1.1rem;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.emoji-picker[hidden] {
  display: none;
}

.emoji-search {
  padding: 0.5rem 0.7rem;
}

.emoji-scroll {
  max-height: 16rem;
  overflow-y: auto;
}

.emoji-section h3 {
  margin: 0.4rem 0 0.25rem;
  color: var(--muted);
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.emoji-grid {
  display: grid;
  grid-template-columns: repeat(8, minmax(0, 1fr));
}

.emoji-option {
  padding: 0.25rem 0;
  border: 0;
  border-radius: 0.45rem;
  background: transparent;
  font-size: 1.3rem;
  line-height: 1.4;
}

.emoji-option:hover,
.emoji-option:focus-visible {
  background: var(--surface-2);
}

.emoji-empty {
  margin: 0.5rem 0;
  color: var(--muted);
  text-align: center;
}

.attachment-button {
  position: absolute;
  bottom: 0.4rem;
  left: 0.4rem;
  display: grid;
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 0.55rem;
  color: var(--muted);
  cursor: pointer;
  place-items: center;
}

.attachment-button:hover,
.composer-field:has(input[type="file"]:focus-visible) .attachment-button {
  background: var(--surface-2);
  color: var(--text);
}

.composer-field:has(input[type="file"]:focus-visible) .attachment-button {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.composer-field:has(input[type="file"]:disabled) .attachment-button {
  cursor: wait;
  opacity: 0.65;
}

/* A selected file is shown below the field; the row takes no space otherwise. */
form:has(.attachment-selection > button:not(.hidden)) .attachment-button {
  color: var(--accent);
}

.attachment-selection {
  display: flex;
  min-width: 0;
  grid-column: 1 / -1;
  align-items: center;
  gap: 0.65rem;
}

.attachment-selection:has(> button.hidden) {
  margin-top: -0.75rem;
}

.attachment-name {
  min-width: 0;
  flex: 1;
  overflow: hidden;
  color: var(--muted);
  font-size: 0.82rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.attachment-card {
  display: grid;
  width: min(34rem, 100%);
  gap: 0.65rem;
  margin-top: 0.35rem;
  padding: 0.75rem;
  border: 1px solid var(--border);
  border-radius: 0.8rem;
  background: var(--surface-2);
}

.attachment-preview {
  display: block;
  width: auto;
  max-width: 100%;
  max-height: 24rem;
  border-radius: 0.55rem;
  object-fit: contain;
}

.attachment-details {
  display: grid;
  min-width: 0;
  gap: 0.2rem;
}

.attachment-download {
  overflow: hidden;
  color: var(--accent-strong);
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.attachment-metadata {
  color: var(--muted);
  font-size: 0.76rem;
  overflow-wrap: anywhere;
}

@media (max-width: 34rem) {
  .presence-panel {
    display: none;
  }

}
