:root {
  color-scheme: light;
  --bg: #f5f7fa;
  --surface: #ffffff;
  --surface-strong: #eef6f4;
  --text: #17202a;
  --muted: #687385;
  --line: #d9e0e8;
  --line-strong: #aeb9c7;
  --primary: #116a63;
  --primary-dark: #0d514c;
  --accent: #344b8e;
  --danger: #b42318;
  --warning-bg: #fff7df;
  --success-bg: #eaf7ef;
  --shadow: 0 10px 30px rgba(22, 34, 51, 0.08);
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", "Yu Gothic UI", "Meiryo", sans-serif;
  font-size: 16px;
  line-height: 1.6;
}

a {
  color: var(--primary);
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 22px clamp(16px, 4vw, 40px);
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 10;
}

.app-header h1,
.panel h2,
.detail-pane h2,
.list-pane h2 {
  margin: 0;
  line-height: 1.2;
}

.app-header h1 {
  font-size: 24px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
}

.header-actions,
.button-row,
.action-strip,
.sticky-actions,
.section-head,
.pane-head,
.pane-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.nav-link,
.button,
button {
  min-height: 42px;
  border-radius: 8px;
  border: 1px solid var(--line-strong);
  padding: 9px 14px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  white-space: normal;
  text-align: center;
}

.nav-link.active {
  color: var(--primary);
  border-color: rgba(17, 106, 99, 0.35);
  background: var(--surface-strong);
}

.primary {
  background: var(--primary);
  border-color: var(--primary);
  color: #ffffff;
}

.primary:hover,
.primary:focus-visible {
  background: var(--primary-dark);
}

.secondary {
  background: var(--surface);
}

.small {
  min-height: 34px;
  padding: 6px 10px;
  font-size: 14px;
}

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

button:focus-visible,
a:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible {
  outline: 3px solid rgba(17, 106, 99, 0.25);
  outline-offset: 2px;
}

.page-shell {
  width: min(1120px, calc(100% - 28px));
  margin: 24px auto 56px;
}

.notice,
.panel,
.list-pane,
.detail-pane {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.notice {
  padding: 14px 16px;
  margin-bottom: 16px;
  background: var(--warning-bg);
}

.panel {
  padding: clamp(16px, 3vw, 28px);
}

.intake-form {
  display: grid;
  gap: 18px;
}

fieldset {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
  margin: 0;
}

legend {
  padding: 0 8px;
  font-weight: 800;
  color: var(--primary-dark);
}

label {
  display: grid;
  gap: 6px;
  min-width: 0;
}

label span,
.status-control span {
  font-size: 14px;
  font-weight: 800;
}

label b {
  color: var(--danger);
  font-size: 12px;
}

input,
textarea,
select {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  padding: 11px 12px;
  color: var(--text);
  background: #ffffff;
  font: inherit;
  min-width: 0;
}

textarea {
  resize: vertical;
}

input[aria-invalid="true"],
textarea[aria-invalid="true"] {
  border-color: var(--danger);
  background: #fff5f3;
}

small,
.muted {
  color: var(--muted);
}

.grid {
  display: grid;
  gap: 14px;
}

.grid.two {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.grid.three {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.flow-detail-grid {
  margin-top: 14px;
}

.wide-field {
  grid-column: 1 / -1;
}

.field-help {
  margin: 0 0 12px;
  color: var(--muted);
  line-height: 1.7;
}

.file-drop {
  border: 1px dashed var(--line-strong);
  border-radius: 8px;
  padding: 16px;
  background: #fbfcfe;
}

.file-drop label {
  margin: 0;
}

.selected-files {
  display: grid;
  gap: 8px;
  padding: 0;
  margin: 12px 0 0;
  list-style: none;
}

.selected-files li {
  display: grid;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: #ffffff;
}

.selected-files .file-summary {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
}

.selected-files span,
.selected-files input {
  overflow-wrap: anywhere;
}

.attachment-name-field {
  gap: 4px;
}

.attachment-name-field span {
  font-size: 12px;
  font-weight: 800;
  color: var(--muted);
}

.selected-files .file-warning {
  border-color: rgba(180, 35, 24, 0.55);
  background: #fff5f3;
}

.selected-files .file-warning small {
  color: var(--danger);
  font-weight: 800;
}

.form-status {
  min-height: 24px;
  font-weight: 700;
}

.draft-status {
  min-height: 20px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.form-status.error,
.detail-error.visible,
.error-text {
  color: var(--danger);
}

.form-status.loading {
  color: var(--accent);
}

.sticky-actions {
  justify-content: flex-end;
  padding: 12px 0 0;
}

.complete-panel {
  display: grid;
  gap: 12px;
  background: var(--success-bg);
}

.result-list {
  display: grid;
  gap: 8px;
  margin: 0;
}

.result-list div {
  display: grid;
  grid-template-columns: 96px minmax(0, 1fr);
  gap: 12px;
}

.result-list dt {
  color: var(--muted);
  font-weight: 700;
}

.result-list dd {
  margin: 0;
  overflow-wrap: anywhere;
}

.admin-shell {
  display: grid;
  grid-template-columns: minmax(300px, 380px) minmax(0, 1fr);
  gap: 18px;
  width: min(1380px, calc(100% - 28px));
  margin: 18px auto 56px;
}

.list-pane,
.detail-pane {
  min-width: 0;
  padding: 16px;
}

.list-pane {
  align-self: start;
  position: sticky;
  top: 94px;
  max-height: calc(100vh - 118px);
  overflow: auto;
}

.pane-head {
  justify-content: space-between;
  margin-bottom: 10px;
}

.pane-actions {
  justify-content: flex-end;
}

.stats-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 12px;
}

.stats-strip div {
  display: grid;
  gap: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px;
  background: #fbfcfe;
  min-width: 0;
}

.stats-strip strong {
  font-size: 20px;
  line-height: 1.1;
  color: var(--primary-dark);
}

.stats-strip span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.state-line {
  min-height: 24px;
  color: var(--muted);
  font-weight: 700;
}

.list-tools {
  display: grid;
  gap: 10px;
  margin-bottom: 10px;
}

.list-tools label {
  gap: 4px;
}

.list-tools input,
.list-tools select {
  min-height: 40px;
  padding: 8px 10px;
}

.submission-list {
  display: grid;
  gap: 10px;
  margin-top: 10px;
}

.submission-item {
  width: 100%;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  justify-items: stretch;
  text-align: left;
  gap: 8px;
  min-height: 0;
}

.submission-item.selected {
  border-color: rgba(17, 106, 99, 0.65);
  background: var(--surface-strong);
}

.item-main,
.item-meta {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.item-main strong,
.item-main small {
  overflow-wrap: anywhere;
}

.item-meta {
  grid-template-columns: auto minmax(0, 1fr) auto auto;
  align-items: center;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 26px;
  border-radius: 999px;
  padding: 3px 9px;
  background: #e8edf7;
  color: #223b74;
  font-size: 12px;
  font-weight: 800;
}

.missing-count,
.ok-count {
  justify-self: end;
  border-radius: 999px;
  padding: 3px 8px;
  font-size: 12px;
  font-weight: 800;
}

.missing-count {
  background: var(--warning-bg);
  color: #765100;
}

.ok-count {
  background: var(--success-bg);
  color: var(--primary-dark);
}

.empty-list,
.empty-detail {
  padding: 28px 12px;
  color: var(--muted);
}

.detail-content {
  display: grid;
  gap: 18px;
}

.detail-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(180px, 260px);
  gap: 16px;
  align-items: start;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}

.status-control {
  align-self: start;
}

.detail-section {
  border-top: 1px solid var(--line);
  padding-top: 16px;
}

.detail-section h3,
.section-head h3 {
  margin: 0 0 10px;
  font-size: 18px;
}

.section-head {
  justify-content: space-between;
}

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

.answer-grid div,
.path-list div {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  min-width: 0;
}

.answer-grid dt,
.path-list dt {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.answer-grid dd,
.path-list dd {
  margin: 4px 0 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.path-list {
  display: grid;
  gap: 10px;
  margin: 0;
}

.path-list code {
  font-family: Consolas, "Yu Gothic UI", monospace;
  font-size: 13px;
  overflow-wrap: anywhere;
}

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

.attachment-list li {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
}

.attachment-list span {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.attachment-list strong {
  overflow-wrap: anywhere;
}

.review-section {
  background: #fbfcfe;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
}

.review-count {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.review-list {
  display: grid;
  gap: 8px;
  padding: 0;
  margin: 0;
  list-style: none;
}

.review-list li {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 10px;
  align-items: start;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 10px;
  background: #ffffff;
}

.review-list span:last-child {
  display: grid;
  gap: 1px;
  min-width: 0;
}

.review-status {
  border-radius: 999px;
  padding: 3px 8px;
  font-size: 12px;
  font-weight: 800;
}

.review-status.ok {
  background: var(--success-bg);
  color: var(--primary-dark);
}

.review-status.missing {
  background: var(--warning-bg);
  color: #765100;
}

.next-action {
  margin: 10px 0 0;
  font-weight: 800;
}

.md-preview {
  min-height: 260px;
  font-family: Consolas, "Yu Gothic UI", monospace;
  font-size: 14px;
  line-height: 1.55;
  white-space: pre;
}

.question-preview {
  margin-top: 10px;
}

.question-actions {
  margin-top: 10px;
}

.question-actions h4 {
  margin: 0;
  font-size: 15px;
}

.hidden {
  display: none !important;
}

@media (max-width: 860px) {
  .app-header {
    position: static;
    align-items: flex-start;
    flex-direction: column;
  }

  .grid.two,
  .grid.three,
  .admin-shell,
  .detail-head,
  .answer-grid,
  .wide-field {
    grid-template-columns: 1fr;
  }

  .wide-field {
    grid-column: auto;
  }

  .list-pane {
    position: static;
    max-height: none;
  }

  .sticky-actions {
    justify-content: stretch;
  }

  .sticky-actions button,
  .button-row .button,
  .action-strip .button,
  .action-strip button {
    width: 100%;
  }
}

@media (max-width: 480px) {
  body {
    font-size: 15px;
  }

  .page-shell,
  .admin-shell {
    width: min(100% - 16px, 100%);
    margin-top: 10px;
  }

  .panel,
  .list-pane,
  .detail-pane {
    padding: 12px;
  }

  fieldset {
    padding: 14px 12px;
  }

  .header-actions {
    width: 100%;
  }

  .nav-link {
    flex: 1 1 120px;
  }

  .attachment-list li,
  .item-meta,
  .selected-files li {
    grid-template-columns: 1fr;
  }

  .stats-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
