:root {
  --bg: #f1f3f8;
  --bg-soft: #e9ecf3;
  --card: #ffffff;
  --border: #e2e6ee;
  --border-strong: #cdd3df;
  --primary: #0f3a3a;
  --primary-dark: #082525;
  --primary-soft: #1d6e6a;
  --accent: #c9a44c;
  --text: #18222e;
  --muted: #5a6878;
  --warn: #b45309;
  --warn-bg: #fff7e6;
  --shadow-sm: 0 1px 2px rgba(15, 30, 45, 0.04), 0 2px 8px rgba(15, 30, 45, 0.04);
  --shadow-md: 0 6px 24px rgba(15, 30, 45, 0.08);
  --radius: 10px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  font-family: "Inter", "Hiragino Sans", "Yu Gothic UI", system-ui, sans-serif;
  background:
    radial-gradient(1200px 600px at 10% -10%, rgba(29, 110, 106, 0.08), transparent 60%),
    radial-gradient(900px 500px at 100% 0%, rgba(201, 164, 76, 0.06), transparent 55%),
    var(--bg);
  color: var(--text);
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
}

/* ---------- Header ---------- */
.app-header {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 1.25rem;
  padding: 0.85rem 1.6rem;
  background:
    linear-gradient(135deg, #061d1d 0%, #0f3a3a 50%, #154848 100%);
  color: #fff;
  position: sticky;
  top: 0;
  z-index: 10;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  box-shadow: 0 4px 18px rgba(8, 37, 37, 0.18);
}

.app-back {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  color: rgba(255, 255, 255, 0.78);
  text-decoration: none;
  font-size: 0.82rem;
  letter-spacing: 0.02em;
  padding: 0.35rem 0.55rem 0.35rem 0.4rem;
  border-radius: 6px;
  transition: color 0.15s, background 0.15s;
}
.app-back svg { width: 14px; height: 14px; }
.app-back:hover { color: #fff; background: rgba(255, 255, 255, 0.06); }

.brand {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.85rem;
  white-space: nowrap;
}
.brand-mark {
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: 0.32em;
  text-transform: uppercase;
  color: #fff;
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.25);
}
.brand-mark::first-letter { color: var(--accent); }
.brand-divider {
  width: 1px;
  height: 18px;
  background: linear-gradient(180deg, transparent, rgba(255, 255, 255, 0.45), transparent);
}
.brand-sub {
  font-size: 0.7rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.62);
  font-weight: 500;
}

.header-actions { display: flex; gap: 0.5rem; }

/* ---------- Buttons ---------- */
button {
  font-family: inherit;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.42rem;
  padding: 0.5rem 0.9rem;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(255, 255, 255, 0.05);
  color: #fff;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.83rem;
  letter-spacing: 0.04em;
  font-weight: 500;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.08s ease;
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
}
.icon-btn svg {
  width: 15px;
  height: 15px;
  flex-shrink: 0;
  stroke: currentColor;
}
.icon-btn:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.13);
  border-color: rgba(255, 255, 255, 0.32);
}
.icon-btn:active:not(:disabled) { transform: translateY(1px); }
.icon-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* Primary action (analyze) sits in the light area, not on the header */
.icon-btn--primary {
  background: linear-gradient(180deg, #1d6e6a 0%, #0f3a3a 100%);
  color: #fff;
  border: 1px solid #082525;
  padding: 0.7rem 1.5rem;
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  box-shadow: 0 4px 14px rgba(15, 58, 58, 0.28), inset 0 1px 0 rgba(255, 255, 255, 0.12);
}
.icon-btn--primary svg { width: 17px; height: 17px; }
.icon-btn--primary:hover:not(:disabled) {
  background: linear-gradient(180deg, #21807c 0%, #154848 100%);
  border-color: #082525;
}

/* Generic plain buttons (e.g. dialog footer) */
.settings-dialog button {
  padding: 0.5rem 1rem;
  border: 1px solid var(--border-strong);
  background: white;
  border-radius: 7px;
  cursor: pointer;
  font-size: 0.9rem;
  color: var(--text);
}
.settings-dialog button:hover:not(:disabled) { background: #f4f6fa; }
.settings-dialog button#settings-save {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary-dark);
  font-weight: 600;
}
.settings-dialog button#settings-save:hover { background: var(--primary-dark); }

/* ---------- Main ---------- */
.app-main {
  padding: 1.4rem 1.6rem 2.4rem;
  max-width: 1400px;
  margin: 0 auto;
}

/* 常時表示の注意書き：本ツールが医学的診断ではないことを画面上でも明示する。 */
.app-disclaimer {
  max-width: 1400px;
  margin: 0 auto 1rem;
  padding: 0.6rem 0.9rem;
  background: var(--warn-bg);
  border: 1px solid #e7cfa0;
  border-left: 3px solid var(--warn);
  border-radius: 8px;
  color: #7a5310;
  font-size: 0.82rem;
  line-height: 1.55;
}

/* ---------- Patient info ---------- */
.patient-info {
  background: var(--card);
  padding: 1.1rem 1.2rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  margin-bottom: 1.2rem;
  display: flex;
  flex-wrap: wrap;
  gap: 1rem 1.2rem;
  align-items: end;
  box-shadow: var(--shadow-sm);
}

.field { display: flex; flex-direction: column; gap: 0.3rem; min-width: 200px; flex: 1; }
.field label {
  font-size: 0.78rem;
  color: var(--muted);
  letter-spacing: 0.04em;
  font-weight: 500;
  text-transform: uppercase;
}
.field input, .field select {
  padding: 0.55rem 0.65rem;
  border: 1px solid var(--border);
  border-radius: 7px;
  font-size: 0.95rem;
  background: #fff;
  color: var(--text);
  transition: border-color 0.15s, box-shadow 0.15s;
  font-family: inherit;
}
.field input:focus, .field select:focus {
  outline: none;
  border-color: var(--primary-soft);
  box-shadow: 0 0 0 3px rgba(29, 110, 106, 0.14);
}

.consent {
  flex-basis: 100%;
  display: flex;
  align-items: flex-start;
  gap: 0.55rem;
  padding: 0.7rem 0.85rem;
  background: var(--warn-bg);
  border: 1px solid #f3deb1;
  border-radius: 8px;
  font-size: 0.85rem;
  color: #6b4316;
  line-height: 1.5;
}
.consent input[type="checkbox"] {
  margin-top: 0.18rem;
  accent-color: var(--primary);
}

.field--full { flex-basis: 100%; }
.field--full small {
  color: var(--muted);
  font-size: 0.76rem;
  margin-top: 0.4rem;
  line-height: 1.45;
}

.chip-group {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 0.45rem;
  margin-top: 0.1rem;
}
.chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.4rem 0.75rem;
  background: #fff;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  cursor: pointer;
  font-size: 0.85rem;
  color: var(--text);
  letter-spacing: 0.01em;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
  user-select: none;
}
.chip:hover { border-color: var(--primary-soft); }
.chip input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  width: 13px;
  height: 13px;
  border: 1.4px solid var(--border-strong);
  border-radius: 3px;
  margin: 0;
  position: relative;
  flex-shrink: 0;
  transition: background 0.15s, border-color 0.15s;
}
.chip input[type="checkbox"]:checked {
  background: var(--primary);
  border-color: var(--primary);
}
.chip input[type="checkbox"]:checked::after {
  content: "";
  position: absolute;
  left: 3px;
  top: 0px;
  width: 4px;
  height: 8px;
  border: solid #fff;
  border-width: 0 1.6px 1.6px 0;
  transform: rotate(45deg);
}
.chip:has(input:checked) {
  background: #ecf5f3;
  border-color: var(--primary-soft);
  color: var(--primary);
  font-weight: 600;
}

/* ---------- Upload grid ---------- */
.upload-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.upload-card {
  position: relative;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.9rem 0.95rem 1rem;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-sm);
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}
.upload-card:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
  border-color: var(--border-strong);
}
.upload-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 14px;
  right: 14px;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--primary-soft), transparent);
  border-radius: 2px;
  opacity: 0.55;
}

.upload-card h2 {
  margin: 0 0 0.7rem;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--primary);
}

.dropzone {
  display: block;
  padding: 1.6rem 1rem;
  border: 1.5px dashed var(--border-strong);
  border-radius: 8px;
  text-align: center;
  cursor: pointer;
  color: var(--muted);
  background: linear-gradient(180deg, #fafbfd, #f4f6fa);
  font-size: 0.88rem;
  letter-spacing: 0.02em;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}
.dropzone:hover {
  border-color: var(--primary-soft);
  color: var(--primary);
  background: linear-gradient(180deg, #f5fbfa, #ecf5f3);
}
.dropzone input { display: none; }
.dropzone.has-image { display: none; }

.canvas-wrap {
  position: relative;
  margin-top: 0.7rem;
  border-radius: 8px;
  overflow: hidden;
  background: #0c1116;
  display: none;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.04);
}
.canvas-wrap.has-image { display: block; }
.canvas-wrap canvas { width: 100%; height: auto; display: block; }

.metric-list {
  list-style: none;
  margin: 0.7rem 0 0;
  padding: 0.55rem 0.8rem;
  background: #f6f8fc;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.84rem;
  display: none;
}
.metric-list.has-data { display: block; }
.metric-list li {
  display: flex;
  justify-content: space-between;
  padding: 0.22rem 0;
  border-bottom: 1px dashed #e1e5ee;
}
.metric-list li:last-child { border-bottom: none; }
.metric-list .metric-name { color: var(--muted); letter-spacing: 0.02em; }
.metric-list .metric-value { font-weight: 600; font-variant-numeric: tabular-nums; color: var(--text); }
.metric-list .metric-value.warn { color: var(--warn); }

/* ---------- Summary ---------- */
.summary-section {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.2rem 1.3rem;
  box-shadow: var(--shadow-sm);
}
.summary-actions {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}
.status-text {
  color: var(--muted);
  font-size: 0.88rem;
  letter-spacing: 0.02em;
}

.summary-output { line-height: 1.75; min-height: 1rem; }
.summary-output:empty { display: none; }
.summary-output h3 {
  margin: 1.3rem 0 0.4rem;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--primary);
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.4rem;
  position: relative;
}
.summary-output h3::after {
  content: "";
  position: absolute;
  bottom: -1px;
  left: 0;
  width: 36px;
  height: 2px;
  background: var(--accent);
}
.summary-output ul { padding-left: 1.4rem; }
.summary-output .disclaimer {
  margin-top: 1.5rem;
  padding: 0.75rem 0.9rem;
  background: var(--warn-bg);
  border: 1px solid #f3deb1;
  border-radius: 8px;
  font-size: 0.83rem;
  color: #6b4316;
}

/* ---------- Settings dialog ---------- */
.settings-dialog {
  border: none;
  border-radius: 12px;
  padding: 1.6rem;
  width: min(460px, 92vw);
  box-shadow: 0 20px 60px rgba(8, 37, 37, 0.28);
}
.settings-dialog::backdrop { background: rgba(8, 18, 24, 0.55); backdrop-filter: blur(2px); }
.settings-dialog h2 {
  margin: 0 0 1.1rem;
  font-size: 0.85rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--primary);
  font-weight: 700;
}
.settings-dialog .field { width: 100%; margin-bottom: 0.85rem; }
.settings-dialog small { color: var(--muted); font-size: 0.78rem; margin-top: 0.25rem; line-height: 1.4; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 0.5rem; margin-top: 1.2rem; }

/* ---------- Auth gate ---------- */
body.auth-locked { overflow: hidden; }
body.auth-locked > *:not(.auth-dialog) { filter: blur(4px); pointer-events: none; user-select: none; }

.auth-dialog {
  border: none;
  border-radius: 14px;
  padding: 1.6rem 1.6rem 1.4rem;
  max-width: 380px;
  width: calc(100% - 2rem);
  background: #fff;
  box-shadow: 0 18px 60px rgba(8, 30, 30, 0.25);
}
.auth-dialog::backdrop { background: rgba(8, 18, 24, 0.55); backdrop-filter: blur(3px); }
.auth-dialog h2 {
  margin: 0 0 0.5rem;
  font-size: 1.05rem;
  color: var(--primary);
  letter-spacing: 0.02em;
}
.auth-lead {
  margin: 0 0 1rem;
  font-size: 0.82rem;
  color: var(--muted);
  line-height: 1.5;
}
.auth-dialog .field { width: 100%; margin-bottom: 0.85rem; }
.auth-remember {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.85rem;
  color: var(--text);
  cursor: pointer;
  user-select: none;
}
.auth-remember input { accent-color: var(--primary); }
.auth-error {
  min-height: 1.2em;
  margin: 0.5rem 0 0;
  color: #b3261e;
  font-size: 0.82rem;
}

/* ---------- Responsive ---------- */
@media (max-width: 720px) {
  .app-header {
    grid-template-columns: 1fr;
    gap: 0.6rem;
    padding: 0.7rem 1rem;
  }
  .brand { justify-content: flex-start; }
  .brand-sub { display: none; }
  .header-actions { justify-content: flex-end; }
  .app-main { padding: 1rem 0.9rem 2rem; }
  .icon-btn { padding: 0.45rem 0.7rem; font-size: 0.78rem; }
  .icon-btn span { display: none; }

  /* Horizontal swipe carousel for upload cards on mobile */
  .upload-grid {
    display: flex;
    flex-wrap: nowrap;
    grid-template-columns: none;
    overflow-x: auto;
    overflow-y: visible;
    scroll-snap-type: x mandatory;
    scroll-behavior: smooth;
    gap: 0.7rem;
    padding-bottom: 0.7rem;
    margin-left: -0.9rem;
    margin-right: -0.9rem;
    padding-left: 0.9rem;
    padding-right: 0.9rem;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .upload-grid::-webkit-scrollbar { display: none; }
  .upload-card {
    flex: 0 0 90%;
    scroll-snap-align: center;
    scroll-snap-stop: always;
  }
  .upload-card:hover { transform: none; }

  .carousel-dots {
    display: flex;
    justify-content: center;
    gap: 0.4rem;
    margin: 0 0 1rem;
  }
  .carousel-dots .dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--border-strong);
    transition: background 0.2s, width 0.2s;
  }
  .carousel-dots .dot.active {
    background: var(--primary);
    width: 18px;
    border-radius: 3px;
  }
  .carousel-dots .dot.filled { background: var(--primary-soft); }
}

/* Hide carousel dots on desktop */
.carousel-dots { display: none; }

/* ---------- A4 Report ---------- */
/* The summary-output is now a container of <article class="report-page"> sized to A4.
   210mm × 297mm at 96dpi ≈ 794px × 1123px. */
.summary-output { min-height: 1rem; }
.summary-output:empty { display: none; }
.summary-output .empty-state { color: var(--muted); padding: 1rem 0; }
.summary-output .raw-summary {
  white-space: pre-wrap;
  background: #f7f8fb;
  padding: 0.8rem 1rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  font-size: 0.85rem;
}

.report-page {
  width: 210mm;
  min-height: 297mm;
  margin: 1.4rem auto;
  padding: 14mm 14mm 12mm;
  background: #fff;
  color: #1f2a36;
  box-shadow: 0 4px 22px rgba(15, 30, 45, 0.12);
  border-radius: 4px;
  display: flex;
  flex-direction: column;
  position: relative;
  font-size: 11pt;
  line-height: 1.55;
  page-break-after: always;
  break-after: page;
}
.report-page:last-child { page-break-after: auto; break-after: auto; }

.report-head {
  border-bottom: 2px solid var(--primary);
  padding-bottom: 0.6rem;
  margin-bottom: 0.9rem;
  position: relative;
}
.report-head__brand {
  font-size: 10pt;
  letter-spacing: 0.22em;
  color: var(--primary);
  font-weight: 700;
  text-transform: uppercase;
}
.report-head__brand span {
  margin-left: 0.6rem;
  color: var(--muted);
  letter-spacing: 0.14em;
  font-weight: 500;
}
.report-head__title {
  margin: 0.25rem 0 0.25rem;
  font-size: 18pt;
  font-weight: 700;
  color: var(--primary-dark);
  letter-spacing: 0.06em;
}
.report-head__meta {
  display: flex;
  gap: 1.2rem;
  font-size: 10pt;
  color: var(--muted);
}
.report-head__meta b { color: var(--text); }
.report-head__lead {
  margin: 0.3rem 0 0;
  font-size: 10pt;
  color: var(--muted);
}
.report-head--green {
  border-bottom-color: #2e6b3a;
}
.report-head--green .report-head__brand,
.report-head--green .report-head__title { color: #1f4d27; }

/* Patient-reported pain areas (report) */
.report-pain-areas {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem 0.45rem;
  padding: 0.45rem 0.65rem;
  background: #f4ebf6;
  border: 1px solid #d2b3da;
  border-left: 3px solid #6a3a78;
  border-radius: 4px;
  font-size: 9.5pt;
}
.report-pain-areas__label {
  font-weight: 700;
  color: #4a2655;
  letter-spacing: 0.04em;
  margin-right: 0.2rem;
  font-size: 8.8pt;
  text-transform: uppercase;
}
.report-pain-chip {
  display: inline-flex;
  align-items: center;
  padding: 0.12rem 0.55rem;
  background: #fff;
  border: 1px solid #c4a3cd;
  color: #4a2655;
  border-radius: 999px;
  font-size: 9pt;
  font-weight: 600;
}

/* ===== Page 1 layout ===== */
.report-page1-body {
  display: grid;
  grid-template-columns: 0.85fr 1.15fr;
  gap: 0.9rem;
  margin-bottom: 0.7rem;
}

.report-photo {
  position: relative;
  background: #f7f4ef;
  border: 1px solid #d8cdb9;
  border-radius: 6px;
  overflow: hidden;
  min-height: 260px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.report-photo img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  max-height: 360px;
  background: #fff;
}
.report-photo__placeholder {
  color: #8a7858;
  font-size: 11pt;
  padding: 1.4rem;
}
.report-photo__caption {
  position: absolute;
  top: 0.4rem;
  left: 0.6rem;
  background: rgba(15, 58, 58, 0.78);
  color: #fff;
  padding: 0.18rem 0.55rem;
  font-size: 9pt;
  letter-spacing: 0.12em;
  border-radius: 4px;
}

.report-right { display: flex; flex-direction: column; gap: 0.6rem; }

.report-diagnosis {
  font-size: 10.5pt;
  color: #2a3540;
  line-height: 1.65;
  background: #fbf8f3;
  border-left: 3px solid var(--accent);
  padding: 0.55rem 0.8rem;
  border-radius: 0 4px 4px 0;
}
.report-diagnosis p { margin: 0.15rem 0; }

/* Anatomy panel */
.anatomy-panel {
  border: 1px solid #e5dccb;
  border-radius: 6px;
  padding: 0.4rem 0.6rem 0.5rem;
  background: #fffaf2;
}
.anatomy-views {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.4rem;
}
.anatomy-view {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.15rem;
}
.anatomy-svg {
  width: 100%;
  height: auto;
  max-height: 340px;
}
.anatomy-view__caption {
  font-size: 9pt;
  color: var(--muted);
  letter-spacing: 0.1em;
}
.anatomy-legend {
  display: flex;
  justify-content: center;
  gap: 1.4rem;
  margin-top: 0.25rem;
  font-size: 9pt;
  color: var(--muted);
}
.legend-item { display: inline-flex; align-items: center; gap: 0.35rem; }
.legend-swatch {
  display: inline-block;
  width: 11px;
  height: 11px;
  border-radius: 50%;
}
.legend-swatch.swatch-weak { background: #3b8a4f; }
.legend-swatch.swatch-tight { background: #d97a26; }

/* Muscle name callouts on the anatomy overlay */
.muscle-label__leader {
  stroke: #6b6259;
  stroke-width: 1.2;
  fill: none;
  opacity: 0.7;
}
.muscle-label__bg {
  fill: #ffffff;
  stroke: #6b6259;
  stroke-width: 1;
  opacity: 0.92;
}
.muscle-label__text {
  font-size: 14px;
  font-family: inherit;
  font-weight: 600;
  fill: #1f2a36;
  dominant-baseline: middle;
}
.muscle-label--weak  .muscle-label__bg     { stroke: #3b8a4f; }
.muscle-label--weak  .muscle-label__leader { stroke: #3b8a4f; }
.muscle-label--weak  .muscle-label__text   { fill: #1d5a2c; }
.muscle-label--tight .muscle-label__bg     { stroke: #d97a26; }
.muscle-label--tight .muscle-label__leader { stroke: #d97a26; }
.muscle-label--tight .muscle-label__text   { fill: #8a4912; }

/* Muscle lists (鍛/ほぐ) */
.muscle-lists {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.7rem;
  margin-top: 0.4rem;
}
.muscle-list { border-radius: 6px; padding: 0.5rem 0.6rem; }
.muscle-list--weak  { background: #ecf6ef; border: 1px solid #c9e2cf; }
.muscle-list--tight { background: #fbf0e2; border: 1px solid #ecd2ab; }
.muscle-list header {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-bottom: 0.4rem;
  font-size: 10pt;
  font-weight: 700;
}
.muscle-list--weak  header .muscle-list__icon { color: #2c7a3e; }
.muscle-list--tight header .muscle-list__icon { color: #b85e15; }
.muscle-list__title { color: #1f2a36; }
.muscle-list__sub  { color: var(--muted); font-weight: 500; font-size: 8.5pt; margin-left: 0.2rem; }
.muscle-list ul { list-style: none; padding: 0; margin: 0; display: grid; gap: 0.32rem; }
.muscle-card {
  background: #fff;
  border: 1px solid #e0d8c8;
  border-radius: 4px;
  padding: 0.32rem 0.55rem;
}
.muscle-card__label { font-weight: 600; font-size: 9.5pt; color: #1f2a36; }
.muscle-card__note  { font-size: 8.8pt; color: #5a6878; margin-top: 0.08rem; line-height: 1.4; }
.muscle-card--weak  { border-left: 3px solid #3b8a4f; }
.muscle-card--tight { border-left: 3px solid #d97a26; }
.muscle-card--empty { color: var(--muted); text-align: center; padding: 0.5rem; }

.report-foot {
  margin-top: auto;
  padding-top: 0.6rem;
  border-top: 1px dashed #d6cfbf;
  color: #8a7858;
  font-size: 8.5pt;
}
.report-foot small { display: block; }
.report-foot__disclaimer {
  margin-top: 0.3rem;
  color: #6b6259;
  line-height: 1.45;
}
/* Page 1 disclaimer footer sits at the very bottom of the sheet. */
.report-foot--disclaimer {
  color: #6b6259;
}

/* ===== Page 2 layout (training plan) ===== */
.training-grid {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.7rem;
  flex: 1;
}
/* Each card is the pre-rendered exercise image plus a dynamic 目安 panel
   absolutely positioned over the white-out area in the bottom-right. */
.training-card {
  position: relative;
  border: 1px solid #d6e2d8;
  border-radius: 8px;
  background: #fff;
  overflow: hidden;
  break-inside: avoid;
  display: flex;
  align-items: stretch;
  justify-content: center;
}
.training-card__img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  background: #fff;
}
.training-card__rx {
  position: absolute;
  right: 4%;
  bottom: 4%;
  width: 38%;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.35em;
  pointer-events: none;
}
.training-card__rx-label {
  font-size: clamp(0.7rem, 1.6cqw, 1rem);
  font-weight: 700;
  color: #0f3a3a;
  letter-spacing: 0.04em;
}
.training-card__rx-value {
  width: 100%;
  background: #fff;
  border: 1.5px solid #0f3a3a;
  border-radius: 10px;
  padding: 0.55em 0.4em;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  line-height: 1.15;
  color: #18222e;
  font-weight: 700;
  letter-spacing: 0.02em;
}
.training-card__rx-reps {
  font-size: clamp(1.05rem, 2.3cqw, 1.55rem);
}
.training-card__rx-sep {
  font-size: clamp(0.78rem, 1.6cqw, 1.1rem);
  font-weight: 600;
  color: #4a5868;
  margin: 0.05em 0;
}
.training-card__rx-sets {
  font-size: clamp(1.05rem, 2.3cqw, 1.55rem);
}
.training-card { container-type: inline-size; }

.training-card--empty { grid-column: 1 / -1; padding: 1.2rem; text-align: center; color: var(--muted); }

/* ===== Freemium paywall (無料プランのゲート) ===== */
/* 無料プランのレポートに斜めの透かしを敷き詰める（画面・印刷とも）。 */
.report-page { position: relative; }
.report-watermark {
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background-image: url("data:image/svg+xml,%3Csvg%20xmlns='http://www.w3.org/2000/svg'%20width='330'%20height='230'%3E%3Ctext%20x='12'%20y='140'%20transform='rotate(-28%20165%20115)'%20font-family='sans-serif'%20font-size='30'%20font-weight='700'%20fill='%230f3a3a'%20fill-opacity='0.09'%3E無料版%20POSTURA%3C/text%3E%3C/svg%3E");
  background-repeat: repeat;
  /* 印刷時も透かしを残す（配布物の抑止が目的）。 */
  -webkit-print-color-adjust: exact;
  print-color-adjust: exact;
}
/* 2枚目（トレーニング）をブラーで隠し、CTAを重ねる。 */
.report-page--2.is-locked { position: relative; }
/* タイトル（見出し）はシャープに残し「ここに個別メニューがある」と伝える。
   隠すのは中身のトレーニンググリッドのみ。 */
.report-page--2.is-locked .training-grid {
  filter: blur(10px);
  pointer-events: none;
  user-select: none;
}
.paywall-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  background: rgba(246, 248, 250, 0.35);
  z-index: 2;
}
.limit-reached {
  display: flex;
  justify-content: center;
  padding: 2.5rem 1rem;
}
.paywall-cta {
  max-width: 340px;
  text-align: center;
  background: #fff;
  border: 1px solid var(--border-strong);
  border-radius: 16px;
  padding: 1.8rem 1.5rem;
  box-shadow: 0 10px 40px rgba(15, 30, 45, 0.18);
}
.paywall-cta__title {
  font-size: 1.15rem;
  font-weight: 800;
  color: #0f3a3a;
  margin-bottom: 0.55rem;
}
.paywall-cta__sub {
  font-size: 0.92rem;
  color: var(--muted);
  line-height: 1.65;
  margin: 0 0 1.25rem;
}
.upgrade-btn {
  display: inline-block;
  background: linear-gradient(180deg, #1d6e6a 0%, #0f3a3a 100%);
  color: #fff;
  font-weight: 700;
  text-decoration: none;
  padding: 0.75rem 1.5rem;
  border-radius: 11px;
  box-shadow: var(--shadow-sm);
  transition: filter 0.15s ease, transform 0.08s ease;
}
.upgrade-btn:hover { filter: brightness(1.08); }
.upgrade-btn:active { transform: translateY(1px); }

/* ===== Print rules ===== */
@page {
  size: A4 portrait;
  margin: 0;
}
@media print {
  .no-print { display: none !important; }
  .upload-grid { display: none !important; }
  body {
    background: #fff;
    margin: 0;
  }
  .app-main { padding: 0; max-width: none; margin: 0; }
  .summary-section {
    box-shadow: none;
    border: none;
    padding: 0;
    background: transparent;
  }
  .summary-output { padding: 0; }
  .report-page {
    margin: 0;
    box-shadow: none;
    border-radius: 0;
    width: 210mm;
    min-height: 297mm;
    padding: 12mm 12mm 10mm;
  }
}
