:root {
  color-scheme: light;
  --bg: #f3f7fb;
  --bg-glow: rgb(34 207 255 / 16%);
  --panel: #ffffff;
  --panel-subtle: #eef5fb;
  --control-bg: #f8fbff;
  --hover: #53d8ff66;
  --disabled-bg: #e2e8ef;
  --code-bg: #e8eef5;
  --pre-bg: #0b0f14;
  --pre-text: #e8eef6;
  --shadow: rgb(5 7 10 / 10%);
  --tool-open-bg: #edf9fc;
  --tool-border-active: #0f7180;
  --error-bg: #fff1ef;
  --error-border: #ff9a8d;
  --text: #15202c;
  --muted: #596879;
  --muted-quiet: #7a8796;
  --border: #cbd6e2;
  --accent: #0f7180;
  --accent-dark: #0a5664;
  --accent-bright: #22cfff;
  --brand: #d60d87;
  --brand-bright: #ff149d;
  --danger: #c9362d;
  --button-text: #ffffff;
  --focus-ring: rgb(34 207 255 / 32%);
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: #0b0f14;
    --bg-glow: rgb(34 207 255 / 10%);
    --panel: #121923;
    --panel-subtle: #182231;
    --control-bg: #101722;
    --hover: #3786fd66;
    --disabled-bg: #202936;
    --code-bg: #182231;
    --pre-bg: #05070a;
    --pre-text: #e8eef6;
    --shadow: rgb(0 0 0 / 32%);
    --tool-open-bg: #142434;
    --tool-border-active: #22cfff;
    --error-bg: #321916;
    --error-border: #b44b3d;
    --text: #e8eef6;
    --muted: #a9b6c7;
    --muted-quiet: #6f7d8e;
    --border: #2a3545;
    --accent: #22cfff;
    --accent-dark: #0f7180;
    --accent-bright: #63dcff;
    --brand: #ff149d;
    --brand-bright: #ff5dbb;
    --danger: #ff6f61;
    --button-text: #05070a;
    --focus-ring: rgb(34 207 255 / 34%);
  }
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  min-height: 100vh;
  margin: 0;
  background:
    radial-gradient(circle at top center, var(--bg-glow), transparent 90rem),
    linear-gradient(180deg, var(--bg), var(--bg));
  color: var(--text);
  font: 16px/1.5 Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

a {
  color: var(--accent);
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

a:hover {
  color: var(--accent-bright);
}

.shell {
  width: min(1080px, calc(100% - 32px));
  margin: 0 auto;
  padding: 24px 0;
}

body.login {
  display: grid;
  min-height: 100vh;
  place-items: center;
}

body.login .shell {
  width: min(440px, calc(100% - 32px));
  padding: 0;
}

.login-panel,
.markdown,
.changed-documents,
.agent-run,
.list,
.search-form,
.document-actions,
.revision-list,
.pagination,
.offline-panel {
  position: relative;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 14px 40px var(--shadow);
}

.login-panel::before,
.markdown::before,
.changed-documents::before,
.agent-run::before,
.search-form::before,
.list::before {
  position: absolute;
  top: 10px;
  right: 0px;
  width: 34px;
  height: 34px;
  background: linear-gradient(135deg, transparent 50%, var(--brand) 50%);
  content: "";
  clip-path: polygon(100% 0, 100% 100%, 0 0);
}

.login-panel {
  padding: 28px;
}

.offline-panel {
  max-width: 520px;
  padding: 28px;
}

.offline-panel p {
  margin-bottom: 0;
  color: var(--muted);
}

h1,
h2,
h3 {
  line-height: 1.2;
}

h1 {
  margin: 0;
  font-size: clamp(1.55rem, 3vw, 1.9rem);
  font-weight: 750;
  letter-spacing: 0;
}

h2 {
  margin-top: 28px;
  font-size: 1.1rem;
  font-weight: 700;
}

label {
  display: block;
  margin: 18px 0;
  color: var(--muted);
  font-weight: 650;
}

label:has(input[type="search"]) {
  margin: 0;
}

input {
  display: block;
  width: 100%;
  margin-top: 6px;
  padding: 11px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--control-bg);
  color: var(--text);
  font: inherit;
}

input:focus-visible,
button:focus-visible,
a:focus-visible,
summary:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  box-shadow: 0 0 0 4px var(--focus-ring);
}

button,
.pagination a,
.document-actions a,
.document-status-link,
.logout,
.notification-toggle,
.transcript-toggle-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 8px 14px;
  border: 1px solid var(--brand);
  border-radius: 6px;
  background: var(--brand);
  color: var(--button-text);
  font: inherit;
  font-weight: 750;
  text-decoration: none;
  cursor: pointer;
  transition: background 140ms ease, border-color 140ms ease, color 140ms ease, transform 140ms ease;
}

button:hover,
.pagination a:hover,
.document-actions a:hover,
.document-status-link:hover,
.logout:hover,
.notification-toggle:hover,
.transcript-toggle-button:hover {
  border-color: var(--brand-bright);
  background: var(--brand-bright);
}

button:disabled,
.notification-toggle:disabled {
  border-color: var(--border);
  background: var(--disabled-bg);
  color: var(--muted);
  cursor: default;
}

.error {
  padding: 10px 12px;
  border: 1px solid var(--error-border);
  border-radius: 6px;
  background: var(--error-bg);
  color: var(--danger);
}

.brand-lockup {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  min-width: 0;
}

.brand-mark {
  display: inline-grid;
  width: 46px;
  height: 46px;
  flex: 0 0 auto;
  place-items: center;
  border: 1px solid color-mix(in srgb, var(--accent) 54%, var(--border));
  border-radius: 10px;
  background: #05070a;
  box-shadow: 0 0 18px rgb(34 207 255 / 20%);
}

.brand-mark img {
  display: block;
  width: 36px;
  height: 36px;
}

.login-brand {
  justify-content: flex-start;
}

.topbar {
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-areas:
    "left actions"
    "title title";
  align-items: flex-start;
  gap: 14px 20px;
  margin-bottom: 22px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--border);
}

.topbar-title {
  grid-area: title;
  min-width: 0;
  text-align: center;
}

.topbar-left {
  grid-area: left;
  display: flex;
  justify-content: flex-start;
}

.topbar p {
  margin: 7px 0 0;
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
  font-size: 0.84rem;
}

.topbar-actions {
  grid-area: actions;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 10px;
}

.back,
.topbar-actions a[aria-current="page"],
.pagination a {
  border-color: var(--accent);
  background: transparent;
  color: var(--accent);
}

.back {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 8px 14px;
  border: 1px solid var(--accent);
  border-radius: 6px;
  font-weight: 750;
  text-decoration: none;
}

.back.icon-button svg {
    margin-left: -5px;
}

.back:hover,
.topbar-actions a[aria-current="page"],
.pagination a:hover {
  border-color: var(--accent-bright);
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  color: var(--accent-bright);
}

.icon-button {
  width: 40px;
  min-width: 40px;
  padding: 0;
}

.icon-button svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  pointer-events: none;
}

.notification-toggle {
  position: relative;
}

.notification-toggle::after {
  position: absolute;
  right: 7px;
  bottom: 7px;
  width: 8px;
  height: 8px;
  border: 2px solid var(--panel);
  border-radius: 999px;
  background: var(--muted-quiet);
  content: "";
}

.notification-toggle[data-push-state="enabled"] {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 18%, transparent);
  color: var(--accent-bright);
}

.notification-toggle[data-push-state="enabled"]::after {
  background: var(--accent);
  box-shadow: 0 0 10px var(--accent);
}

.notification-toggle[data-push-state="available"],
.notification-toggle[data-push-state="enabling"] {
  border-color: var(--brand);
  background: color-mix(in srgb, var(--brand) 16%, transparent);
  color: var(--brand-bright);
}

.notification-toggle[data-push-state="available"]::after,
.notification-toggle[data-push-state="enabling"]::after {
  background: var(--brand);
}

.notification-toggle[data-push-state="blocked"] {
  border-color: var(--danger);
  background: color-mix(in srgb, var(--danger) 14%, transparent);
  color: var(--danger);
}

.notification-toggle[data-push-state="blocked"]::after {
  background: var(--danger);
}

.push-icon {
  display: inline-flex;
}

.notification-toggle .push-icon-on {
  display: none;
}

.notification-toggle[data-push-state="enabled"] .push-icon-on {
  display: inline-flex;
}

.notification-toggle[data-push-state="enabled"] .push-icon-off {
  display: none;
}

.list {
  overflow: hidden;
}

.search-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 14px;
  align-items: end;
  padding: 18px;
}

.document-list-tools {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 14px;
  align-items: stretch;
  margin-bottom: 18px;
}

.url-archive-list-tools .search-form {
  grid-template-columns: 1fr minmax(140px, 220px) auto;
}

.document-status-link {
  align-self: stretch;
  min-width: 118px;
}

.transcript-row {
  position: relative;
  display: grid;
  grid-template-columns: minmax(180px, 220px) minmax(80px, 120px) 1fr;
  gap: 16px;
  padding: 17px 20px 17px 24px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  text-decoration: none;
  transition: background 140ms ease, transform 140ms ease, border-color 140ms ease;
}

.transcript-row::before {
  position: absolute;
  top: 16px;
  bottom: 16px;
  left: 0;
  width: 4px;
  background: var(--accent);
  content: "";
  opacity: 0.72;
}

.transcript-row:last-child {
  border-bottom: 0;
}

.transcript-row:hover {
  background: var(--hover);
}

.transcript-row:hover::before {
  background: var(--brand);
  opacity: 1;
}

.timestamp,
.source {
  min-width: 0;
  overflow: hidden;
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
  font-size: 0.84rem;
  font-weight: 650;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.source {
  color: var(--accent);
}

.preview {
  min-width: 0;
  overflow: hidden;
  color: var(--text);
  font-weight: 500;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.document-row .preview strong {
  margin-right: 8px;
  color: var(--text);
}

.url-tags {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-left: 8px;
  vertical-align: middle;
}

.url-tags span {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 2px 7px;
  border: 1px solid color-mix(in srgb, var(--accent) 44%, var(--border));
  border-radius: 999px;
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 750;
}

.empty {
  margin: 0;
  padding: 24px;
  color: var(--muted);
}

.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 18px;
  padding: 12px;
}

.pagination span {
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
  font-size: 0.84rem;
}

.pagination a.disabled {
  border-color: var(--border);
  background: var(--disabled-bg);
  color: var(--muted);
  pointer-events: none;
}

.markdown {
  padding: 26px;
}

.transcript-content {
  overflow: hidden;
}

.transcript-toggle-input {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  border: 0;
  opacity: 0;
  pointer-events: none;
}

.transcript-full,
.transcript-less,
.transcript-toggle-input:checked ~ .transcript-preview,
.transcript-toggle-input:checked ~ .transcript-toggle-row .transcript-more {
  display: none;
}

.transcript-toggle-input:checked ~ .transcript-full {
  display: block;
}

.transcript-toggle-input:checked ~ .transcript-toggle-row .transcript-less {
  display: inline-flex;
}

.transcript-toggle-row {
  display: flex;
  justify-content: flex-start;
  margin-top: 18px;
}

.transcript-toggle-button {
  min-height: 36px;
  padding: 7px 12px;
  user-select: none;
}

.transcript-preview :first-child,
.transcript-full :first-child {
  margin-top: 0;
}

.transcript-preview :last-child,
.transcript-full :last-child {
  margin-bottom: 0;
}

.transcript-toggle-input:focus-visible ~ .transcript-toggle-row .transcript-toggle-button {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  box-shadow: 0 0 0 4px var(--focus-ring);
}

.document-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  margin-bottom: 18px;
  padding: 12px;
}

.document-actions form {
  margin: 0;
}

.document-actions a,
.document-actions button {
  min-height: 38px;
  border-color: var(--brand);
  background: var(--brand);
  color: var(--button-text);
}

.document-actions .danger-button {
  border-color: var(--danger);
  background: transparent;
  color: var(--danger);
}

.document-actions .danger-button:hover {
  border-color: var(--danger);
  background: color-mix(in srgb, var(--danger) 14%, transparent);
  color: var(--danger);
}

.markdown blockquote {
  margin-left: 0;
  padding: 10px 14px;
  border-left: 3px solid var(--accent);
  background: var(--panel-subtle);
  color: var(--muted);
}

.markdown hr {
  border: 0;
  border-top: 1px solid var(--border);
}

.agent-run {
  margin-top: 20px;
  padding: 24px;
}

.changed-documents {
  margin-top: 20px;
  padding: 24px;
}

.changed-documents h2,
.agent-run h2 {
  margin: 0 0 16px;
}

.changed-documents ul {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.changed-documents li {
  display: grid;
  gap: 4px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--control-bg);
}

.changed-documents a {
  width: fit-content;
  color: var(--text);
  font-weight: 750;
}

.changed-documents span,
.changed-documents small {
  min-width: 0;
  overflow-wrap: anywhere;
  color: var(--muted);
}

.changed-documents span {
  font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
  font-size: 0.86rem;
}

.agent-meta {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin: 0;
}

.agent-meta div {
  min-width: 0;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel-subtle);
}

.agent-meta dt,
.tool-details dt {
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
  font-size: 0.76rem;
  font-weight: 700;
  text-transform: uppercase;
}

.agent-meta dd {
  margin: 4px 0 0;
  overflow-wrap: anywhere;
  font-weight: 750;
}

.agent-summary {
  margin: 16px 0 0;
  color: var(--text);
}

.document-meta code {
  overflow-wrap: anywhere;
}

.url-meta dd {
  min-width: 0;
  overflow-wrap: anywhere;
}

.url-archive-detail .url-tags {
  margin-left: 0;
}

.inline-empty {
  padding: 0;
  background: transparent;
}

.revision-list {
  display: grid;
  gap: 12px;
  padding: 14px;
}

.revision-card {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--control-bg);
  overflow: hidden;
}

.revision-card summary {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  cursor: pointer;
  list-style: none;
}

.revision-card summary::-webkit-details-marker {
  display: none;
}

.revision-card summary span {
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
  font-size: 0.84rem;
}

.revision-card p {
  margin: 0;
  padding: 0 14px 12px;
  color: var(--muted);
}

.revision-card pre {
  margin: 0;
  border-radius: 0;
}

.tool-calls {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 18px;
}

.tool-call {
  width: 220px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--control-bg);
  color: var(--text);
  box-shadow: 0 1px 2px var(--shadow);
  overflow: hidden;
  transition: border-color 140ms ease, transform 140ms ease;
}

.tool-call:hover {
  border-color: var(--tool-border-active);
}

.tool-call[open] {
  width: min(100%, 460px);
  border-color: var(--tool-border-active);
}

.tool-call summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  min-height: 68px;
  padding: 12px 12px 12px 14px;
  background: var(--tool-open-bg);
  cursor: pointer;
  list-style: none;
}

.tool-call:not([open]) summary {
  background: var(--control-bg);
}

.tool-call summary::-webkit-details-marker {
  display: none;
}

.tool-copy {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.tool-copy strong,
.tool-copy span {
  display: block;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tool-copy strong {
  color: var(--text);
  font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
  font-size: 0.9rem;
}

.tool-copy span {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 400;
}

.tool-call img {
  width: 34px;
  height: 34px;
  flex: 0 0 auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #05070a;
}

.tool-details {
  padding: 0 14px 14px;
}

.tool-details dl {
  display: grid;
  gap: 8px;
  margin: 0 0 12px;
}

.tool-details div {
  display: grid;
  grid-template-columns: 80px minmax(0, 1fr);
  gap: 10px;
}

.tool-details dd {
  min-width: 0;
  margin: 0;
  overflow-wrap: anywhere;
}

.tool-details pre {
  margin: 0;
}

.tool-result {
  margin: 10px 0 0;
  color: var(--muted);
}

.markdown :first-child {
  margin-top: 0;
}

.markdown :last-child {
  margin-bottom: 0;
}

pre {
  overflow-x: auto;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--pre-bg);
  color: var(--pre-text);
}

code {
  padding: 2px 5px;
  border-radius: 4px;
  background: var(--code-bg);
  font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
}

pre code {
  padding: 0;
  background: transparent;
  color: inherit;
}

.dot {
  color: var(--muted-quiet);
}

@media (max-width: 720px) {
  .shell {
    width: min(100% - 20px, 1080px);
    padding: 18px 0;
  }

  .topbar {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 10px;
  }

  .topbar-actions {
    flex: 0 0 auto;
    gap: 8px;
  }

  .brand-lockup {
    gap: 10px;
  }

  .brand-mark {
    width: 40px;
    height: 40px;
  }

  .brand-mark img {
    width: 31px;
    height: 31px;
  }

  .back {
    min-height: 36px;
    font-size: 0.9rem;
  }

  .topbar-actions .logout,
  .topbar-actions .notification-toggle {
    min-height: 36px;
    font-size: 0.9rem;
  }

  .icon-button {
    width: 36px;
    min-width: 36px;
  }

  .transcript-row {
    grid-template-columns: 1fr;
    gap: 4px;
  }

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

  .document-list-tools {
    grid-template-columns: 1fr;
  }

  .url-archive-list-tools .search-form {
    grid-template-columns: 1fr;
  }

  .agent-meta {
    grid-template-columns: 1fr;
  }

  .tool-call {
    width: 100%;
  }

  .preview {
    white-space: normal;
  }
}
