:root {
  --bg: #f6f7f8;
  --panel: #ffffff;
  --line: #d9dee5;
  --line-strong: #b9c1cc;
  --text: #17202a;
  --muted: #687382;
  --blue: #2457a6;
  --blue-ink: #153a71;
  --green: #15803d;
  --green-bg: #e7f6ec;
  --amber: #9a5b00;
  --amber-bg: #fff3d6;
  --red: #b42318;
  --red-bg: #fde8e5;
  --teal: #0f766e;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.08);
  font-family:
    "Yu Gothic UI", "Meiryo", system-ui, -apple-system, BlinkMacSystemFont,
    "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
}

button,
.button,
input {
  font: inherit;
}

button,
.button {
  min-height: 36px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: var(--panel);
  color: var(--text);
  cursor: pointer;
  padding: 0 12px;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  white-space: nowrap;
}

button:hover,
.button:hover {
  border-color: var(--blue);
}

button.primary,
.button.primary {
  background: var(--blue);
  border-color: var(--blue);
  color: #fff;
}

button.ghost,
.button.ghost {
  background: transparent;
}

button.danger {
  border-color: #e3a29b;
  color: var(--red);
  background: #fff;
}

input[type="text"] {
  width: 100%;
  min-height: 36px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  padding: 0 10px;
  background: #fff;
  color: var(--text);
}

input[type="search"] {
  width: 100%;
  min-height: 36px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  padding: 0 10px;
  background: #fff;
  color: var(--text);
}

input[type="file"] {
  display: none;
}

label {
  display: grid;
  gap: 4px;
  color: var(--muted);
  font-size: 12px;
  min-width: 160px;
}

.app-shell {
  display: grid;
  grid-template-columns: 340px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  border-right: 1px solid var(--line);
  background: #fbfcfd;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-width: 0;
}

.brand h1 {
  margin: 0;
  font-size: 22px;
  line-height: 1.2;
}

.brand p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 12px;
  word-break: break-all;
}

.toolbar,
.filters {
  display: flex;
  gap: 8px;
  align-items: center;
}

.toolbar > * {
  flex: 1;
}

.filter {
  flex: 1;
  background: #fff;
}

.filter.active {
  border-color: var(--blue);
  color: var(--blue-ink);
  box-shadow: inset 0 0 0 1px var(--blue);
}

.search-box {
  min-width: 0;
}

.toggle-row {
  display: flex;
  grid-template-columns: none;
  gap: 8px;
  align-items: center;
  min-height: 24px;
  color: var(--text);
}

.toggle-row input {
  width: 16px;
  height: 16px;
}

.case-list {
  display: grid;
  gap: 8px;
  overflow: auto;
  padding-right: 2px;
}

.case-item {
  width: 100%;
  min-height: 92px;
  text-align: left;
  justify-content: flex-start;
  align-items: stretch;
  flex-direction: column;
  border-color: var(--line);
  background: var(--panel);
  box-shadow: var(--shadow);
  padding: 10px;
}

.case-item.active {
  border-color: var(--blue);
  box-shadow: inset 0 0 0 1px var(--blue);
}

.case-top {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: flex-start;
}

.case-title {
  font-weight: 700;
  color: var(--text);
  line-height: 1.35;
}

.case-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.case-actions {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-end;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.status-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 4px;
}

.status-button {
  min-height: 30px;
  padding: 0 10px;
  font-size: 12px;
}

.status-button.active {
  border-color: var(--blue);
  color: var(--blue-ink);
  box-shadow: inset 0 0 0 1px var(--blue);
}

.workspace {
  min-width: 0;
  display: grid;
  grid-template-rows: auto 1fr;
}

.input-band {
  border-bottom: 1px solid var(--line);
  background: #fff;
  padding: 14px 18px;
  display: grid;
  grid-template-columns: minmax(320px, 1fr) minmax(360px, 1.4fr);
  gap: 12px;
  align-items: end;
}

.input-group {
  display: flex;
  gap: 8px;
  align-items: end;
  min-width: 0;
}

.input-group .wide {
  flex: 1;
}

.file-picker {
  min-width: auto;
}

.file-picker span {
  min-height: 36px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  padding: 0 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text);
  background: #fff;
  cursor: pointer;
}

.detail {
  min-width: 0;
  overflow: auto;
  padding: 20px;
}

.empty-state,
.loading,
.error {
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: 8px;
  padding: 18px;
  color: var(--muted);
}

.error {
  color: var(--red);
  background: var(--red-bg);
  border-color: #f5b7b1;
}

.summary-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 16px;
  align-items: start;
}

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

.hero-panel {
  padding: 18px;
}

.side-panel {
  padding: 14px;
}

.section {
  margin-top: 16px;
  overflow: hidden;
}

.section-header {
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
}

.section-header h3,
.side-panel h3,
.hero-panel h2 {
  margin: 0;
}

.hero-panel h2 {
  font-size: 24px;
  line-height: 1.25;
}

.side-panel h3,
.section-header h3 {
  font-size: 16px;
}

.subtle {
  color: var(--muted);
}

.score-line {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-top: 14px;
  flex-wrap: wrap;
}

.score {
  font-size: 34px;
  line-height: 1;
  font-weight: 800;
  color: var(--blue-ink);
}

.badge,
.chip {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 12px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--muted);
}

.badge.good {
  background: var(--green-bg);
  color: var(--green);
  border-color: #b8e4c5;
}

.badge.caution {
  background: var(--amber-bg);
  color: var(--amber);
  border-color: #f2d28b;
}

.badge.risk {
  background: var(--red-bg);
  color: var(--red);
  border-color: #f5b7b1;
}

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

.fact-list,
.question-list,
.file-list {
  list-style: none;
  margin: 10px 0 0;
  padding: 0;
  display: grid;
  gap: 8px;
}

.fact-list li,
.question-list li,
.file-list li {
  border-top: 1px solid var(--line);
  padding-top: 8px;
}

.criteria-table {
  width: 100%;
  border-collapse: collapse;
}

.criteria-table th,
.criteria-table td {
  text-align: left;
  vertical-align: top;
  padding: 11px 12px;
  border-bottom: 1px solid var(--line);
}

.criteria-table th {
  font-size: 12px;
  color: var(--muted);
  background: #fbfcfd;
  position: sticky;
  top: 0;
}

.bar {
  width: 100%;
  height: 8px;
  background: #edf0f3;
  border-radius: 999px;
  overflow: hidden;
  margin-top: 4px;
}

.bar span {
  display: block;
  height: 100%;
  background: var(--teal);
}

.bar span.caution {
  background: #b7791f;
}

.bar span.risk {
  background: var(--red);
}

.reason-list,
.evidence-list {
  display: grid;
  gap: 5px;
}

.reason {
  color: var(--muted);
}

.reason.positive strong {
  color: var(--green);
}

.reason.negative strong {
  color: var(--red);
}

.evidence {
  color: #3c4654;
  font-size: 12px;
  background: #f7f8fa;
  border-left: 3px solid var(--line-strong);
  padding: 6px 8px;
}

.hidden {
  display: none !important;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(23, 32, 42, 0.38);
  display: flex;
  align-items: stretch;
  justify-content: flex-end;
}

.modal-panel {
  width: min(980px, 100vw);
  height: 100vh;
  overflow: auto;
  background: #fff;
  border-left: 1px solid var(--line);
  box-shadow: -8px 0 24px rgba(16, 24, 40, 0.18);
}

.criteria-modal-panel {
  display: grid;
  grid-template-rows: auto auto auto 1fr;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: start;
  padding: 18px;
  border-bottom: 1px solid var(--line);
}

.modal-header h2 {
  margin: 0;
  font-size: 22px;
}

.modal-header p {
  margin: 4px 0 0;
  color: var(--muted);
}

.criteria-actions {
  display: flex;
  gap: 8px;
  padding: 12px 18px;
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}

.criteria-message {
  padding: 0 18px;
  min-height: 0;
}

.criteria-message > div {
  margin-top: 12px;
  border-radius: 6px;
  padding: 10px 12px;
}

.criteria-message .success {
  color: var(--green);
  background: var(--green-bg);
  border: 1px solid #b8e4c5;
}

.criteria-message .failure {
  color: var(--red);
  background: var(--red-bg);
  border: 1px solid #f5b7b1;
}

.criteria-editor {
  padding: 18px;
  display: grid;
  gap: 12px;
}

.criterion-editor {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.criterion-editor.deleted {
  opacity: 0.56;
}

.criterion-head {
  display: grid;
  grid-template-columns: minmax(160px, 1fr) 96px 96px auto;
  gap: 10px;
  padding: 12px;
  align-items: end;
  border-bottom: 1px solid var(--line);
  background: #fbfcfd;
}

.criterion-body {
  padding: 12px;
  display: grid;
  gap: 12px;
}

.criterion-body label {
  min-width: 0;
}

.criterion-description {
  min-height: 68px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  padding: 8px 10px;
  resize: vertical;
  font: inherit;
}

.keyword-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.keyword-group {
  border: 1px solid var(--line);
  border-radius: 6px;
  overflow: hidden;
}

.keyword-group-header {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: center;
  padding: 8px 10px;
  background: #fbfcfd;
  border-bottom: 1px solid var(--line);
}

.keyword-group-header strong {
  font-size: 13px;
}

.keyword-list {
  display: grid;
  gap: 8px;
  padding: 10px;
}

.keyword-row {
  display: grid;
  grid-template-columns: minmax(120px, 1fr) 72px auto;
  gap: 8px;
  align-items: end;
}

.keyword-row label {
  min-width: 0;
}

input[type="number"] {
  width: 100%;
  min-height: 36px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  padding: 0 8px;
}

@media (max-width: 980px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    border-right: 0;
    border-bottom: 1px solid var(--line);
    max-height: 48vh;
  }

  .input-band,
  .summary-grid {
    grid-template-columns: 1fr;
  }

  .criterion-head,
  .keyword-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .input-group {
    flex-wrap: wrap;
  }

  .input-group label {
    flex: 1 1 100%;
  }

  .detail {
    padding: 12px;
  }

  .criteria-table {
    font-size: 12px;
  }

  .modal-panel {
    width: 100vw;
  }

  .keyword-row {
    grid-template-columns: 1fr 72px;
  }

  .keyword-row button {
    grid-column: 1 / -1;
  }
}

.input-band {
  grid-template-columns: 1fr;
}

.input-group {
  justify-content: flex-start;
}
