 :root{
  --bg:#16222a; /* lighter background */
  --panel:#22303a; /* lighter panel */
  --accent:#e6f0d9; /* brighter text */
  --muted:#b8c7a6; /* lighter muted */
  --danger:#c14a4a;
}
*{box-sizing:border-box;font-family:Inter,Segoe UI,Roboto,Arial,Helvetica,sans-serif}
html,body,#app{height:100%}
body{
  margin:0;
  background:linear-gradient(180deg,#1a2733 0%, #2a3b4d 100%);
  color:var(--accent);
}
.app{max-width:1000px;margin:32px auto;padding:18px;border-radius:8px;background:linear-gradient(180deg,rgba(255,255,255,0.02),rgba(0,0,0,0.02));box-shadow:0 6px 28px rgba(0,0,0,0.6)}
.header{display:flex;align-items:flex-end;justify-content:space-between;padding:12px 18px;border-bottom:1px solid rgba(255,255,255,0.03)}
.brand{font-size:36px;font-weight:700;letter-spacing:4px;color:#e6f0d9}
.subtitle{color:var(--muted);font-size:13px}
.main {
  display: grid;
  grid-template-columns: 320px 1fr;
  grid-template-areas: 
    "left msg-list";
  gap: 16px;
  padding: 18px;
  height: calc(100vh - 140px);
}

/* Media query for mobile screens */
@media screen and (max-width: 768px) {
  .main {
    display: flex;
    flex-direction: column;
    height: auto;
    padding: 8px;
  }

  .main > * {
    width: 100% !important;
    max-width: none !important;
  }

  .message-list {
    order: -1; /* Move messages to top */
    height: 60vh;
  }

  .messages {
    max-height: none;
    height: calc(60vh - 60px); /* Account for header */
  }

  #rosterPanel {
    max-height: none;
  }

  .app {
    margin: 0;
    border-radius: 0;
    padding: 8px;
  }
}

.main > :first-child {
  grid-area: left;
  display: flex;
  flex-direction: column;
  gap: 16px;
  align-items: start;
}

.panel {
  background: var(--panel);
  padding: 16px;
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,0.06);
  width: 100%;
  box-shadow: 0 2px 12px rgba(0,0,0,0.08);
}

#loginPanel { 
  grid-area: login; 
}

#rosterPanel { 
  grid-area: roster;
  max-height: 200px;
  overflow-y: auto;
}

.message-compose {
  grid-area: compose;
}

.messages {
  max-height: calc(100vh - 200px);
  overflow-y: auto;
  padding-right: 8px;
  /* Fancy scrollbar styling */
  scrollbar-width: thin;
  scrollbar-color: rgba(184, 199, 166, 0.3) rgba(13, 26, 36, 0.5);
}

/* Webkit scrollbar styling */
.messages::-webkit-scrollbar {
  width: 8px;
}

.messages::-webkit-scrollbar-track {
  background: rgba(13, 26, 36, 0.5);
  border-radius: 4px;
}

.messages::-webkit-scrollbar-thumb {
  background: rgba(184, 199, 166, 0.3);
  border-radius: 4px;
  transition: background 0.2s;
}

.messages::-webkit-scrollbar-thumb:hover {
  background: rgba(184, 199, 166, 0.5);
}

.message-list {
  grid-area: msg-list;
  height: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  align-self: stretch;
}

.panel h3 {
  margin: 0;
  color: #f0f7e8;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

button.icon-button {
  background: none;
  padding: 4px 8px;
  font-size: 20px;
  line-height: 1;
  transition: transform 0.2s ease-in-out;
}

button.icon-button:hover {
  transform: rotate(30deg);
}

.controls label, input, textarea {
  display: block;
  width: 100%;
  margin-bottom: 8px;
}

.pin-info {
  color: var(--muted);
  font-size: 0.9em;
}

.panel.roster {
  border-left: 3px solid #4a944a;
}

#loginHint {
  margin-bottom: 12px;
  font-weight: 500;
}

input, textarea {
  background: #07121a;
  border: 1px solid rgba(255,255,255,0.04);
  color: var(--accent);
  padding: 8px;
  border-radius: 4px;
}

.hint.small {
  font-size: 12px;
  color: var(--muted);
  margin-top: -6px;
  margin-bottom: 12px;
}

.actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}

button {
  background: #0f2a2a;
  border: none;
  padding: 8px 12px;
  border-radius: 4px;
  color: #e8f4ea;
  cursor: pointer;
}

button:hover {
  opacity: 0.95;
}

button.danger {
  background: #3a1f1f;
}

/* Message panel specific styles */
.messages {
  flex: 1;
  overflow-y: auto;
  padding: 4px;
  min-height: 300px;
  margin: 0;
}

/* Fancy scrollbar styling for both messages and roster */
.messages::-webkit-scrollbar,
#rosterPanel::-webkit-scrollbar {
  width: 8px;
}

.messages::-webkit-scrollbar-track,
#rosterPanel::-webkit-scrollbar-track {
  background: rgba(0,0,0,0.2);
  border-radius: 4px;
}

.messages::-webkit-scrollbar-thumb,
#rosterPanel::-webkit-scrollbar-thumb {
  background: rgba(184,199,166,0.2);
  border-radius: 4px;
}

.messages::-webkit-scrollbar-thumb:hover,
#rosterPanel::-webkit-scrollbar-thumb:hover {
  background: rgba(184,199,166,0.3);
}

.msg {
  border-left: 3px solid rgba(255,255,255,0.03);
  padding: 8px;
  margin-bottom: 8px;
  background: linear-gradient(180deg,rgba(255,255,255,0.01),transparent);
}

.roster-list {
  margin-bottom: 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  max-height: 120px;
  overflow-y: auto;
}

.roster-item {
  background: rgba(255,255,255,0.03);
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 14px;
  border: 1px solid transparent;
}

.roster-item.current {
  background: rgba(74, 148, 74, 0.15);
  border-color: rgba(74, 148, 74, 0.3);
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
}

.roster-item.current:hover {
  background: rgba(74, 148, 74, 0.25);
  box-shadow: 0 0 15px rgba(74, 148, 74, 0.15);
}

/* Panel header styling */
.message-list h3,
.message-compose h3 {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.message-list .actions {
  margin-top: auto;
}

@media (max-width: 800px) {
  .main {
    grid-template-columns: 1fr;
    grid-template-areas: 
      "login"
      "roster"
      "compose"
      "msg-list";
    height: auto;
  }
  
  .message-list {
    min-height: 400px;
  }
  
  #rosterPanel {
    max-height: none;
  }
}
.msg .meta{font-size:12px;color:var(--muted);display:flex;gap:8px;align-items:center}
.msg .body{margin-top:6px;color:#eef6df}
.hint,.empty,.error{color:var(--muted);padding:8px}

@media (max-width:800px){.main{grid-template-columns:1fr}}
