:root {
  color-scheme: light dark;
  --bg: #0b1220;
  --card: #111827;
  --text: #e5e7eb;
  --muted: #9ca3af;
  --accent: #22c55e;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}

.hidden {
  display: none !important;
}

.authScreen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.authCard {
  width: min(420px, 100%);
  background: var(--card);
  border: 1px solid #1f2937;
  border-radius: 12px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.colorPicker {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.colorSwatch {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.colorSwatch input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.colorSwatch .swatch {
  width: 28px;
  height: 28px;
  border-radius: 999px;
  background: var(--swatch);
  border: 2px solid rgba(255, 255, 255, 0.18);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.35) inset;
}

.colorSwatch input:checked + .swatch {
  outline: 2px solid rgba(255, 255, 255, 0.85);
  outline-offset: 2px;
  border-color: rgba(255, 255, 255, 0.65);
}

header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px;
  border-bottom: 1px solid #1f2937;
}

.authRow {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.topRightMenu {
  position: relative;
}

.menuDots {
  width: 40px;
  font-size: 20px;
  line-height: 1;
  padding: 4px 0;
}

.menuPanel {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 230px;
  background: var(--card);
  border: 1px solid #1f2937;
  border-radius: 10px;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  z-index: 20;
}

.menuUser {
  color: var(--muted);
  font-size: 12px;
  padding: 4px 2px 8px;
}

.modalOverlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 50;
}

.modal {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: min(480px, 92vw);
  background: var(--card);
  border: 1px solid #1f2937;
  border-radius: 12px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  z-index: 51;
}

.modalHeader {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modalBody {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.modalFooter {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.iconBtn {
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.secondaryBtn {
  background: #0b1220;
  border-color: #2a3446;
}

.userPickRow {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.userPickRow label {
  flex: 1;
}
nav {
  display: flex;
  gap: 8px;
  padding: 12px 16px;
}

main {
  padding: 0 16px 24px;
}

.tab {
  display: none;
}

.tab.active {
  display: block;
}

button,
input,
textarea {
  border: 1px solid #374151;
  background: #0f172a;
  color: var(--text);
  border-radius: 8px;
  padding: 8px 10px;
}

button {
  cursor: pointer;
}

button.active {
  border-color: var(--accent);
}

.chatForm,
.formCol {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 12px;
}

#chat.tab.active {
  display: flex;
  flex-direction: column;
  min-height: 68vh;
}

.chatTopBar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: 6px 0 10px;
}

.chatTitle {
  margin: 0;
  flex: 1;
  text-align: center;
}

.chatItem {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.chatItemTitle {
  font-weight: 700;
}

.chatItemMeta {
  color: var(--muted);
  font-size: 12px;
}

.fileAttachment {
  margin-top: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.fileLink {
  color: var(--accent);
  text-decoration: none;
  word-break: break-word;
}

.chatMessages {
  flex: 1;
  overflow-y: auto;
  min-height: 320px;
  max-height: 68vh;
  margin-bottom: 12px;
}

.chatComposer {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: auto;
}

.chatInputWrap {
  position: relative;
  flex: 1;
}

.chatInputWrap #messageInput {
  width: 100%;
  padding-right: 42px;
}

.chatInputWrap #attachFileBtn {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
}

.iconActionBtn {
  width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

.iconActionBtn svg {
  width: 20px;
  height: 20px;
  display: block;
  fill: none;
  stroke: currentColor;
}

.sendBtn {
  border-color: var(--accent);
  color: var(--accent);
}

.formRow {
  display: grid;
  grid-template-columns: repeat(5, minmax(120px, 1fr));
  gap: 8px;
  margin-bottom: 12px;
}

.scheduleFilterGroup {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.scheduleFilterBtn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 10px;
  border: 1px solid #374151;
  background: #0f172a;
  color: var(--text);
  border-radius: 999px;
  cursor: pointer;
  user-select: none;
  margin: 0;
}

.scheduleFilterBtn input[type="radio"] {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.scheduleFilterBtn:hover {
  border-color: #64748b;
}

/* Selected state (modern browsers) */
.scheduleFilterBtn:has(input[type="radio"]:checked) {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(34, 197, 94, 0.18);
}

/* Fallback if :has() is not supported */
.scheduleFilterBtn.isSelected {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(34, 197, 94, 0.18);
}

.list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.card {
  background: var(--card);
  border: 1px solid #1f2937;
  border-radius: 10px;
  padding: 10px;
}

.meta {
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 6px;
}

.messageHeader {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.dangerBtn {
  border-color: #7f1d1d;
}

.messageActions {
  position: relative;
}

.iconDotsBtn {
  width: 30px;
  height: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border-radius: 6px;
}

.iconDotsBtn svg {
  width: 18px;
  height: 18px;
  fill: currentColor;
}

.messageMenu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  min-width: 140px;
  background: var(--card);
  border: 1px solid #1f2937;
  border-radius: 8px;
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  z-index: 10;
}

#currentUser {
  color: var(--muted);
  font-size: 12px;
}

.media {
  max-width: 100%;
  max-height: 280px;
  border-radius: 8px;
  margin-top: 8px;
}

pre {
  white-space: pre-wrap;
  margin: 8px 0 0;
}

@media (max-width: 900px) {
  .formRow {
    grid-template-columns: 1fr;
  }
}
