:root {
  color-scheme: light;
  --bg: #f7f7f4;
  --sidebar: #111214;
  --sidebar-soft: #1b1d20;
  --surface: #ffffff;
  --surface-soft: #f1f2ef;
  --text: #171717;
  --muted: #6d726f;
  --line: #dedfd9;
  --accent: #10a37f;
  --accent-dark: #0d8468;
  --danger: #b3261e;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
textarea,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-height: 100vh;
  padding: 18px;
  background: var(--sidebar);
  color: #f5f5f3;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  display: grid;
  width: 36px;
  height: 36px;
  place-items: center;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-weight: 760;
}

.brand strong,
.topbar strong {
  display: block;
  font-size: 15px;
  line-height: 1.25;
}

.brand span,
.topbar span,
.resource-note {
  display: block;
  color: #a8aba6;
  font-size: 12px;
  line-height: 1.45;
}

.new-chat,
.clear-chat,
.ghost-button,
.primary-button,
.composer button {
  border: 0;
  border-radius: 8px;
  font-weight: 650;
}

.new-chat {
  width: 100%;
  padding: 11px 12px;
  background: #26292d;
  color: #fff;
  text-align: left;
}

.new-chat:hover {
  background: #30343a;
}

.clear-chat {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: transparent;
  color: #d9ddd7;
  text-align: left;
}

.clear-chat:hover {
  border-color: rgba(255, 255, 255, 0.22);
  background: #1b1d20;
}

.panel {
  border-top: 1px solid rgba(255, 255, 255, 0.09);
  padding-top: 14px;
}

.panel-title {
  margin-bottom: 10px;
  color: #d9ddd7;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.toggle-row {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 34px;
  color: #f5f5f3;
  font-size: 14px;
}

.toggle-row input {
  width: 17px;
  height: 17px;
  accent-color: var(--accent);
}

.sessions-panel {
  min-height: 0;
  flex: 1;
}

.sessions {
  display: grid;
  gap: 6px;
  overflow: auto;
  max-height: 100%;
}

.session-button {
  overflow: hidden;
  border: 0;
  border-radius: 7px;
  padding: 9px 10px;
  background: transparent;
  color: #d9ddd7;
  font-size: 13px;
  text-align: left;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.session-button.active,
.session-button:hover {
  background: var(--sidebar-soft);
}

.chat-area {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  min-width: 0;
  min-height: 100vh;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  min-height: 64px;
  padding: 12px 24px;
  border-bottom: 1px solid var(--line);
  background: rgba(247, 247, 244, 0.92);
  backdrop-filter: blur(14px);
}

.topbar span {
  color: var(--muted);
}

.menu-button {
  display: none;
}

.icon-button {
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: currentColor;
}

.menu-button span {
  display: block;
  width: 18px;
  height: 2px;
  margin: 4px 0;
  background: #242424;
}

.ghost-button {
  padding: 9px 12px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
}

.messages {
  overflow-y: auto;
  padding: 34px 24px 24px;
}

.empty-state {
  width: min(760px, 100%);
  margin: 8vh auto 0;
  text-align: center;
}

.empty-state h2 {
  margin: 0 0 10px;
  font-size: clamp(28px, 4vw, 42px);
  line-height: 1.08;
  letter-spacing: 0;
}

.empty-state p {
  margin: 0 auto;
  max-width: 620px;
  color: var(--muted);
  font-size: 16px;
  line-height: 1.6;
}

.quick-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin: 28px auto 0;
  max-width: 720px;
}

.quick-prompt {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: var(--surface);
  color: var(--text);
  font-size: 14px;
  line-height: 1.35;
  text-align: left;
}

.quick-prompt:hover {
  border-color: #b9bbb4;
}

.message {
  display: grid;
  grid-template-columns: 38px minmax(0, 760px);
  gap: 14px;
  width: min(940px, 100%);
  margin: 0 auto 22px;
}

.avatar {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border-radius: 8px;
  background: #202124;
  color: #fff;
  font-size: 13px;
  font-weight: 760;
}

.message.user .avatar {
  background: #e6e7e2;
  color: #202124;
}

.bubble {
  min-width: 0;
  padding: 2px 0;
  font-size: 16px;
  line-height: 1.65;
}

.bubble p,
.bubble ul,
.bubble ol {
  margin: 0 0 11px;
}

.bubble p:last-child,
.bubble ul:last-child,
.bubble ol:last-child {
  margin-bottom: 0;
}

.bubble ul,
.bubble ol {
  padding-left: 22px;
}

.bubble li {
  margin: 4px 0;
}

.bubble h3,
.bubble h4 {
  margin: 16px 0 8px;
  font-size: 1em;
  line-height: 1.35;
}

.bubble h3:first-child,
.bubble h4:first-child {
  margin-top: 0;
}

.bubble strong {
  font-weight: 760;
}

.bubble em {
  font-style: italic;
}

.bubble pre {
  overflow-x: auto;
  border-radius: 8px;
  padding: 14px;
  background: #17191c;
  color: #f4f4f2;
  font-size: 13px;
  line-height: 1.5;
}

.bubble code {
  border-radius: 5px;
  padding: 2px 5px;
  background: #e9ebe6;
  font-size: 0.92em;
}

.bubble pre code {
  padding: 0;
  background: transparent;
}

.thinking-row {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
  color: var(--muted);
  font-size: 13px;
}

.thinking-dots {
  display: inline-flex;
  gap: 3px;
}

.thinking-dots i {
  width: 5px;
  height: 5px;
  border-radius: 999px;
  background: var(--accent);
  opacity: 0.35;
  animation: thinkingPulse 1s ease-in-out infinite;
}

.thinking-dots i:nth-child(2) {
  animation-delay: 120ms;
}

.thinking-dots i:nth-child(3) {
  animation-delay: 240ms;
}

@keyframes thinkingPulse {
  0%,
  80%,
  100% {
    transform: translateY(0);
    opacity: 0.35;
  }

  40% {
    transform: translateY(-3px);
    opacity: 0.95;
  }
}

.message-actions {
  margin-top: 8px;
}

.copy-button {
  border: 0;
  border-radius: 7px;
  padding: 6px 8px;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
}

.copy-button:hover {
  background: var(--surface-soft);
  color: var(--text);
}

.composer {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  width: min(860px, calc(100% - 32px));
  margin: 0 auto 22px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.composer textarea {
  resize: none;
  max-height: 190px;
  min-height: 44px;
  border: 0;
  outline: 0;
  padding: 11px 8px;
  color: var(--text);
  background: transparent;
  font-size: 15px;
  line-height: 1.45;
}

.composer button,
.primary-button {
  padding: 0 18px;
  background: var(--accent);
  color: #fff;
}

.composer button:hover,
.primary-button:hover {
  background: var(--accent-dark);
}

.composer button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.overlay {
  display: none;
}

.login-dialog {
  width: min(420px, calc(100% - 28px));
  border: 0;
  border-radius: 12px;
  padding: 0;
  box-shadow: var(--shadow);
}

.login-dialog::backdrop {
  background: rgba(17, 18, 20, 0.45);
}

.login-dialog form {
  display: grid;
  gap: 14px;
  padding: 24px;
}

.login-dialog h1 {
  margin: 0;
  font-size: 23px;
  line-height: 1.2;
}

.login-dialog p {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.45;
}

.login-dialog input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  outline: 0;
}

.login-error {
  min-height: 18px;
  color: var(--danger);
  font-size: 13px;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
}

@media (max-width: 780px) {
  .app-shell {
    display: block;
  }

  .sidebar {
    position: fixed;
    z-index: 20;
    inset: 0 auto 0 0;
    width: min(86vw, 310px);
    transform: translateX(-105%);
    transition: transform 180ms ease;
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .overlay.open {
    position: fixed;
    z-index: 15;
    inset: 0;
    display: block;
    background: rgba(0, 0, 0, 0.35);
  }

  .chat-area {
    min-height: 100vh;
  }

  .topbar {
    padding: 10px 14px;
  }

  .menu-button {
    display: block;
  }

  .messages {
    padding: 24px 14px 18px;
  }

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

  .avatar {
    width: 30px;
    height: 30px;
    border-radius: 7px;
    font-size: 12px;
  }

  .bubble {
    font-size: 15px;
    line-height: 1.58;
  }

  .quick-grid {
    grid-template-columns: 1fr;
  }

  .composer {
    width: calc(100% - 20px);
    margin-bottom: 12px;
    grid-template-columns: minmax(0, 1fr);
  }

  .composer button {
    min-height: 42px;
  }
}
