:root {
  --bg: #ffffff;
  --text: #111111;
  --muted: #767676;
  --line: rgba(17, 17, 17, 0.08);
  --line-strong: rgba(17, 17, 17, 0.16);
  --accent: #111111;
  --user: #111111;
  --assistant: #666666;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: "Plus Jakarta Sans", sans-serif;
}

body {
  animation: pageFade 320ms ease;
}

button,
input,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 240px 1fr;
}

.rail {
  padding: 24px 18px;
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 18px;
  background: #fff;
}

.rail-top {
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}

.brand,
.workspace-header h2,
.empty-state h3,
.login-panel h2 {
  margin: 0;
  font-family: "Plus Jakarta Sans", sans-serif;
  font-weight: 600;
  letter-spacing: -0.03em;
}

.brand {
  font-size: 1rem;
  line-height: 1.2;
}

.rail-actions,
.history-meta,
.workspace-header,
.composer-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.text-button,
.submit-button {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--text);
  padding: 0;
  transition: opacity 140ms ease, transform 140ms ease;
}

.text-button:hover,
.submit-button:hover {
  opacity: 0.65;
}

.text-button.primary {
  font-weight: 600;
}

.history-meta {
  font-size: 0.82rem;
  color: var(--muted);
  padding-top: 2px;
}

.conversation-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow-y: auto;
  padding-right: 2px;
}

.history-item {
  border: 0;
  background: transparent;
  text-align: left;
  color: var(--text);
  padding: 10px 0;
  border-bottom: 1px solid rgba(20, 20, 18, 0.06);
  transition: padding-left 160ms ease, color 160ms ease;
}

.history-item:hover,
.history-item.active {
  padding-left: 8px;
}

.history-item.active {
  color: var(--accent);
}

.history-item small {
  display: block;
  margin-top: 5px;
  color: var(--muted);
}

.workspace {
  min-height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr auto;
}

.workspace-header {
  padding: 24px 28px 16px;
  border-bottom: 1px solid var(--line);
  background: #fff;
  position: sticky;
  top: 0;
  z-index: 2;
}

.workspace-header h2 {
  font-size: 1rem;
  line-height: 1.2;
  font-weight: 600;
}

.messages {
  padding: 24px 28px 12px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  overflow-y: auto;
}

.empty-state {
  max-width: 560px;
  padding: 48px 0 80px;
  margin: auto 0;
}

.empty-state h3 {
  font-size: 1.4rem;
  line-height: 1.2;
  max-width: 16ch;
}

.message-row {
  max-width: 820px;
  display: grid;
  gap: 10px;
  padding: 0 0 20px;
  border-bottom: 1px solid rgba(20, 20, 18, 0.07);
  animation: rise 220ms ease;
}

.message-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.76rem;
  color: var(--muted);
}

.message-row.user .role {
  color: var(--user);
}

.message-row.assistant .role {
  color: var(--assistant);
}

.message-body {
  white-space: pre-wrap;
  font-size: 0.98rem;
  line-height: 1.7;
  color: var(--text);
}

.composer {
  padding: 16px 28px 24px;
  border-top: 1px solid var(--line);
  background: #fff;
}

textarea,
input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 0;
  background: #fff;
  color: var(--text);
  padding: 14px 0;
  outline: none;
  resize: vertical;
  transition: border-color 140ms ease, background 140ms ease;
}

textarea {
  min-height: 124px;
  border-left: 0;
  border-right: 0;
  border-top: 0;
}

input {
  border-left: 0;
  border-right: 0;
  border-top: 0;
  padding-left: 0;
  padding-right: 0;
}

textarea::placeholder,
input::placeholder {
  color: #9a958c;
}

textarea:focus,
input:focus {
  border-color: var(--accent);
  background: transparent;
}

.submit-button {
  font-weight: 600;
}

.submit-button.full {
  width: 100%;
  text-align: left;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.submit-button:disabled {
  opacity: 0.44;
  cursor: wait;
}

.overlay {
  position: fixed;
  inset: 0;
  display: none;
  place-items: center;
  padding: 28px;
  background: rgba(255, 255, 255, 0.96);
}

.overlay.visible {
  display: grid;
}

.login-panel {
  width: min(420px, 100%);
  padding: 20px 0 0;
  border-top: 1px solid var(--line-strong);
}

.login-panel h2 {
  font-size: 1.8rem;
  line-height: 1.05;
  margin-bottom: 14px;
}

.login-panel label {
  display: block;
  margin: 22px 0 8px;
  color: var(--muted);
}

.status-text,
.composer-hint,
.message-meta,
.error-text,
.error-text {
  margin: 0;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(14px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes pageFade {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

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

  .rail {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
}

@media (max-width: 640px) {
  .rail,
  .workspace-header,
  .messages,
  .composer {
    padding-left: 16px;
    padding-right: 16px;
  }

  .empty-state {
    padding-top: 36px;
  }

  .empty-state h3 {
    max-width: none;
    font-size: 1.3rem;
  }
}
