﻿:root {
  --paper: #f1e4c7;
  --paper-deep: #e5d2a8;
  --ink: #1f1a15;
  --ink-soft: #4d3b2d;
  --line: #a7865d;
  --accent: #6e4f2e;
  --accent-deep: #4d351d;
  --ash: #c8b692;
  --ash-deep: #b59c72;
  --ok: #275e33;
  --warn: #7f1d1d;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: "Batang", "Times New Roman", serif;
  background:
    radial-gradient(circle at 18% 12%, rgba(255, 255, 240, 0.25), transparent 34%),
    radial-gradient(circle at 86% 92%, rgba(158, 118, 66, 0.2), transparent 30%),
    repeating-linear-gradient(
      0deg,
      rgba(117, 80, 35, 0.045) 0,
      rgba(117, 80, 35, 0.045) 1px,
      transparent 1px,
      transparent 4px
    ),
    linear-gradient(160deg, var(--paper), var(--paper-deep));
}

.shell {
  max-width: 980px;
  margin: 0 auto;
  padding: 24px 16px 40px;
}

.page {
  display: none;
}

.page.is-active {
  display: block;
  animation: pageFade 0.35s ease;
}

.intro-frame,
.rule-frame,
.analyze-frame {
  border: 2px solid var(--line);
  border-radius: 18px;
  padding: 16px;
  background: rgba(250, 242, 223, 0.88);
  box-shadow: 0 14px 28px rgba(41, 27, 16, 0.18);
}

.hero-wrap {
  position: relative;
  display: flex;
  flex-direction: column;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid #8f6e44;
  min-height: 260px;
  background: #120f0d;
}

.hero-image {
  width: 100%;
  height: min(84vh, 1100px);
  object-fit: contain;
  background: #050505;
  display: block;
}

.hero-text {
  margin: 0;
  text-align: center;
  color: #ffffff;
  letter-spacing: 0.01em;
  font-size: clamp(1.25rem, 2.2vw, 2rem);
  font-weight: 700;
  line-height: 1.3;
  padding: 10px 14px;
  background: #0a0a0a;
  border-bottom: 1px solid rgba(255, 255, 255, 0.18);
}

.intro-actions {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin-top: 14px;
}

.decline-text {
  margin: 12px 0 0;
  text-align: center;
  font-size: 1.15rem;
  color: #5f1320;
  font-weight: 700;
}

.btn {
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 10px 20px;
  font-size: 1rem;
  font-family: inherit;
  cursor: pointer;
  transition: transform 0.08s ease, background-color 0.2s ease;
}

.btn:hover {
  transform: translateY(-1px);
}

.btn-ink {
  background: var(--accent);
  color: #f7ecce;
  border-color: #4d351d;
}

.btn-ink:hover {
  background: var(--accent-deep);
}

.btn-ash {
  background: var(--ash);
  color: #2a2118;
  border-color: #8a7150;
}

.btn-ash:hover {
  background: var(--ash-deep);
}

.btn:disabled {
  background: #b7a486;
  border-color: #9e8a69;
  color: #534032;
  cursor: not-allowed;
  transform: none;
}

.rule-frame h1 {
  margin: 0 0 10px;
  text-align: center;
  font-size: clamp(1.6rem, 2.6vw, 2.2rem);
}

.rule-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.rule-item {
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1px solid #b39267;
  border-radius: 10px;
  padding: 12px;
  background: rgba(255, 248, 229, 0.7);
  opacity: 0;
  transform: translateY(-10px);
  animation: ruleDrop 0.4s ease forwards;
  animation-delay: var(--delay, 0s);
}

.rule-delay-1 {
  --delay: 0.05s;
}

.rule-delay-2 {
  --delay: 0.12s;
}

.rule-delay-3 {
  --delay: 0.19s;
}

.rule-delay-4 {
  --delay: 0.26s;
}

.rule-delay-5 {
  --delay: 0.33s;
}

.rule-delay-6 {
  --delay: 0.4s;
}

.rule-delay-7 {
  --delay: 0.47s;
}

.rule-check {
  inline-size: 18px;
  block-size: 18px;
  accent-color: #6c502f;
}

.rule-hint {
  margin: 12px 0 0;
  text-align: center;
  color: var(--ink-soft);
  font-weight: 600;
}

.rule-hint.done {
  color: var(--ok);
}

#analyzePage.page.is-active {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: calc(100vh - 64px);
}

#completePage.page.is-active {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: calc(100vh - 64px);
}

#resultPage.page.is-active {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: calc(100vh - 64px);
}

.analyze-frame {
  inline-size: min(86vmin, 560px);
  min-height: 280px;
  max-height: 86vh;
  margin: 0 auto;
  background: #ffffff;
  border: 2px solid #d9c7a7;
  box-shadow: 0 16px 30px rgba(38, 26, 15, 0.14);
  padding: 26px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: 12px;
}

.upload-title {
  margin: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  font-size: clamp(1.8rem, 4.2vw, 2.8rem);
  line-height: 1.1;
  font-weight: 800;
  color: #2f2216;
  background: #f5e8cb;
  border: 2px solid #8f724f;
  border-radius: 12px;
  padding: 10px 24px;
  box-shadow: 0 8px 18px rgba(72, 49, 21, 0.15);
  cursor: pointer;
  transition: transform 0.08s ease, background-color 0.2s ease;
}

.upload-title:hover {
  background: #f0deb8;
  transform: translateY(-1px);
}

.analyze-hint {
  margin: 0;
  color: var(--ink-soft);
  text-align: center;
  font-weight: 700;
}

#photoInput {
  display: none;
}

.notice-box {
  width: 100%;
  margin-top: 6px;
  border: 1px solid #d8c4a0;
  background: #fdf8ea;
  border-radius: 12px;
  padding: 14px;
}

.notice-box h3 {
  margin: 0 0 10px;
  font-size: 1.25rem;
}

.notice-box p {
  margin: 0 0 10px;
  color: #3e2f20;
  line-height: 1.5;
}

.notice-box p:last-child {
  margin-bottom: 0;
}

.complete-frame {
  inline-size: min(86vmin, 560px);
  min-height: 260px;
  margin: 0 auto;
  background: #ffffff;
  border: 2px solid #d9c7a7;
  border-radius: 18px;
  box-shadow: 0 16px 30px rgba(38, 26, 15, 0.14);
  padding: 26px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  text-align: center;
}

.complete-frame h2 {
  margin: 0;
  font-size: clamp(1.8rem, 4vw, 2.6rem);
}

.complete-frame p {
  margin: 0;
  color: var(--ink-soft);
  font-weight: 700;
}

.result-frame {
  inline-size: min(92vmin, 680px);
  max-height: 86vh;
  margin: 0 auto;
  background: #ffffff;
  border: 2px solid #d9c7a7;
  border-radius: 18px;
  box-shadow: 0 16px 30px rgba(38, 26, 15, 0.14);
  padding: 24px;
  overflow-y: auto;
}

.result-frame h2 {
  margin: 0;
  text-align: center;
  font-size: clamp(1.8rem, 4vw, 2.6rem);
}

#resultStatus {
  margin: 8px 0 0;
  text-align: center;
  color: var(--ink-soft);
  font-weight: 700;
}

.result-summary {
  margin: 12px 0 0;
  padding: 10px 12px;
  border: 1px solid #d3be97;
  border-radius: 10px;
  background: #f9f2de;
  text-align: center;
  font-weight: 700;
}

.result-metrics {
  list-style: none;
  margin: 12px 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.result-actions {
  margin-top: 12px;
  display: flex;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
}

.share-link-preview {
  margin: 10px 0 0;
  padding: 8px 10px;
  border: 1px dashed #d0b98f;
  border-radius: 8px;
  background: #fff8ea;
  color: #4f3d2c;
  text-align: center;
  font-size: 0.92rem;
  word-break: break-all;
}

.result-metrics li {
  border: 1px solid #d5c19d;
  background: #fef9ee;
  border-radius: 10px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.result-metrics.report-mode {
  gap: 12px;
}

.result-metrics.report-mode .report-section {
  border: 1px solid #cdb58d;
  background: #fffdf8;
  border-radius: 12px;
  padding: 12px;
  gap: 10px;
}

.result-metrics.report-mode .report-section-other {
  border: 1px solid #bfa47a;
  border-left: 5px solid #8a6236;
  background: linear-gradient(180deg, #f8f1e1 0%, #fffaf0 100%);
  box-shadow: inset 0 0 0 1px #ebddc3;
}

.result-metrics.report-mode .report-section-other .report-title {
  color: #6b4b27;
  border-bottom: 1px solid #d2ba94;
}

.result-metrics.report-mode .report-section-other .report-line {
  color: #4f3a27;
}

.report-title {
  font-size: 1.04rem;
  font-weight: 900;
  color: #2f2217;
  padding-bottom: 6px;
  border-bottom: 1px dashed #d9c4a0;
}

.report-body {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.report-line {
  color: #53402e;
  line-height: 1.56;
  word-break: keep-all;
}

.report-status {
  padding: 6px 8px;
  border-radius: 8px;
  border: 1px solid #dcc39d;
  background: #f8f1e0;
  font-weight: 800;
  color: #3d2c1e;
}

.report-basis {
  padding: 5px 8px;
  border-radius: 8px;
  border: 1px dashed #d7bf98;
  background: #fff8ea;
  color: #5b432c;
  font-size: 0.95rem;
}

.report-divider {
  height: 0;
  border-top: 1px dashed #d7bf98;
  margin: 2px 0 4px;
}

.report-label {
  font-weight: 800;
  color: #3b2a1d;
  margin-right: 4px;
}

.report-triad-upper .report-label,
.report-triad-upper .report-text {
  color: #4f3622;
}

.report-triad-middle .report-label,
.report-triad-middle .report-text {
  color: #4f3622;
}

.report-triad-lower .report-label,
.report-triad-lower .report-text {
  color: #5a3f2c;
}

.metric-title {
  font-weight: 800;
}

.metric-keywords {
  color: #4e3b2a;
  font-weight: 700;
}

.metric-basis {
  color: #4f3d2c;
  font-size: 0.94rem;
  font-weight: 700;
}

.metric-divider {
  height: 0;
  border-top: 1px dashed #d7bf98;
  margin: 2px 0 4px;
}

.metric-desc {
  color: #5a4632;
  line-height: 1.5;
  white-space: pre-line;
}

.result-disclaimer {
  margin: 12px 0 0;
  color: #5a4632;
  font-size: 0.95rem;
  line-height: 1.5;
}

.analysis-spinner {
  width: 58px;
  height: 58px;
  border-radius: 50%;
  border: 6px solid #e2d2b6;
  border-top-color: #7b5a34;
  animation: spin 1s linear infinite;
}

@media (max-width: 860px) {
  .analyze-frame {
    inline-size: 92vmin;
    max-height: 88vh;
  }

  .complete-frame {
    inline-size: 92vmin;
  }

  .result-frame {
    inline-size: 92vmin;
    max-height: 88vh;
  }

  .hero-image {
    height: 68vh;
  }
}

@keyframes pageFade {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes ruleDrop {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

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