:root {
  --bg: #ecebe7;
  --paper: #f8f7f3;
  --paper-soft: #f2f1ec;
  --ink: #181818;
  --muted: #666666;
  --line: #d8d5ce;
  --accent: #111111;
  --accent-dark: #000000;
  --warm: #8b8b8b;
  --code: #efefeb;
  --measure: 970px;
  --quiet: #eef3f6;
  --mono: ui-monospace, "SFMono-Regular", "IBM Plex Mono", "Cascadia Mono", "Liberation Mono", monospace;
  --sans: "Instrument Sans", "Helvetica Neue", Helvetica, Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  background: var(--bg);
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: linear-gradient(180deg, #f1f0eb 0%, #e9e7e0 100%);
  font-family: var(--mono);
  line-height: 1.6;
}

a {
  color: var(--accent);
  text-decoration-color: color-mix(in srgb, var(--accent), transparent 35%);
  text-decoration-thickness: 0.08em;
  text-underline-offset: 0.16em;
}

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

.shell {
  width: min(calc(100% - 40px), 1780px);
  min-height: calc(100vh - 40px);
  margin: 20px auto;
  padding: 40px clamp(22px, 7vw, 92px) 82px;
  background: var(--paper);
  border: 1px solid rgba(31, 43, 50, 0.08);
  border-radius: 18px;
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.05);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  max-width: var(--measure);
  margin: 0 auto;
  padding: 0 0 16px;
  border-bottom: 1px solid color-mix(in srgb, var(--line), transparent 12%);
}

.brand {
  color: var(--accent);
  font-size: clamp(1.46rem, 1.9vw, 1.9rem);
  font-weight: 800;
  letter-spacing: -0.03em;
  text-decoration: none;
}

.login {
  padding: 0;
  color: var(--ink);
  background: transparent;
  border: 0;
  border-radius: 0;
  font-size: 0.84rem;
  font-weight: 700;
  text-decoration: none;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.view {
  max-width: var(--measure);
  margin: 52px auto 0;
}

.hero-line {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 360px);
  gap: 34px;
  align-items: start;
  padding-bottom: 22px;
  border-bottom: 1px solid color-mix(in srgb, var(--line), transparent 12%);
}

h1 {
  margin: 0;
  font-family: var(--sans);
  font-size: clamp(1.84rem, 2.35vw, 2.2rem);
  line-height: 1.06;
  letter-spacing: -0.03em;
}

.new-analysis {
  margin: 18px 0 0;
  color: var(--muted);
  font-size: 0.94rem;
  font-weight: 650;
  max-width: 36rem;
  line-height: 1.52;
}

.search-label {
  display: block;
}

.search-label span {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

.search-label input {
  width: 100%;
  min-height: 46px;
  padding: 0 16px;
  color: var(--ink);
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 10px;
  outline: none;
}

.search-label input:focus {
  border-color: #9a9a9a;
  background: var(--paper);
}

.report-card,
.tab,
.back-link,
.login,
.submit-button {
  transition: color 180ms ease, border-color 180ms ease, background-color 180ms ease;
}

.report-card:focus-visible,
.tab:focus-visible,
.back-link:focus-visible,
.login:focus-visible {
  outline: 2px solid rgba(0, 0, 0, 0.18);
  outline-offset: 4px;
}

.submit-form {
  display: grid;
  gap: 16px;
  max-width: 820px;
  margin-top: 26px;
}

.meta-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(220px, 0.55fr);
  gap: 16px;
}

.submit-form label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-weight: 800;
  font-size: 0.92rem;
}

.submit-form input,
.submit-form select,
.submit-form textarea {
  width: 100%;
  padding: 12px 14px;
  color: var(--ink);
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 10px;
  outline: none;
}

.submit-form textarea {
  resize: vertical;
  min-height: 132px;
  line-height: 1.45;
}

#submit-report-md {
  min-height: 260px;
}

#submit-poc-md {
  min-height: 190px;
}

#submit-sources {
  min-height: 120px;
}

#edit-summary,
#edit-sources {
  min-height: 96px;
}

.submit-form input:focus,
.submit-form select:focus,
.submit-form textarea:focus {
  border-color: #9a9a9a;
}

.submit-form input:invalid,
.submit-form select:invalid,
.submit-form textarea:invalid {
  box-shadow: none;
}

.submit-actions {
  display: flex;
  align-items: center;
  gap: 16px;
  padding-top: 4px;
}

.submit-button {
  min-height: 38px;
  padding: 0 14px;
  color: var(--paper);
  background: var(--ink);
  border: 1px solid var(--ink);
  cursor: pointer;
  font-weight: 800;
  border-radius: 10px;
  font-size: 0.92rem;
}

.submit-button:hover,
.submit-button:focus-visible {
  background: #2a2a2a;
  border-color: #2a2a2a;
  outline: none;
}

.submit-button:focus-visible {
  box-shadow: 0 0 0 3px rgba(24, 24, 24, 0.14);
}

.submit-button-danger {
  color: #fff;
  background: #2c2c2c;
  border-color: #2c2c2c;
}

.submit-button-danger:hover,
.submit-button-danger:focus-visible {
  background: #101010;
  border-color: #101010;
}

.submit-button-secondary {
  color: var(--ink);
  background: transparent;
  border-color: var(--line);
}

.submit-button-secondary:hover,
.submit-button-secondary:focus-visible {
  background: var(--paper-soft);
  border-color: #bcb7af;
}

.back-link {
  color: var(--ink);
}

.submit-result {
  min-height: 30px;
  color: var(--muted);
  font-weight: 700;
  font-size: 0.92rem;
}

.detail-actions {
  flex: 0 0 auto;
}

.detail-action {
  display: inline-flex;
  align-items: center;
}

.detail-action-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 0 14px;
  color: var(--ink);
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 10px;
  font-size: 0.84rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-decoration: none;
  text-transform: uppercase;
  white-space: nowrap;
}

.detail-action-button:hover,
.detail-action-button:focus-visible {
  background: var(--paper-soft);
  border-color: #bcb7af;
  outline: none;
}

.detail-action-button:focus-visible {
  box-shadow: 0 0 0 3px rgba(24, 24, 24, 0.12);
}

.reports-list {
  margin-top: 40px;
}

.reports-pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-top: 26px;
  padding-top: 18px;
  border-top: 1px solid color-mix(in srgb, var(--line), transparent 12%);
}

.pagination-summary,
.pagination-page {
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 700;
}

.pagination-controls {
  display: flex;
  align-items: center;
  gap: 12px;
}

.pagination-button {
  min-height: 34px;
  padding: 0 12px;
  color: var(--ink);
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 10px;
  cursor: pointer;
  font-weight: 700;
}

.pagination-button:hover,
.pagination-button:focus-visible {
  background: var(--paper-soft);
  border-color: #bcb7af;
  outline: none;
}

.pagination-button:disabled {
  opacity: 0.45;
  cursor: default;
  background: transparent;
}

.report-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(180px, 220px);
  gap: 26px;
  padding: 24px 0 26px;
  border-bottom: 1px solid color-mix(in srgb, var(--line), transparent 8%);
  text-decoration: none;
}

.report-card > div {
  min-width: 0;
}

.report-card:first-child {
  border-top: 0;
}

.eyebrow {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-bottom: 12px;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.eyebrow span {
  padding: 0;
  background: transparent;
  border: 0;
  border-radius: 0;
}

.report-card h2 {
  margin: 0;
  color: var(--ink);
  font-family: var(--sans);
  font-size: 1.5rem;
  line-height: 1.16;
  letter-spacing: 0;
  overflow-wrap: anywhere;
}

.report-card p {
  margin: 12px 0 0;
  color: #536063;
  font-size: 0.98rem;
  font-weight: 600;
  max-width: 42rem;
  line-height: 1.5;
}

.card-side {
  min-width: 0;
  align-self: center;
  color: var(--muted);
  text-align: right;
  font-size: 0.84rem;
  font-weight: 700;
}

.card-side code {
  color: var(--accent-dark);
  background: transparent;
  border: 0;
  border-radius: 0;
  padding: 0;
}

.card-side span {
  display: block;
  margin-top: 10px;
}

.report-card:hover h2,
.report-card:hover .card-side {
  color: var(--ink);
}

.report-card:hover {
  border-color: #bdb8af;
}

.back-link {
  display: inline-block;
  margin-bottom: 16px;
  font-weight: 800;
  font-size: 0.88rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.report-head {
  padding-bottom: 18px;
  border-bottom: 1px solid color-mix(in srgb, var(--line), transparent 12%);
}

.detail-head-grid {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
}

.detail-main {
  min-width: 0;
  flex: 1 1 auto;
}

.detail-info-row {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 10px 18px;
  margin-top: 14px;
}

.detail-meta {
  display: flex;
  gap: 12px;
  margin-top: 0;
  color: var(--muted);
  font-weight: 800;
  text-transform: uppercase;
  font-size: 0.84rem;
  letter-spacing: 0.08em;
}

.tx-row {
  margin-top: 14px;
  color: var(--muted);
  font-weight: 800;
}

.tx-row code {
  display: inline-block;
  max-width: min(100%, 64rem);
  overflow-wrap: anywhere;
  color: var(--ink);
  background: transparent;
  border: 0;
  border-radius: 0;
  padding: 0;
}

.detail-date {
  display: inline-block;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 700;
  white-space: nowrap;
}

.tabs {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 14px 0 10px;
  border-bottom: 1px solid color-mix(in srgb, var(--line), transparent 12%);
}

.tab {
  min-width: 0;
  min-height: 30px;
  padding: 0;
  color: var(--ink);
  background: transparent;
  border: 1px solid transparent;
  cursor: pointer;
  font-weight: 800;
  font-size: 0.94rem;
}

.tab:hover,
.tab:focus,
.tab.active {
  background: transparent;
  border-color: transparent;
  box-shadow: inset 0 -2px 0 var(--ink);
  border-radius: 0;
  outline: none;
}

.panel {
  margin-top: 14px;
  padding: 0 0 16px;
}

.delete-confirmation {
  display: grid;
  gap: 12px;
  max-width: 720px;
  padding: 14px;
  background: var(--paper-soft);
  border: 1px solid var(--line);
  border-radius: 10px;
}

.delete-confirmation-text {
  margin: 0;
  color: var(--ink);
  font-size: 0.94rem;
  font-weight: 700;
}

.delete-confirmation-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.markdown {
  max-width: 100%;
  overflow-wrap: anywhere;
}

.markdown h1,
.markdown h2,
.markdown h3,
.markdown h4 {
  margin: 22px 0 10px;
  padding-bottom: 6px;
  border-bottom: 1px solid color-mix(in srgb, var(--line), transparent 10%);
  font-family: var(--sans);
  line-height: 1.12;
}

.markdown h1 {
  font-size: clamp(1.6rem, 2.5vw, 2.2rem);
}

.markdown h2 {
  font-size: clamp(1.24rem, 1.7vw, 1.64rem);
}

.markdown h3 {
  font-size: clamp(1.08rem, 1.3vw, 1.28rem);
}

.markdown p,
.markdown li,
.markdown blockquote {
  font-size: clamp(0.92rem, 0.9vw, 0.98rem);
  font-weight: 560;
  line-height: 1.62;
}

.ordered-line {
  margin-left: 1.2em;
}

.markdown ul {
  padding-left: 1.45em;
}

.markdown li + li {
  margin-top: 10px;
}

.markdown hr {
  height: 2px;
  margin: 24px 0;
  background: #d3d0ca;
  border: 0;
  border-radius: 0;
}

.markdown code {
  padding: 0.1em 0.28em;
  background: var(--code);
  border: 1px solid #d7d3cc;
  border-radius: 5px;
}

.markdown pre {
  overflow-x: auto;
  padding: 16px;
  background: #191919;
  color: #f3f3ef;
  border: 1px solid #313131;
  border-radius: 10px;
}

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

.source-list {
  padding: 0;
  list-style: none;
}

.source-list li {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  padding: 14px 0;
  border-bottom: 1px solid color-mix(in srgb, var(--line), transparent 8%);
}

.source-list a {
  text-align: right;
}

.empty {
  color: var(--muted);
  font-size: 1.02rem;
  font-weight: 700;
}

@media (max-width: 760px) {
  .shell {
    width: min(calc(100% - 18px), 100%);
    min-height: calc(100vh - 18px);
    margin: 9px auto;
    padding: 20px 18px 58px;
    border-radius: 16px;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.05);
  }

  .topbar,
  .hero-line,
  .report-card {
    display: block;
  }

  .brand {
    font-size: clamp(1.56rem, 8.8vw, 2.3rem);
  }

  .login {
    display: inline-block;
    margin-top: 14px;
  }

  .view {
    margin-top: 36px;
  }

  .search-label input {
    margin-top: 18px;
  }

  .card-side {
    margin-top: 14px;
    text-align: left;
  }

  .detail-head-grid {
    display: block;
  }

  .detail-actions {
    margin-top: 14px;
  }

  .detail-action-button {
    width: 100%;
  }

  .detail-info-row {
    display: block;
  }

  .detail-date {
    display: block;
    margin-top: 10px;
  }

  .tabs {
    flex-wrap: wrap;
  }

  .submit-actions {
    display: block;
  }

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

  .submit-button {
    width: 100%;
  }

  .submit-actions .submit-button + .submit-button {
    margin-top: 12px;
  }

  .delete-confirmation-actions {
    display: block;
  }

  .delete-confirmation-actions .submit-button + .submit-button {
    margin-top: 12px;
  }

  .source-list li {
    display: block;
  }

  .source-list a {
    display: block;
    margin-top: 8px;
    text-align: left;
  }

  .reports-pagination,
  .pagination-controls {
    display: block;
  }

  .pagination-controls {
    margin-top: 12px;
  }

  .pagination-button {
    width: 100%;
  }

  .pagination-controls .pagination-button + .pagination-page,
  .pagination-page + .pagination-button {
    margin-top: 10px;
    display: block;
  }
}
