* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  margin: 0;
  font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
  background: #f6f7f9;
  color: #1d1f23;
  display: flex;
  flex-direction: column;
}

header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  background: #fff;
  border-bottom: 1px solid #e3e5e8;
}
.head-left, .head-right { display: flex; align-items: center; gap: 10px; }
.conn { color: #c0c4cc; font-size: 11px; }
.conn.ok { color: #2eb67d; }

button {
  font: inherit;
  padding: 5px 12px;
  border: 1px solid #d4d7dc;
  border-radius: 6px;
  background: #fff;
  cursor: pointer;
}
button:hover { background: #f0f1f3; }

#channel-tabs {
  display: flex;
  gap: 6px;
  padding: 8px 16px;
  background: #fff;
  border-bottom: 1px solid #e3e5e8;
  overflow-x: auto;
}
#channel-tabs button { border: none; background: none; color: #555; border-radius: 14px; padding: 4px 12px; white-space: nowrap; }
#channel-tabs button.active { background: #e8f0fe; color: #1a56db; font-weight: 600; }
.tab-badge {
  background: #e8912d; color: #fff;
  border-radius: 9px; font-size: 10.5px; font-weight: 600;
  padding: 1px 6px; margin-left: 5px; vertical-align: 1px;
}

#feed { flex: 1; overflow-y: auto; padding: 12px 16px; }
.msg {
  background: #fff;
  border: 1px solid #e8eaed;
  border-radius: 8px;
  padding: 8px 12px;
  margin-bottom: 8px;
  max-width: 860px;
}
.msg.mention { border-left: 3px solid #e8912d; background: #fff8ef; }
.msg .meta { font-size: 12px; color: #70757d; margin-bottom: 2px; }
.msg .body { white-space: pre-wrap; word-break: break-word; }
.msg .body a { color: #1a56db; }
.msg .body img.emoji { height: 19px; vertical-align: -4px; }
.msg.thread { margin-left: 28px; border-left: 3px solid #d4d7dc; max-width: 832px; }
.thread-quote {
  font-size: 12px; color: #70757d;
  background: #f6f7f9; border-radius: 4px;
  padding: 2px 8px; margin: 2px 0 4px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

#settings {
  position: fixed;
  top: 54px;
  right: 12px;
  width: 300px;
  background: #fff;
  border: 1px solid #d4d7dc;
  border-radius: 10px;
  padding: 14px 16px;
  box-shadow: 0 8px 24px rgba(0,0,0,.12);
}
#settings h2 { margin: 0 0 10px; font-size: 15px; }
#settings fieldset { border: 1px solid #e3e5e8; border-radius: 8px; margin: 0 0 10px; }
#settings label { display: block; margin: 4px 0; }
#settings .block input { width: 100%; margin-top: 4px; padding: 6px 8px; border: 1px solid #d4d7dc; border-radius: 6px; }
.hint { font-size: 12px; color: #8a8f98; }

#composer {
  background: #fff;
  border-top: 1px solid #e3e5e8;
  padding: 8px 16px 10px;
}
.composer-row { display: flex; gap: 8px; align-items: center; max-width: 860px; }
#composer-input { flex: 1; padding: 8px 10px; border: 1px solid #d4d7dc; border-radius: 8px; font: inherit; }
#composer-input:disabled { background: #f0f1f3; }
#send-btn { background: #1a56db; color: #fff; border: none; padding: 8px 16px; border-radius: 8px; }
#send-btn:disabled { background: #b9c5e8; cursor: default; }
#connect-btn {
  white-space: nowrap;
  background: #4a154b;
  color: #fff;
  text-decoration: none;
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 13px;
}
#reply-chip {
  display: flex; align-items: center; gap: 6px;
  font-size: 12px; color: #555;
  background: #f0f4ff; border: 1px solid #d6e0fb; border-radius: 6px;
  padding: 3px 8px; margin-bottom: 6px; max-width: 860px;
}
#reply-chip button { border: none; background: none; padding: 0 2px; font-size: 14px; color: #777; }
.reply-btn {
  display: none;
  position: absolute; right: 8px; top: 6px;
  font-size: 11px; padding: 2px 8px; border-radius: 10px;
}
.msg { position: relative; }
.msg:hover .reply-btn { display: inline-block; }
.thread-quote { cursor: pointer; }
.thread-quote:hover { text-decoration: underline; }
.thread-btn {
  display: inline-block;
  margin-top: 4px;
  font-size: 11.5px;
  color: #1a56db;
  background: #eef3ff;
  border: 1px solid #d6e0fb;
  border-radius: 12px;
  padding: 2px 10px;
}

#thread-panel {
  position: fixed; top: 0; right: 0; bottom: 0;
  width: 400px; max-width: 90vw;
  background: #fff;
  border-left: 1px solid #e3e5e8;
  box-shadow: -4px 0 16px rgba(0,0,0,.08);
  display: flex; flex-direction: column;
  z-index: 6;
}
.tp-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 16px; border-bottom: 1px solid #e3e5e8; font-weight: 600;
}
#tp-close { border: none; background: none; font-size: 18px; color: #777; padding: 0 4px; }
#tp-list { flex: 1; overflow-y: auto; padding: 8px 16px; }
.tp-msg { border-bottom: 1px solid #f0f1f3; padding: 8px 0; }
.tp-msg.tp-parent { background: #f8f9fb; border-radius: 6px; padding: 8px 10px; margin-bottom: 4px; }
.tp-compose { display: flex; gap: 8px; padding: 10px 12px; border-top: 1px solid #e3e5e8; }
#tp-input { flex: 1; padding: 8px 10px; border: 1px solid #d4d7dc; border-radius: 8px; font: inherit; }
#tp-send { background: #1a56db; color: #fff; border: none; padding: 8px 14px; border-radius: 8px; }
#tp-send:disabled { background: #b9c5e8; }

.overlay {
  position: fixed;
  inset: 0;
  background: #f6f7f9;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
}
.login-card {
  background: #fff;
  border: 1px solid #e3e5e8;
  border-radius: 12px;
  padding: 28px 32px;
  width: 320px;
  text-align: center;
}
.login-card h1 { font-size: 18px; margin: 0 0 6px; }
.login-card input { width: 100%; padding: 8px 10px; margin: 10px 0; border: 1px solid #d4d7dc; border-radius: 6px; }
.login-card button { width: 100%; background: #1a56db; color: #fff; border: none; padding: 8px; }
.error { color: #d93025; font-size: 13px; }
