:root {
  --background: #f7f8fb;
  --foreground: #1f2933;
  --muted: #667085;
  --border: #d9dee7;
  --panel: #ffffff;
  --panel-subtle: #f0f4f8;
  --primary: #226f54;
  --primary-strong: #18513d;
  --danger: #b42318;
  --topbar-background: rgba(255, 255, 255, 0.9);
  --input-background: #ffffff;
  --button-secondary-background: #ffffff;
  --button-disabled-background: #8aa89b;
  --error-border: #f5c2c7;
  --error-background: #fff5f5;
  --error-foreground: #842029;
  --notice-border: #f3d08a;
  --notice-background: #fff8e8;
  --notice-foreground: #6f4e00;
  --status-background: #e9eef5;
  --status-foreground: #344054;
  --status-failed-background: #fff1f0;
  --status-success-background: #e9f7ef;
  --danger-background: #fff7f7;
  --danger-border: #f2b8b5;
  --danger-copy: #7a271a;
  --toggle-background: #e9eef5;
  --toggle-thumb: #ffffff;
  --toggle-icon: #667085;
  --toggle-active: #1c3462;
}

:root[data-theme="dark"] {
  --background: #111827;
  --foreground: #eef4f8;
  --muted: #a6b3c2;
  --border: #2d3a4d;
  --panel: #182231;
  --panel-subtle: #202d3d;
  --primary: #13a58c;
  --primary-strong: #0e8d78;
  --danger: #ff8a80;
  --topbar-background: rgba(17, 24, 39, 0.92);
  --input-background: #111827;
  --button-secondary-background: #182231;
  --button-disabled-background: #385b55;
  --error-border: #7f2d34;
  --error-background: #341b22;
  --error-foreground: #ffc4c4;
  --notice-border: #8f6c22;
  --notice-background: #2f2614;
  --notice-foreground: #ffd98a;
  --status-background: #273447;
  --status-foreground: #d5dfeb;
  --status-failed-background: #3a2028;
  --status-success-background: #14342d;
  --danger-background: #321d22;
  --danger-border: #7f2d34;
  --danger-copy: #ffc4c4;
  --toggle-background: #263447;
  --toggle-thumb: #eef4f8;
  --toggle-icon: #a6b3c2;
  --toggle-active: #00b1a7;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
  overflow-x: hidden;
}

body {
  margin: 0;
  background: var(--background);
  color: var(--foreground);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input,
textarea {
  font: inherit;
}

.page-shell {
  min-height: 100vh;
}

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

.topbar {
  border-bottom: 1px solid var(--border);
  background: var(--topbar-background);
}

.topbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 64px;
  padding: 12px 0;
  gap: 16px;
}

.brand {
  display: inline-flex;
  align-items: center;
  flex: 0 0 auto;
  min-height: 65px;
}

.brand-logo {
  display: block;
  width: auto;
  height: 65px;
}

.brand-logo-dark {
  display: none;
}

:root[data-theme="dark"] .brand-logo-light {
  display: none;
}

:root[data-theme="dark"] .brand-logo-dark {
  display: block;
}

.nav-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 12px;
  min-width: 0;
}

.nav-link {
  font-weight: 650;
}

.main {
  padding: 40px 0;
}

.stack {
  display: grid;
  gap: 20px;
}

.section-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  min-width: 0;
}

.section-header > * {
  min-width: 0;
}

.section-title {
  margin: 0;
  font-size: 28px;
  line-height: 1.15;
}

.section-copy {
  margin: 8px 0 0;
  color: var(--muted);
}

.panel {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel);
  min-width: 0;
}

.panel-padding {
  padding: 24px;
}

.form {
  display: grid;
  gap: 16px;
}

.field {
  display: grid;
  gap: 8px;
}

.label {
  font-size: 14px;
  font-weight: 650;
}

.input,
.textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--input-background);
  color: var(--foreground);
  padding: 11px 12px;
}

.textarea {
  min-height: 96px;
  resize: vertical;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  max-width: 100%;
  min-height: 40px;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 0 14px;
  background: var(--primary);
  color: #fff;
  font-weight: 650;
  cursor: pointer;
  text-align: center;
  white-space: normal;
}

.button:hover {
  background: var(--primary-strong);
}

.button:disabled,
.button:disabled:hover {
  background: var(--button-disabled-background);
  cursor: not-allowed;
  opacity: 0.85;
}

.button.secondary {
  border-color: var(--border);
  background: var(--button-secondary-background);
  color: var(--foreground);
}

.button.secondary:hover {
  background: var(--panel-subtle);
}

.button.danger {
  background: var(--danger);
}

.button-icon {
  margin-right: 8px;
}

.inline-form {
  display: inline-flex;
}

.rename-form {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto;
  align-items: end;
  gap: 12px;
}

.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 68px;
  height: 40px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: transparent;
  padding: 0;
  cursor: pointer;
}

.theme-toggle:hover {
  background: var(--panel-subtle);
}

.theme-toggle-track {
  position: relative;
  display: grid;
  grid-template-columns: 1fr 1fr;
  align-items: center;
  width: 58px;
  height: 30px;
  border-radius: 999px;
  background: var(--toggle-background);
}

.theme-toggle-icon {
  position: relative;
  z-index: 1;
  display: grid;
  place-items: center;
  color: var(--toggle-icon);
  font-size: 15px;
  line-height: 1;
}

.theme-toggle-thumb {
  position: absolute;
  top: 4px;
  left: 4px;
  width: 22px;
  height: 22px;
  border-radius: 999px;
  background: var(--toggle-thumb);
  box-shadow: 2px 2px 0 #000000;
  transition: transform 0.18s ease;
}

.theme-toggle-sun {
  color: var(--toggle-active);
}

:root[data-theme="dark"] .theme-toggle-thumb {
  transform: translateX(28px);
}

:root[data-theme="dark"] .theme-toggle-sun {
  color: var(--toggle-icon);
}

:root[data-theme="dark"] .theme-toggle-moon {
  color: var(--toggle-active);
}

.pending-submit {
  display: grid;
  justify-items: start;
  gap: 6px;
  min-width: 0;
}

.nav-actions .pending-submit {
  justify-items: end;
}

.spinner {
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.45);
  border-top-color: #fff;
  border-radius: 999px;
  animation: spin 0.75s linear infinite;
}

.pending-helper {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

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

.success {
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--status-success-background);
  color: var(--foreground);
  padding: 10px 12px;
}

.empty {
  border: 1px dashed var(--border);
  border-radius: 8px;
  background: var(--panel-subtle);
  color: var(--muted);
  padding: 28px;
  text-align: center;
}

.project-list {
  display: grid;
  gap: 12px;
}

.project-row {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel);
  padding: 18px;
}

.project-row h2 {
  margin: 0;
  font-size: 18px;
}

.project-count {
  color: var(--muted);
  font-weight: 600;
}

.project-row h3 {
  margin: 0;
  font-size: 17px;
}

.project-row p {
  margin: 6px 0 0;
  color: var(--muted);
  overflow-wrap: anywhere;
}

.row-meta {
  display: grid;
  justify-items: end;
  gap: 6px;
  min-width: 120px;
}

.meta {
  color: var(--muted);
  font-size: 14px;
}

.auth-wrap {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 32px 16px;
}

.auth-card {
  width: min(440px, 100%);
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel);
  padding: 28px;
}

.auth-card h1 {
  margin: 0 0 8px;
  font-size: 28px;
}

.auth-card p {
  margin: 0 0 24px;
  color: var(--muted);
}

.auth-divider {
  height: 1px;
  margin: 22px 0;
  background: var(--border);
}

.notice {
  border: 1px solid var(--notice-border);
  border-radius: 8px;
  background: var(--notice-background);
  color: var(--notice-foreground);
  padding: 14px;
  line-height: 1.45;
}

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

.facts div {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px;
}

.facts dt,
.meta {
  color: var(--muted);
  font-size: 14px;
}

.facts dd {
  margin: 6px 0 0;
  font-weight: 650;
}

.status-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  min-width: 0;
}

.fact-value {
  margin: 6px 0 0;
  overflow-wrap: anywhere;
  font-weight: 650;
}

.cost-total {
  margin: 6px 0 0;
  font-size: 28px;
  font-weight: 750;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  border-radius: 999px;
  padding: 4px 10px;
  background: var(--status-background);
  color: var(--status-foreground);
  font-size: 13px;
  font-weight: 700;
  width: fit-content;
}

.status-failed {
  background: var(--status-failed-background);
  color: var(--danger);
}

.status-created,
.status-bot_created {
  background: var(--status-success-background);
  color: var(--primary-strong);
}

.transcript-list {
  display: grid;
  gap: 14px;
  margin-top: 20px;
  min-width: 0;
}

.utterance {
  border-top: 1px solid var(--border);
  padding-top: 14px;
  min-width: 0;
}

.utterance:first-child {
  border-top: 0;
  padding-top: 0;
}

.utterance p {
  margin: 8px 0 0;
  line-height: 1.55;
  max-width: 100%;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.utterance-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  color: var(--muted);
  font-size: 14px;
  min-width: 0;
}

.summary-grid {
  display: grid;
  gap: 22px;
  margin-top: 20px;
}

.summary-grid section {
  border-top: 1px solid var(--border);
  padding-top: 18px;
}

.summary-grid section:first-child {
  border-top: 0;
  padding-top: 0;
}

.summary-metadata {
  display: grid;
  gap: 6px;
}

.summary-metadata p {
  color: var(--muted);
}

.summary-metadata strong {
  color: var(--text);
}

.summary-grid h3 {
  margin: 0 0 10px;
  font-size: 17px;
}

.summary-grid p {
  margin: 0;
  line-height: 1.55;
}

.summary-list {
  display: grid;
  gap: 10px;
  margin: 0;
  padding-left: 20px;
}

.summary-list li {
  line-height: 1.5;
}

.summary-list span {
  display: block;
  color: var(--muted);
  font-size: 14px;
  margin-top: 4px;
}

.summary-object {
  display: grid;
  gap: 4px;
  margin-top: 0;
}

.summary-controls {
  display: grid;
  grid-template-columns: minmax(220px, 1.15fr) minmax(180px, 0.75fr) auto;
  align-items: end;
  gap: 14px;
  margin-top: 22px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel-subtle);
  padding: 16px;
}

.summary-control-field {
  gap: 8px;
}

.summary-control-field .label {
  font-size: 14px;
}

.summary-control-field .input {
  min-height: 46px;
  font-size: 15px;
  font-weight: 650;
}

.summary-generate-action {
  display: grid;
  min-width: 178px;
}

.summary-generate-action .pending-submit,
.summary-generate-action .button {
  width: 100%;
}

.danger-zone {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border: 1px solid var(--danger-border);
  border-radius: 8px;
  background: var(--danger-background);
  padding: 18px 20px;
}

.danger-zone h2 {
  margin: 0;
  color: var(--danger);
  font-size: 17px;
}

.danger-zone p {
  margin: 6px 0 0;
  color: var(--danger-copy);
  font-size: 14px;
}

.delete-project-form {
  display: grid;
  min-width: min(100%, 360px);
  gap: 10px;
}

.compact-field {
  gap: 6px;
}

.cost-breakdown,
.cost-events {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.usage-metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-top: 18px;
}

.usage-metric {
  border-top: 1px solid var(--border);
  padding-top: 14px;
}

.usage-metric p {
  margin-bottom: 0;
}

.cost-row,
.cost-event {
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: center;
  gap: 12px;
  border-top: 1px solid var(--border);
  padding-top: 12px;
}

.cost-event {
  grid-template-columns: 1fr auto;
}

.cost-row:first-child,
.cost-event:first-child {
  border-top: 0;
  padding-top: 0;
}

.cost-row span,
.cost-event p {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}

.cost-row span:first-child {
  color: var(--foreground);
  font-weight: 650;
}

.admin-usage-table {
  display: grid;
  gap: 0;
  overflow-x: auto;
}

.admin-usage-row {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) 90px 120px 120px 120px;
  gap: 12px;
  align-items: center;
  border-top: 1px solid var(--border);
  padding: 12px 0;
}

.admin-usage-row:first-child {
  border-top: 0;
}

.admin-usage-row span {
  color: var(--muted);
  font-size: 14px;
}

.admin-usage-row span:first-child {
  color: var(--foreground);
  font-weight: 650;
  overflow-wrap: anywhere;
}

.admin-usage-head span {
  color: var(--muted);
  font-weight: 750;
  text-transform: uppercase;
}

.cost-event div:last-child {
  text-align: right;
}

.compact-field {
  gap: 6px;
}

.preline {
  white-space: pre-line;
}

@media (max-width: 640px) {
  .section-header,
  .project-row,
  .danger-zone,
  .topbar-inner {
    flex-direction: column;
    align-items: stretch;
  }

  .nav-actions {
    justify-content: space-between;
  }

  .facts,
  .status-grid,
  .summary-controls,
  .rename-form,
  .usage-metrics,
  .cost-row,
  .cost-event {
    grid-template-columns: 1fr;
  }

  .admin-usage-row {
    grid-template-columns: minmax(180px, 1fr) repeat(4, minmax(80px, auto));
    min-width: 640px;
  }

  .cost-event div:last-child {
    text-align: left;
  }
}

/* Neobrutalist skin */
:root,
:root[data-theme="dark"] {
  --background: #fff7df;
  --foreground: #111111;
  --muted: #373737;
  --border: #000000;
  --panel: #ffffff;
  --panel-subtle: #d7ff45;
  --primary: #ffe24a;
  --primary-strong: #ffd000;
  --danger: #ff4fa3;
  --topbar-background: #7cf7ff;
  --input-background: #ffffff;
  --button-secondary-background: #ffffff;
  --button-disabled-background: #d9d9d9;
  --error-border: #000000;
  --error-background: #ff6b6b;
  --error-foreground: #111111;
  --notice-border: #000000;
  --notice-background: #ffe24a;
  --notice-foreground: #111111;
  --status-background: #d7ff45;
  --status-foreground: #111111;
  --status-failed-background: #ff6b6b;
  --status-success-background: #7cf7ff;
  --danger-background: #ff9fd0;
  --danger-border: #000000;
  --danger-copy: #111111;
  --toggle-background: #ffffff;
  --toggle-thumb: #ffe24a;
  --toggle-icon: #111111;
  --toggle-active: #111111;
  --neo-shadow: 4px 4px 0 #000000;
  --neo-shadow-small: 3px 3px 0 #000000;
  --neo-border: 3px solid #000000;
  --neo-border-thin: 2px solid #000000;
  --focus-ring: #2457ff;
}

body {
  background: var(--background);
  color: var(--foreground);
  font-family:
    Arial Black, Impact, ui-sans-serif, system-ui, -apple-system,
    BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

a {
  text-decoration-thickness: 3px;
  text-underline-offset: 4px;
}

a:hover {
  text-decoration: underline;
}

button,
input,
select,
textarea {
  font: inherit;
}

:focus-visible {
  outline: 4px solid var(--focus-ring);
  outline-offset: 3px;
}

.topbar {
  border-bottom: var(--neo-border);
  background: var(--topbar-background);
  box-shadow: 0 4px 0 #000000;
}

.brand-logo {
  filter: drop-shadow(2px 2px 0 #000000);
}

.section-title,
.auth-card h1,
.project-row h2,
.project-row h3,
.summary-grid h3,
.danger-zone h2,
h1,
h2,
h3 {
  color: #111111;
  font-weight: 950;
  letter-spacing: 0;
  text-transform: none;
}

.section-title,
.auth-card h1 {
  font-size: clamp(30px, 5vw, 54px);
  line-height: 0.95;
  text-shadow: 3px 3px 0 #ffe24a;
}

.panel,
.auth-card,
.project-row,
.utterance,
.summary-grid section,
.facts div,
.summary-controls,
.danger-zone,
.empty,
.error,
.success,
.notice,
.theme-toggle,
.status-badge,
.input,
.textarea,
.button,
.admin-usage-row,
.cost-row,
.cost-event {
  border: var(--neo-border);
  border-radius: 0;
  box-shadow: var(--neo-shadow);
}

.panel,
.auth-card,
.project-row,
.facts div,
.summary-controls,
.empty {
  background: var(--panel);
}

.panel:nth-of-type(3n + 1),
.project-row:nth-child(3n + 1) {
  background: #ffffff;
}

.panel:nth-of-type(3n + 2),
.project-row:nth-child(3n + 2),
.summary-controls {
  background: #d7ff45;
}

.panel:nth-of-type(3n),
.project-row:nth-child(3n),
.facts div:nth-child(2) {
  background: #7cf7ff;
}

.panel-padding,
.auth-card,
.project-row,
.danger-zone {
  padding: 24px;
}

.input,
.textarea {
  background: #ffffff;
  color: #111111;
  font-weight: 800;
  box-shadow: var(--neo-shadow-small);
}

.input::placeholder,
.textarea::placeholder {
  color: #4b4b4b;
  opacity: 1;
}

.label,
.meta,
.facts dt,
.section-copy,
.project-row p,
.utterance-meta,
.summary-list span,
.cost-row span,
.cost-event p,
.admin-usage-row span {
  color: #111111;
}

.label,
.nav-link,
.meta {
  font-weight: 900;
}

.button {
  min-height: 46px;
  background: var(--primary);
  color: #111111;
  font-weight: 950;
  text-transform: uppercase;
  box-shadow: var(--neo-shadow);
  transition:
    transform 0.12s ease,
    box-shadow 0.12s ease,
    background-color 0.12s ease;
}

.button:hover {
  background: #d7ff45;
}

.button.secondary {
  background: #ffffff;
  color: #111111;
}

.button.secondary:hover {
  background: #7cf7ff;
}

.button.danger,
.danger-zone {
  background: #ff4fa3;
  color: #111111;
}

.button:active,
.project-row:active,
.theme-toggle:active {
  box-shadow: none;
  transform: translate(4px, 4px);
}

.button:disabled,
.button:disabled:hover {
  background: var(--button-disabled-background);
  color: #111111;
  box-shadow: var(--neo-shadow);
  transform: none;
}

.theme-toggle {
  background: #ffffff;
  border-radius: 999px;
}

.theme-toggle-track {
  border: var(--neo-border-thin);
  background: #7cf7ff;
  box-shadow: inset 2px 2px 0 rgba(0, 0, 0, 0.18);
}

.theme-toggle-thumb {
  background: #ffe24a;
  box-shadow: 2px 2px 0 #000000;
}

.error,
.status-failed {
  background: #ff6b6b;
  color: #111111;
}

.success,
.status-created,
.status-bot_created {
  background: #7cf7ff;
  color: #111111;
}

.notice,
.status-badge {
  background: #ffe24a;
  color: #111111;
}

.status-badge {
  border-radius: 999px;
  font-weight: 950;
  text-transform: uppercase;
}

.empty {
  border-style: solid;
  background: #ffffff;
  color: #111111;
  font-weight: 900;
}

.utterance {
  border-top: var(--neo-border-thin);
  background: #ffffff;
  padding: 16px;
  box-shadow: var(--neo-shadow-small);
}

.summary-grid section,
.usage-metric,
.cost-row,
.cost-event,
.admin-usage-row {
  border-top: var(--neo-border-thin);
}

.summary-grid section {
  background: #ffffff;
  padding: 18px;
}

.auth-divider {
  height: 3px;
  background: #000000;
}

.spinner {
  border-color: #111111;
  border-top-color: #ffffff;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: 0.001ms !important;
  }

  .button:active,
  .project-row:active,
  .theme-toggle:active {
    transform: none;
  }
}

@media (max-width: 640px) {
  .panel-padding,
  .auth-card,
  .project-row,
  .danger-zone {
    padding: 18px;
  }

  .section-title,
  .auth-card h1 {
    font-size: 34px;
  }

  .button,
  .input,
  .textarea,
  .panel,
  .auth-card,
  .project-row,
  .summary-controls,
  .danger-zone,
  .empty,
  .error,
  .success,
  .notice {
    box-shadow: 3px 3px 0 #000000;
  }
}
