:root {
  color-scheme: light dark;

  --bg: #f6f7f9;
  --surface: #ffffff;
  --border: #dfe3e8;
  --text: #1a1d21;
  --text-muted: #5c6570;
  --accent: #2f6fed;
  --accent-text: #ffffff;
  --danger: #b4232a;
  --success: #1a7f4b;
  --radius: 10px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14161a;
    --surface: #1c1f24;
    --border: #2c3138;
    --text: #e8eaed;
    --text-muted: #9aa4b0;
    --accent: #5b8dff;
    --accent-text: #0d1014;
    --danger: #ff8a8a;
    --success: #6ee7a8;
  }
}

* {
  box-sizing: border-box;
}

/* The `hidden` attribute is honoured only by a UA rule, which any author
   `display:` declaration outranks — so a flex or grid element toggled from JS
   silently stops hiding. That is not hypothetical: `.panel { display: flex }`
   kept the signed-out gate on screen after sign-in. One global rule fixes it
   for every element, including ones added later. */
[hidden] {
  display: none !important;
}

body {
  margin: 0;
  padding: 2.5rem 1.25rem;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.55 ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
}

.shell {
  margin: 0 auto;
  max-width: 46rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.shell__header h1 {
  margin: 0 0 0.35rem;
  font-size: 1.6rem;
  letter-spacing: -0.01em;
}

.shell__subtitle {
  margin: 0;
  color: var(--text-muted);
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.panel__heading {
  margin: 0;
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.panel__actions {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  flex-wrap: wrap;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.field__label {
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.field__input {
  width: 100%;
  padding: 0.75rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  color: inherit;
  font: 0.95rem/1.6 ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace;
  resize: vertical;
}

.field__input:focus-visible,
.button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.button {
  padding: 0.6rem 1.3rem;
  border: none;
  border-radius: var(--radius);
  background: var(--accent);
  color: var(--accent-text);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
}

.button:hover:not(:disabled) {
  filter: brightness(1.08);
}

.button:disabled {
  opacity: 0.55;
  cursor: progress;
}

.status {
  margin: 0;
  min-height: 1.2em;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.status[data-tone="error"] {
  color: var(--danger);
  font-weight: 500;
}

.status[data-tone="success"] {
  color: var(--success);
  font-weight: 500;
}

.panel__hint {
  margin: -0.35rem 0 0;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.field-grid {
  display: grid;
  gap: 0.9rem;
  grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr));
}

.field__input--single {
  font: 0.95rem/1.4 ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  resize: none;
}

.field__optional {
  font-weight: 400;
  letter-spacing: 0;
  text-transform: none;
  opacity: 0.75;
}

.field__error {
  font-size: 0.82rem;
  color: var(--danger);
}

.field__input[aria-invalid="true"] {
  border-color: var(--danger);
}

.button--secondary {
  background: transparent;
  color: var(--accent);
  border: 1px solid var(--accent);
}

.button--secondary:hover:not(:disabled) {
  background: color-mix(in srgb, var(--accent) 10%, transparent);
  filter: none;
}

.output {
  margin: 0;
  padding: 0.9rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  font: 0.95rem/1.6 ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

/* Signed-in badge, pinned to the top corner and out of the page flow. */
.badge {
  position: fixed;
  top: 0.75rem;
  right: 0.75rem;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.35rem 0.5rem 0.35rem 0.4rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  font-size: 0.85rem;
}


.badge__avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  object-fit: cover;
}

.badge__name {
  max-width: 14rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text);
}

.badge__signout {
  padding: 0.2rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: transparent;
  color: var(--text-muted);
  font: inherit;
  cursor: pointer;
}

.badge__signout:hover {
  color: var(--text);
  border-color: var(--text-muted);
}

/* The signed-out gate. */
.panel--gate {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  text-align: center;
}

.gate__button {
  /* Google renders its own button in here; reserve the height so the panel
     does not jump when the script finishes loading. */
  min-height: 44px;
  display: flex;
  justify-content: center;
}

/* The admin log needs more room than the prompt form. */
.shell--wide {
  max-width: 1100px;
}

.table-scroll {
  overflow-x: auto;
}

.log {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.log th,
.log td {
  padding: 0.5rem 0.6rem;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
}

.log th {
  color: var(--text-muted);
  font-weight: 600;
  white-space: nowrap;
}

.log td {
  /* Preserve the shape of a pasted prompt without letting one unbroken string
     stretch the table past the viewport. */
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  max-width: 28rem;
}

.log tr:last-child td {
  border-bottom: none;
}

/* Expandable Input/Output blocks under an admin event's Detail cell. */
.log__exchange {
  margin-top: 0.5rem;
}

.log__exchange-toggle {
  cursor: pointer;
  color: var(--text-muted);
  font-size: 0.8rem;
  font-weight: 600;
}

.log__exchange-label {
  margin: 0.5rem 0 0.25rem;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.log__exchange-text {
  margin: 0;
  padding: 0.5rem 0.6rem;
  border-radius: var(--radius);
  background: var(--bg);
  font: 0.8rem/1.5 ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

/* Attribution result summary and per-section cards. */
.attribution-summary {
  margin: 0 0 0.75rem;
  font-size: 0.9rem;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.attribution-output__heading {
  margin: 1rem 0 0.5rem;
  font-size: 0.82rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}

.attribution-output {
  margin: 0 0 0.75rem;
  padding: 0.9rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-muted, rgba(0, 0, 0, 0.03));
  font: inherit;
  line-height: 1.6;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.attribution-card {
  margin: 0 0 0.75rem;
  padding: 0.9rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  line-height: 1.6;
}

.attribution-card:last-child {
  margin-bottom: 0;
}

.attribution-card__text {
  margin: 0 0 0.5rem;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.attribution-card__badge {
  margin: 0;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

/* The footer citation on the attribution page. */
.cite {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.cite p {
  margin: 0;
}

.cite a {
  color: var(--accent);
}
