:root {
  color-scheme: light;
  --bg: #f5f2eb;
  --surface: #fffdf8;
  --surface-strong: #ffffff;
  --ink: #22211e;
  --muted: #67635b;
  --line: #d8d1c5;
  --teal: #11796f;
  --teal-dark: #0b5f58;
  --amber: #d89117;
  --red: #c7433f;
  --green: #39845a;
  --blue: #396a9f;
  --shadow: 0 16px 36px rgba(49, 43, 34, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family:
    Inter, "Noto Sans JP", "Hiragino Kaku Gothic ProN", "Yu Gothic", Meiryo,
    sans-serif;
}

button,
input,
select {
  font: inherit;
}

button,
.file-button {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
  color: var(--ink);
  padding: 0 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  transition:
    transform 120ms ease,
    border-color 120ms ease,
    background 120ms ease;
}

button:hover,
.file-button:hover {
  border-color: #a69d8d;
  transform: translateY(-1px);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
  transform: none;
}

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

.file-button input {
  display: none;
}

.app-header {
  min-height: 96px;
  padding: 22px clamp(18px, 4vw, 44px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 253, 248, 0.82);
  backdrop-filter: blur(12px);
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand-lockup {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 16px;
}

.hpi-header-logo {
  width: clamp(88px, 10vw, 142px);
  height: auto;
  flex: 0 0 auto;
  display: block;
  object-fit: contain;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--teal-dark);
  font-size: 0.74rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(1.6rem, 3vw, 2.4rem);
  line-height: 1.1;
}

h2 {
  margin-bottom: 14px;
  font-size: 1.05rem;
}

.status-pill {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 12px;
  color: var(--muted);
  background: var(--surface);
  white-space: nowrap;
}

.header-copy {
  margin: 8px 0 0;
  color: var(--muted);
  font-weight: 700;
  line-height: 1.5;
}

.header-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

.contact-button {
  min-height: 40px;
  border: 1px solid var(--teal);
  border-radius: 8px;
  padding: 9px 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--surface-strong);
  color: var(--teal-dark);
  font-weight: 900;
  text-decoration: none;
  white-space: nowrap;
}

.contact-button:hover {
  background: #eef8f4;
}

.primary-contact {
  border-color: var(--teal);
  background: var(--teal);
  color: #fff;
}

.primary-contact:hover {
  background: var(--teal-dark);
}

.app-shell {
  width: min(1440px, 100%);
  margin: 0 auto;
  padding: 22px clamp(14px, 3vw, 34px) 40px;
}

.start-panel {
  margin-bottom: 18px;
  padding: clamp(18px, 3vw, 28px);
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(300px, 0.7fr);
  align-items: center;
  gap: 22px;
  border: 1px solid rgba(17, 121, 111, 0.22);
  border-radius: 8px;
  background: linear-gradient(135deg, #fffdf8 0%, #eef8f4 100%);
  box-shadow: var(--shadow);
}

.start-copy h2 {
  margin: 0 0 12px;
  font-size: clamp(1.45rem, 3vw, 2.45rem);
  line-height: 1.18;
}

.start-copy p {
  max-width: 820px;
  margin: 0;
  color: var(--muted);
  font-weight: 700;
  line-height: 1.8;
}

.start-badges,
.insight-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.start-badges {
  margin-top: 16px;
}

.start-badges span,
.insight-list span {
  border: 1px solid rgba(17, 121, 111, 0.22);
  border-radius: 999px;
  padding: 7px 10px;
  background: rgba(255, 255, 255, 0.72);
  color: var(--teal-dark);
  font-size: 0.82rem;
  font-weight: 900;
  white-space: nowrap;
}

.start-action-card {
  padding: 16px;
  border: 1px solid rgba(17, 121, 111, 0.18);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.72);
}

.guide-button {
  width: 100%;
  min-height: 56px;
  border-color: var(--teal);
  background: var(--teal);
  color: #fff;
  font-size: 1.02rem;
  font-weight: 900;
}

.guide-button:hover {
  background: var(--teal-dark);
}

.start-action-card p {
  margin: 12px 0 14px;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 800;
  line-height: 1.7;
}

.guide-panel {
  margin: 12px 0 14px;
  padding: 12px;
  display: grid;
  gap: 8px;
  border: 1px solid rgba(17, 121, 111, 0.22);
  border-radius: 8px;
  background: #fffdf8;
  color: var(--ink);
  font-size: 0.9rem;
  font-weight: 800;
  line-height: 1.55;
}

.guide-panel[hidden] {
  display: none;
}

.guide-panel strong {
  color: var(--teal-dark);
}

.guide-jump-button {
  justify-self: start;
  min-height: 36px;
  margin-top: 2px;
  border-color: var(--amber);
  background: #fff4cf;
  color: #5f3b00;
  font-size: 0.86rem;
  font-weight: 900;
}

.guide-jump-button:hover {
  border-color: #ad720f;
  background: #ffe6a1;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 18px;
  align-items: start;
}

.media-panel,
.control-panel,
.score-panel,
.summary-panel,
.comparison-panel,
.projection-panel,
.details {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.media-panel {
  overflow: hidden;
}

.video-stage {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  min-height: 320px;
  max-height: min(68vh, 620px);
  background:
    linear-gradient(90deg, rgba(17, 121, 111, 0.1) 1px, transparent 1px),
    linear-gradient(rgba(17, 121, 111, 0.1) 1px, transparent 1px), #2d2a25;
  background-size: 32px 32px;
}

#overlay {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

#videoDisplay {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: none;
  width: 100%;
  height: 100%;
  background: #151412;
}

#videoDisplay.active {
  display: block;
}

#overlay {
  z-index: 2;
}

video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #151412;
  z-index: 0;
}

video.source-hidden {
  opacity: 0;
}

#overlay {
  pointer-events: none;
}

.event-timeline {
  display: block;
  width: calc(100% - 28px);
  height: 68px;
  margin: 0 14px 12px;
  border: 1px solid rgba(17, 23, 35, 0.12);
  border-radius: 8px;
  background: #fffdf8;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.6);
  cursor: ew-resize;
}

.event-timeline[hidden] {
  display: none;
}

.video-controls {
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 12px;
  z-index: 4;
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  min-height: 48px;
  padding: 8px 10px;
  border-radius: 8px;
  background: rgba(21, 20, 18, 0.78);
  color: #fff;
  backdrop-filter: blur(8px);
}

.video-controls[hidden] {
  display: none;
}

#playPauseButton {
  width: 34px;
  height: 34px;
  padding: 0;
  border-color: rgba(255, 255, 255, 0.4);
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
}

#seekBar {
  width: 100%;
  accent-color: var(--teal);
}

#timeLabel {
  min-width: 92px;
  color: rgba(255, 255, 255, 0.82);
  font-size: 0.82rem;
  font-weight: 800;
  text-align: right;
}

.empty-state {
  position: absolute;
  inset: 0;
  z-index: 3;
  display: grid;
  place-content: center;
  gap: 8px;
  padding: 24px;
  text-align: center;
  color: #fff;
  background: rgba(21, 20, 18, 0.48);
}

.empty-state[hidden] {
  display: none;
}

.empty-state span {
  color: rgba(255, 255, 255, 0.76);
}

.empty-state.countdown {
  background: rgba(21, 20, 18, 0.62);
}

.empty-state.pose-warning {
  align-content: end;
  place-content: end center;
  padding-bottom: 34px;
  background: linear-gradient(
    180deg,
    rgba(21, 20, 18, 0.1) 0%,
    rgba(21, 20, 18, 0.72) 100%
  );
}

.empty-state.pose-warning strong {
  display: inline-block;
  width: min(92vw, 560px);
  border-radius: 8px 8px 0 0;
  padding: 16px 18px 8px;
  background: rgba(199, 67, 63, 0.96);
  font-size: clamp(1.35rem, 3vw, 2.2rem);
  line-height: 1.25;
}

.empty-state.pose-warning span {
  display: inline-block;
  width: min(92vw, 560px);
  border-radius: 0 0 8px 8px;
  padding: 0 18px 16px;
  background: rgba(199, 67, 63, 0.96);
  color: rgba(255, 255, 255, 0.9);
}

.empty-state.loading {
  background: rgba(21, 20, 18, 0.7);
}

.loading-spinner {
  width: 54px;
  height: 54px;
  margin: 0 auto 8px;
  border: 4px solid rgba(255, 255, 255, 0.28);
  border-top-color: #ffffff;
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}

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

.countdown-circle {
  width: clamp(190px, 28vw, 310px);
  aspect-ratio: 1680 / 936;
  margin: 0 auto 14px;
  border: 10px solid rgba(255, 255, 255, 0.92);
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: rgba(17, 121, 111, 0.86);
  color: #fff;
  font-size: clamp(7rem, 17vw, 12rem);
  font-weight: 900;
  line-height: 1;
  box-shadow: 0 18px 42px rgba(0, 0, 0, 0.34);
}

.media-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 14px;
  border-top: 1px solid var(--line);
  background: var(--surface-strong);
}

.download-menu {
  position: relative;
}

.download-menu[hidden] {
  display: none;
}

.download-menu summary {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--surface-strong);
  color: var(--ink);
  font-weight: 900;
  cursor: pointer;
  list-style: none;
}

.download-menu summary::-webkit-details-marker {
  display: none;
}

.download-options {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  z-index: 8;
  min-width: 190px;
  padding: 6px;
  display: grid;
  gap: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
  box-shadow: var(--shadow);
}

.download-options button {
  justify-content: flex-start;
  min-height: 38px;
  width: 100%;
}

.download-status {
  min-height: 20px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

.media-actions.guide-focus,
.rotation-tools.guide-focus {
  animation: guidePulse 1100ms ease-in-out 5;
}

@keyframes guidePulse {
  0%,
  100% {
    box-shadow: inset 0 0 0 0 rgba(216, 145, 23, 0);
    background-color: var(--surface-strong);
  }

  45% {
    box-shadow: inset 0 0 0 4px rgba(216, 145, 23, 0.78);
    background-color: #fff4cf;
  }
}

.rotation-tools {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding: 0 14px 12px;
  background: var(--surface-strong);
}

.rotation-tools > span {
  color: var(--muted);
  font-weight: 800;
  margin-right: 4px;
}

.rotation-button {
  width: 48px;
  height: 42px;
  padding: 0;
  display: inline-grid;
  place-items: center;
}

.rotation-button.active {
  border-color: var(--teal);
  background: #eef8f4;
  color: var(--teal-dark);
  font-weight: 800;
}

.rotate-icon {
  position: relative;
  display: inline-grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border: 2px solid currentColor;
  border-radius: 50%;
  font-size: 0.78rem;
  line-height: 1;
}

.rotate-icon b {
  font-size: 0.72rem;
}

.rotate-arrow {
  position: absolute;
  top: -10px;
  right: -7px;
  font-size: 1.18rem;
  line-height: 1;
  background: #fff;
}

.rotation-button.active .rotate-arrow {
  background: #eef8f4;
}

.rotate-zero {
  border-style: dashed;
  font-weight: 900;
}

.media-note {
  margin: 0;
  padding: 0 14px 14px;
  color: var(--muted);
  background: var(--surface-strong);
  font-size: 0.86rem;
  line-height: 1.6;
}

.control-panel {
  padding: 18px;
}

.panel-section + .panel-section {
  border-top: 1px solid var(--line);
  margin-top: 18px;
  padding-top: 18px;
}

label {
  display: grid;
  gap: 7px;
  margin: 0 0 14px;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 700;
}

select,
input[type="number"] {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 11px;
  background: #fff;
  color: var(--ink);
}

.check-row {
  grid-template-columns: 18px 1fr;
  align-items: center;
  color: var(--ink);
  font-weight: 600;
}

.check-row input {
  width: 18px;
  height: 18px;
}

.result-grid {
  margin-top: 18px;
  display: grid;
  grid-template-columns: 1.15fr 1.25fr 1.35fr 1.25fr;
  gap: 18px;
}

.share-panel {
  margin-top: 18px;
  padding: 18px;
  display: grid;
  grid-template-columns: 1.5fr auto;
  gap: 18px;
  align-items: center;
  border: 1px solid rgba(17, 121, 111, 0.22);
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(17, 121, 111, 0.12), rgba(57, 106, 159, 0.08)),
    var(--surface);
  box-shadow: var(--shadow);
}

.share-panel[hidden] {
  display: none;
}

.share-panel h2 {
  margin-bottom: 6px;
}

.share-panel p {
  margin: 0;
  color: var(--muted);
  line-height: 1.7;
}

.share-card-preview {
  display: block;
  width: 100%;
  max-width: 460px;
  aspect-ratio: 1680 / 936;
  margin-top: 14px;
  border: 1px solid rgba(17, 121, 111, 0.16);
  border-radius: 8px;
  background: #f4fbf8;
  box-shadow: 0 10px 24px rgba(21, 20, 18, 0.08);
}

.share-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.share-primary {
  min-width: 152px;
  min-height: 46px;
  box-shadow: 0 12px 22px rgba(17, 121, 111, 0.18);
}

.person-selector {
  margin-top: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
  padding: 18px;
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 16px;
  align-items: center;
}

.person-selector[hidden] {
  display: none;
}

.person-selector h2 {
  margin-bottom: 0;
}

.person-cards {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.person-card {
  width: 138px;
  min-height: 172px;
  padding: 10px;
  display: grid;
  gap: 8px;
  justify-items: center;
  border: 2px solid var(--line);
  background: var(--surface-strong);
}

.person-card.selected {
  border-color: var(--teal);
  background: #eef8f4;
  box-shadow:
    0 0 0 4px rgba(17, 121, 111, 0.22),
    0 12px 24px rgba(17, 121, 111, 0.16);
}

.person-thumb-wrap {
  width: 104px;
  aspect-ratio: 1;
  padding: 3px;
  border-radius: 10px;
  background: var(--line);
}

.person-card img {
  display: block;
  width: 104px;
  aspect-ratio: 1;
  border-radius: 8px;
  object-fit: cover;
  background: #d8d1c5;
}

.person-card span {
  font-weight: 800;
}

.person-card small {
  color: var(--muted);
  text-align: center;
}

.score-panel,
.summary-panel,
.comparison-panel,
.projection-panel {
  min-height: 190px;
  padding: 18px;
}

.score-panel {
  display: grid;
  gap: 18px;
}

.score-panel h2 {
  margin: 0;
  font-size: clamp(3rem, 8vw, 5.4rem);
  line-height: 0.95;
}

.score-panel small {
  font-size: 1.05rem;
  color: var(--muted);
}

#riskLabel {
  margin: 8px 0 0;
  font-weight: 800;
}

.score-meter {
  height: 12px;
  border-radius: 999px;
  overflow: hidden;
  background: #e7dfd3;
}

.score-meter div {
  width: 0%;
  height: 100%;
  background: var(--green);
  transition:
    width 240ms ease,
    background 240ms ease;
}

.summary-panel p,
.comparison-panel p,
.projection-panel div {
  color: var(--muted);
  line-height: 1.75;
}

.summary-panel,
.comparison-panel,
.projection-panel {
  display: grid;
  align-content: start;
  gap: 12px;
}

.percentile {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 10px;
}

.panel-chart {
  width: 100%;
  height: 140px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffdf8;
}

.percentile span {
  font-size: 1.9rem;
  font-weight: 900;
  color: var(--blue);
  line-height: 1.2;
}

.percentile small {
  color: var(--muted);
  font-weight: 800;
}

.details {
  margin-top: 18px;
  padding: 18px;
}

.detail-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 16px;
}

.detail-header h2 {
  margin-bottom: 0;
}

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

.metric {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: var(--surface-strong);
  min-width: 0;
}

.metric-action {
  cursor: pointer;
}

.metric-action:hover {
  border-color: rgba(17, 121, 111, 0.45);
  background: #f4fbf8;
}

.metric span {
  display: block;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

.metric strong {
  display: block;
  margin-top: 8px;
  font-size: 1.45rem;
}

.timeline-wrap {
  margin-top: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: #fff;
}

#timeline {
  display: block;
  width: 100%;
  height: 140px;
}

.note {
  margin: 14px 0 0;
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.7;
}

.business-panel {
  margin-top: 18px;
  padding: 18px;
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 18px;
  border: 1px solid rgba(17, 121, 111, 0.22);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.business-panel h2 {
  margin-bottom: 8px;
}

.business-panel p {
  margin: 0;
  color: var(--muted);
  line-height: 1.7;
}

.business-copy {
  min-width: 0;
}

.business-brand {
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.business-brand img {
  width: 74px;
  height: auto;
  display: block;
  object-fit: contain;
}

.business-brand .eyebrow {
  margin: 0;
}

.legal-links {
  margin-top: 18px;
  display: flex;
  justify-content: center;
  gap: 18px;
  flex-wrap: wrap;
  color: var(--muted);
  font-weight: 800;
}

.legal-links a,
.legal-panel a {
  color: var(--teal-dark);
}

.legal-shell {
  width: min(920px, 100%);
  margin: 0 auto;
  padding: 24px clamp(14px, 3vw, 34px) 48px;
}

.legal-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: clamp(20px, 4vw, 36px);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.legal-panel h2 {
  margin: 28px 0 10px;
  font-size: 1.15rem;
}

.legal-panel h2:first-of-type {
  margin-top: 10px;
}

.legal-panel p {
  margin: 0;
  color: var(--muted);
  line-height: 1.9;
}

.legal-date {
  font-weight: 800;
}

@media (max-width: 1180px) {
  .start-panel,
  .workspace,
  .person-selector,
  .result-grid,
  .share-panel,
  .business-panel {
    grid-template-columns: 1fr;
  }

  .control-panel {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 18px;
  }

  .panel-section + .panel-section {
    border-top: 0;
    margin-top: 0;
    padding-top: 0;
  }

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

@media (max-width: 720px) {
  .app-shell {
    padding-top: 12px;
  }

  .start-panel {
    padding: 16px;
    gap: 14px;
  }

  .start-copy h2 {
    font-size: 1.5rem;
  }

  .start-copy p {
    font-size: 0.9rem;
    line-height: 1.65;
  }

  .start-badges {
    margin-top: 12px;
  }

  .guide-button {
    min-height: 50px;
  }

  .app-header,
  .detail-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .app-header {
    min-height: 0;
    padding: 10px 14px;
    gap: 8px;
  }

  .brand-lockup {
    width: 100%;
    align-items: center;
    gap: 10px;
  }

  .hpi-header-logo {
    width: 62px;
  }

  .header-actions {
    width: 100%;
    justify-content: stretch;
    gap: 8px;
  }

  .header-actions > * {
    flex: 1 1 140px;
  }

  .app-header .eyebrow {
    display: none;
  }

  h1 {
    font-size: 1.35rem;
  }

  .header-copy {
    margin-top: 3px;
    font-size: 0.78rem;
    line-height: 1.35;
  }

  .contact-button,
  .status-pill {
    min-height: 34px;
    padding: 7px 9px;
    font-size: 0.78rem;
  }

  .status-pill {
    white-space: normal;
  }

  .video-stage {
    min-height: 220px;
  }

  .control-panel,
  .metric-grid {
    grid-template-columns: 1fr;
  }

  .media-actions > * {
    flex: 1 1 140px;
  }

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

  .share-actions > * {
    flex: 1 1 180px;
  }

  .share-card-preview {
    max-width: 100%;
  }
}
