:root {
  color-scheme: light;
  --ink: #171918;
  --muted: #69716e;
  --line: #dfe4e1;
  --surface: #f6f8f7;
  --panel: #ffffff;
  --accent: #009f7a;
  --accent-dark: #00785c;
  --yellow: #f0d600;
  --danger: #b54136;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
  letter-spacing: 0;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  margin: 0;
}

[hidden] {
  display: none !important;
}

body {
  overflow: hidden;
  background: var(--surface);
  color: var(--ink);
}

button,
textarea {
  font: inherit;
  letter-spacing: 0;
}

button {
  color: inherit;
}

.app-shell {
  display: grid;
  grid-template-columns: 252px minmax(0, 1fr);
  width: 100%;
  min-height: 100dvh;
}

.app-shell[aria-hidden="true"] {
  pointer-events: none;
  user-select: none;
}

.auth-gate {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 24px;
  overflow-y: auto;
  background: rgba(26, 31, 29, 0.64);
  backdrop-filter: blur(5px);
}

.auth-dialog {
  width: min(100%, 520px);
  padding: 42px 46px 30px;
  border: 1px solid rgba(255, 255, 255, 0.72);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 24px 64px rgba(10, 20, 16, 0.28);
  text-align: center;
}

.auth-brand {
  display: grid;
  place-items: center;
  width: 72px;
  height: 72px;
  margin: 0 auto 20px;
  border: 1px solid #dce7e2;
  border-radius: 8px;
  background: #f3f8f6;
  box-shadow: 0 12px 28px rgba(0, 120, 92, 0.13);
}

.auth-brand img {
  width: 58px;
  height: 58px;
  border-radius: 7px;
}

.auth-dialog h2 {
  margin: 0;
  font-size: 30px;
  line-height: 1.2;
  font-weight: 760;
}

.auth-subtitle {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 16px;
  line-height: 1.6;
}

.auth-divider {
  height: 1px;
  margin: 26px 0 22px;
  background: var(--line);
}

.auth-notice {
  display: grid;
  grid-template-columns: 26px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  border: 1px solid #bde0d2;
  border-radius: 7px;
  background: #eef8f4;
  color: #17624f;
  text-align: left;
}

.auth-notice-icon {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border: 2px solid var(--accent);
  border-radius: 50%;
  font-size: 14px;
  font-weight: 750;
  line-height: 1;
}

.auth-notice p {
  margin: 0;
  font-size: 14px;
  line-height: 1.6;
}

.auth-benefits {
  display: grid;
  gap: 13px;
  margin: 24px 0 28px;
  padding: 0;
  color: #4e5854;
  list-style: none;
  text-align: left;
}

.auth-benefits li {
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr);
  gap: 8px;
  align-items: start;
  font-size: 15px;
  line-height: 1.55;
}

.auth-benefits span {
  color: var(--accent);
  font-size: 18px;
  font-weight: 750;
  line-height: 1.35;
}

.auth-login {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 52px;
  padding: 12px 18px 12px 42px;
  border-radius: 7px;
  background: var(--accent);
  box-shadow: 0 10px 24px rgba(0, 120, 92, 0.2);
  color: #ffffff;
  text-decoration: none;
  font-size: 16px;
  font-weight: 720;
}

.auth-login:hover {
  background: var(--accent-dark);
}

.auth-login:focus-visible {
  outline: 3px solid rgba(0, 159, 122, 0.28);
  outline-offset: 3px;
}

.auth-login span:last-child {
  font-size: 23px;
  font-weight: 500;
  line-height: 1;
}

.auth-footnote {
  margin: 14px 0 0;
  color: #9aa39f;
  font-size: 12px;
}

.sidebar {
  display: flex;
  flex-direction: column;
  min-width: 0;
  padding: 20px 16px 16px;
  border-right: 1px solid var(--line);
  background: #f1f4f2;
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  min-height: 44px;
}

.brand img {
  flex: 0 0 auto;
  width: 38px;
  height: 38px;
  border-radius: 8px;
}

.brand div {
  display: grid;
  min-width: 0;
  line-height: 1.2;
}

.brand strong {
  font-size: 15px;
  font-weight: 700;
}

.brand span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

.new-chat {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  min-height: 40px;
  margin-top: 24px;
  border: 1px solid #cfd7d3;
  border-radius: 6px;
  background: var(--panel);
  cursor: pointer;
  font-weight: 650;
}

.new-chat:hover {
  border-color: #aebbb5;
  background: #fafcfb;
}

.new-chat span:first-child {
  color: var(--accent-dark);
  font-size: 20px;
  line-height: 1;
}

.conversation-list {
  margin-top: 28px;
}

.nav-label {
  margin: 0 8px 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

.conversation-item {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  min-height: 38px;
  padding: 8px 10px;
  overflow: hidden;
  border: 0;
  border-radius: 5px;
  background: transparent;
  cursor: pointer;
  text-align: left;
}

.conversation-item.active {
  background: #dfe9e5;
}

.conversation-item span:last-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.conversation-icon {
  width: 7px;
  height: 7px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--yellow);
  box-shadow: 0 0 0 3px rgba(240, 214, 0, 0.18);
}

.sidebar-footer {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: auto;
  padding: 12px 8px 2px;
  color: var(--muted);
  font-size: 12px;
}

.status-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 3px rgba(0, 159, 122, 0.12);
}

.unavailable .status-dot {
  background: var(--danger);
  box-shadow: 0 0 0 3px rgba(181, 65, 54, 0.12);
}

.working .status-dot {
  background: var(--yellow);
  box-shadow: 0 0 0 3px rgba(240, 214, 0, 0.18);
}

.chat-panel {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  min-width: 0;
  min-height: 100dvh;
  background: var(--panel);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 70px;
  padding: 12px 24px;
  border-bottom: 1px solid var(--line);
}

.topbar h1 {
  margin: 0;
  font-size: 17px;
  font-weight: 720;
}

.topbar p {
  display: flex;
  align-items: center;
  gap: 7px;
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.icon-button,
.send-button {
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  border: 0;
  cursor: pointer;
}

.icon-button {
  width: 36px;
  height: 36px;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-size: 22px;
}

.icon-button:hover {
  background: var(--surface);
  color: var(--danger);
}

.icon-button:disabled,
.new-chat:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.messages {
  width: min(100%, 900px);
  margin: 0 auto;
  padding: 34px 32px 24px;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.message {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  gap: 13px;
  margin-bottom: 28px;
}

.message.user {
  grid-template-columns: minmax(0, 1fr);
  justify-items: end;
}

.avatar {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--panel);
}

.avatar img {
  width: 26px;
  height: 26px;
  border-radius: 6px;
}

.message-body {
  min-width: 0;
  padding-top: 4px;
}

.message-body strong {
  display: block;
  margin-bottom: 7px;
  font-size: 13px;
}

.message-text {
  margin: 0;
  color: #303633;
  font-size: 15px;
  line-height: 1.75;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.user .message-text {
  max-width: min(620px, 88%);
  padding: 10px 14px;
  border-radius: 7px 7px 2px 7px;
  background: #202522;
  color: #ffffff;
  line-height: 1.6;
}

.pending .message-text::after {
  content: "";
  display: inline-block;
  width: 6px;
  height: 6px;
  margin-left: 8px;
  border-radius: 50%;
  background: var(--accent);
  animation: pulse 1s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 0.25; }
  50% { opacity: 1; }
}

.composer-wrap {
  padding: 14px 24px 18px;
  border-top: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.96);
}

.composer {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 38px;
  align-items: end;
  gap: 10px;
  width: min(100%, 836px);
  margin: 0 auto;
  padding: 9px 9px 9px 15px;
  border: 1px solid #cfd7d3;
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 5px 18px rgba(28, 38, 34, 0.07);
}

.composer:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(0, 159, 122, 0.1);
}

.composer textarea {
  width: 100%;
  min-height: 36px;
  max-height: 160px;
  padding: 7px 0 5px;
  resize: none;
  overflow-y: auto;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink);
  line-height: 1.5;
}

.composer textarea::placeholder {
  color: #949c98;
}

.send-button {
  width: 38px;
  height: 38px;
  border-radius: 6px;
  background: var(--accent);
  color: #ffffff;
  font-size: 21px;
  font-weight: 700;
}

.send-button:hover {
  background: var(--accent-dark);
}

.send-button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.connection-note {
  margin: 8px auto 0;
  color: var(--muted);
  font-size: 11px;
  text-align: center;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

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

  .sidebar {
    display: none;
  }

  .topbar {
    min-height: 62px;
    padding: 10px 16px;
  }

  .messages {
    padding: 26px 16px 18px;
  }

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

  .avatar {
    width: 30px;
    height: 30px;
  }

  .avatar img {
    width: 23px;
    height: 23px;
  }

  .user .message-text {
    max-width: 94%;
  }

  .composer-wrap {
    padding: 10px 12px calc(12px + env(safe-area-inset-bottom));
  }

  .auth-gate {
    align-items: center;
    padding: 16px;
  }

  .auth-dialog {
    padding: 28px 22px 22px;
  }

  .auth-brand {
    width: 64px;
    height: 64px;
    margin-bottom: 16px;
  }

  .auth-brand img {
    width: 52px;
    height: 52px;
  }

  .auth-dialog h2 {
    font-size: 25px;
  }

  .auth-subtitle {
    font-size: 14px;
  }

  .auth-divider {
    margin: 20px 0 18px;
  }

  .auth-benefits {
    gap: 10px;
    margin: 20px 0 22px;
  }

  .auth-benefits li {
    font-size: 14px;
  }
}

@media (max-height: 650px) {
  .auth-gate {
    place-items: start center;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
  }
}
