#app {
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
  padding-bottom: env(safe-area-inset-bottom);
}

.main {
  min-height: 0;
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) clamp(158px, 22vw, 230px);
  grid-template-rows: auto minmax(0, 1fr);
  grid-template-areas:
    "tabs tabs"
    "log names";
}

.main.no-names {
  grid-template-columns: minmax(0, 1fr);
  grid-template-areas:
    "tabs"
    "log";
}

.main.no-names #names { display: none; }

#brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  padding: 12px 14px 4px;
  background: #f4f1ea;
}

.brand-name { min-width: 0; }

.brand-title {
  color: #000;
  font-weight: 800;
  font-size: clamp(22px, 4vw, 34px);
  letter-spacing: -0.04em;
  line-height: 0.95;
  text-transform: uppercase;
}

#channels { grid-area: tabs; }
.center { grid-area: log; }
#names {
  grid-area: names;
  padding: 8px 6px;
}

#names, #log {
  border: 1px solid #000;
  min-height: 0;
  min-width: 0;
}

.center {
  min-height: 0;
  min-width: 0;
  display: grid;
  grid-template-rows: minmax(0, 1fr);
}

#channels {
  min-height: 0;
  min-width: 0;
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 8px;
  overflow-x: auto;
  overflow-y: hidden;
  margin: 0;
  border: 0;
  background: #f0e4c8;
  box-shadow: none;
  padding: 8px 12px 10px;
}

#names, #log { overflow: auto; }

#names, #log, #channels {
  scrollbar-width: thin;
  scrollbar-color: #3f2a1a #f4f1ea;
}

#channels { scrollbar-color: #3f2a1a #f0e4c8; }

#names::-webkit-scrollbar,
#log::-webkit-scrollbar,
#channels::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

#names::-webkit-scrollbar-button,
#log::-webkit-scrollbar-button,
#channels::-webkit-scrollbar-button {
  display: none;
  width: 0;
  height: 0;
}

#names::-webkit-scrollbar-thumb,
#log::-webkit-scrollbar-thumb,
#channels::-webkit-scrollbar-thumb {
  background: #3f2a1a;
}

#names::-webkit-scrollbar-track,
#log::-webkit-scrollbar-track {
  background: #f4f1ea;
}

#channels::-webkit-scrollbar-track { background: #f0e4c8; }

.row, .name {
  padding: 3px 8px;
  white-space: pre;
  cursor: pointer;
}

.name {
  color: #3f2a1a;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.01em;
}

.name-prefix {
  display: inline-block;
  width: 13px;
  height: 13px;
  margin-right: 4px;
  vertical-align: -2px;
  color: #e87820;
  letter-spacing: 0;
}

.name-prefix svg,
.name-prefix img {
  display: block;
  width: 13px;
  height: 13px;
}

.name-prefix img { object-fit: contain; }

.name-head {
  width: fit-content;
  max-width: 100%;
  margin: 10px 0 6px;
  padding: 5px 8px;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.04em;
  line-height: 1.15;
  text-align: center;
  text-transform: uppercase;
  cursor: default;
}

.name-head-short { display: none; }

.name-head-admin {
  background: #3f2a1a;
  color: #fff;
  transform: rotate(-1.5deg);
}

.name-head-mod {
  background: #e87820;
  color: #fff;
  transform: rotate(1.5deg);
}

.name-head-user {
  background: #fff;
  color: #3f2a1a;
  border: 2px solid #3f2a1a;
}

.chan {
  flex: 0 0 auto;
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
  cursor: pointer;
}

.chan-face {
  display: block;
  border: 2px solid #3f2a1a;
  background: #fff;
  color: #3f2a1a;
  box-shadow: none;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.03em;
  line-height: 1.1;
  text-transform: uppercase;
  padding: 3px 8px;
  white-space: pre;
}

.row.me { font-weight: bold; }
.chan.active .chan-face {
  background: #3f2a1a;
  color: #fff;
  box-shadow: 3px 3px 0 #c46a28;
}

.chan:active .chan-face,
.chan.pressed .chan-face {
  transform: translate(3px, 3px);
  box-shadow: none;
}

@media (max-width: 720px) {
  #app { grid-template-rows: auto minmax(0, 1fr) auto; }
  .main { grid-template-columns: minmax(0, 1fr) clamp(92px, 18vw, 200px); }
  .main.no-names { grid-template-columns: minmax(0, 1fr); }
  #names { padding: 6px 4px; }
  #channels {
    scrollbar-width: none;
    -ms-overflow-style: none;
  }
  #channels::-webkit-scrollbar { display: none; }
  .brand-title { font-size: 22px; }
  .chan-face { font-size: 11px; line-height: 1; padding: 2px 7px; }
  input, #login button { font-size: 16px; }
  .name { padding: 8px 4px; }
  .name-head { font-size: 10px; letter-spacing: 0.02em; padding: 3px 4px; }
  .name-head-full { display: none; }
  .name-head-short { display: inline; }
}
