/* 文字色はすべて背景に対して 4.5:1 以上（WCAG AA）になる組み合わせにしている */
:root {
  color-scheme: light dark;
  --fg: #1a1a1a;
  --bg: #ffffff;
  --surface: #f4f5f7;
  --border: #8a8f98;
  --muted: #555b65;
  --link: #1a56db;
  --primary: #1d4ed8;
  --primary-hover: #1e40af;
  --on-primary: #ffffff;
  --error: #b42318;
  --error-bg: #fef3f2;
  --error-strong: #b42318;
  --notice: #05603a;
  --notice-bg: #ecfdf3;
  --focus: #1d4ed8;
}

@media (prefers-color-scheme: dark) {
  :root {
    --fg: #e8e8e8;
    --bg: #15171a;
    --surface: #1f2226;
    --border: #7d838c;
    --muted: #b0b5bd;
    --link: #8ab4ff;
    --primary: #3b6fe0;
    --primary-hover: #5583ea;
    --on-primary: #ffffff;
    --error: #ffb4ab;
    --error-bg: #3a1714;
  --error-strong: #b42318;
    --notice: #8ee4af;
    --notice-bg: #10291c;
    --focus: #8ab4ff;
  }
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--fg);
  background: var(--bg);
  font-family: system-ui, -apple-system, "Segoe UI", "Hiragino Sans", "Noto Sans JP", sans-serif;
  font-size: 1rem;
  line-height: 1.7;
}

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

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

.container {
  max-width: 960px;
  margin: 0 auto;
  padding: 0 16px;
}

.skip-link {
  position: absolute;
  left: -9999px;
}
.skip-link:focus {
  left: 16px;
  top: 8px;
  padding: 8px 12px;
  background: var(--bg);
  z-index: 10;
}

/* ---- ヘッダー・フッター ---- */

.site-header {
  border-bottom: 1px solid var(--border);
}

.site-header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 64px;
  flex-wrap: wrap;
}

.brand {
  color: var(--fg);
  font-weight: 700;
  font-size: 1.25rem;
  text-decoration: none;
}

.site-nav {
  display: flex;
  align-items: center;
  gap: 16px;
}

.site-nav form {
  margin: 0;
}

.site-footer {
  margin-top: 64px;
  padding: 24px 0;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.875rem;
}

.footer-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 24px;
}

/* ---- 本文 ---- */

main {
  padding-top: 24px;
}

h1 {
  font-size: 1.75rem;
  line-height: 1.3;
}

h2 {
  font-size: 1.25rem;
  margin-top: 40px;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 16px;
}

.summary {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 8px 24px;
}
.summary dt {
  font-weight: 700;
}
.summary dd {
  margin: 0;
  overflow-wrap: anywhere;
}
.summary meter {
  display: block;
  width: 100%;
  max-width: 320px;
  height: 16px;
}
@media (max-width: 480px) {
  .summary {
    grid-template-columns: 1fr;
    gap: 0;
  }
  .summary dd {
    margin-bottom: 12px;
  }
}

/* ---- ボタン ---- */

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 8px 20px;
  border: 1px solid var(--primary);
  border-radius: 8px;
  background: var(--primary);
  color: var(--on-primary);
  font: inherit;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
}
.button:hover {
  background: var(--primary-hover);
  border-color: var(--primary-hover);
}

.button-secondary {
  background: transparent;
  color: var(--fg);
  border-color: var(--border);
  font-weight: 400;
}
.button-secondary:hover {
  background: var(--surface);
  border-color: var(--border);
}

/* ---- フォーム ---- */

.stack {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 20px;
  max-width: 480px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  width: 100%;
}

.field label {
  font-weight: 700;
}

.field input[type="text"],
.field input[type="email"],
.field input[type="password"] {
  width: 100%;
  min-height: 44px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  color: var(--fg);
  font: inherit;
  font-size: 1rem; /* 16px 未満だと iOS が入力時に拡大する */
}

.field input[aria-invalid="true"] {
  border: 2px solid var(--error);
}

.hint {
  margin: 0;
  color: var(--muted);
  font-size: 0.875rem;
}

.field-error {
  margin: 0;
  color: var(--error);
  font-weight: 700;
}

.checkbox {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-weight: 400 !important;
  min-height: 44px;
  padding-top: 10px;
}
.checkbox input {
  width: 20px;
  height: 20px;
  margin: 3px 0 0;
  flex: none;
}

.field textarea {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  color: var(--fg);
  font: inherit;
  font-size: 1rem;
  resize: vertical;
}

.field input[type="file"] {
  font: inherit;
  min-height: 44px;
  max-width: 100%;
}

.copy-field {
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
}

.button-danger {
  background: var(--error-strong);
  border-color: var(--error-strong);
}
.button-danger:hover {
  background: var(--error-strong);
  filter: brightness(1.1);
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.radio-group {
  border: 0;
  margin: 0;
  padding: 0;
}
.radio-group legend {
  font-weight: 700;
  padding: 0;
}
.radio-group .checkbox {
  padding-top: 10px;
}

.report-link {
  margin-top: 32px;
  font-size: 0.875rem;
}

.report-card h3 {
  font-size: 1.0625rem;
}

/* ---- アップローダー ---- */

.description {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.filename {
  overflow-wrap: anywhere;
}

.panel {
  margin: 24px 0;
  padding: 4px 20px 20px;
  border: 1px solid var(--border);
  border-radius: 8px;
}

.badge {
  display: inline-block;
  margin-left: 8px;
  padding: 0 8px;
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 0.8125rem;
  white-space: nowrap;
}

.file-table {
  width: 100%;
  border-collapse: collapse;
}
.file-table th,
.file-table td {
  padding: 8px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
}
.file-table .col-name,
.file-table .col-comment {
  overflow-wrap: anywhere;
}

/* 狭い画面では表を縦並びのカードにして、横スクロールを出さない */
@media (max-width: 640px) {
  .file-table thead {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
  }
  .file-table tr {
    display: block;
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
  }
  .file-table td {
    display: grid;
    grid-template-columns: 6em 1fr;
    gap: 8px;
    padding: 2px 0;
    border: 0;
  }
  .file-table td::before {
    content: attr(data-label);
    color: var(--muted);
  }
}

.pagination {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 16px;
  margin-top: 24px;
}
.pagination a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
}

.uploader-list li {
  margin-bottom: 8px;
  overflow-wrap: anywhere;
}

.upload-status {
  list-style: none;
  margin: 0;
  padding: 0;
  width: 100%;
}
.upload-status li {
  display: grid;
  grid-template-columns: 1fr;
  gap: 4px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}
.upload-status progress {
  width: 100%;
  height: 12px;
}
.upload-name {
  overflow-wrap: anywhere;
  font-weight: 700;
}
.upload-status .is-error .upload-state {
  color: var(--error);
  font-weight: 700;
}

.alert {
  padding: 12px 16px;
  border-radius: 8px;
  border-left: 4px solid;
}
.alert-error {
  color: var(--error);
  background: var(--error-bg);
}
.alert-notice {
  color: var(--notice);
  background: var(--notice-bg);
}
