:root {
  color-scheme: light;
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  line-height: 1.5;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: #f5f7fb;
  color: #1f2937;
}

.side-menu {
  position: fixed;
  top: 0;
  left: 0;
  width: min(320px, 85vw);
  height: 100vh;
  background: #ffffff;
  border-right: 1px solid #e5e7eb;
  padding: 1rem;
  transform: translateX(-100%);
  transition: transform 0.2s ease-in-out;
  z-index: 20;
  overflow-y: auto;
}

.side-menu.open {
  transform: translateX(0);
}

.side-menu-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.75rem;
}

.side-menu-header h2 {
  margin: 0;
  font-size: 1rem;
  color: #374151;
}

.side-menu-subheading {
  margin: 0 0 0.5rem;
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #6b7280;
}

.side-menu-settings {
  margin-bottom: 1.25rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid #e5e7eb;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.settings-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: #374151;
}

.settings-input {
  width: 100%;
  border-radius: 0.5rem;
  border: 1px solid #d1d5db;
  padding: 0.5rem 0.6rem;
  font: inherit;
  font-size: 0.9rem;
}

.settings-input:focus {
  outline: 2px solid #2563eb;
  outline-offset: 2px;
}

.settings-row-button {
  align-self: flex-start;
  margin-top: 0.15rem;
}

.settings-hint {
  margin: 0.35rem 0 0;
  font-size: 0.8rem;
  color: #6b7280;
  line-height: 1.35;
}

.settings-hint-tight {
  margin-top: 0.15rem;
  margin-bottom: 0.35rem;
}

.settings-textarea {
  width: 100%;
  resize: vertical;
  min-height: 4.5rem;
  border-radius: 0.5rem;
  border: 1px solid #d1d5db;
  padding: 0.5rem 0.6rem;
  font: inherit;
  font-size: 0.9rem;
  line-height: 1.4;
}

.settings-textarea:focus {
  outline: 2px solid #2563eb;
  outline-offset: 2px;
}

.settings-key-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-top: 0.25rem;
}

.settings-key-actions .secondary-button,
.settings-key-actions .danger-button {
  font-size: 0.85rem;
  padding: 0.45rem 0.65rem;
}

.danger-button {
  background: #fef2f2;
  color: #b91c1c;
  border: 1px solid #fecaca;
  border-radius: 0.75rem;
  padding: 0.75rem 1.1rem;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.danger-button:hover {
  background: #fee2e2;
}

.danger-button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.menu-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.28);
  z-index: 15;
}

.hidden {
  display: none;
}

.chat-layout {
  width: min(900px, 100%);
  margin: 0 auto;
  height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 1rem;
  gap: 0.75rem;
}

.chat-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
}

.chat-header > div {
  flex: 1;
}

.chat-header h1 {
  margin: 0;
  font-size: 1.5rem;
}

.chat-header p {
  margin: 0.25rem 0 0;
  color: #4b5563;
}

.chat-log {
  flex: 1;
  min-height: 0;
  background: #ffffff;
  border: 1px solid #e5e7eb;
  border-radius: 0.75rem;
  padding: 1rem;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.message {
  max-width: 85%;
  padding: 0.7rem 0.9rem;
  border-radius: 0.75rem;
  white-space: pre-wrap;
  word-break: break-word;
}

.message.user {
  align-self: flex-end;
  background: #2563eb;
  color: #ffffff;
  border-bottom-right-radius: 0.25rem;
}

.message.assistant {
  align-self: flex-start;
  background: #eef2ff;
  color: #1e293b;
  border-bottom-left-radius: 0.25rem;
}

.message.system {
  align-self: center;
  background: #fef3c7;
  color: #92400e;
}

.chat-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.75rem;
}

.secondary-button {
  background: #e5e7eb;
  color: #1f2937;
}

.icon-button {
  background: #ffffff;
  color: #1f2937;
  border: 1px solid #d1d5db;
  width: 2.5rem;
  height: 2.5rem;
  padding: 0;
  display: inline-flex;
  justify-content: center;
  align-items: center;
  font-size: 1.2rem;
  border-radius: 0.6rem;
}

.archive-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.archive-item {
  display: grid;
  gap: 0.5rem;
  border: 1px solid #e5e7eb;
  border-radius: 0.5rem;
  padding: 0.55rem 0.65rem;
  font-size: 0.9rem;
  background: #f8fafc;
}

.archive-item.clickable {
  cursor: pointer;
}

.archive-item.clickable:hover {
  background: #eef2ff;
}

.archive-item-title {
  font-weight: 600;
}

.archive-item-meta {
  color: #6b7280;
}

textarea {
  width: 100%;
  resize: none;
  border-radius: 0.75rem;
  border: 1px solid #d1d5db;
  padding: 0.75rem;
  font: inherit;
}

textarea:focus,
button:focus {
  outline: 2px solid #2563eb;
  outline-offset: 2px;
}

button {
  border: none;
  border-radius: 0.75rem;
  padding: 0.75rem 1.1rem;
  background: #2563eb;
  color: #fff;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

button[disabled] {
  cursor: not-allowed;
  opacity: 0.65;
}

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

@media (max-width: 640px) {
  .chat-layout {
    padding: 0.75rem;
  }

  .chat-header {
    align-items: stretch;
    flex-direction: column;
  }

  .chat-form {
    grid-template-columns: 1fr;
  }

  .message {
    max-width: 100%;
  }
}
