:root {
  color-scheme: light;
  --bg: #eef1f5;
  --surface: #ffffff;
  --surface-2: #f7f9fb;
  --line: #d9dee7;
  --text: #18202f;
  --muted: #647084;
  --blue: #2563eb;
  --green: #168057;
  --red: #be3d3d;
  --amber: #b7791f;
  --focus: #0f766e;
  font-family: "Meiryo", "Yu Gothic", system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
}

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

button {
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  min-height: 36px;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
a:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--focus), white 45%);
  outline-offset: 2px;
}

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

.eyebrow {
  margin: 0 0 2px;
  color: var(--muted);
  font-size: 12px;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: 22px;
}

h2 {
  font-size: 15px;
}

.status-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.status-strip span {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 5px 10px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.workspace {
  display: grid;
  grid-template-columns: 280px minmax(340px, 0.75fr) minmax(760px, 1.5fr);
  gap: 12px;
  padding: 12px;
  min-height: calc(100vh - 70px);
}

.upload-rail,
.preview-panel,
.check-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  min-width: 0;
}

.upload-rail {
  padding: 12px;
  align-self: start;
  position: sticky;
  top: 78px;
}

.file-box,
.inline-fields label {
  display: grid;
  gap: 6px;
  margin-bottom: 10px;
}

.file-box span,
.inline-fields span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.file-box input,
.inline-fields input,
.check-table input,
.check-table select,
.check-table textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
}

.file-box input,
.inline-fields input {
  padding: 8px;
}

.file-box.required span::after {
  content: " *";
  color: var(--red);
}

.inline-fields {
  display: grid;
  grid-template-columns: 92px 1fr;
  gap: 8px;
}

.notice {
  border-radius: 7px;
  border: 1px solid var(--line);
  padding: 9px;
  min-height: 38px;
  font-size: 13px;
  line-height: 1.45;
}

.notice.neutral {
  background: #f8fafc;
  color: var(--muted);
}

.notice.ok {
  border-color: color-mix(in srgb, var(--green), white 58%);
  background: #ecfdf5;
  color: #0f6847;
}

.notice.warn {
  border-color: color-mix(in srgb, var(--amber), white 52%);
  background: #fff7ed;
  color: #8a5214;
}

.notice.error {
  border-color: color-mix(in srgb, var(--red), white 55%);
  background: #fef2f2;
  color: #9d2f2f;
}

.action-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 10px;
}

.action-row .primary {
  grid-column: 1 / -1;
}

.primary {
  background: var(--blue);
  border-color: var(--blue);
  color: #fff;
  font-weight: 700;
}

.secondary {
  background: #f8fafc;
  color: #1f2a3b;
}

.download-link {
  display: block;
  margin-top: 10px;
  padding: 9px 10px;
  border-radius: 7px;
  background: #ecfdf5;
  color: #0f6847;
  text-align: center;
  font-weight: 700;
  text-decoration: none;
}

.preview-grid {
  display: grid;
  grid-template-rows: 1fr 1fr;
  gap: 12px;
  min-height: 0;
}

.preview-panel,
.check-panel {
  display: flex;
  flex-direction: column;
  min-height: 300px;
  overflow: hidden;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border-bottom: 1px solid var(--line);
  padding: 10px 12px;
  background: var(--surface-2);
}

.panel-head span {
  color: var(--muted);
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.preview-empty {
  display: grid;
  place-items: center;
  min-height: 260px;
  color: var(--muted);
  padding: 16px;
  text-align: center;
}

.preview-panel iframe,
.preview-panel img {
  width: 100%;
  height: 100%;
  min-height: 260px;
  border: 0;
  object-fit: contain;
  background: #f8fafc;
}

.table-head {
  align-items: center;
}

.segmented {
  display: inline-flex;
  gap: 2px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 2px;
  background: #fff;
}

.segmented button {
  border: 0;
  border-radius: 5px;
  min-height: 28px;
  padding: 3px 9px;
  font-size: 12px;
}

.segmented button.active {
  background: #dbeafe;
  color: #1d4ed8;
  font-weight: 700;
}

.table-wrap {
  overflow: auto;
  min-height: 0;
}

.check-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
  font-size: 13px;
}

.check-table th,
.check-table td {
  border-bottom: 1px solid var(--line);
  padding: 8px;
  vertical-align: top;
}

.check-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #f8fafc;
  color: var(--muted);
  font-size: 12px;
  text-align: left;
}

.check-table th:nth-child(1) { width: 128px; }
.check-table th:nth-child(2) { width: 118px; }
.check-table th:nth-child(3) { width: 118px; }
.check-table th:nth-child(4) { width: 96px; }
.check-table th:nth-child(5),
.check-table th:nth-child(6) { width: 58px; }
.check-table th:nth-child(7) { width: 184px; }

.item-label {
  font-weight: 700;
  line-height: 1.35;
}

.check-table input,
.check-table select,
.check-table textarea {
  padding: 7px;
  min-height: 34px;
}

.check-table textarea {
  resize: vertical;
  min-height: 34px;
  max-height: 120px;
}

tr.status-ok {
  background: #f0fdf4;
}

tr.status-diff {
  background: #fff7ed;
}

tr.status-attention {
  background: #fffbeb;
}

.toast {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 20;
  max-width: min(420px, calc(100vw - 32px));
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #18202f;
  color: #fff;
  padding: 12px 14px;
  box-shadow: 0 14px 34px rgba(15, 23, 42, 0.22);
}

@media (max-width: 1180px) {
  .workspace {
    grid-template-columns: 260px 1fr;
  }

  .check-panel {
    grid-column: 1 / -1;
  }
}

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

  .workspace {
    grid-template-columns: 1fr;
    padding: 8px;
  }

  .upload-rail {
    position: static;
  }

  .preview-grid {
    grid-template-rows: none;
  }

  .check-table {
    min-width: 920px;
  }
}
