:root {
  --bg: #313338;
  --panel: #2b2d31;
  --input-bg: #383a40;
  --muted: #b5bac1;
  --accent: #5865f2;
  --bubble: #2f3136;
  --font-sans: "gg sans", "segoe ui", roboto, "helvetica neue", arial, sans-serif;
}

/* base */
html, body {
  height: 100%;
  margin: 0;
  font-family: var(--font-sans);
  background: var(--bg);
  color: #e0e0e0;
}

/* layout */
.app {
  display: grid;
  grid-template-columns: minmax(320px, 380px) 1fr;
  gap: 16px;
  padding: 16px;
  box-sizing: border-box;
  height: 100%;
  overflow: hidden;
}

.panel {
  background: var(--panel);
  border-radius: 8px;
  padding: 14px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.4);
  overflow-y: auto;
  overflow-x: hidden;
  min-width: 0;
}

/* left panel */
.left {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* typography */
h1 {
  font-size: 16px;
  margin: 0 0 8px;
  color: white;
}

.small {
  font-size: 13px;
  color: var(--muted);
}

/* buttons */
.btn {
  background: var(--accent);
  color: white;
  padding: 8px 10px;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 600;
  border: none;
  transition: background 0.15s;
}
.btn:hover {
  background: #4752c4;
}
input[type="file"] {
  display: none;
}

.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

/* inputs */
textarea, #quickSearch {
  width: 100%;
  padding: 8px 10px;
  border-radius: 6px;
  border: none;
  background: var(--input-bg);
  color: #ddd;
  box-sizing: border-box;
  font-size: 13px;
}
textarea {
  min-height: 300px;
  font-family: monospace;
  resize: vertical;
}

/* viewer */
.viewer {
  padding: 18px;
  overflow-y: auto;
  position: relative;
}

/* header */
.header {
  display: flex;
  gap: 16px;
  align-items: center;
  margin-bottom: 16px;
  border-bottom: 1px solid #3c3f44;
  padding-bottom: 8px;
}

.guild-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  background: #222;
  flex-shrink: 0;
  overflow: hidden;
}

.guild-icon img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.channel-info h2 {
  margin: 0;
  font-size: 18px;
  color: white;
}

.channel-info p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

/* messages */
.messages {
  display: flex;
  flex-direction: column;
  gap: 0;
  max-width: 900px;
}

/* each message row */
.msg-row {
  display: flex !important;
  align-items: flex-start;
  gap: 12px;
  padding: 6px 16px;
  width: 100%;
  box-sizing: border-box;
  transition: background 0.15s;
}
.msg-row:hover {
  background: rgba(255,255,255,0.03);
}

.avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: #1e1f22;
  flex-shrink: 0;
  overflow: hidden;
  margin-top: 4px;
}
.avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* message body */
.msg-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.msg-meta {
  display: flex;
  align-items: baseline;
  gap: 6px;
  margin-bottom: 2px;
}

.username {
  font-weight: 600;
  color: white;
}

.timestamp {
  font-size: 12px;
  color: var(--muted);
}

.content {
  background: none;
  color: #dcddde;
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.4;
  font-size: 15px;
}

/* quoted blocks, code, and attachments and audio */
.quote {
  border-left: 3px solid rgba(255, 255, 255, 0.1);
  padding-left: 8px;
  color: var(--muted);
  margin: 4px 0;
  font-size: 14px;
}

.code {
  background: #1e1f22;
  padding: 6px 8px;
  border-radius: 6px;
  font-family: monospace;
  font-size: 13px;
  overflow-x: auto;
  margin: 6px 0;
}

.attachment {
  margin-top: 6px;
  background: rgba(255,255,255,0.03);
  padding: 8px;
  border-radius: 6px;
  font-size: 13px;
  color: #b9bbbe;
}

/* grouping for same author */
.msg-group.same-author {
  margin-left: 52px;
}

/* date separator */
.date-sep {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 18px 0;
  color: var(--muted);
  font-weight: 600;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.date-sep::before, .date-sep::after {
  content: "";
  height: 1px;
  background: #3a3c40;
  flex: 1;
}

/* footer */
.footer {
  margin-top: 16px;
  color: var(--muted);
  font-size: 13px;
}

a {
  color: hsl(221, 94%, 65%);
  text-decoration: underline;
}

.attachment audio {
  width: 100%;
  outline: none;
  border-radius: 50px;
  margin-top: 6px;
  background-color: transparent;
  display: block;
  overflow: hidden; 
  border: none; 
}

/* chrome / edge / safari (webkit-based browsers) */
.attachment audio::-webkit-media-controls-panel {
  background-color: #2f3136;     /* discord-dark background */
  border-radius: 50px;
  color: white !important;
}

.attachment audio::-webkit-media-controls-play-button,
.attachment audio::-webkit-media-controls-timeline,
.attachment audio::-webkit-media-controls-volume-slider,
.attachment audio::-webkit-media-controls-current-time-display,
.attachment audio::-webkit-media-controls-time-remaining-display {
  filter: invert(1) brightness(2);  /* make icons and bars white */
}

/* firefox (partial support, color inversion for consistency) */
.attachment audio::-moz-range-track,
.attachment audio::-moz-range-progress {
  background-color: white;
}

.attachment audio::-moz-range-thumb {
  background-color: white;
  border: none;
}



/* embeds and media thumbnails */

.embed {
  display: flex;
  flex-direction: column;
  background: rgba(46,48,54,0.4);
  border-left: 4px solid var(--accent);
  border-radius: 4px;
  padding: 8px;
  margin-top: 6px;
  gap: 6px;
  max-width: 520px;
}

.embed-inner {
  display: flex;
  flex-direction: row;
  align-items: flex-start;
  gap: 8px;
}

.embed-thumb {
  flex: 0 0 80px;
  height: 80px;
  border-radius: 4px;
  overflow: hidden;
  background: #1e1f22;
}
.embed-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 4px;
}

.embed-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.embed-title {
  font-weight: 600;
  color: white;
  font-size: 14px;
}

.embed-desc {
  font-size: 13px;
  color: var(--muted);
  line-height: 1.4;
}

.embed-url {
  font-size: 12px;
  color: #6893e4;
  text-decoration: none;
  word-break: break-all;
}
.embed-url:hover {
  text-decoration: underline;
}

.embed-image {
  margin-top: 6px;
  border-radius: 4px;
  overflow: hidden;
  max-width: 520px;
}
.embed-image img, .embed-image video {
  width: 100%;
  height: auto;
  border-radius: 4px;
  display: block;
}

/* json viewer */

/* chrome, edge, safari */
.viewer::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

.viewer::-webkit-scrollbar-track {
  background: #202225;
  border-radius: 4px;
}

.viewer::-webkit-scrollbar-thumb {
  background: #4f545c;
  border-radius: 4px;
}

.viewer::-webkit-scrollbar-thumb:hover {
  background: #72767d;
}

/* the json input */

/* firefox */
.viewer {
  scrollbar-width: thin;
  scrollbar-color: #4f545c #202225;
}

/* chrome, edge, safari */
#jsonInput::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

#jsonInput::-webkit-scrollbar-track {
  background: #202225;
  border-radius: 4px;
}

#jsonInput::-webkit-scrollbar-thumb {
  background: #4f545c;
  border-radius: 4px;
}

#jsonInput::-webkit-scrollbar-thumb:hover {
  background: #72767d;
}

/* firefox */
#jsonInput {
  scrollbar-width: thin;
  scrollbar-color: #4f545c #202225;
}



/* responsive */
@media (max-width: 900px) {
  .app {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
  }
  .left { order: 2; }
  .viewer { order: 1; }
}
