:root {
  color-scheme: light;
  --bg: #f7f7f4;
  --panel: #ffffff;
  --panel-soft: #f0f2ed;
  --text: #202124;
  --muted: #686d73;
  --line: #dedfd9;
  --accent: #176b5b;
  --accent-dark: #10483f;
  --assistant: #ffffff;
  --user: #176b5b;
  --shadow: 0 18px 48px rgba(32, 33, 36, 0.12);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
}

button,
textarea {
  font: inherit;
}

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

.page-header {
  grid-column: 1 / -1;
  width: 100%;
  background: linear-gradient(135deg, #0f172a 0%, #1a56db 50%, #10b981 100%);
  overflow: hidden;
}

.header-image {
  width: 100%;
  height: auto;
  display: block;
  object-fit: cover;
}

.github-ribbon {
  position: fixed;
  top: 0;
  right: 0;
  z-index: 9999;
  overflow: hidden;
  width: 150px;
  height: 150px;
  text-decoration: none;
}

.github-ribbon span {
  position: absolute;
  display: block;
  width: 225px;
  padding: 8px 0;
  background: #24292e;
  box-shadow: 0 5px 10px rgba(0, 0, 0, 0.2);
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  text-align: center;
  text-transform: none;
  letter-spacing: 0.5px;
  top: 42px;
  right: -55px;
  transform: rotate(45deg);
  transition: background 0.3s ease;
}

.github-ribbon:hover span {
  background: #2ea44f;
}

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

.visitor-counter {
  display: flex;
  justify-content: flex-start;
  margin-bottom: 8px;
}

.visitor-badge {
  max-width: 100%;
  height: auto;
}

.resources-panel {
  display: flex;
  flex-direction: column;
  gap: 24px;
  padding: 24px;
  border-left: 1px solid var(--line);
  background: #f0f2ed;
  overflow-y: auto;
}

.resources-panel h2 {
  margin: 0;
  font-size: 0.9rem;
  text-transform: uppercase;
  color: var(--muted);
  letter-spacing: 0;
}

.resources-section {
  margin-bottom: 16px;
}

.resources-section h3 {
  margin: 0 0 12px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--accent);
}

.resources-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.resources-list li {
  margin-bottom: 12px;
}

.resources-list a {
  display: block;
  color: var(--text);
  text-decoration: none;
  font-size: 0.8rem;
  line-height: 1.4;
  transition: color 0.2s;
}

.resources-list a:hover {
  color: var(--accent);
  text-decoration: underline;
}

.resources-list .author {
  font-size: 0.75rem;
  color: var(--muted);
  margin-top: 2px;
}

.resources-list .year {
  font-size: 0.7rem;
  color: var(--muted);
  font-style: italic;
}

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

.mark,
.avatar {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
}

.brand h1,
.chat-header h2,
.memory-panel h2 {
  margin: 0;
  letter-spacing: 0;
}

.brand h1 {
  font-size: 1.2rem;
}

.brand p,
.chat-header p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.memory-panel {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.55);
}

.memory-panel h2 {
  font-size: 0.9rem;
  text-transform: uppercase;
  color: var(--muted);
}

.memory-panel dl {
  display: grid;
  gap: 14px;
  margin: 16px 0 0;
}

.memory-panel dt {
  color: var(--muted);
  font-size: 0.78rem;
}

.memory-panel dd {
  margin: 4px 0 0;
  font-weight: 650;
  overflow-wrap: anywhere;
}

.reset-button,
.composer button {
  min-height: 42px;
  border: 0;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  font-weight: 700;
}

.reset-button {
  margin-top: auto;
}

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

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

.chat-header {
  display: flex;
  align-items: center;
  min-height: 78px;
  padding: 18px 28px;
  border-bottom: 1px solid var(--line);
  background: rgba(247, 247, 244, 0.86);
  backdrop-filter: blur(12px);
}

.chat-header h2 {
  font-size: 1rem;
}

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

.message {
  display: grid;
  grid-template-columns: 36px minmax(0, 760px);
  gap: 14px;
  align-items: start;
  max-width: 980px;
  margin: 0 auto 20px;
}

.message p {
  margin: 0;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--assistant);
  box-shadow: 0 1px 0 rgba(32, 33, 36, 0.04);
  line-height: 1.55;
  overflow-wrap: anywhere;
}

.message.user {
  grid-template-columns: minmax(0, 760px) 36px;
  justify-content: end;
}

.message.user .avatar {
  grid-column: 2;
  grid-row: 1;
  background: #30343b;
}

.message.user p {
  grid-column: 1;
  background: var(--user);
  color: #fff;
  border-color: var(--user);
}

.thinking {
  display: flex;
  gap: 5px;
  width: fit-content;
}

.thinking span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--muted);
  animation: pulse 1s infinite ease-in-out;
}

.thinking span:nth-child(2) {
  animation-delay: 0.15s;
}

.thinking span:nth-child(3) {
  animation-delay: 0.3s;
}

.composer {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 96px;
  gap: 10px;
  max-width: 980px;
  width: calc(100% - 56px);
  margin: 0 auto;
  padding: 18px 0 24px;
}

.composer textarea {
  width: 100%;
  min-height: 48px;
  max-height: 160px;
  resize: vertical;
  padding: 13px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  outline: none;
  background: var(--panel);
  color: var(--text);
  box-shadow: var(--shadow);
}

.composer textarea:focus {
  border-color: var(--accent);
}

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

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

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

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

  .page-header {
    display: none;
  }

  .github-ribbon {
    width: 100px;
    height: 100px;
  }

  .github-ribbon span {
    width: 150px;
    padding: 5px 0;
    top: 28px;
    right: -38px;
    font-size: 10px;
  }

  .sidebar {
    display: none;
  }

  .resources-panel {
    display: none;
  }

  .chat {
    height: 100vh;
  }

  .chat-header {
    padding: 14px 16px;
  }

  .chat-header p {
    display: none;
  }

  .messages {
    padding: 16px;
  }

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

  .message.user .avatar {
    grid-column: 1;
  }

  .message.user p {
    grid-column: 2;
  }

  .mark,
  .avatar {
    width: 32px;
    height: 32px;
  }

  .composer {
    grid-template-columns: 1fr;
    width: calc(100% - 32px);
    padding-bottom: 16px;
  }
}
