:root {
  color-scheme: light;
  --bg: #eef2f6;
  --surface: #ffffff;
  --surface-2: #f4f7fb;
  --surface-3: #e8eef5;
  --ink: #111827;
  --muted: #64748b;
  --line: #d7dee8;
  --accent: #12385b;
  --accent-2: #0f766e;
  --accent-3: #2563eb;
  --ok: #15803d;
  --warning: #b45309;
  --danger: #b91c1c;
  --shadow: 0 18px 45px rgba(15, 23, 42, 0.08);
  --shadow-soft: 0 10px 28px rgba(15, 23, 42, 0.06);
}

* {
  box-sizing: border-box;
}

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

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

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

.simple-mode .app-shell {
  grid-template-columns: minmax(320px, 410px) minmax(0, 1fr);
}

.simple-mode .detailed-only,
.detail-mode .simple-only {
  display: none !important;
}

.setup-preview {
  display: none !important;
}

[hidden] {
  display: none !important;
}

.sidebar {
  background: #f8fafc;
  border-right: 1px solid var(--line);
  padding: 22px;
  overflow-y: auto;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 22px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-weight: 800;
}

.eyebrow,
.label {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
h3 {
  margin: 0;
  letter-spacing: 0;
  line-height: 1.25;
}

h1 {
  font-size: 25px;
}

.diagnosis-form {
  display: grid;
  gap: 14px;
}

.mode-panel {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #e8eef5;
  padding: 7px;
  position: sticky;
  top: 12px;
  z-index: 5;
  box-shadow: var(--shadow-soft);
}

.mode-button {
  min-height: 46px;
  border-color: transparent;
  background: transparent;
  color: var(--muted);
  font-size: 15px;
}

.mode-button.active {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 8px 18px rgba(18, 56, 91, 0.22);
}

.mode-button:not(.active) {
  background: var(--surface);
  color: var(--ink);
}

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

.panel {
  padding: 18px;
}

.panel h2 {
  margin-bottom: 14px;
  font-size: 16px;
}

.field {
  display: grid;
  gap: 6px;
  margin-bottom: 14px;
}

.field:last-child {
  margin-bottom: 0;
}

.field label,
.field span,
.segmented legend {
  color: #344246;
  font-size: 13px;
  font-weight: 700;
}

.field-help,
.field-error {
  margin: -2px 0 0;
  font-size: 12px;
  line-height: 1.5;
}

.field-help {
  color: var(--muted);
}

.field-error {
  min-height: 18px;
  color: var(--danger);
  font-weight: 700;
}

.field.has-error input,
.field.has-error select,
.field.has-error textarea {
  border-color: var(--danger);
  box-shadow: 0 0 0 3px rgba(185, 28, 28, 0.12);
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid #c9d4d2;
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  padding: 10px 11px;
  outline: none;
}

textarea {
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(18, 56, 91, 0.14);
}

.segmented {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin: 0;
  padding: 0;
  border: 0;
}

.segmented legend {
  grid-column: 1 / -1;
  margin-bottom: 2px;
}

.segmented label {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: #2f3c40;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}

.segmented input {
  width: auto;
  margin: 0 6px 0 0;
}

.actions {
  display: grid;
  grid-template-columns: 1fr 1.4fr;
  gap: 10px;
}

.simple-mode .actions {
  grid-template-columns: 1fr;
}

button {
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-3);
  color: var(--ink);
  font-weight: 800;
  cursor: pointer;
}

button[type="submit"] {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

button[type="submit"].is-analyzing {
  border-color: #b91c1c;
  background: #dc2626;
  color: #fff;
}

button[type="submit"].is-analyzing:hover {
  background: #b91c1c;
}

button:hover {
  filter: brightness(0.98);
}

.workspace {
  padding: 28px 32px;
  overflow: auto;
}

.simple-mode .workspace {
  max-width: 1180px;
}

.workspace-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 14px;
}

.workspace-header h2 {
  font-size: 30px;
}

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

.status-strip span {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 700;
}

.summary-band {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 128px;
  gap: 20px;
  align-items: center;
  margin-bottom: 18px;
  padding: 22px;
  border-left: 6px solid var(--accent);
  background: var(--surface);
  box-shadow: var(--shadow-soft);
}

.simple-intro {
  margin-bottom: 18px;
  padding: 22px;
  border-left: 6px solid var(--accent);
  background: var(--surface);
  box-shadow: var(--shadow-soft);
}

.simple-intro h3 {
  font-size: 22px;
}

.simple-intro p {
  margin: 8px 0 0;
  color: var(--muted);
}

.summary-band h3 {
  font-size: 24px;
}

.summary-band p:last-child {
  margin: 8px 0 0;
  color: var(--muted);
}

.score-preview {
  display: grid;
  place-items: center;
  width: 112px;
  height: 112px;
  border: 8px solid #e1e8f0;
  border-top-color: var(--accent);
  border-right-color: var(--accent-2);
  border-radius: 50%;
}

.score-preview span {
  font-size: 30px;
  font-weight: 900;
  line-height: 1;
}

.score-preview small {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.content-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 18px;
  margin-bottom: 18px;
}

.section-block {
  padding: 20px;
  margin-bottom: 18px;
}

.section-heading {
  margin-bottom: 14px;
}

.section-heading h3 {
  font-size: 18px;
}

.metric-list,
.note-list,
.checklist,
.output-plan,
.analysis-result {
  display: grid;
  gap: 10px;
}

.metric {
  display: grid;
  grid-template-columns: minmax(120px, 180px) minmax(0, 1fr) 44px;
  gap: 10px;
  align-items: center;
}

.metric-name,
.check-title {
  font-weight: 800;
}

.bar {
  height: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: #e1e8f0;
}

.bar span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--accent-3);
}

.metric-score {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  text-align: right;
}

.note,
.check-item,
.output-item,
.analysis-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdff;
  padding: 14px;
}

.result-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  padding: 10px 12px;
  box-shadow: none;
}

.result-actions strong {
  display: block;
  margin-bottom: 2px;
  font-size: 14px;
}

.result-actions p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

.report-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: flex-end;
}

.secondary-action {
  min-width: auto;
  min-height: 34px;
  padding: 0 12px;
  background: #fff;
  font-size: 13px;
}

.primary-export {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

.note strong,
.output-item strong,
.analysis-card strong {
  display: block;
  margin-bottom: 4px;
}

.note p,
.check-item p,
.output-item p,
.analysis-card p {
  margin: 0;
  color: var(--muted);
}

.summary-card {
  border-left: 6px solid var(--accent);
  background: #fff;
}

.summary-card > strong {
  font-size: 20px;
  color: var(--ink);
}

.summary-list {
  margin-top: 12px;
}

.summary-list ul {
  margin: 6px 0 0;
  padding-left: 20px;
  color: var(--muted);
}

.summary-list li + li {
  margin-top: 4px;
}

.detail-overview-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 10px 18px;
  margin-top: 14px;
}

.result-section {
  display: grid;
  gap: 12px;
}

.section-heading.compact {
  margin: 6px 0 0;
}

.focus-score-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.focus-score-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 16px;
  box-shadow: var(--shadow-soft);
}

.focus-score-card span {
  display: block;
  color: var(--muted);
  font-size: 13px;
  font-weight: 900;
}

.focus-score-card strong {
  display: block;
  margin-top: 4px;
  color: var(--accent);
  font-size: 34px;
  line-height: 1;
}

.focus-score-card small {
  margin-left: 2px;
  color: var(--muted);
  font-size: 13px;
}

.focus-score-card p {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.priority-list {
  display: grid;
  gap: 10px;
}

.priority-item {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr);
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 14px;
}

.priority-index {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-size: 18px;
  font-weight: 900;
}

.priority-item strong {
  display: block;
  margin-bottom: 4px;
}

.priority-item p {
  margin: 0;
  color: var(--muted);
}

.keyword-summary {
  border-left: 5px solid var(--accent-3);
}

.keyword-table {
  display: grid;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.keyword-row {
  display: grid;
  grid-template-columns: minmax(140px, 1.3fr) minmax(96px, 0.8fr) 74px 88px minmax(150px, 1.2fr);
  gap: 10px;
  align-items: center;
  border-top: 1px solid var(--line);
  padding: 11px 12px;
  color: var(--muted);
  font-size: 13px;
}

.keyword-row:first-child {
  border-top: 0;
}

.keyword-head {
  background: #f1f5f9;
  color: #334155;
  font-weight: 900;
}

.keyword-row strong {
  color: var(--ink);
}

.keyword-suggestion {
  grid-column: 1 / -1;
  margin: -2px 0 0;
  color: #475569;
  font-size: 12px;
  line-height: 1.55;
}

.evidence-note {
  margin-top: 8px;
  color: #475569;
  font-size: 12px;
  line-height: 1.55;
}

.basis-card {
  background: #f8fbff;
}

.coverage-missing {
  color: var(--warning);
  font-weight: 900;
}

.coverage-ok {
  color: var(--ok);
  font-weight: 900;
}

.ai-search-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 10px;
}

.action-card ul {
  margin: 8px 0 0;
  padding-left: 20px;
  color: var(--muted);
}

.rule-details {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 0;
}

.rule-details summary {
  cursor: pointer;
  padding: 14px;
  color: var(--ink);
  font-weight: 900;
}

.rule-details-inner {
  display: grid;
  gap: 14px;
  border-top: 1px solid var(--line);
  padding: 14px;
}

.check-item {
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr);
  gap: 10px;
}

.check-icon {
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #e6f4ef;
  color: var(--ok);
  font-weight: 900;
}

.analysis-status {
  border: 1px dashed #b9c7c5;
  border-radius: 8px;
  background: #f8faf9;
  color: var(--muted);
  padding: 14px;
}

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

.thinking-box {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
}

.thinking-content {
  min-width: 0;
}

.spinner {
  width: 34px;
  height: 34px;
  border: 4px solid #dce8e4;
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}

.thinking-title {
  margin: 0;
  color: var(--ink);
  font-weight: 800;
}

.thinking-step {
  margin: 2px 0 0;
  color: var(--muted);
}

.progress-track {
  width: 100%;
  height: 8px;
  margin-top: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: #dce8e4;
}

.progress-track span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
  transition: width 0.35s ease;
}

.progress-meta {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 6px;
  color: var(--muted);
  font-size: 0.86rem;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.analysis-status.error {
  border-color: #b91c1c;
  background: #fff7f7;
  color: #b91c1c;
}

.analysis-score-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
}

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

.analysis-score span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.analysis-score strong {
  font-size: 24px;
}

.analysis-score small {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.severity {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  margin-bottom: 6px;
  border-radius: 999px;
  padding: 2px 9px;
  font-size: 12px;
  font-weight: 800;
}

.severity.high {
  background: #fee2e2;
  color: #991b1b;
}

.severity.medium {
  background: #ffedd5;
  color: #9a3412;
}

.severity.low,
.severity.info {
  background: #e0f2fe;
  color: #075985;
}

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

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

  .content-grid {
    grid-template-columns: 1fr;
  }

  .focus-score-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 720px) {
  .result-actions {
    align-items: stretch;
    flex-direction: column;
  }

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

  .secondary-action {
    flex: 1 1 92px;
  }

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

  .keyword-head {
    display: none;
  }

  .keyword-row {
    gap: 4px;
    align-items: start;
  }
}

@media (max-width: 680px) {
  .sidebar,
  .workspace {
    padding: 18px;
  }

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

  .workspace-header {
    display: grid;
  }

  .status-strip {
    justify-content: flex-start;
  }

  .progress-meta {
    flex-wrap: wrap;
  }

  .summary-band {
    display: grid;
  }

  .score-preview {
    width: 96px;
    height: 96px;
  }

  .actions,
  .segmented,
  .metric {
    grid-template-columns: 1fr;
  }

  .metric-score {
    text-align: left;
  }
}
