* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  color: #111;
  background: #fff;
  max-width: 680px;
  margin: 0 auto;
  padding: 2rem 1rem;
  line-height: 1.6;
}

h1, h2, h3 {
  font-weight: bold;
  margin: 1.5em 0 0.5em;
}

h1 {
  font-size: 1.4rem;
}

h2 {
  font-size: 1.15rem;
}

h3 {
  font-size: 1rem;
}

p {
  margin: 0.75em 0;
}

a {
  color: #555;
  text-decoration: underline;
}

a:hover {
  color: #111;
}

dt {
  margin-top: 1em;
}

dt:first-child {
  margin-top: 0;
}

dd {
  margin-left: 1.5em;
}

ul, ol {
  padding-left: 1.5em;
  margin: 0.75em 0;
}

li {
  margin: 0.25em 0;
}

code {
  font-family: inherit;
  background: #f5f5f5;
  padding: 0.15em 0.3em;
  border-radius: 2px;
}

pre {
  background: #f5f5f5;
  padding: 1em;
  overflow-x: auto;
  margin: 0.75em 0;
  border-radius: 2px;
}

pre code {
  padding: 0;
  background: none;
}

img {
  max-width: 100%;
  height: auto;
}

hr {
  border: none;
  border-top: 1px solid #ddd;
  margin: 2em 0;
}

blockquote {
  border-left: 3px solid #666;
  margin-left: 0;
  padding-left: 1em;
  color: #888;
}

/* Local-model selector shared by the browser inference demos. */
.model-picker {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem;
  margin: 1.25rem 0 0;
  padding: 0;
  border: 0;
}

.model-picker legend {
  grid-column: 1 / -1;
  margin-bottom: 0;
  padding: 0;
  color: #111;
  font: 700 0.76rem/1.2 ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.model-picker-hint {
  grid-column: 1 / -1;
  margin: 0 0 0.1rem;
  color: #777;
  font-size: 0.78rem;
  line-height: 1.45;
}

.model-card {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.35rem 0.7rem;
  min-width: 0;
  min-height: 9.25rem;
  padding: 0.85rem;
  border: 1px solid #d7d7d7;
  border-radius: 3px;
  background: linear-gradient(145deg, #fff, #f5f5f2);
  color: #111;
  text-align: left;
  cursor: pointer;
  transition: border-color 150ms ease, box-shadow 150ms ease, transform 150ms ease, background 150ms ease;
}

.model-card:hover:not(:disabled) {
  border-color: #111;
  box-shadow: 4px 4px 0 #111;
  transform: translate(-2px, -2px);
}

.model-card.selected {
  border-color: #111;
  background: #111;
  color: #fff;
  box-shadow: 4px 4px 0 #c8ff00;
}

.model-card:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.model-card-top,
.model-card-description,
.model-card-size {
  grid-column: 1 / -1;
}

.model-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.model-card-eyebrow,
.model-card-size {
  color: #777;
  font-size: 0.68rem;
  letter-spacing: 0.09em;
}

.model-card.selected .model-card-eyebrow,
.model-card.selected .model-card-size {
  color: #c8ff00;
}

.model-card-mark {
  display: inline-grid;
  width: 1.7rem;
  height: 1.7rem;
  place-items: center;
  border: 1px solid currentColor;
  border-radius: 50%;
  font-size: 0.68rem;
  font-weight: 700;
}

.model-card-title {
  font-size: 0.98rem;
  line-height: 1.2;
}

.model-card-description {
  color: #666;
  font-size: 0.76rem;
  line-height: 1.45;
}

.model-card.selected .model-card-description {
  color: #ddd;
}

@media (max-width: 620px) {
  .model-picker {
    grid-template-columns: 1fr;
  }
}

/* Quiet, local-only chat history controls. */
.chat-history-control {
  padding: 0.45em 0.8em;
  font-size: 0.85rem;
}

.chat-history-dialog {
  position: fixed;
  inset: 0;
  margin: auto;
  width: min(42rem, calc(100vw - 2rem));
  max-height: min(80vh, 44rem);
  padding: 1.25rem;
  border: 1px solid #111;
  border-radius: 2px;
  background: #fff;
  color: #111;
  box-shadow: 6px 6px 0 #c8ff00;
}

.chat-history-dialog::backdrop {
  background: rgba(17, 17, 17, 0.2);
}

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

.chat-history-dialog-header {
  margin-bottom: 0.35rem;
}

.chat-history-note,
.chat-history-empty,
.chat-history-session-meta {
  margin: 0;
  color: #777;
  font-size: 0.78rem;
}

.chat-history-list {
  display: grid;
  gap: 0.5rem;
  max-height: 15rem;
  margin-top: 1rem;
  overflow-y: auto;
}

.chat-history-session {
  display: grid;
  gap: 0.25rem;
  width: 100%;
  padding: 0.7rem 0.8rem;
  border: 1px solid #ddd;
  background: #fff;
  color: #111;
  text-align: left;
}

.chat-history-session:hover {
  border-color: #111;
  background: #f5f5f2;
  color: #111;
}

.chat-history-session-title,
.chat-history-detail-title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-history-detail {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid #ddd;
}

.chat-history-transcript {
  display: grid;
  gap: 0.75rem;
  max-height: 20rem;
  margin: 1rem 0;
  overflow-y: auto;
  padding-right: 0.25rem;
}

.chat-history-message {
  padding-left: 0.75rem;
  border-left: 2px solid #ddd;
}

.chat-history-message.user {
  border-left-color: #111;
}

.chat-history-message-role {
  display: block;
  margin-bottom: 0.25rem;
  color: #777;
  font: 700 0.68rem/1.2 ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.chat-history-message p {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
}

/* Small, local-only roleplay character editor. */
.persona-dialog {
  position: fixed;
  inset: 0;
  margin: auto;
  width: min(42rem, calc(100vw - 2rem));
  max-height: min(86vh, 48rem);
  overflow-y: auto;
  padding: 1.25rem;
  border: 1px solid #111;
  border-radius: 2px;
  background: #fff;
  color: #111;
  box-shadow: 6px 6px 0 #c8ff00;
}

.persona-dialog::backdrop {
  background: rgba(17, 17, 17, 0.2);
}

.persona-dialog-header,
.persona-dialog-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.persona-dialog-header {
  justify-content: space-between;
}

.persona-dialog-note {
  margin: 0.35rem 0 0;
  color: #777;
  font-size: 0.78rem;
}

.persona-form {
  display: grid;
  gap: 0.9rem;
  margin-top: 1rem;
}

.persona-field {
  display: grid;
  gap: 0.25rem;
}

.persona-field-label {
  color: #111;
  font: 700 0.7rem/1.2 ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.persona-field-hint {
  color: #777;
  font-size: 0.76rem;
  line-height: 1.35;
}

.persona-field input,
.persona-field textarea {
  box-sizing: border-box;
  width: 100%;
  padding: 0.55rem 0.65rem;
  border: 1px solid #d7d7d7;
  border-radius: 2px;
  background: #fff;
  color: #111;
  font: inherit;
  line-height: 1.45;
}

.persona-field input:focus,
.persona-field textarea:focus {
  outline: none;
  border-color: #111;
  box-shadow: 2px 2px 0 #c8ff00;
}

.persona-dialog-actions {
  flex-wrap: wrap;
  justify-content: flex-end;
  margin-top: 0.2rem;
}

.persona-defaults {
  margin-right: auto;
  padding: 0.45em 0;
  border: 0;
  background: transparent;
  color: #555;
  font-size: 0.85rem;
  text-decoration: underline;
}

.persona-defaults:hover {
  background: transparent;
  color: #111;
}

@media (max-width: 620px) {
  .chat-history-dialog {
    width: calc(100vw - 1.25rem);
    padding: 1rem;
  }

  .persona-dialog {
    width: calc(100vw - 1.25rem);
    padding: 1rem;
  }
}
