#caf {
  max-width: 1100px;
  margin: 0 auto;
  padding: 12px
}

.bar {
  background: rgba(20, 88, 122, .85);
  color: #fff;
  text-align: center;
  padding: 12px;
  border-radius: 18px;
  font-weight: 700;
  letter-spacing: 2px;
  margin-bottom: 8px;
  cursor: pointer;
  border: 1px solid var(--glass-bd);
  box-shadow: var(--shadow);
  -webkit-backdrop-filter: var(--blur);
  backdrop-filter: var(--blur);
  transition: transform .15s;
}

.bar:hover {
  transform: translateY(-2px)
}

.bar small {
  display: block;
  font-weight: 400;
  letter-spacing: 0;
  margin-top: 4px;
  opacity: .9
}

#tables {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
  gap: 16px;
  margin-top: 16px;
}

.table {
  background: var(--glass);
  border: 1px solid var(--glass-bd);
  border-radius: 50% 50% 18px 18px / 28% 28% 18px 18px;
  padding: 16px 8px;
  min-height: 120px;
  text-align: center;
  cursor: pointer;
  box-shadow: var(--shadow);
  -webkit-backdrop-filter: var(--blur);
  backdrop-filter: var(--blur);
  transition: transform .15s, border-color .15s, box-shadow .15s;
}

.table:last-child:nth-child(odd) {
  grid-column: 1 / -1
}

.table:hover {
  transform: translateY(-3px);
  border-color: var(--p)
}

.table.mine {
  border: 2px solid var(--p);
  box-shadow: 0 0 0 4px rgba(37, 148, 203, .25), var(--shadow)
}

.table b {
  display: block;
  margin-bottom: 6px
}

.table .n {
  display: inline-block;
  margin-top: 8px;
  padding: 4px 12px;
  border-radius: 999px;
  font-size: .8rem;
  font-weight: 700;
  color: #fff;
  background: var(--p)
}

.table .n:empty {
  display: none
}

.n.empty {
  opacity: .5;
}

/* kutija umesto skeletona kad se baza ne javi (prikazuje je showConnectionProblem u render.js) */
.conn-box {
  grid-column: 1 / -1;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 20px 18px;
  text-align: center;
  background: var(--card);
  color: var(--tx);
  border: 1px solid var(--danger);
  border-radius: 16px;
}

.conn-box span {
  opacity: .8;
  font-size: .9rem;
}

/* skeleton: sivi blokovi koji se presijavaju dok se podaci ne učitaju */
.sk {
  display: block;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--bubble) 25%, var(--bd) 37%, var(--bubble) 63%);
  background-size: 400% 100%;
  animation: sk-shimmer 1.4s ease infinite;
}

@keyframes sk-shimmer {
  0% {
    background-position: 100% 50%;
  }

  100% {
    background-position: 0 50%;
  }
}

.table.skeleton {
  cursor: default;
  pointer-events: none;
}

.sk-title {
  width: 60%;
  height: 1.1em;
  margin: 6px auto 0;
}

.sk-pill {
  width: 3.4rem;
  height: 1.5rem;
  margin: 14px auto 0;
}

/* u šanku je pozadina tamnoplava, pa je skeleton providno beo */
.bar .sk {
  background: linear-gradient(90deg, rgba(255, 255, 255, .18) 25%, rgba(255, 255, 255, .38) 37%, rgba(255, 255, 255, .18) 63%);
  background-size: 400% 100%;
}

.bar .sk-line {
  width: 45%;
  max-width: 220px;
  height: .85em;
  margin: 8px auto 0;
}

@media (prefers-reduced-motion: reduce) {
  .sk {
    animation: none;
  }
}


.ico-people {
  display: inline-block;
  width: 1.2em;
  height: 1.2em;
  vertical-align: -0.15em;
  background: currentColor;
  -webkit-mask: url("../img/icons/ui/people.svg") center / contain no-repeat;
  mask: url("../img/icons/ui/people.svg") center / contain no-repeat;
}

.lock {
  font-size: .75rem;
  opacity: .7;
  margin-top: 1rem;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 6px;
  line-height: 0;
}

.icon-btn[hidden],
.chat-actions [hidden] {
  display: none;
}

.icon-btn img {
  display: block;
}

.icon-btn:disabled {
  opacity: .4;
  cursor: not-allowed;
}

.chat-actions {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

/* meni sa tri tačke u zaglavlju chata */
.chat-menu {
  position: relative;
}

.menu-list {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 20;
  min-width: 210px;
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  background: var(--pd);
  color: #fff;
  border-radius: 14px;
  box-shadow: var(--shadow);
}

.menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 12px;
  background: transparent;
  color: inherit;
  text-align: left;
  border-radius: 10px;
}

.menu-item:hover:not(:disabled) {
  background: rgba(255, 255, 255, .15);
  filter: none;
}

.menu-item img {
  flex: none;
}

.menu-list .menu-item.radio-on {
  box-shadow: none;
  /* u meniju ne treba prsten kao na dugmetu u zaglavlju */
}

.menu-item.radio-on .menu-label::after {
  content: ' ♪';
}

/* "Ko je za stolom" postoji samo na telefonu/tabletu (na desktopu je lista stalno sa strane) */
.menu-list .menu-item.menu-people {
  display: none;
}

.menu-sep {
  margin: 4px 6px;
  border: 0;
  border-top: 1px solid rgba(255, 255, 255, .25);
}

/* popup "Ko je za stolom": manji od chata, lista se skroluje unutra */
.people-modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(10, 26, 36, .45);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
}

.people-modal[hidden] {
  display: none;
}

.people-box {
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 320px;
  max-height: 60vh;
  max-height: 60dvh;
  background: var(--card);
  color: var(--tx);
  border: 1px solid var(--bd);
  border-radius: 20px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.people-head {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 12px 12px 18px;
  border-bottom: 1px solid var(--bd);
}

.people-list {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px 18px;
}

.people-list .mem {
  margin: 0;
}

.people-empty {
  opacity: .7;
  text-align: center;
}

/* popup je samo za telefon; na većem ekranu je lista stalno sa strane */
@media (min-width: 768px) {
  .people-modal {
    display: none !important;
  }
}

/* radio: modal je stalno u strani (nevidljiv kad je zatvoren), da muzika ne staje */
.radio-modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(0, 0, 0, .45);
}

.radio-modal:not(.open) {
  visibility: hidden;
  pointer-events: none;
  background: transparent;
}

.radio-card {
  width: 100%;
  max-width: 420px;
  padding: 16px;
  background: var(--card);
  color: var(--tx);
  border: 1px solid var(--bd);
  border-radius: 20px;
  box-shadow: var(--shadow);
}

.radio-head,
.radio-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.radio-head {
  margin-bottom: 12px;
}

.radio-foot {
  margin-top: 12px;
  font-size: .8rem;
}

.radio-player iframe {
  display: block;
  width: 100%;
  height: 100px;
  border: 0;
}

/* dugme svetli dok radio svira */
[data-radio-toggle].radio-on {
  box-shadow: 0 0 0 3px rgba(37, 148, 203, .45);
}

#ctopic {
  font-size: .8rem;
}

#chat {
  margin-top: 20px;
  display: none;
  overflow: hidden;
  background: var(--glass-solid);
  border: 1px solid var(--glass-bd);
  border-radius: 20px;
  box-shadow: var(--shadow);
}

#chat .top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding: 10px 14px;
  background: rgba(37, 148, 203, .9);
  color: #fff;
}

.cw {
  display: flex;
  flex-wrap: wrap
}

#msgs {
  flex: 1 1 320px;
  height: 340px;
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 2px
}

/* brojač znakova ispod poruka; crven kad je limit prekoračen */
.len-hint {
  flex: none;
  padding: 4px 14px 0;
  font-size: .8rem;
  text-align: right;
  opacity: .7;
}

.len-hint.over {
  opacity: 1;
  font-weight: 700;
  color: var(--danger);
}

/* polje za poruku: na svetloj temi okvir je boje --p, na tamnoj ostaje kao i ostala polja */
#inp {
  border-color: var(--p);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) #inp {
    border-color: var(--glass-bd);
  }
}

:root[data-theme="dark"] #inp {
  border-color: var(--glass-bd);
}

#inp[aria-invalid="true"] {
  outline: 2px solid var(--danger);
  outline-offset: 0;
}

/* dugme za slanje: ikonica send.svg umesto teksta (boja ikonice = boja teksta dugmeta) */
#snd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 9px 14px;
  line-height: 0;
}

.ico-send {
  display: block;
  width: 22px;
  height: 22px;
  background: currentColor;
  -webkit-mask: url("../img/icons/ui/send.svg") center / contain no-repeat;
  mask: url("../img/icons/ui/send.svg") center / contain no-repeat;
}

.send {
  display: flex;
  gap: 8px;
  padding: 10px;
  border-top: 1px solid var(--glass-bd)
}

#members {
  flex: 0 0 200px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 12px;
  font-size: .9rem;
  border-left: 1px solid var(--glass-bd)
}

#members br {
  display: none
}

.mem {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  margin-bottom: 6px;
  gap: 8px
}

.msg-row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  max-width: 85%;
  flex: none
}

.msg-row.first {
  margin-top: 10px
}

.msg-row.theirs {
  align-self: flex-start
}

.msg-row.mine {
  align-self: flex-end;
  flex-direction: row-reverse
}

.msg-avatar {
  flex: none;
  width: 36px;
  height: 36px
}

.msg-avatar .avatar {
  width: 36px;
  height: 36px;
  margin: 0
}

.msg-bubble {
  min-width: 0;
  padding: 6px 12px 4px;
  border-radius: 16px;
  background: var(--bubble);
  word-break: break-word
}

.msg-row.theirs.first .msg-bubble {
  border-top-left-radius: 4px
}

.msg-row.mine .msg-bubble {
  background: var(--p);
  color: #fff
}

.msg-row.mine.first .msg-bubble {
  border-top-right-radius: 4px
}

.msg-name {
  font-size: .8rem;
  font-weight: 700;
  color: var(--p);
  margin-bottom: 2px
}

.msg-row.mine .msg-name {
  color: #dff1fb;
  text-align: right
}

.msg-text {
  white-space: pre-wrap;
  font-weight: normal
}

.msg-time {
  font-size: .7rem;
  opacity: .65;
  text-align: right;
  margin-top: 2px
}

@media (min-width: 768px) {
  #caf {
    padding: 16px
  }

  .bar {
    padding: 16px;
    letter-spacing: 3px
  }

  .table {
    padding: 32px 20px;
    min-height: 150px
  }

  .table:last-child:nth-child(odd) {
    grid-column: auto
  }
}

@media (min-width: 992px) {
  .table {
    grid-column: span 2
  }
}

@media (max-width: 767px) {
  #chat[style*="block"] {
    position: fixed;
    inset: 0;
    z-index: 60;
    margin: 0;
    border: 0;
    border-radius: 0;
    height: 100dvh;
    display: flex !important;
    flex-direction: column;
  }

  #chat .top {
    flex: none;
    padding: 10px 12px
  }

  .cw {
    flex: 1;
    min-height: 0;
    flex-direction: column;
    flex-wrap: nowrap
  }

  #msgs {
    flex: 1 1 auto;
    height: auto;
    min-height: 0
  }

  .menu-list .menu-item.menu-people {
    display: flex;
  }

  /* na telefonu se lista ljudi otvara u popupu ("Ko je za stolom"), ne stoji na vrhu chata */
  #members {
    order: -1;
    flex: none;
    display: none;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px 14px;
    border-left: 0;
    border-bottom: 1px solid var(--glass-bd);
    padding: 8px 12px;
    max-height: 22vh;
    overflow-y: auto;
  }

  .mem {
    margin: 0;
    flex-direction: row
  }

  .send {
    flex: none;
    padding: 8px 10px calc(8px + env(safe-area-inset-bottom, 0px))
  }

  .send button {
    padding: 9px 14px
  }
}

/* Ko-fi malo dugme u traci chata: po defaultu nigde */
#kofi-btn-mobile {
  display: none;
  line-height: 1;
  padding: 6px 8px;
}

/* telefon + otvoren chat: malo dugme se vidi, veliki plutajući Ko-fi nestaje */
@media (max-width: 1400px) {
  body.chat-open #kofi-btn-mobile {
    display: inline-flex;
  }

  body.chat-open .kofi-overlay {
    display: none !important;
  }
}