/* ============================================================
   縁 -enishi- Design System v2
   「静かな和紙 × 墨 × 金」— 恋愛アプリの軽さではなく、
   信頼を預けられる上質さ。スマートフォン最優先。
   ============================================================ */

:root {
  /* 紙と墨 */
  --bg: #faf7f1;          /* 生成りの和紙 */
  --bg2: #f3eee4;         /* 少し焼けた紙 */
  --card: #fffdf8;
  --ink: #262218;         /* 墨 */
  --ink2: #5d564a;
  --ink3: #8d8574;
  --line: #e5ddcc;
  --line2: #d8cdb5;
  /* 金と朱 */
  --gold: #a8862f;
  --gold2: #c9ab5e;
  --gold-soft: #f2e8cf;
  --green: #4a7a52;
  --red: #b0503c;
  --shadow: 0 1px 2px rgba(38,34,24,.04), 0 8px 28px -12px rgba(38,34,24,.14);
  --shadow-lift: 0 2px 4px rgba(38,34,24,.05), 0 18px 44px -16px rgba(38,34,24,.22);
  --serif: "Shippori Mincho", "Hiragino Mincho ProN", "Yu Mincho", "Noto Serif JP", serif;
  --sans: "Zen Kaku Gothic New", "Hiragino Kaku Gothic ProN", "Noto Sans JP", -apple-system, sans-serif;
  --ease: cubic-bezier(.22,.9,.24,1);
  --pad: clamp(18px, 5vw, 26px);
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

body {
  font-family: var(--sans);
  background: var(--bg);
  color: var(--ink2);
  font-size: 15px;
  line-height: 1.85;
  letter-spacing: .015em;
  min-height: 100dvh;
  /* 和紙の繊維感: 微細な斑を重ねる */
  background-image:
    radial-gradient(1200px 500px at 85% -5%, rgba(201,171,94,.10), transparent 60%),
    radial-gradient(900px 420px at -10% 8%, rgba(176,80,60,.05), transparent 55%),
    repeating-linear-gradient(0deg, transparent 0 2px, rgba(38,34,24,.008) 2px 3px),
    repeating-linear-gradient(90deg, transparent 0 3px, rgba(38,34,24,.006) 3px 4px);
  background-attachment: fixed;
}

.app {
  max-width: 480px;
  margin: 0 auto;
  padding: var(--pad);
  padding-bottom: calc(96px + env(safe-area-inset-bottom));
  min-height: 100dvh;
}

/* ---------- ページ遷移: ふわりと立ち上がる ---------- */
.page-in { animation: pageIn .5s var(--ease) both; }
@keyframes pageIn {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: none; }
}
/* 子要素の時間差リビール */
.reveal > * { animation: pageIn .6s var(--ease) both; }
.reveal > *:nth-child(1) { animation-delay: .02s }
.reveal > *:nth-child(2) { animation-delay: .08s }
.reveal > *:nth-child(3) { animation-delay: .14s }
.reveal > *:nth-child(4) { animation-delay: .20s }
.reveal > *:nth-child(5) { animation-delay: .26s }
.reveal > *:nth-child(6) { animation-delay: .32s }
.reveal > *:nth-child(7) { animation-delay: .38s }
.reveal > *:nth-child(8) { animation-delay: .44s }

/* ---------- タイポグラフィ ---------- */
h1, h2, h3, .serif { font-family: var(--serif); color: var(--ink); font-weight: 600; }
h2 { font-size: 22px; letter-spacing: .06em; margin-bottom: 10px; }
h3 { font-size: 14px; letter-spacing: .12em; color: var(--ink2); margin: 14px 0 6px; }
p { margin: 8px 0; }
.small { font-size: 12.5px; color: var(--ink3); line-height: 1.9; }
.center { text-align: center; }
.mt { margin-top: 14px; } .mtl { margin-top: 30px; }
.hidden { display: none !important; }
b { color: var(--ink); font-weight: 600; }

/* 章見出し(英字の小さなラベル) */
.mark, .daily-date {
  font-size: 10.5px;
  letter-spacing: .42em;
  text-indent: .42em;
  color: var(--gold);
  text-align: center;
  font-weight: 500;
  margin: 18px 0 6px;
}
.mark::before, .mark::after,
.daily-date::before, .daily-date::after {
  content: "";
  display: inline-block;
  width: 26px; height: 1px;
  background: linear-gradient(90deg, transparent, var(--gold2));
  vertical-align: middle;
  margin: 0 10px 3px;
}
.daily-date::after, .mark::after { background: linear-gradient(90deg, var(--gold2), transparent); }

/* ---------- ヒーロー: 円相(えんそう)と「縁」 ---------- */
.hero { text-align: center; padding: 34px 0 10px; }
.hero .enso {
  width: 168px; height: 168px;
  margin: 8px auto 2px;
  display: grid; place-items: center;
  position: relative;
}
.hero .enso svg { position: absolute; inset: 0; overflow: visible; }
.hero .enso circle {
  fill: none;
  stroke: var(--gold2);
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-dasharray: 470;
  stroke-dashoffset: 470;
  transform: rotate(-80deg);
  transform-origin: center;
  animation: enso 1.6s .2s var(--ease) forwards;
  opacity: .9;
}
@keyframes enso { to { stroke-dashoffset: 52; } } /* 円相は閉じきらない */
.hero h1 {
  font-size: 84px;
  font-weight: 500;
  letter-spacing: 0;
  line-height: 1;
  position: relative;
  animation: inkIn 1.1s .35s var(--ease) both;
}
@keyframes inkIn {
  from { opacity: 0; filter: blur(6px); transform: scale(.96); }
  to   { opacity: 1; filter: blur(0); transform: none; }
}
.hero .sub {
  font-family: var(--serif);
  color: var(--ink3);
  letter-spacing: .5em;
  text-indent: .5em;
  font-size: 12px;
  margin-top: 14px;
}
.hero .lead { margin-top: 26px; font-size: 15px; line-height: 2.15; }

/* 理念カード */
.principle {
  border-left: 2px solid var(--gold2);
  padding: 4px 0 4px 18px;
  margin: 26px 0;
}
.principle .serif { font-size: 16.5px; letter-spacing: .04em; }
.principle .small { margin-top: 4px; }

/* ---------- ボタン ---------- */
.btn {
  display: block; width: 100%;
  border: none; cursor: pointer;
  font-family: var(--sans);
  font-size: 15px; font-weight: 600;
  letter-spacing: .1em; text-indent: .1em;
  color: #fffdf6;
  background: linear-gradient(160deg, #383226, #262218 60%);
  border-radius: 999px;
  padding: 15px 20px;
  box-shadow: var(--shadow-lift);
  position: relative; overflow: hidden;
  transition: transform .18s var(--ease), box-shadow .18s var(--ease), opacity .2s;
}
.btn::after { /* 金の光が一度だけ流れる */
  content: "";
  position: absolute; inset: 0;
  background: linear-gradient(115deg, transparent 30%, rgba(201,171,94,.28) 50%, transparent 70%);
  transform: translateX(-120%);
  animation: sheen 3.2s 1.2s ease-in-out 1;
}
@keyframes sheen { 12% { transform: translateX(120%); } 100% { transform: translateX(120%); } }
.btn:active { transform: scale(.975); box-shadow: var(--shadow); }
.btn:disabled { opacity: .55; transform: none; }
.btn.subtle {
  background: var(--card);
  color: var(--ink);
  border: 1px solid var(--line2);
  box-shadow: var(--shadow);
}
.btn.ghost {
  background: transparent;
  color: var(--ink3);
  border: 1px solid var(--line2);
  box-shadow: none;
}
.btn.ghost::after, .btn.subtle::after { display: none; }
.btn.sm { padding: 10px 16px; font-size: 13px; width: auto; display: inline-block; }
.linklike {
  background: none; border: none; cursor: pointer;
  font-family: var(--sans); font-size: 13px;
  color: var(--gold);
  text-decoration: underline;
  text-underline-offset: 4px;
  text-decoration-color: var(--gold2);
  padding: 4px 0;
}

/* ---------- フォーム ---------- */
label { display: block; margin: 16px 0 6px; font-size: 12.5px; letter-spacing: .08em; color: var(--ink2); }
input, select, textarea {
  width: 100%;
  font-family: var(--sans); font-size: 15px;
  color: var(--ink);
  background: var(--card);
  border: 1px solid var(--line2);
  border-radius: 12px;
  padding: 13px 14px;
  transition: border-color .2s, box-shadow .2s;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--gold2);
  box-shadow: 0 0 0 3px rgba(201,171,94,.18);
}
textarea { min-height: 96px; resize: vertical; line-height: 1.8; }
.row { display: flex; gap: 12px; } .row > * { flex: 1; }
.notice {
  background: var(--gold-soft);
  border: 1px solid var(--gold2);
  border-radius: 12px;
  padding: 12px 14px;
  font-size: 12.5px;
  color: #6b5a28;
  margin-top: 14px;
  line-height: 1.9;
}

/* ---------- 診断 ---------- */
.q-progress {
  height: 3px; border-radius: 99px;
  background: var(--line);
  margin: 18px 0 22px;
  overflow: hidden;
}
.q-progress > div {
  height: 100%;
  background: linear-gradient(90deg, var(--gold2), var(--gold));
  border-radius: 99px;
  transition: width .5s var(--ease);
}
.q-title {
  font-family: var(--serif);
  font-size: 20px; color: var(--ink);
  line-height: 1.7; letter-spacing: .03em;
  margin: 6px 0 22px;
  min-height: 68px;
}
.opt {
  display: flex; align-items: center; gap: 14px;
  width: 100%; text-align: left;
  font-family: var(--sans); font-size: 14.5px; color: var(--ink);
  background: var(--card);
  border: 1px solid var(--line2);
  border-radius: 14px;
  padding: 15px 16px;
  margin: 10px 0;
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: transform .16s var(--ease), border-color .16s, background .16s;
}
.opt::before {
  content: attr(data-i);
  flex: 0 0 26px; height: 26px;
  display: grid; place-items: center;
  font-family: var(--serif); font-size: 12px;
  color: var(--gold);
  border: 1px solid var(--gold2);
  border-radius: 50%;
}
.opt:active { transform: scale(.98); }
.opt.chosen {
  border-color: var(--gold);
  background: var(--gold-soft);
  animation: chosen .3s var(--ease);
}
@keyframes chosen { 40% { transform: scale(.97); } }

/* ---------- カード ---------- */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 20px;
  margin: 16px 0;
  box-shadow: var(--shadow);
}

/* ---------- 分析結果 ---------- */
.arch-name {
  font-family: var(--serif);
  font-size: clamp(30px, 9vw, 38px);
  color: var(--ink);
  text-align: center;
  letter-spacing: .08em;
  margin-top: 18px;
  animation: inkIn 1s .15s var(--ease) both;
}
.arch-line { text-align: center; color: var(--ink3); font-size: 13px; margin: 6px 0 10px; }
.axis { margin: 16px 0 4px; }
.axis .name { font-size: 12.5px; letter-spacing: .1em; color: var(--ink2); margin-bottom: 7px; }
.axis .bar {
  position: relative; height: 4px;
  background: var(--line);
  border-radius: 99px;
}
.axis .fill {
  position: absolute; inset: 0 auto 0 0;
  background: linear-gradient(90deg, var(--gold2), var(--gold));
  border-radius: 99px;
  animation: growBar 1s .3s var(--ease) both;
  transform-origin: left;
}
@keyframes growBar { from { transform: scaleX(0); } }
.axis .dot {
  position: absolute; top: 50%;
  width: 11px; height: 11px;
  background: var(--card);
  border: 2px solid var(--gold);
  border-radius: 50%;
  transform: translate(-50%, -50%);
  box-shadow: 0 1px 4px rgba(38,34,24,.25);
  animation: pageIn .4s 1s var(--ease) both;
}
.axis .lbls { display: flex; justify-content: space-between; font-size: 10.5px; color: var(--ink3); margin-top: 5px; }

.badge {
  display: inline-block;
  font-size: 11px; letter-spacing: .06em;
  border: 1px solid var(--line2);
  color: var(--ink2);
  border-radius: 999px;
  padding: 3px 11px;
  margin: 2px 4px 2px 0;
  background: var(--card);
}
.badge.green { color: var(--green); border-color: #b5cbb9; background: #f0f6f1; }
.badge.gold { color: var(--gold); border-color: var(--gold2); background: var(--gold-soft); }

.share-img {
  width: 100%; border-radius: 14px;
  border: 1px solid var(--line);
  box-shadow: var(--shadow-lift);
  margin: 8px 0;
}
.snsrow { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-top: 8px; }
.snsrow .btn { padding: 11px 4px; font-size: 12.5px; letter-spacing: .04em; text-indent: 0; }

/* ---------- 今日の一人 ---------- */
.countdown {
  font-family: var(--serif);
  font-size: 56px;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
  letter-spacing: .1em;
  margin: 10px 0;
  animation: breathe 3.4s ease-in-out infinite;
}
@keyframes breathe { 50% { opacity: .55; } }

.pick-card {
  border: 1px solid var(--gold2);
  box-shadow: var(--shadow-lift);
  position: relative;
  overflow: hidden;
  padding: 24px 22px;
}
.pick-card::before { /* 封緘の金線 */
  content: "";
  position: absolute; inset: 0 0 auto 0; height: 3px;
  background: linear-gradient(90deg, transparent, var(--gold2) 30%, var(--gold) 50%, var(--gold2) 70%, transparent);
}
.pick-name { font-family: var(--serif); font-size: 26px; color: var(--ink); letter-spacing: .05em; }
.pick-meta { font-size: 12.5px; color: var(--ink3); margin: 2px 0 10px; }
.why {
  font-family: var(--serif);
  font-size: 15.5px; line-height: 2.1;
  color: var(--ink);
  background: linear-gradient(180deg, var(--bg2), transparent);
  border-radius: 12px;
  padding: 16px 16px;
  margin: 12px 0;
  position: relative;
}
.why::before {
  content: "なぜ、この二人か";
  display: block;
  font-size: 10px; letter-spacing: .34em;
  color: var(--gold);
  margin-bottom: 6px;
}
ul.fits, ul.frictions { list-style: none; margin: 4px 0; }
ul.fits li, ul.frictions li {
  position: relative;
  padding-left: 20px;
  font-size: 13.5px;
  margin: 7px 0;
  line-height: 1.85;
}
ul.fits li::before {
  content: "○";
  position: absolute; left: 0; top: 0;
  color: var(--green); font-size: 11px;
}
ul.frictions li::before {
  content: "△";
  position: absolute; left: 0; top: 0;
  color: var(--red); font-size: 11px;
}

/* ---------- チャット ---------- */
.chat { padding: 14px 0 8px; display: flex; flex-direction: column; gap: 10px; min-height: 40vh; }
.msg {
  max-width: 82%;
  padding: 11px 15px;
  font-size: 14.5px; line-height: 1.8;
  border-radius: 18px;
  position: relative;
  animation: msgIn .3s var(--ease) both;
  word-break: break-word;
}
@keyframes msgIn { from { opacity: 0; transform: translateY(6px) scale(.97); } }
.msg.mine {
  align-self: flex-end;
  background: linear-gradient(160deg, #383226, #262218);
  color: #f6f2e8;
  border-bottom-right-radius: 6px;
}
.msg.theirs {
  align-self: flex-start;
  background: var(--card);
  border: 1px solid var(--line);
  border-bottom-left-radius: 6px;
  box-shadow: var(--shadow);
}
.msg .at { display: block; font-size: 9.5px; opacity: .55; margin-top: 4px; letter-spacing: .05em; }
.safety {
  font-size: 12px;
  color: #7a5c22;
  background: var(--gold-soft);
  border: 1px dashed var(--gold2);
  border-radius: 12px;
  padding: 10px 14px;
  line-height: 1.8;
  animation: pageIn .4s var(--ease) both;
}
.polish-sheet {
  border: 1px solid var(--gold2); border-radius: 14px;
  background: var(--gold-soft); padding: 14px 16px; margin: 10px 0;
  animation: pageIn .4s var(--ease) both;
}
.polish-sheet h3 { font-family: var(--serif); font-size: 14px; font-weight: 600; color: var(--gold); }
.polish-sheet pre {
  white-space: pre-wrap; word-break: break-word; margin: 8px 0 0;
  font-family: inherit; font-size: 13.5px; line-height: 1.8; color: var(--ink);
}
.chatbar {
  position: sticky;
  bottom: calc(74px + env(safe-area-inset-bottom));
  display: flex; gap: 8px; align-items: flex-end;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  padding: 10px 0;
  border-top: 1px solid var(--line);
}
.chatbar textarea { min-height: 46px; max-height: 120px; border-radius: 999px; padding: 12px 18px; }
.chatbar .btn { width: auto; padding: 12px 18px; flex-shrink: 0; }
.guide-toggle { font-size: 12px; color: var(--gold); cursor: pointer; letter-spacing: .05em; }

/* AI添削の提案シート */
.polish-sheet {
  border: 1px solid var(--gold2);
  background: var(--card);
  border-radius: 16px;
  padding: 16px;
  margin: 10px 0;
  box-shadow: var(--shadow-lift);
  animation: pageIn .35s var(--ease) both;
}
.polish-sheet pre {
  font-family: var(--sans);
  white-space: pre-wrap;
  font-size: 13.5px; color: var(--ink); line-height: 1.9;
}

/* ---------- プラン ---------- */
.plan {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 18px 20px;
  margin: 14px 0;
  box-shadow: var(--shadow);
  transition: transform .2s var(--ease);
}
.plan.current {
  border-color: var(--gold);
  background: linear-gradient(180deg, var(--gold-soft), var(--card) 45%);
}
.plan b { font-family: var(--serif); font-size: 17px; letter-spacing: .08em; }
.plan .pr { float: right; font-family: var(--serif); font-size: 19px; color: var(--ink); }

/* ---------- スケルトン ---------- */
.skel {
  border-radius: 14px;
  background: linear-gradient(100deg, var(--bg2) 40%, #efe8d8 50%, var(--bg2) 60%);
  background-size: 200% 100%;
  animation: skel 1.3s linear infinite;
  border: 1px solid var(--line);
}
@keyframes skel { to { background-position: -200% 0; } }

/* ---------- タブバー ---------- */
.tabbar {
  position: fixed;
  left: 50%; transform: translateX(-50%);
  bottom: calc(12px + env(safe-area-inset-bottom));
  width: min(456px, calc(100% - 24px));
  display: flex;
  background: color-mix(in srgb, #fffdf8 88%, transparent);
  backdrop-filter: blur(14px) saturate(1.2);
  -webkit-backdrop-filter: blur(14px) saturate(1.2);
  border: 1px solid var(--line2);
  border-radius: 22px;
  box-shadow: var(--shadow-lift);
  padding: 6px;
  z-index: 50;
}
.tabbar button {
  flex: 1;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  background: none; border: none; cursor: pointer;
  font-family: var(--sans); font-size: 10px; letter-spacing: .08em;
  color: var(--ink3);
  padding: 8px 2px 7px;
  border-radius: 16px;
  transition: color .2s, background .25s var(--ease);
}
.tabbar button svg { width: 21px; height: 21px; stroke: currentColor; fill: none; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.tabbar button.active {
  color: var(--gold);
  background: var(--gold-soft);
}
.tabbar button.active svg { stroke-width: 1.9; }
.tabbar button:active { transform: scale(.94); }

/* ---------- トースト ---------- */
.toast {
  position: fixed;
  left: 50%; transform: translateX(-50%);
  bottom: calc(96px + env(safe-area-inset-bottom));
  max-width: min(420px, calc(100% - 40px));
  background: #262218;
  color: #f6f2e8;
  font-size: 13px; line-height: 1.7;
  border-radius: 14px;
  padding: 12px 18px;
  box-shadow: var(--shadow-lift);
  z-index: 100;
  animation: toastIn .35s var(--ease) both;
}
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, 10px); } }

/* ---------- その他 ---------- */
::selection { background: var(--gold-soft); }
a { color: var(--gold); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-delay: 0s !important; transition-duration: .01ms !important; }
}
