@font-face { font-family: "gg sans"; src: url("/fonts/ggsans-400.woff2") format("woff2"); font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: "gg sans"; src: url("/fonts/ggsans-500.woff2") format("woff2"); font-weight: 500; font-style: normal; font-display: swap; }
@font-face { font-family: "gg sans"; src: url("/fonts/ggsans-600.woff2") format("woff2"); font-weight: 600; font-style: normal; font-display: swap; }
@font-face { font-family: "gg sans"; src: url("/fonts/ggsans-700.woff2") format("woff2"); font-weight: 700; font-style: normal; font-display: swap; }

@font-face { font-family: "Sakura"; src: url("/fonts/discord/Sakura-400.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Jellybean"; src: url("/fonts/discord/Jellybean-400.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Modern"; src: url("/fonts/discord/Modern-500.woff2") format("woff2"); font-weight: 500; font-display: swap; }
@font-face { font-family: "Medieval"; src: url("/fonts/discord/Medieval-400.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "8Bit"; src: url("/fonts/discord/8Bit-400.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Vampyre"; src: url("/fonts/discord/Vampyre-400.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Tempo"; src: url("/fonts/discord/Tempo-600.woff2") format("woff2"); font-weight: 600; font-display: swap; }
@font-face { font-family: "Monkey Bars"; src: url("/fonts/discord/MonkeyBars-700.woff2") format("woff2"); font-weight: 700; font-display: swap; }
@font-face { font-family: "Mainframe"; src: url("/fonts/discord/Mainframe-700.woff2") format("woff2"); font-weight: 700; font-display: swap; }
@font-face { font-family: "Headbang"; src: url("/fonts/discord/Headbang-400.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Journal"; src: url("/fonts/discord/Journal-700.woff2") format("woff2"); font-weight: 700; font-display: swap; }

:root {
  --panel: #111214;
  --panel-2: #1e1f22;
  --border: #2b2d31;
  --text: #dbdee1;
  --muted: #949ba4;
  --accent: #5865f2;
  --chat-bg: #1a1a1e;
  --clan-bg: #333338;
  --header: #f2f3f5;
  --danger: #ed4245;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  background: #0b0c0e;
  color: var(--text);
  font-family: "gg sans", system-ui, sans-serif;
}

.app {
  display: grid;
  grid-template-columns: minmax(300px, 380px) 1fr;
  height: 100vh;
  min-height: 100vh;
}

.panel {
  background: var(--panel);
  border-right: 1px solid var(--border);
  overflow: auto;
  padding: 20px 18px 32px;
}

.panel-head h1 {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--header);
  letter-spacing: -0.02em;
}

.panel-head p {
  margin-top: 6px;
  font-size: 0.85rem;
  color: var(--muted);
  line-height: 1.4;
}

.block {
  margin-top: 22px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
}

.block h2 {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin-bottom: 10px;
}

.row {
  display: flex;
  gap: 8px;
  align-items: center;
}

.row.gap { margin-top: 12px; flex-wrap: wrap; }

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 10px;
}

.field span {
  font-size: 0.75rem;
  color: var(--muted);
}

input[type="text"],
input[type="time"],
select,
textarea {
  width: 100%;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font: inherit;
  font-size: 0.9rem;
  padding: 9px 11px;
  outline: none;
}

textarea { resize: vertical; min-height: 72px; }

input:focus, select:focus, textarea:focus {
  border-color: #4e5058;
}

.btn {
  border: 0;
  border-radius: 8px;
  background: #2b2d31;
  color: var(--header);
  font: inherit;
  font-weight: 600;
  font-size: 0.85rem;
  padding: 9px 14px;
  cursor: pointer;
  white-space: nowrap;
}

.btn:hover { filter: brightness(1.08); }
.btn.primary { background: var(--accent); color: #fff; }
.btn.ghost { background: transparent; border: 1px solid var(--border); }
.btn.danger { background: transparent; color: var(--danger); border: 1px solid #5c2326; }

.check {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  color: var(--muted);
  margin: 8px 0 12px;
  cursor: pointer;
}

.check.compact { margin: 0; font-size: 0.8rem; }

.err {
  color: #f23f43;
  font-size: 0.8rem;
  margin-top: 8px;
}

.user-list, .msg-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 10px;
}

.user-card, .msg-card {
  display: flex;
  gap: 10px;
  align-items: center;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 10px;
}

.user-card img {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  object-fit: cover;
}

.user-card .meta, .msg-card .meta {
  flex: 1;
  min-width: 0;
}

.user-card .name, .msg-card .name {
  font-weight: 600;
  font-size: 0.88rem;
  color: var(--header);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-card .sub, .msg-card .sub {
  font-size: 0.72rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.msg-card .sub { white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }

.icon-btn {
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  padding: 4px;
}

.icon-btn:hover { color: var(--danger); }

.stage {
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: #0e0f12;
}

.stage-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 18px;
  border-bottom: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 600;
}

.stage-scroll {
  flex: 1;
  overflow: auto;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 28px 20px 40px;
}

/* —— Discord chat surface —— */
.discord-chat {
  width: min(720px, 100%);
  background: var(--chat-bg);
  border-radius: 0;
  padding: 8px 0 16px;
}

.chat-inner {
  min-height: 120px;
}

/* Discord cozy layout: avatar at 16px, content column starts at 72px */
.msg {
  position: relative;
  display: grid;
  grid-template-columns: 72px 1fr;
  padding: 0.125rem 16px 0.125rem 0;
  overflow: visible;
}

.msg.group {
  margin-top: 1.0625rem;
}

.msg.follow {
  margin-top: 0;
  min-height: 0;
}

.msg.follow .avatar-col { visibility: hidden; }

.avatar-col {
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding-top: 2px;
}

/* Push avatar under the reply row so it lines up with the username */
.msg.has-reply .avatar-col {
  position: relative;
  z-index: 2;
  /* reply line (1.125rem) + gap below reply (10px) */
  padding-top: calc(1.125rem + 10px);
}

.msg.has-reply .body {
  position: relative;
  z-index: 1;
}

.avatar-wrap {
  position: relative;
  width: 40px;
  height: 40px;
}

.avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
  display: block;
}

.deco {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 46px;
  height: 46px;
  transform: translate(-50%, -50%);
  pointer-events: none;
  object-fit: contain;
}

.body {
  min-width: 0;
  padding-right: 8px;
  overflow: visible;
}

.header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  line-height: 1.25rem;
  min-height: 1.25rem;
  gap: 0;
}

.name {
  font-size: 1rem;
  font-weight: 500;
  line-height: 1.25rem;
  margin-right: 0.25rem;
  color: #fff;
  font-synthesis: none;
}

.discord-chat .font-3 { font-family: Sakura, "gg sans", Arial, sans-serif; font-weight: 400; letter-spacing: .04em; }
.discord-chat .font-4 { font-family: Jellybean, "gg sans", Arial, sans-serif; font-weight: 400; }
.discord-chat .font-6 { font-family: Modern, "gg sans", Arial, sans-serif; font-weight: 500; letter-spacing: .01em; }
.discord-chat .font-7 { font-family: Medieval, "gg sans", Arial, sans-serif; font-weight: 400; letter-spacing: .02em; }
.discord-chat .font-8 { font-family: "8Bit", "gg sans", Arial, sans-serif; font-weight: 400; letter-spacing: .02em; }
.discord-chat .font-10 { font-family: Vampyre, "gg sans", Arial, sans-serif; font-weight: 400; letter-spacing: .01em; }
.discord-chat .font-11 { font-family: "gg sans", Arial, sans-serif; font-weight: 500; }
.discord-chat .font-12 { font-family: Tempo, "gg sans", Arial, sans-serif; font-weight: 600; letter-spacing: .03em; }
.discord-chat .font-13 { font-family: "Monkey Bars", "gg sans", Arial, sans-serif; font-weight: 700; }
.discord-chat .font-14 { font-family: Mainframe, "gg sans", Arial, sans-serif; font-weight: 700; letter-spacing: .03em; }
.discord-chat .font-15 { font-family: Headbang, "gg sans", Arial, sans-serif; font-weight: 400; }
.discord-chat .font-16 { font-family: Journal, "gg sans", Arial, sans-serif; font-weight: 700; }

.clan {
  display: inline-flex;
  align-items: center;
  height: 15px;
  padding: 0 4px;
  margin-right: 0.25rem;
  border-radius: 4px;
  background: var(--clan-bg);
  gap: 2px;
  flex-shrink: 0;
}

.clan-badge {
  width: 13px;
  height: 13px;
  object-fit: contain;
}

.clan-text {
  font-family: "gg sans", sans-serif;
  font-size: 9px;
  font-weight: 500;
  line-height: 15px;
  color: #f2f3f5;
  text-transform: none;
}

.bot-tag {
  display: inline-flex;
  align-items: center;
  height: 15px;
  padding: 0 4px;
  margin-right: 0.25rem;
  border-radius: 3px;
  background: #5865f2;
  color: #fff;
  font-family: "gg sans", sans-serif;
  font-size: 10px;
  font-weight: 700;
  line-height: 15px;
}

.timestamp {
  font-family: "gg sans", sans-serif;
  font-size: 0.75rem;
  line-height: 1.25rem;
  color: #949ba4;
  margin-left: 0.25rem;
  font-weight: 400;
}

.content {
  font-family: "gg sans", sans-serif;
  font-size: 1rem;
  font-weight: 400;
  line-height: 1.375rem;
  color: #dbdee1;
  white-space: pre-wrap;
  word-wrap: break-word;
  overflow-wrap: anywhere;
}

.attachments {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 4px;
  max-width: 520px;
}

.attachments img,
.attachments video {
  max-width: 100%;
  max-height: 350px;
  border-radius: 8px;
  display: block;
}

.attach-file {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: #2b2d31;
  border-radius: 8px;
  padding: 10px 12px;
  color: #00a8fc;
  font-size: 0.9rem;
  text-decoration: none;
  max-width: 100%;
}

/* Reply preview — Discord cozy .repliedMessage */
.reply {
  position: relative;
  display: flex;
  align-items: center;
  margin-top: 0;
  margin-bottom: 10px;
  padding-top: 0;
  font-family: "gg sans", sans-serif;
  font-size: 0.875rem;
  line-height: 1.125rem;
  color: #b9bbbe;
  white-space: nowrap;
  min-width: 0;
  max-width: 100%;
  user-select: none;
  overflow: visible;
}

/*
 * Spine ::before — Discord sets all 4 borders (0 on unused sides) so
 * border-top-left-radius actually curves. Extends down to avatar mid;
 * avatar-col sits above via z-index so the tip tucks under the pfp.
 */
.reply::before {
  content: "";
  display: block;
  position: absolute;
  box-sizing: border-box;
  top: 50%;
  right: 100%;
  /* stop short of the avatar — leave a clear gap above the pfp */
  bottom: -2px;
  left: -36px;
  margin: -1px 4px -2px -1px;
  border-width: 2px 0 0 2px;
  border-style: solid;
  border-color: #4e5058;
  border-top-left-radius: 8px;
  pointer-events: none;
}

.reply-avatar {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  margin-right: 0.25rem;
}

.reply-name {
  font-size: inherit;
  line-height: inherit;
  color: #fff;
  opacity: 0.64;
  flex-shrink: 0;
  margin-right: 0.25rem;
  font-synthesis: none;
}

/* Nitro fonts on reply names — inherit family/weight from .font-* */
.reply-name.font-11 {
  font-family: "gg sans", Arial, sans-serif;
  font-weight: 500;
}

.reply-clan {
  height: 14px;
  margin-right: 0.25rem;
  flex-shrink: 0;
  opacity: 0.9;
}

.reply-clan .clan-badge {
  width: 12px;
  height: 12px;
}

.reply-clan .clan-text {
  font-size: 8px;
  line-height: 14px;
}

.reply-text {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: inherit;
  font-family: "gg sans", sans-serif;
  font-weight: 400;
  font-size: inherit;
  line-height: inherit;
}

.reply-text.attachment-only {
  font-style: italic;
}

.reply-text .reply-attach-icon {
  display: inline-block;
  width: 16px;
  height: 16px;
  margin-left: 4px;
  vertical-align: -3px;
  color: #b9bbbe;
}

.discord-chat.compact .msg.group { margin-top: 0.5rem; }

.empty-hint {
  padding: 40px 24px;
  text-align: center;
  color: #6d6f78;
  font-size: 0.95rem;
}

@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .panel { max-height: 48vh; border-right: 0; border-bottom: 1px solid var(--border); }
}
