* {
  box-sizing: border-box;
}

:root {
  --sidebar: #3f0f40;
  --sidebar-hover: #5a245b;
  --sidebar-active: #1164a3;
  --sidebar-text: #d1c4d1;
  --border: #ddd;
  --text: #1d1c1d;
  --muted: #616061;
  --bg: #fff;
}

html,
body {
  margin: 0;
  width: 100%;
  height: 100%;
  font-family: Arial, "Noto Sans KR", sans-serif;
  color: var(--text);
  background: var(--bg);
}

body {
  overflow: hidden;
}

button,
textarea {
  font: inherit;
}

button {
  border: 0;
  background: none;
  cursor: pointer;
}

.app {
  display: flex;
  width: 100%;
  height: 100vh;
  overflow: hidden;
}

/* =========================
   LEFT SIDEBAR
========================= */

.sidebar {
  width: 260px;
  min-width: 260px;
  height: 100vh;
  background: var(--sidebar);
  color: #fff;
  display: flex;
  flex-direction: column;
}

.workspace {
  height: 68px;
  min-height: 68px;
  padding: 12px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.15);
}

.workspace-avatar {
  width: 36px;
  height: 36px;
  flex: 0 0 36px;
  border-radius: 8px;
  background: #fff;
  color: var(--sidebar);
  display: grid;
  place-items: center;
  font-size: 17px;
  font-weight: 800;
}

.workspace-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.workspace-info strong {
  font-size: 15px;
  line-height: 1;
}

.workspace-info span {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.65);
}

.icon-btn {
  width: 28px !important;
  padding: 0 !important;
  color: #fff !important;
  text-align: center !important;
  font-size: 18px !important;
}

.sidebar-section {
  padding: 12px 10px 0;
}

.sidebar-section.quick {
  display: grid;
  gap: 2px;
  padding-top: 10px;
}

.sidebar-section button {
  width: 100%;
  height: 32px;
  padding: 6px 10px;
  color: #eee;
  text-align: left;
  border-radius: 6px;
  font-size: 14px;
  line-height: 20px;
  transition: background 0.12s ease;
}

.sidebar-section button:hover {
  background: var(--sidebar-hover);
}

.sidebar-section.quick button {
  color: #d9cdd9;
}

.section-title {
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 10px;
  color: var(--sidebar-text);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.section-title .plus-btn {
  width: auto;
  height: 24px;
  padding: 0 3px;
  color: #fff;
  font-size: 18px;
}

.channel {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.channel.active {
  background: var(--sidebar-active);
  color: #fff;
  font-weight: 700;
}

.person {
  display: flex !important;
  align-items: center;
  gap: 8px;
}

.status {
  display: inline-block;
  width: 8px;
  height: 8px;
  flex: 0 0 8px;
  border-radius: 50%;
  background: #2bac76;
}

.status.away {
  background: #eab308;
}

.profile {
  margin-top: auto;
  padding: 12px 14px;
  min-height: 64px;
  display: flex;
  align-items: center;
  gap: 9px;
  background: rgba(0, 0, 0, 0.15);
}

.profile > div:nth-child(2) {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.profile strong {
  font-size: 13px;
}

.profile span {
  font-size: 11px;
  opacity: 0.7;
}

/* =========================
   MAIN
========================= */

.main {
  min-width: 0;
  flex: 1;
  height: 100vh;
  display: flex;
  flex-direction: column;
  position: relative;
  background: #fff;
}

.topbar {
  height: 68px;
  min-height: 68px;
  padding: 0 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #fff;
}

.channel-title {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 10px;
}

.hash {
  color: #616061;
  font-size: 26px;
  font-weight: 400;
  line-height: 1;
}

.channel-title > div {
  min-width: 0;
}

.channel-title h1 {
  margin: 0;
  font-size: 17px;
  line-height: 21px;
  font-weight: 700;
}

.channel-title span:last-child {
  display: block;
  max-width: 600px;
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 3px;
  margin-left: 20px;
}

.top-btn {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 6px;
  font-size: 15px;
}

.top-btn:hover {
  background: #f3f3f3;
}

/* =========================
   MESSAGE AREA
========================= */

.messages {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 0 28px 150px;
  scrollbar-width: thin;
}

.channel-intro {
  padding: 30px 0 22px;
  margin-bottom: 14px;
  border-bottom: 1px solid #eee;
}

.large-hash {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: #eee;
  color: #555;
  font-size: 25px;
  font-weight: 700;
}

.channel-intro h2 {
  margin: 12px 0 5px;
  font-size: 22px;
  line-height: 28px;
}

.channel-intro p {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 20px;
}

.message {
  display: flex;
  gap: 12px;
  padding: 9px 4px;
  border-radius: 6px;
  transition: background 0.1s ease;
}

.message:hover {
  background: #f8f8f8;
}

.avatar {
  width: 38px;
  height: 38px;
  flex: 0 0 38px;
  display: grid;
  place-items: center;
  border-radius: 7px;
  color: #fff;
  font-size: 14px;
  font-weight: 700;
}

.avatar.emma {
  background: #1264a3;
}

.avatar.james {
  background: #611f69;
}

.avatar.sarah {
  background: #007a5a;
}

.avatar.me {
  background: #e01e5a;
}

.message-content {
  min-width: 0;
  padding-top: 1px;
}

.message-meta {
  display: flex;
  align-items: baseline;
  gap: 8px;
  line-height: 18px;
}

.message-meta strong {
  font-size: 14px;
  font-weight: 700;
}

.message-meta span {
  color: var(--muted);
  font-size: 11px;
}

.message-content p {
  margin: 4px 0 0;
  color: #1d1c1d;
  font-size: 14px;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
}

/* =========================
   MESSAGE COMPOSER
========================= */

.composer-wrap {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 10;
  padding: 14px 28px 22px;
  background: linear-gradient(
    to bottom,
    rgba(255, 255, 255, 0),
    rgba(255, 255, 255, 0.95) 20%,
    #fff 38%
  );
}

.composer {
  width: 100%;
  border: 1px solid #a8a8a8;
  border-radius: 8px;
  background: #fff;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.composer:focus-within {
  border-color: #1264a3;
  box-shadow: 0 0 0 1px #1264a3;
}

.composer-tools {
  height: 36px;
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 0 8px;
  border-bottom: 1px solid #eee;
}

.composer-tools button {
  width: 28px;
  height: 28px;
  padding: 0;
  display: grid;
  place-items: center;
  border-radius: 5px;
  color: #4a4a4a;
  font-size: 14px;
  font-weight: 700;
}

.composer-tools button:hover {
  background: #f0f0f0;
}

#messageInput {
  display: block;
  width: 100%;
  min-height: 66px;
  padding: 12px;
  border: 0;
  outline: 0;
  resize: none;
  color: var(--text);
  background: #fff;
  font-size: 14px;
  line-height: 20px;
}

#messageInput::placeholder {
  color: #888;
}

.composer-bottom {
  height: 42px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 8px;
}

.composer-hint {
  color: #888;
  font-size: 11px;
}

.send-btn {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border-radius: 5px;
  background: #007a5a;
  color: #fff;
  font-size: 14px;
}

.send-btn:hover {
  background: #006b4f;
}

/* =========================
   ONEPACE RIGHT PANEL
========================= */

.right-panel {
  width: 360px;
  min-width: 360px;
  height: 100vh;
  border-left: 1px solid var(--border);
  background: #fff;
  box-shadow: -3px 0 12px rgba(0, 0, 0, 0.05);
  overflow-y: auto;
}

.right-panel.hidden {
  display: none;
}

.panel-header {
  height: 68px;
  padding: 0 18px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.panel-header strong {
  font-size: 16px;
}

.panel-header button {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border-radius: 5px;
  color: #666;
  font-size: 24px;
}

.panel-header button:hover {
  background: #f3f3f3;
}

.panel-body {
  padding: 22px 20px;
}

.ai-badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 8px;
  border-radius: 20px;
  background: #f1e7ff;
  color: #611f69;
  font-size: 11px;
  font-weight: 700;
}

.panel-body h2 {
  margin: 10px 0 5px;
  font-size: 22px;
  line-height: 28px;
}

.muted {
  margin: 0 0 22px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.panel-body label {
  display: block;
  margin-bottom: 7px;
  font-size: 12px;
  font-weight: 700;
}

.select {
  min-height: 42px;
  padding: 11px 12px;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border: 1px solid #ccc;
  border-radius: 6px;
  color: #333;
  font-size: 13px;
}

.primary,
.secondary {
  width: 100%;
  border-radius: 6px;
  padding: 10px;
  font-weight: 700;
  font-size: 13px;
}

.primary {
  color: #fff;
  background: #611f69;
}

.primary:hover {
  background: #4e1856;
}

.secondary {
  margin-top: 15px;
  background: #f1f1f1;
  color: #333;
}

.secondary:hover {
  background: #e5e5e5;
}

.summary-result {
  margin-top: 22px;
  padding-top: 18px;
  border-top: 1px solid #eee;
}

.summary-result.hidden {
  display: none;
}

.result-title {
  margin-bottom: 12px;
  font-size: 14px;
  font-weight: 700;
}

.result-item {
  padding: 10px 0;
  border-bottom: 1px solid #eee;
}

.result-item span {
  display: block;
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 11px;
}

.result-item strong {
  display: block;
  font-size: 13px;
  line-height: 1.4;
}

/* =========================
   TOAST
========================= */

.toast {
  position: fixed;
  left: 50%;
  bottom: 25px;
  z-index: 100;
  transform: translateX(-50%);
  padding: 10px 16px;
  border-radius: 6px;
  background: #1d1c1d;
  color: #fff;
  font-size: 13px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.toast.hidden {
  display: none;
}

/* =========================
   ONEPACE EXTENSION
========================= */

#onepace-root {
  position: relative;
  z-index: 1000;
}

/* =========================
   SCROLLBAR
========================= */

.messages::-webkit-scrollbar,
.right-panel::-webkit-scrollbar {
  width: 8px;
}

.messages::-webkit-scrollbar-thumb,
.right-panel::-webkit-scrollbar-thumb {
  background: #c7c7c7;
  border-radius: 8px;
}

.messages::-webkit-scrollbar-track,
.right-panel::-webkit-scrollbar-track {
  background: transparent;
}

/* =========================
   RESPONSIVE
========================= */

@media (max-width: 1100px) {
  .sidebar {
    width: 230px;
    min-width: 230px;
  }

  .right-panel {
    width: 320px;
    min-width: 320px;
  }
}

@media (max-width: 800px) {
  .right-panel {
    display: none;
  }
}

@media (max-width: 650px) {
  .sidebar {
    width: 220px;
    min-width: 220px;
  }

  .messages {
    padding-left: 18px;
    padding-right: 18px;
  }

  .composer-wrap {
    padding-left: 18px;
    padding-right: 18px;
  }
}