:root {
  color-scheme: light;
  --bg: #f5f7fa;
  --panel: #ffffff;
  --text: #16202a;
  --muted: #647184;
  --line: #d9e0e8;
  --accent: #0f766e;
  --accent-dark: #115e59;
  --danger: #b42318;
  --warn: #a15c07;
  --good: #137333;
  --chip: #edf2f7;
  --shadow: 0 8px 24px rgba(19, 31, 43, 0.08);
}

* {
  box-sizing: border-box;
}

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

button,
input,
select {
  font: inherit;
}

button {
  border: 0;
  border-radius: 6px;
  padding: 9px 12px;
  background: var(--accent);
  color: white;
  cursor: pointer;
}

button:hover {
  background: var(--accent-dark);
}

button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

input,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 9px 10px;
  background: white;
  color: var(--text);
}

.topbar {
  min-height: 92px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 22px 28px;
  border-bottom: 1px solid var(--line);
  background: #ffffff;
}

.topbar h1 {
  margin: 0;
  font-size: 26px;
  line-height: 1.1;
}

.topbar p {
  margin: 6px 0 0;
  color: var(--muted);
}

.topbar-actions {
  display: flex;
  align-items: end;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.manual-url-form {
  display: flex;
  gap: 8px;
  align-items: end;
}

.manual-url-form[hidden] {
  display: none;
}

.manual-url-form input {
  width: min(430px, 42vw);
  min-width: 250px;
  height: 44px;
  font-size: 17px;
}

.manual-url-form button {
  height: 44px;
  padding: 0 18px;
  font-weight: 700;
  white-space: nowrap;
}

.language-switch {
  display: grid;
  gap: 6px;
  min-width: 92px;
  color: var(--muted);
  font-size: 13px;
}

.layout {
  display: grid;
  grid-template-columns: 270px minmax(420px, 1fr) 430px;
  gap: 18px;
  padding: 18px;
}

.panel,
.content-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.controls {
  grid-column: 1;
  grid-row: 1 / span 2;
  position: sticky;
  top: 18px;
  align-self: start;
  padding: 16px;
}

.controls label {
  display: grid;
  gap: 6px;
  margin-top: 14px;
  color: var(--muted);
  font-size: 13px;
}

.stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.stat {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px;
  background: #f8fafc;
}

.stat strong {
  display: block;
  font-size: 20px;
}

.stat span {
  color: var(--muted);
  font-size: 12px;
}

.content-list,
.pagination {
  grid-column: 2;
  display: grid;
  gap: 12px;
  align-content: start;
}

.pagination {
  grid-template-columns: auto 1fr auto;
  align-items: center;
  color: var(--muted);
  font-size: 13px;
}

.pagination span {
  text-align: center;
}

.content-card {
  width: 100%;
  display: block;
  padding: 14px;
  text-align: left;
  color: inherit;
  cursor: pointer;
}

.content-card:hover,
.content-card.active {
  border-color: var(--accent);
}

.card-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.card-title {
  font-weight: 750;
  font-size: 17px;
}

.card-summary,
.detail-summary,
.source-excerpt {
  color: var(--muted);
  line-height: 1.45;
}

.card-summary {
  margin: 7px 0 11px;
  font-size: 14px;
}

.score {
  min-width: 58px;
  text-align: right;
  font-weight: 800;
  color: var(--accent);
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.chip {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  padding: 3px 8px;
  background: var(--chip);
  color: #344054;
  font-size: 12px;
}

.chip.good {
  background: #dcfce7;
  color: var(--good);
}

.chip.warn {
  background: #fff4d6;
  color: var(--warn);
}

.detail {
  grid-column: 3;
  grid-row: 1 / span 2;
  position: sticky;
  top: 18px;
  align-self: start;
  max-height: calc(100vh - 36px);
  overflow: auto;
  padding: 18px;
}

.detail h2 {
  margin: 0 0 8px;
  font-size: 24px;
  line-height: 1.2;
}

.detail h3 {
  margin: 22px 0 10px;
  font-size: 15px;
}

.detail-cover {
  width: 100%;
  max-height: 260px;
  border-radius: 8px;
  object-fit: cover;
  margin: 12px 0;
  border: 1px solid var(--line);
}

.url {
  display: inline-block;
  margin-bottom: 10px;
  color: var(--accent);
  overflow-wrap: anywhere;
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin: 14px 0;
}

.metric {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px;
  background: #f8fafc;
}

.metric span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.metric strong {
  display: block;
  margin-top: 4px;
}

.case,
.classification {
  border-top: 1px solid var(--line);
  padding-top: 12px;
  margin-top: 12px;
}

.related-case {
  display: block;
  width: 100%;
  margin: 8px 0;
  padding: 10px 12px;
  text-align: left;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--text);
  cursor: pointer;
}

.related-case strong,
.related-case span {
  display: block;
}

.related-case span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.35;
}

.source-excerpt {
  max-height: 240px;
  overflow: auto;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f8fafc;
  white-space: pre-wrap;
}

.attachment {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.attachment + .attachment {
  margin-top: 10px;
}

.attachment-head {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-bottom: 8px;
}

.attachment-head a {
  color: var(--accent);
  font-weight: 700;
  word-break: break-word;
}

.empty,
.loading {
  color: var(--muted);
  padding: 22px;
  background: #ffffff;
  border: 1px dashed var(--line);
  border-radius: 8px;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  max-width: 420px;
  padding: 12px 14px;
  border-radius: 8px;
  background: var(--text);
  color: white;
  box-shadow: var(--shadow);
}

@media (max-width: 1160px) {
  .layout {
    grid-template-columns: 260px minmax(0, 1fr);
  }

  .detail {
    grid-column: 2;
    grid-row: auto;
    position: static;
    max-height: none;
  }
}

@media (max-width: 780px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .topbar-actions,
  .manual-url-form {
    width: 100%;
    justify-content: stretch;
  }

  .manual-url-form input {
    width: 100%;
    min-width: 0;
  }

  .layout {
    grid-template-columns: 1fr;
    padding: 12px;
  }

  .controls,
  .content-list,
  .pagination,
  .detail {
    grid-column: 1;
    position: static;
  }

}
