:root {
  color-scheme: light;
  --bg: #ffffff;
  --panel: #ffffff;
  --panel-2: #f0f2f5;
  --line: #dbdbdb;
  --text: #111111;
  --muted: #737373;
  --bubble-user: #2f6cf6;
  --bubble-peer: #efefef;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  font-family: "Segoe UI", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}

body {
  padding: 0;
}

h1,
h2,
h3,
p {
  margin: 0;
}

.ig-shell {
  width: 100%;
  height: 100vh;
  display: grid;
  grid-template-columns: 72px 340px 1fr;
  overflow: hidden;
}

.ig-left-nav {
  border-right: 1px solid var(--line);
  display: grid;
  grid-template-rows: auto 1fr auto;
  padding: 14px 10px;
  background: #fff;
}

.ig-logo {
  font-size: 1.12rem;
  font-weight: 700;
  text-align: center;
  margin-top: 6px;
}

.ig-nav-icons {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  margin-top: 28px;
}

.nav-icon {
  border: none;
  background: transparent;
  width: 42px;
  height: 42px;
  border-radius: 12px;
  cursor: pointer;
  font-size: 1.2rem;
}

.nav-icon.active,
.nav-icon:hover {
  background: #f2f2f2;
}

.ig-nav-bottom {
  display: flex;
  justify-content: center;
  margin-bottom: 8px;
}

.ig-inbox {
  border-right: 1px solid var(--line);
  background: #fff;
  display: grid;
  grid-template-rows: auto auto auto 1fr auto;
}

.inbox-head {
  padding: 18px 16px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.inbox-head h1 {
  font-size: 1.85rem;
  font-weight: 700;
}

.icon-btn {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  width: 34px;
  height: 34px;
  border-radius: 10px;
  cursor: pointer;
}

.search-wrap {
  padding: 0 16px 10px;
}

.search-wrap input {
  width: 100%;
  border: none;
  border-radius: 10px;
  background: #efefef;
  color: var(--muted);
  padding: 10px 12px;
}

.msg-headline {
  padding: 2px 16px 10px;
  font-size: 1.5rem;
  font-weight: 700;
}

.thread-list {
  padding: 8px;
  overflow: auto;
}

.thread {
  padding: 10px 10px;
  border-radius: 12px;
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 10px;
  align-items: center;
  cursor: pointer;
}

.active-thread {
  background: #f2f3f5;
}

.muted-thread {
  opacity: 0.72;
}

.thread:hover {
  background: #1a1f28;
}

.avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-weight: 700;
  color: #111;
}

.avatar.large {
  width: 86px;
  height: 86px;
  font-size: 1.6rem;
}

.avatar.photo {
  background: #f7d65a;
}

.avatar.empty {
  background: #ececec;
  color: #666;
}

.thread-copy {
  min-width: 0;
}

.thread-name {
  font-size: 0.94rem;
  font-weight: 500;
}

.thread-preview {
  color: var(--muted);
  font-size: 0.83rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #808898;
}

.status-dot.ready {
  background: #2cd46b;
}

.status-dot.busy {
  background: #ffb020;
}

.status-dot.error {
  background: #ff4d6d;
}

.rail-foot {
  padding: 12px;
  border-top: 1px solid var(--line);
  background: #fff;
}

.meta-row {
  font-size: 0.78rem;
  color: var(--muted);
  margin-bottom: 5px;
}

.control-row {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
  margin-top: 8px;
}

.ghost-btn {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  color: var(--text);
  padding: 8px 10px;
  cursor: pointer;
}

.ghost-btn:hover {
  filter: brightness(1.1);
}

.danger-btn {
  border-color: #ff8a99;
  color: #b21734;
}

.dm-panel {
  display: grid;
  grid-template-rows: auto 1fr auto;
  background: #fff;
  min-height: 0;
}

.dm-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
}

.dm-user {
  display: flex;
  gap: 10px;
  align-items: center;
}

.dm-user h2 {
  font-size: 1rem;
}

.dm-user p {
  font-size: 0.78rem;
  color: var(--muted);
}

.dm-actions {
  display: flex;
  gap: 8px;
}

.mini-icon {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: #fff;
  cursor: pointer;
}

.intro-card {
  padding: 20px 16px 14px;
  text-align: center;
  border-bottom: 1px solid var(--line);
}

.intro-card h3 {
  margin-top: 8px;
  font-size: 1.1rem;
}

.intro-card p {
  margin-top: 6px;
  color: var(--muted);
  font-size: 0.88rem;
}

.messages {
  grid-row: 2;
  padding: 14px 16px;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 0;
  background: #fff;
}

.hidden {
  display: none;
}

.message {
  max-width: min(72%, 680px);
  border-radius: 22px;
  padding: 10px 12px;
  line-height: 1.45;
  white-space: pre-wrap;
  word-wrap: break-word;
  animation: rise 200ms ease;
}

.message.user {
  align-self: flex-end;
  background: var(--bubble-user);
  color: #fff;
  border-bottom-right-radius: 8px;
}

.message.assistant {
  align-self: flex-start;
  background: var(--bubble-peer);
  color: #222;
  border-bottom-left-radius: 8px;
}

.message.system {
  align-self: center;
  background: #fafafa;
  color: var(--muted);
  border: 1px dashed #dadada;
  font-size: 0.82rem;
  max-width: 90%;
}

.message-meta {
  font-size: 0.64rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  opacity: 0.68;
  margin-bottom: 4px;
}

.typing {
  display: inline-flex;
  gap: 4px;
  align-items: center;
}

.typing span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #6b7280;
  animation: pulse 1s infinite ease-in-out;
}

.typing span:nth-child(2) {
  animation-delay: 0.12s;
}

.typing span:nth-child(3) {
  animation-delay: 0.24s;
}

.composer {
  grid-row: 3;
  border-top: 1px solid var(--line);
  padding: 6px 12px 8px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 6px;
  background: #fff;
}

.composer input {
  border: 1px solid #d8d8d8;
  border-radius: 999px;
  background: #fff;
  color: #111;
  height: 30px;
  padding: 4px 10px;
  font-size: 0.78rem;
  line-height: 1.1;
  outline: none;
}

.composer input:focus {
  border-color: #9fbaf7;
}

.composer input::placeholder {
  font-size: 0.78rem;
}

.composer button {
  border: none;
  border-radius: 999px;
  height: 30px;
  padding: 4px 10px;
  background: transparent;
  color: #4da3ff;
  font-weight: 600;
  font-size: 0.78rem;
  line-height: 1;
  cursor: pointer;
}

.composer button:hover {
  filter: brightness(1.15);
}

.composer button:disabled,
.composer input:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

@keyframes rise {
  from {
    transform: translateY(8px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

@keyframes pulse {
  0%,
  80%,
  100% {
    opacity: 0.28;
    transform: translateY(0);
  }
  40% {
    opacity: 1;
    transform: translateY(-2px);
  }
}

@media (max-width: 920px) {
  .ig-shell {
    height: 100vh;
    grid-template-columns: 1fr 1fr;
  }

  .ig-left-nav {
    display: none;
  }

  .message {
    max-width: 86%;
  }
}

@media (max-width: 720px) {
  .ig-shell {
    grid-template-columns: 1fr;
  }

  .ig-inbox {
    display: none;
  }
}