:root {
  color-scheme: light dark;
  --bg: #f6f3ec;
  --paper: #fffdf8;
  --ink: #1d1c19;
  --muted: #6f6a60;
  --line: #e4ded2;
  --line-strong: #cfc6b6;
  --accent: #df4b2b;
  --accent-ink: #fff8f4;
  --mint: #1f7a5c;
  --mint-soft: #e2f2ea;
  --shadow: 0 18px 50px rgba(58, 48, 31, 0.08);
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Pretendard",
    "Noto Sans KR", "Segoe UI", sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14130f;
    --paper: #1c1a15;
    --ink: #f2ecdf;
    --muted: #a49b8b;
    --line: #312d24;
    --line-strong: #4a4437;
    --accent: #ff6b45;
    --accent-ink: #1b0e09;
    --mint: #6fd3ac;
    --mint-soft: #17352a;
    --shadow: 0 18px 50px rgba(0, 0, 0, 0.35);
  }
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background:
    radial-gradient(circle at 12% -10%, rgba(223, 75, 43, 0.09), transparent 38%),
    radial-gradient(circle at 92% 4%, rgba(31, 122, 92, 0.08), transparent 34%),
    var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

a {
  color: var(--mint);
}

.top,
main,
footer {
  width: min(1040px, calc(100% - 32px));
  margin-inline: auto;
}

.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 34px 0 22px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.mark {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: 14px;
  background: var(--ink);
  color: var(--paper);
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.04em;
  box-shadow: var(--shadow);
}

.brand h1 {
  margin: 0;
  font-size: 22px;
  line-height: 1.15;
  letter-spacing: -0.03em;
}

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

.top-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.live {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 11px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--paper);
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.live i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--line-strong);
}

.live[data-state="online"] {
  color: var(--mint);
  border-color: color-mix(in srgb, var(--mint) 35%, var(--line));
}

.live[data-state="online"] i {
  background: var(--mint);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--mint) 18%, transparent);
}

.live[data-state="retrying"] i {
  background: var(--accent);
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 14px;
}

.channels {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.chip {
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 13px;
  cursor: pointer;
  transition: 140ms ease;
}

.chip:hover {
  border-color: var(--line-strong);
  color: var(--ink);
}

.chip[aria-selected="true"] {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--paper);
}

.chip .count {
  margin-left: 5px;
  font-family: var(--mono);
  font-size: 11px;
  opacity: 0.7;
}

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

.search {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 7px;
  padding: 7px 11px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--paper);
  color: var(--muted);
}

label.search {
  flex-direction: row;
  align-items: center;
  gap: 7px;
}

.search input {
  width: 130px;
  border: 0;
  outline: 0;
  padding: 0;
  background: transparent;
  font-size: 13px;
}

.ghost,
.primary {
  border-radius: 10px;
  padding: 8px 13px;
  font-size: 13px;
  cursor: pointer;
  transition: 140ms ease;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.ghost {
  border: 1px solid var(--line);
  background: var(--paper);
  color: var(--ink);
}

.ghost:hover {
  border-color: var(--line-strong);
}

.ghost.small {
  padding: 5px 10px;
  font-size: 12px;
}

.primary {
  border: 1px solid var(--accent);
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 650;
  padding: 10px 20px;
}

.primary:hover {
  filter: brightness(1.05);
}

.primary:disabled {
  opacity: 0.55;
  cursor: wait;
}

.board {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 22px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.messages {
  padding: 2px 22px;
}

.message {
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr);
  gap: 13px;
  padding: 20px 0;
  border-bottom: 1px dashed var(--line);
}

.message:last-child {
  border-bottom: 0;
}

.avatar {
  width: 38px;
  height: 38px;
  border-radius: 13px;
  display: grid;
  place-items: center;
  font-weight: 750;
  font-size: 14px;
  letter-spacing: -0.02em;
  user-select: none;
}

.tone-0 { background: #fde4da; color: #8f2f19; }
.tone-1 { background: #dfeee6; color: #1f6b51; }
.tone-2 { background: #e5e3f7; color: #4b3f99; }
.tone-3 { background: #f8e9c8; color: #7a5a12; }
.tone-4 { background: #dce9f7; color: #2b5688; }
.tone-5 { background: #f6dfe8; color: #8a3358; }
.tone-6 { background: #e8e5d5; color: #625c35; }
.tone-7 { background: #d9eeee; color: #236466; }

@media (prefers-color-scheme: dark) {
  .tone-0 { background: #47271e; color: #ffb59f; }
  .tone-1 { background: #1d3a2e; color: #8fe0be; }
  .tone-2 { background: #2b2747; color: #c2baff; }
  .tone-3 { background: #3f351c; color: #f1d28b; }
  .tone-4 { background: #1e3247; color: #a8cdf2; }
  .tone-5 { background: #432435; color: #f0b1c9; }
  .tone-6 { background: #35321f; color: #d8d2a6; }
  .tone-7 { background: #19383a; color: #9cdddf; }
}

.msg-main {
  min-width: 0;
}

.msg-head {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 7px;
  margin-bottom: 7px;
  font-size: 12.5px;
}

.who {
  font-weight: 700;
  font-size: 13.5px;
}

.arrow {
  color: var(--muted);
}

.type {
  font-family: var(--mono);
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 2px 7px;
  border-radius: 999px;
  background: var(--bg);
  border: 1px solid var(--line);
  color: var(--muted);
}

.type[data-type="question"] { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 35%, var(--line)); }
.type[data-type="answer"] { color: var(--mint); border-color: color-mix(in srgb, var(--mint) 35%, var(--line)); }
.type[data-type="ack"] { color: var(--muted); }

.channel-tag {
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--muted);
}

.time {
  margin-left: auto;
  color: var(--muted);
  font-size: 11.5px;
  white-space: nowrap;
}

.body {
  margin: 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-size: 14.5px;
}

.msg-foot {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 9px;
  min-height: 20px;
}

.id {
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--muted);
  background: transparent;
  border: 0;
  padding: 0;
  cursor: pointer;
}

.id:hover {
  color: var(--ink);
  text-decoration: underline;
}

.reply {
  font-size: 11.5px;
  color: var(--muted);
}

.reply a {
  font-family: var(--mono);
  text-decoration: none;
  border-bottom: 1px dotted var(--line-strong);
}

.empty {
  padding: 58px 22px;
  text-align: center;
  color: var(--muted);
}

.empty-title {
  margin: 0 0 4px;
  color: var(--ink);
  font-weight: 650;
}

.compose {
  margin-top: 18px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 22px;
  box-shadow: var(--shadow);
  padding: 20px 22px 18px;
}

.compose-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 14px;
}

.compose h2,
.api-note h2 {
  margin: 0;
  font-size: 15px;
  letter-spacing: -0.01em;
}

.hint {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.warn {
  margin: 6px 0 0;
  color: var(--accent);
  font-size: 11.5px;
}

.warn code {
  font-family: var(--mono);
  font-size: 0.95em;
}

.row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.row.two {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-top: 10px;
}

label {
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-width: 0;
}

label > span {
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 600;
}

label em {
  font-style: normal;
  font-weight: 400;
  opacity: 0.65;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg);
  padding: 9px 11px;
  font-size: 13.5px;
  outline: 0;
  transition: 140ms ease;
}

input:focus,
select:focus,
textarea:focus {
  border-color: color-mix(in srgb, var(--mint) 55%, var(--line));
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--mint) 13%, transparent);
}

textarea {
  resize: vertical;
  min-height: 92px;
  line-height: 1.55;
}

.body-label {
  margin-top: 10px;
}

.token {
  margin-top: 12px;
  border: 1px dashed var(--line-strong);
  border-radius: 12px;
  padding: 10px 12px;
  background: var(--bg);
}

.token summary {
  cursor: pointer;
  font-size: 12.5px;
  color: var(--muted);
  font-weight: 600;
}

.token input {
  margin-top: 9px;
}

.token p {
  margin: 7px 0 0;
  color: var(--muted);
  font-size: 11.5px;
}

.compose-foot {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 13px;
}

.error {
  margin: 0 auto 0 0;
  color: var(--accent);
  font-size: 12.5px;
}

.api-note {
  margin: 18px 0 0;
  padding: 18px 22px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: color-mix(in srgb, var(--paper) 55%, transparent);
  color: var(--muted);
}

.api-note pre {
  margin: 11px 0 9px;
  padding: 13px 15px;
  background: var(--ink);
  color: var(--paper);
  border-radius: 12px;
  overflow-x: auto;
  font-size: 12px;
  line-height: 1.6;
}

.api-note code {
  font-family: var(--mono);
  font-size: 0.94em;
}

.api-note p {
  margin: 0;
  font-size: 12px;
}

.api-note p code {
  color: var(--ink);
  background: var(--bg);
  padding: 1px 5px;
  border-radius: 5px;
  border: 1px solid var(--line);
}

footer {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 26px 2px 38px;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 10.5px;
}

@media (max-width: 720px) {
  .top {
    padding-top: 24px;
    align-items: flex-start;
  }

  .brand p {
    display: none;
  }

  .toolbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .toolbar-right {
    width: 100%;
  }

  .search {
    flex: 1;
  }

  .search input {
    width: 100%;
  }

  .messages {
    padding-inline: 15px;
  }

  .message {
    grid-template-columns: 34px minmax(0, 1fr);
    gap: 10px;
  }

  .avatar {
    width: 32px;
    height: 32px;
    border-radius: 11px;
    font-size: 12px;
  }

  .time {
    width: 100%;
    margin-left: 0;
  }

  .row,
  .row.two {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .compose,
  .api-note {
    padding-inline: 15px;
  }

  .compose-foot {
    flex-direction: column-reverse;
    align-items: stretch;
  }

  .primary {
    width: 100%;
  }

  footer {
    flex-direction: column;
    gap: 4px;
  }
}

@media (max-width: 420px) {
  .row,
  .row.two {
    grid-template-columns: 1fr;
  }

  .live span {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    scroll-behavior: auto !important;
    transition: none !important;
  }
}
