body {
  font-family: system-ui, sans-serif;
  font-size: 18px;
  line-height: 1.5;
  display: flex;
  justify-content: center;
  align-items: center;
  height: 100vh;
  margin: 0;
  background: #0200ac;
  color: #eee;
}

main {
  text-align: center;
}

form {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  width: 400px;
  margin: 0 auto;
}

form label {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  text-align: left;
}

form input {
  font-family: inherit;
  font-size: inherit;
  padding: 20px;
  border: 2px solid #ffffff;
  border-radius: 4px;
  background: rgba(255,255,255,0.1);
  color: #eee;
}

form input:-webkit-autofill,
form input:-webkit-autofill:hover,
form input:-webkit-autofill:focus,
form input:-webkit-autofill:active {
  -webkit-text-fill-color: #eee;
  caret-color: #eee;
  -webkit-box-shadow: 0 0 0 1000px #1b1ab4 inset;
  transition: background-color 9999s ease-in-out 0s;
}

form button {
  font-family: inherit;
  font-size: inherit;
  padding: 20px;
  border: 2px solid #ffffff;
  border-radius: 4px;
  background: #5355ff;
  color: #fff;
  cursor: pointer;
}

form button:hover {
background: #ff4cf6;
}

.error {
  color: #5355ff;
}

/* rosa */

body.rosa {
  display: block;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  background: #ff4cf6;
}

#topbar {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  box-sizing: border-box;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.6rem;
  padding: 20px;
  background: rgba(2, 0, 172, 0.85);
  z-index: 10;
}

#topbar a {
  color: #eee;
  text-decoration: none;
  cursor: pointer;
}

#topbar a:hover,
#topbar a.active {
  color: #fff;
  text-decoration: underline;
}

#topbar .sep {
  color: #eee;
  opacity: 0.5;
}

#carousel {
  display: flex;
  width: 200vw; /* one 100vw panel per section */
  height: 100vh;
  height: 100dvh;
  transition: transform 0.5s ease;
}

.section {
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  flex-shrink: 0;
  box-sizing: border-box;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 0 1.5rem;
}

/* chat */

.section[data-section="chat"] {
  align-items: stretch;
  justify-content: flex-start;
  padding: 0;
}

#chat-panel {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
  box-sizing: border-box;
  padding: 5.5rem 1.5rem 1rem;
  padding-bottom: calc(1rem + env(safe-area-inset-bottom));
}

#chat-scroll {
  flex: 1;
  /* Without this a flex item won't shrink below its content height, so the
     log grows past the panel and the input field overlaps the last bubble. */
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  touch-action: pan-y;
  width: 100%;
  max-width: 700px;
  margin: 0 auto;
  padding-bottom: 0.5rem;
  scrollbar-width: none;    /* Firefox */
  -ms-overflow-style: none; /* legacy Edge */
}

/* Scrolling stays; only the scrollbar is hidden. */
#chat-scroll::-webkit-scrollbar {
  display: none;
}

#chat-log {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

/* Direct children only. A bare `#chat-log li` also matches list items inside
   rendered markdown, turning each one into a flex row and laying its own words
   out as columns. */
#chat-log > li {
  display: flex;
}

#chat-log > li.from-user {
  justify-content: flex-start;
}

#chat-log > li.from-claude {
  justify-content: flex-end;
}

#chat-log .bubble {
  max-width: 80%;
  box-sizing: border-box;
  padding: 0.75rem 1rem;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.15);
  text-align: left;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

/* Side and tail corner are what distinguish the two, not colour. */
#chat-log li.from-user .bubble {
  border-bottom-left-radius: 2px;
}

#chat-log li.from-claude .bubble {
  border-bottom-right-radius: 2px;
}

#chat-log .bubble.pending .answer::after {
  content: '|';
  animation: blink 0.8s steps(1) infinite;
}

#chat-form {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  width: 100%;
  max-width: 700px;
  margin: 1rem auto 0;
}

#chat-controls {
  display: flex;
  justify-content: center;
  gap: 0.5rem;
}

#chat-controls button {
  font-family: inherit;
  font-size: 0.85rem;
  padding: 0.35rem 0.9rem;
  border: 2px solid #ffffff;
  border-radius: 4px;
  background: none;
  color: #eee;
  cursor: pointer;
}

/* No hover state anywhere in here. "new chat" is an action, so it gets a press
   flash — there's no lasting state for it to show. */
#chat-new:active {
  background: #5355ff;
  color: #fff;
}

/* "thinking mode" is a toggle, driven purely by aria-pressed. Deliberately no
   :active — on the click that turns it OFF, :active would paint it blue for the
   duration of the press and then clear, which reads as a flash. */
#chat-controls button[aria-pressed="true"] {
  background: #5355ff;
  color: #fff;
}

/* Rendered markdown brings its own block spacing, so the bubble's pre-wrap
   would add a blank line per source newline on top of it. */
#chat-log .bubble .answer.markdown-body {
  white-space: normal;
}

/* Headings and paragraphs carry outer margins that would dent the bubble's
   own padding at the top and bottom edges. */
#chat-log .bubble .markdown-body > :first-child {
  margin-top: 0;
}

#chat-log .bubble .markdown-body > :last-child {
  margin-bottom: 0;
}

#chat-log .bubble .thinking {
  margin: 0 0 0.6rem;
  padding-left: 0.6rem;
  border-left: 2px solid rgba(255, 255, 255, 0.35);
  font-size: 0.85rem;
  font-style: italic;
  opacity: 0.75;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

#chat-log .bubble .thinking:empty {
  display: none;
}

/* One line naming any files Claude wrote this turn. */
#chat-log .bubble .tool-notes {
  margin: 0 0 0.5rem;
  font-size: 0.8rem;
  opacity: 0.8;
}

#chat-log .bubble .tool-notes:empty {
  display: none;
}

#chat-input {
  width: 100%;
  box-sizing: border-box;
  font-family: inherit;
  font-size: inherit;
  padding: 20px;
  border: 2px solid #ffffff;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.1);
  color: #eee;
}

#chat-input::placeholder {
  color: rgba(238, 238, 238, 0.6);
}

/* Focus changes nothing visually — border and fill stay at their resting
   values. The rule exists only to suppress the browser's own focus ring,
   which would otherwise draw a second outline around the white border. */
#chat-input:focus,
#chat-input:focus-visible {
  outline: none;
  box-shadow: none;
}

#chat-error {
  width: 100%;
  max-width: 700px;
  margin: 0.5rem auto 0;
  text-align: center;
}

#chat-error[hidden] {
  display: none;
}

.section[data-section="repo"] {
  position: relative;
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-start;
  padding: 0;
}

#repo-content,
#view-content {
  position: absolute;
  inset: 0;
  box-sizing: border-box;
  overflow-y: auto;
  overflow-x: hidden;
  touch-action: pan-y;
  padding: 5.5rem 1.5rem 5rem;
  opacity: 1;
  transition: opacity 0.3s ease;
}

#repo-content[hidden],
#view-content[hidden] {
  display: none;
}

#view-content {
  display: flex;
  flex-direction: column;
}

#view-close {
  position: absolute;
  top: 5.5rem;
  left: 50%;
  transform: translateX(-50%);
  color: #eee;
  text-decoration: none;
  cursor: pointer;
  z-index: 5;
}

#view-close:hover {
  text-decoration: underline;
}

#view-body {
  flex: 1;
  margin-top: 2rem;
  max-width: 700px;
  width: 100%;
  margin-left: auto;
  margin-right: auto;
}

#view-body pre {
  white-space: pre-wrap;
  word-break: break-word;
  overflow-wrap: anywhere;
  text-align: left;
  font-family: inherit;
}

.markdown-body {
  text-align: left;
  overflow-wrap: anywhere;
}

.markdown-body h1,
.markdown-body h2,
.markdown-body h3,
.markdown-body h4,
.markdown-body h5,
.markdown-body h6 {
  margin: 1.2em 0 0.5em;
}

.markdown-body p {
  margin: 0.6em 0;
}

/* list-style is inherited, and #chat-log sets it to none for the chat rows —
   so markdown lists have to ask for their markers back explicitly. */
.markdown-body ul {
  list-style: disc;
}

.markdown-body ol {
  list-style: decimal;
}

.markdown-body ul,
.markdown-body ol {
  margin: 0.6em 0;
  padding-left: 1.5rem;
}

/* display is restated because the chat-row rule used to force these to flex. */
.markdown-body li {
  display: list-item;
  margin: 0.2em 0;
}

.markdown-body code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.9em;
  padding: 0.1em 0.3em;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.18);
}

.markdown-body pre {
  margin: 0.8em 0;
  padding: 0.75rem;
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.25);
  overflow-x: auto;
}

/* The block already has its own background and padding. */
.markdown-body pre code {
  padding: 0;
  background: none;
}

.markdown-body a {
  color: #eee;
  text-decoration: underline;
}

.markdown-body hr {
  border: none;
  border-top: 1px solid #eee;
  margin: 1.2em 0;
}

.markdown-body table {
  border-collapse: collapse;
  table-layout: fixed;
  width: 100%;
  margin: 1em 0;
}

.markdown-body th,
.markdown-body td {
  border: 1px solid rgba(255, 255, 255, 0.3);
  padding: 0.4rem 0.6rem;
  text-align: left;
  overflow-wrap: anywhere;
}

.markdown-body th {
  font-weight: bold;
}

#view-body img {
  max-width: 100%;
  display: block;
  margin: 0 auto;
}

#view-body iframe {
  width: 100%;
  height: 100%;
  min-height: 60vh;
  border: none;
  background: #fff;
  touch-action: pan-y;
}

#file-list {
  list-style: none;
  margin: 0 auto;
  padding: 0;
  /* Wider than before: handle, name and four actions now share one row. */
  max-width: 700px;
  text-align: center;
}

/* Same treatment as a chat bubble — translucent fill, no border — but rounded
   evenly, since there's no tail corner to point anywhere. */
#file-list li {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  box-sizing: border-box;
  padding: 0.75rem 1rem;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.15);
  text-align: left;
}

#file-list li + li {
  margin-top: 0.5rem;
}

/* The row being dragged fades so the gap it will land in stays readable. */
#file-list li.dragging {
  opacity: 0.4;
}

#file-list .handle {
  flex-shrink: 0;
  cursor: grab;
  opacity: 0.6;
  /* line-height: 1; */
  padding: 0.2rem 0.1rem; /* a little more to aim at with a fingertip */
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none; /* no iOS long-press menu mid-drag */
  /* Required for touch dragging: without it the browser claims the gesture
     and pans the page instead of sending pointermove. */
  touch-action: none;
}

#file-list .handle:active {
  cursor: grabbing;
}

#file-list a {
  color: #eee;
}

#file-list .filename {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#file-list .file-actions {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  white-space: nowrap;
  font-size: 0.85rem;
}

#file-list .file-actions a,
#file-list .file-actions button {
  color: #eee;
  text-decoration: none;
  cursor: pointer;
  background: none;
  border: none;
  padding: 0;
  font-family: inherit;
  font-size: inherit;
}

#file-list .file-actions a:hover,
#file-list .file-actions button:hover {
  text-decoration: underline;
}

#file-list .file-actions .sep {
  opacity: 0.5;
}

#upload-bar {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  box-sizing: border-box;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.5rem;
  padding: 1rem 1.5rem;
  padding-bottom: calc(1rem + env(safe-area-inset-bottom));
}

#upload-bar[hidden] {
  display: none;
}

#upload-error {
  flex-basis: 100%;
  margin: 0;
}

#create-btn,
#file-label,
#upload-btn {
  font-family: inherit;
  font-size: inherit;
  padding: 0.6rem 1rem;
  border: 2px solid #ffffff;
  border-radius: 4px;
  background: #5355ff;
  color: #fff;
  cursor: pointer;
}

#create-btn:hover,
#file-label:hover,
#upload-btn:hover {
  background: #ff4cf6;
}

@keyframes blink {
  50% { opacity: 0; }
}

#edit-modal {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  box-sizing: border-box;
  padding: 1.5rem;
  padding-bottom: calc(1.5rem + env(safe-area-inset-bottom));
  background: #ff4cf6;
}

#edit-modal[hidden] {
  display: none;
}

#edit-textarea {
  flex: 1;
  resize: none;
  box-sizing: border-box;
  padding: 1rem;
  border: none;
  outline: none;
  background: transparent;
  color: #eee;
  font-family: inherit;
  font-size: inherit;
}

#edit-actions {
  display: flex;
  justify-content: center;
  gap: 0.5rem;
}

#edit-actions button {
  font-family: inherit;
  font-size: inherit;
  padding: 0.6rem 1rem;
  border: 2px solid #ffffff;
  border-radius: 4px;
  background: #5355ff;
  color: #fff;
  cursor: pointer;
}

#edit-actions button:hover {
  background: #ff4cf6;
}

/* mobile */

@media (max-width: 800px) {
  body {
    font-size: 16px;
  }

  main {
    width: 100%;
    box-sizing: border-box;
    padding: 0 1.25rem;
  }

  form {
    width: 100%;
    box-sizing: border-box;
  }

  form input,
  form button {
    padding: 14px;
  }

  #chat-panel {
    padding-left: 1rem;
    padding-right: 1rem;
  }

  #chat-input {
    padding: 14px;
  }

  #chat-log .bubble {
    max-width: 90%;
  }

  /* Two lines: handle + full filename on the first, actions on the second.
     The name wraps instead of truncating, so it can always be read whole. */
  #file-list li {
    flex-wrap: wrap;
    row-gap: 0.4rem;
  }

  #file-list .filename {
    white-space: normal;
    overflow: visible;
    text-overflow: clip;
    overflow-wrap: anywhere;
  }

  #file-list .file-actions {
    flex-basis: 100%;
  }

  #topbar {
    gap: 0.4rem;
    padding: 1rem;
  }
}