:root {
  --bg: #0b141a;
  --bg-soft: #111b21;
  --bg-panel: #202c33;
  --bg-panel-2: #182229;
  --line-active: #00a884;
  --line-muted: #8696a0;
  --text-main: #e9edef;
  --text-sub: #8696a0;
  --bubble-in: #202c33;
  --bubble-out: #005c4b;
  --accent: #25d366;
  --border: #2a3942;
  --danger: #f15c6d;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  font-family: "Manrope", system-ui, -apple-system, Segoe UI, sans-serif;
  background: radial-gradient(circle at 10% 5%, #20323f 0%, var(--bg) 35%);
  color: var(--text-main);
}

button,
input {
  font: inherit;
}

.app-shell {
  width: min(1600px, 100vw);
  height: 100vh;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 80px 420px 1fr;
  background: linear-gradient(160deg, #0c151c 0%, #0a1117 100%);
  border-left: 1px solid #1e2b33;
  border-right: 1px solid #1e2b33;
}

.rail {
  background: var(--bg-soft);
  border-right: 1px solid var(--border);
  padding: 18px 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
}

.avatar-button,
.rail-action {
  width: 46px;
  height: 46px;
  border-radius: 14px;
  border: 1px solid transparent;
  background: #1f2c33;
  color: #d7dee2;
  cursor: pointer;
  transition: 180ms ease;
}

.avatar-button {
  font-weight: 800;
  background: linear-gradient(130deg, #00a884, #00c2a8);
  color: #072019;
}

.rail-actions {
  display: grid;
  gap: 10px;
}

.rail-action:hover {
  border-color: #3a4e58;
  background: #26353d;
}

.settings {
  margin-top: auto;
}

.chat-panel {
  background: var(--bg-soft);
  border-right: 1px solid var(--border);
  display: grid;
  grid-template-rows: auto auto auto 1fr;
  min-height: 0;
}

.panel-header {
  padding: 20px 20px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid #1a2a33;
}

.panel-header h1 {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 800;
  letter-spacing: 0.3px;
}

.panel-header p {
  margin: 2px 0 0;
  color: var(--text-sub);
  font-size: 0.82rem;
}

.ghost-button {
  border: 1px solid #30434d;
  background: transparent;
  color: var(--text-main);
  border-radius: 12px;
  padding: 7px 11px;
  cursor: pointer;
}

.line-menu {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 12px 14px 10px;
  border-bottom: 1px solid #1a2a33;
}

.line-chip {
  min-width: 88px;
  border: 1px solid #2e414b;
  background: #18242b;
  color: var(--text-main);
  border-radius: 14px;
  padding: 10px 10px;
  cursor: pointer;
  display: grid;
  gap: 2px;
  text-align: left;
}

.line-chip .top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.8rem;
  font-weight: 700;
}

.line-chip .status {
  font-size: 0.72rem;
  color: var(--line-muted);
}

.line-chip.active {
  border-color: #167c67;
  background: linear-gradient(120deg, #17352f, #173033);
}

.dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
}

.dot.ok {
  background: #20cd7f;
  box-shadow: 0 0 0 3px rgba(32, 205, 127, 0.18);
}

.dot.off {
  background: #f1647a;
  box-shadow: 0 0 0 3px rgba(241, 100, 122, 0.16);
}

.search-wrap {
  padding: 10px 14px;
  border-bottom: 1px solid #1a2a33;
}

.search-wrap input {
  width: 100%;
  border: 1px solid #2e414b;
  background: #1a2b33;
  color: var(--text-main);
  border-radius: 12px;
  padding: 11px 12px;
}

.chat-list {
  overflow: auto;
}

.chat-item {
  width: 100%;
  border: 0;
  border-bottom: 1px solid #1b2c35;
  background: transparent;
  color: inherit;
  text-align: left;
  cursor: pointer;
  padding: 12px 14px;
  display: grid;
  grid-template-columns: 48px 1fr auto;
  gap: 10px;
}

.chat-item:hover {
  background: #18262e;
}

.chat-item.active {
  background: #2a3942;
}

.chat-avatar {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: linear-gradient(140deg, #335363, #253d4a);
  display: grid;
  place-items: center;
  color: #d7e3ea;
  font-weight: 700;
}

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

.chat-main h3 {
  margin: 1px 0 4px;
  font-size: 0.96rem;
}

.chat-main p {
  margin: 0;
  font-size: 0.8rem;
  color: var(--text-sub);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-meta {
  display: grid;
  justify-items: end;
  gap: 6px;
}

.chat-meta time {
  font-size: 0.72rem;
  color: var(--text-sub);
}

.unread {
  min-width: 20px;
  height: 20px;
  border-radius: 999px;
  background: #20cd7f;
  color: #072019;
  font-size: 0.72rem;
  display: grid;
  place-items: center;
  padding: 0 6px;
  font-weight: 800;
}

.conversation {
  min-height: 0;
  display: grid;
  grid-template-rows: auto 1fr auto;
  background: var(--bg);
}

.conversation-header {
  background: var(--bg-soft);
  border-bottom: 1px solid #1d2c35;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.contact-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
}

.contact-avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: linear-gradient(140deg, #335363, #253d4a);
  display: grid;
  place-items: center;
  font-weight: 700;
}

.contact-meta h2 {
  margin: 0;
  font-size: 1rem;
}

.contact-meta p {
  margin: 2px 0 0;
  color: var(--text-sub);
  font-size: 0.78rem;
}

.line-badge {
  border: 1px solid #2f434d;
  border-radius: 999px;
  padding: 6px 10px;
  color: #b6c7cf;
  font-size: 0.76rem;
  background: #15242d;
}

.message-list {
  overflow: auto;
  padding: 22px;
  display: grid;
  align-content: flex-start;
  gap: 8px;
  background-image: radial-gradient(circle at 12% 16%, rgba(255, 255, 255, 0.03) 0 1px, transparent 1px),
    radial-gradient(circle at 86% 78%, rgba(255, 255, 255, 0.03) 0 1px, transparent 1px);
  background-size: 30px 30px;
}

.message {
  max-width: min(72%, 560px);
  padding: 9px 12px;
  border-radius: 12px;
  font-size: 0.92rem;
  line-height: 1.35;
  color: #edf3f5;
}

.message.in {
  background: var(--bubble-in);
  justify-self: start;
  border-top-left-radius: 4px;
}

.message.out {
  background: var(--bubble-out);
  justify-self: end;
  border-top-right-radius: 4px;
}

.message small {
  display: block;
  margin-top: 6px;
  color: #9fb5bf;
  font-size: 0.68rem;
  text-align: right;
}

.composer-wrap {
  background: var(--bg-soft);
  border-top: 1px solid #1d2c35;
  padding: 10px 14px 14px;
}

.line-status-banner {
  margin-bottom: 8px;
  border: 1px solid #623239;
  color: #ffd4db;
  background: #3a1f25;
  border-radius: 10px;
  padding: 8px 10px;
  font-size: 0.8rem;
}

.composer {
  display: grid;
  grid-template-columns: 40px 1fr auto;
  gap: 10px;
  align-items: center;
}

.icon-button {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  border: 1px solid #30434d;
  background: #1a2b33;
  color: #cde0e6;
}

.composer input {
  border: 1px solid #30434d;
  background: #1a2b33;
  color: #edf3f5;
  border-radius: 10px;
  padding: 10px 12px;
}

.send-button {
  border: 0;
  background: linear-gradient(135deg, #00a884, #16c79a);
  color: #042018;
  border-radius: 10px;
  padding: 10px 14px;
  font-weight: 800;
  cursor: pointer;
}

.send-button[disabled],
.composer input[disabled] {
  opacity: 0.5;
  cursor: not-allowed;
}

.empty-state {
  color: var(--text-sub);
  text-align: center;
  margin-top: 30vh;
}

@media (max-width: 1024px) {
  .app-shell {
    grid-template-columns: 72px 330px 1fr;
  }
}

@media (max-width: 860px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .rail,
  .chat-panel {
    display: none;
  }

  .conversation {
    grid-template-rows: auto 1fr auto;
  }

  .conversation-header {
    position: sticky;
    top: 0;
    z-index: 2;
  }
}
