/* Final UX polish layered over the core chat styles. */

.nickname-field__header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 6px;
  font-size: 11px;
}

.nickname-field__header .field-label,
.nickname-field__header .nick-counter {
  margin: 0;
  color: #999;
  font: inherit;
}

.nick-counter {
  white-space: nowrap;
}

:root[data-theme="light"] .nickname-field__header .field-label,
:root[data-theme="light"] .nickname-field__header .nick-counter { color: #474049; }

@media (min-width: 481px) and (max-height: 720px) {
  .nickname-field__header {
    margin-bottom: 3px;
  }
}

.registration-consent {
  margin-top: 10px;
  color: #bdbdbd;
  font-size: 12px;
  line-height: 1.5;
}

.registration-consent p {
  margin: 0;
}

.registration-rules-link {
  display: inline;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: #e2b8e8;
  font: inherit;
  text-decoration: underline;
  text-underline-offset: 2px;
  cursor: pointer;
}

.registration-rules-link:focus-visible {
  outline: 2px solid currentColor;
  outline-offset: 3px;
}

:root[data-theme="light"] .registration-rules-link { color: #6b376f; }
:root[data-theme="light"] .registration-consent { color: #302a32; }

.chat-header {
  min-height: 44px;
  padding: 5px 10px;
}

.chat-header__left {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 8px;
}

.chat-header__title {
  flex: 0 0 auto;
  font-size: 15px;
}

.chat-header__room {
  min-width: 0;
  margin-top: 0;
  font-size: 11px;
}

#current-room-label,
#private-target-label {
  display: none !important;
}

.chat-header__right {
  gap: 6px;
}

.room-switcher,
.icon-button {
  height: 30px;
}

.layout-toolbar {
  min-height: 30px;
  padding: 3px 8px;
}

.layout-toolbar__label {
  color: #b7b7b7;
  font-weight: 700;
}

.layout-choice {
  min-height: 23px;
  padding: 0 8px;
}

#general-section > .section-title,
#private-section > .section-title {
  min-height: 22px;
  padding: 3px 10px;
  font-size: 9px;
}

#smile-panel {
  display: none !important;
}

.composer-row {
  gap: 6px;
  padding: 5px 7px;
}

.composer-field {
  position: relative;
  min-height: 34px;
  padding: 0 7px;
  border-radius: 8px;
}

.composer-field #input {
  height: 34px;
  padding-right: 29px;
  font-size: 13px;
}

#target-nickname.selected-target,
.reply-reference {
  height: 24px;
  padding: 0 7px;
  font-size: 11px;
}

.composer-row > .btn {
  min-height: 34px;
  height: 34px;
  padding: 0 12px;
  border-radius: 8px;
  font-size: 13px;
  line-height: 1;
}

.emoji-toggle {
  display: inline-flex;
  width: 25px;
  height: 25px;
  flex: 0 0 25px;
  align-items: center;
  justify-content: center;
  margin-left: -28px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: #9c9c9c;
  cursor: pointer;
  font-size: 17px;
  line-height: 1;
  opacity: 0.78;
}

.emoji-toggle:hover,
.emoji-toggle[aria-expanded="true"] {
  color: #fff;
  opacity: 1;
}

.emoji-popup {
  position: absolute;
  right: 2px;
  bottom: calc(100% + 8px);
  z-index: 1200;
  display: flex;
  width: min(340px, calc(100vw - 34px));
  max-height: 320px;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid #383838;
  border-radius: 12px;
  background: rgba(17, 17, 17, 0.98);
  box-shadow: 0 16px 46px rgba(0, 0, 0, 0.72);
}

.emoji-tabs {
  display: flex;
  flex: 0 0 auto;
  gap: 3px;
  padding: 6px;
  overflow-x: auto;
  overflow-y: hidden;
  border-bottom: 1px solid #2d2d2d;
  background: #0d0d0d;
  scrollbar-width: thin;
}

.emoji-category-tab {
  display: inline-flex;
  width: 35px;
  height: 32px;
  flex: 0 0 35px;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 7px;
  background: transparent;
  cursor: pointer;
  font-size: 19px;
  opacity: 0.68;
}

.emoji-category-tab:hover,
.emoji-category-tab:focus-visible {
  background: #242424;
  opacity: 1;
}

.emoji-category-tab.is-active {
  border-color: rgba(223, 0, 255, 0.5);
  background: rgba(223, 0, 255, 0.13);
  opacity: 1;
}

.emoji-grid {
  display: grid;
  min-height: 0;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  gap: 3px;
  padding: 8px;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-color: #363636 #111;
  scrollbar-width: thin;
}

.emoji-option {
  display: flex;
  min-width: 0;
  height: 34px;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 0;
  border-radius: 7px;
  background: transparent;
  cursor: pointer;
  font-size: 22px;
}

.emoji-option:hover,
.emoji-option:focus-visible {
  background: #292929;
}

.emoji-grid--retro {
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 4px;
}

.emoji-option--retro {
  height: 54px;
  border: 1px solid transparent;
  background: rgba(255, 255, 255, 0.025);
}

.emoji-option--retro:hover,
.emoji-option--retro:focus-visible {
  border-color: rgba(223, 0, 255, 0.58);
  background: rgba(223, 0, 255, 0.12);
}

.smile--retro {
  display: inline-block;
  flex: 0 0 auto;
  vertical-align: middle;
  background-image: url("/smiles/retro-sprite.png?v=retro-sprite-20260829-1");
  background-repeat: no-repeat;
  background-size: 600% 600%;
  background-position:
    calc(var(--retro-column) * 20%)
    calc(var(--retro-row) * 20%);
}

.emoji-retro-preview {
  width: 50px !important;
  height: 50px !important;
  margin: 0 !important;
  filter: drop-shadow(0 2px 2px rgba(0, 0, 0, 0.48));
  transition: transform 140ms ease;
}

.emoji-option--retro:hover .emoji-retro-preview,
.emoji-option--retro:focus-visible .emoji-retro-preview {
  transform: scale(1.12);
}

.messages-list .smile--retro {
  width: 42px;
  height: 42px;
  margin: -11px 3px -10px;
  filter: drop-shadow(0 2px 2px rgba(0, 0, 0, 0.46));
}

:root[data-theme="light"] .emoji-option--retro {
  border-color: #d6c9d8;
  background: rgba(100, 62, 108, 0.045);
}

#list-gen .msg-item.is-for-me {
  margin: 3px 7px;
  padding: 7px 10px;
  border: 1px solid rgba(255, 209, 102, 0.62);
  border-left: 3px solid #ffd166;
  border-radius: 7px;
  background: rgba(255, 209, 102, 0.075);
  box-shadow: inset 0 0 0 1px rgba(255, 209, 102, 0.05);
}

#list-gen .msg-item.is-for-me .msg-time {
  color: #ffd166;
}

.general-ignore-toggle {
  white-space: nowrap;
}

.general-ignore-toggle.is-active {
  border-color: rgba(223, 0, 255, 0.62);
  background: rgba(223, 0, 255, 0.16);
  color: #fff;
}

.general-ignore-toggle:disabled {
  cursor: not-allowed;
  opacity: 0.42;
}

.general-ignored-message {
  display: none !important;
}

#auth-submit:disabled {
  cursor: not-allowed;
  opacity: 0.42;
  filter: none;
}

@media (min-width: 769px) {
  .chat-header {
    min-height: 38px;
    padding: 3px 8px;
    gap: 8px;
  }

  .chat-header__left {
    flex: 1 1 auto;
    gap: 7px;
    overflow: hidden;
  }

  .chat-header__title {
    font-size: 14px;
  }

  .chat-header .layout-toolbar {
    display: flex;
    min-width: 0;
    min-height: 0;
    padding: 0;
    flex: 0 1 auto;
    gap: 3px;
    border: 0;
    background: transparent;
  }

  .chat-header .layout-toolbar__label {
    margin-right: 2px;
    color: #c7c7c7;
    font-size: 10px;
    font-weight: 700;
  }

  .chat-header .layout-choice {
    min-height: 22px;
    height: 22px;
    padding: 0 7px;
    font-size: 10px;
  }

  .chat-header .chat-color-picker {
    margin-left: 3px;
  }

  .chat-header .chat-color-button {
    min-height: 22px;
    height: 22px;
    padding: 0 7px;
    font-size: 10px;
  }

  .chat-header__right {
    flex: 0 0 auto;
    gap: 5px;
  }

  .room-switcher {
    max-width: 185px;
    height: 28px;
    padding: 0 8px;
    font-size: 12px;
  }

  #open-security-dashboard {
    min-height: 28px;
    height: 28px;
    padding: 0 9px;
    font-size: 11px;
    white-space: nowrap;
  }

  #logout-button {
    height: 28px;
    padding: 0 9px;
    font-size: 12px;
  }
}

@media (max-width: 768px) {
  .chat-header {
    min-height: 42px;
    padding: 4px 7px;
  }

  .chat-header__title {
    display: none;
  }

  .room-switcher {
    max-width: 145px;
    height: 29px;
  }

  .icon-button {
    height: 29px;
  }

  .mobile-nav {
    min-height: 34px;
    flex-basis: 34px;
  }

  .composer-row {
    gap: 5px;
    padding: 5px;
  }

  .composer-field {
    min-height: 38px;
    padding: 0 6px;
  }

  .composer-field #input {
    height: 38px;
    padding-right: 30px;
    font-size: 14px;
  }

  #target-nickname.selected-target,
  .reply-reference {
    height: 25px;
    max-width: 32%;
    padding: 0 6px;
    font-size: 11px;
  }

  .composer-row > .btn {
    min-height: 38px;
    height: 38px;
    padding: 0 9px;
    font-size: 13px;
  }

  .emoji-toggle {
    width: 27px;
    height: 27px;
    flex-basis: 27px;
    margin-left: -30px;
    font-size: 18px;
  }

  .emoji-popup {
    left: 0;
    right: auto;
    width: min(315px, calc(100vw - 20px));
    max-height: 300px;
  }

  .emoji-tabs {
    gap: 2px;
    padding: 5px;
  }

  .emoji-category-tab {
    width: 36px;
    height: 32px;
    flex-basis: 36px;
  }

  .emoji-grid {
    grid-template-columns: repeat(6, minmax(0, 1fr));
    padding: 7px;
  }

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

  .emoji-option--retro {
    height: 50px;
  }

  .emoji-retro-preview {
    width: 46px !important;
    height: 46px !important;
  }

  .messages-list .smile--retro {
    width: 40px;
    height: 40px;
    margin-top: -10px;
    margin-bottom: -9px;
  }

  .general-ignore-toggle {
    max-width: 128px;
    overflow: hidden;
    text-overflow: ellipsis;
  }
}

/* Denser message stream: keep more conversation visible without hurting readability. */
.messages-list .msg-item {
  gap: 8px;
  min-height: 0;
  padding-top: 3px;
  padding-bottom: 3px;
  font-size: 13px;
  line-height: 1.25;
}

.messages-list .msg-time {
  min-width: 89px;
  font-size: 10px;
  line-height: 1.35;
}

.messages-list .msg-body,
.messages-list .msg-text {
  line-height: 1.25;
}

.system-list li {
  min-height: 0;
  padding-top: 2px;
  padding-bottom: 2px;
  font-size: 10px;
  line-height: 1.2;
}

/* Join/leave and other service notices should take the least vertical space. */
.messages-list .msg-system-inline {
  gap: 7px;
  padding-top: 2px;
  padding-bottom: 2px;
  border-left-width: 1px;
  font-size: 11px;
  line-height: 1.15;
}

.messages-list .msg-system-inline .msg-time {
  min-width: 81px;
  font-size: 9px;
  line-height: 1.25;
}

.messages-list .msg-system-inline__body {
  line-height: 1.15;
}

/* Addressed/private highlight: preserve the yellow cue but make the frame slimmer. */
.messages-list .msg-item.is-for-me {
  margin: 1px 5px;
  padding: 3px 8px;
  border-left-width: 2px;
  border-radius: 5px;
  box-shadow: none;
}

@media (max-width: 768px) {
  .messages-list .msg-item {
    gap: 7px;
    padding: 2px 8px;
  }

  .messages-list .msg-time {
    min-width: 89px;
    font-size: 10px;
  }

  .messages-list .msg-system-inline {
    padding-top: 1px;
    padding-bottom: 1px;
    font-size: 10px;
  }

  .messages-list .msg-system-inline .msg-time {
    min-width: 81px;
    font-size: 9px;
  }

  .messages-list .msg-item.is-for-me {
    margin: 1px 3px;
    padding: 2px 7px;
  }
}
