/* ツタワルの個性: 航空便(エアメール)の青と赤、便箋の白 */
:root {
  --brand: #2f5bd3; --brand-ink: #fff; --brand-soft: #e7edfc; --brand-strong: #2448ad;
  --mail-red: #d6453d;
  --note-bg: #fff6e0; --note-ink: #6b4a00;
  --bg: #f5f6f9; --line: #e1e4ec; --line-strong: #c5cad6;
}
@media (prefers-color-scheme: dark) {
  :root[data-dark="auto"]:not([data-theme="light"]) {
    --brand: #6f93ff; --brand-ink: #0b1430; --brand-soft: #1b2648; --brand-strong: #9db6ff;
    --note-bg: #2e2510; --note-ink: #f3d58b; --bg: #111318; --surface: #1a1d24; --surface-2: #232733; --line: #2a2f3b; --line-strong: #3d4352;
  }
}

body { padding-bottom: 72px; }
main { padding-top: var(--s4); }

/* 航空便のふち */
.airmail { height: 8px; border-radius: 4px; background: repeating-linear-gradient(-45deg, var(--mail-red) 0 14px, transparent 14px 22px, var(--brand) 22px 36px, transparent 36px 44px); opacity: .9; margin-bottom: var(--s5); }
.airmail--thin { height: 6px; margin: calc(var(--s5) * -1) calc(var(--s5) * -1) var(--s5); border-radius: var(--r-lg) var(--r-lg) 0 0; }

.ui-lang__select { font: inherit; font-size: var(--fs-sm); color: var(--ink-2); background: transparent; border: 1px solid var(--line); border-radius: var(--r-pill); padding: 6px 12px; min-height: 36px; max-width: 120px; }

/* ---- はじめての人向け ---- */
.hero { padding: var(--s5) 0 var(--s6); }
.hero__title { font-size: clamp(30px, 8vw, 44px); font-weight: 800; letter-spacing: .01em; margin-bottom: var(--s4); }
.hero__lead { color: var(--ink-2); font-size: var(--fs-lg); margin-bottom: var(--s5); }
.hero__cta { display: grid; gap: var(--s2); margin-bottom: var(--s6); }
.points { list-style: none; padding: 0; margin: 0; display: grid; gap: var(--s3); }
.points li { display: flex; gap: var(--s3); align-items: center; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); padding: var(--s3) var(--s4); }
.points li > span { font-size: 24px; }
.points b { display: block; } .points div span { color: var(--ink-2); font-size: var(--fs-sm); }
@media (min-width: 768px) {
  .hero__cta { grid-template-columns: auto auto; justify-content: start; }
  .points { grid-template-columns: repeat(3, 1fr); }
  .points li { flex-direction: column; align-items: flex-start; }
}
.section-title { font-size: var(--fs-sm); color: var(--ink-2); font-weight: 700; letter-spacing: .06em; margin: var(--s5) 0 var(--s3); }

/* ---- 登録・ログイン ---- */
.auth { max-width: 460px; margin: var(--s4) auto 0; }
.auth__title { font-size: var(--fs-2xl); font-weight: 800; padding: 0; margin-bottom: var(--s2); }
.auth__lead { color: var(--ink-2); margin-bottom: var(--s5); }
.auth__switch { text-align: center; margin: var(--s5) 0 var(--s2); color: var(--ink-2); font-size: var(--fs-sm); }
.link { background: none; border: 0; padding: 4px; font: inherit; color: var(--brand-strong); font-weight: 700; text-decoration: underline; text-underline-offset: .2em; cursor: pointer; }
fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }
.step-count { font-size: var(--fs-xs); color: var(--ink-3); margin: calc(var(--s3) * -1) 0 var(--s3); font-weight: 700; letter-spacing: .06em; }
.step-nav { display: flex; gap: var(--s2); margin-top: var(--s5); }
.step-nav .n-btn:last-child { flex: 1; }
.lang-grid { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s2); }
.lang-opt { min-height: 56px; border: 1.5px solid var(--line-strong); background: var(--surface); color: var(--ink); border-radius: var(--r-md); font: inherit; font-weight: 700; cursor: pointer; text-align: left; padding: 0 var(--s4); display: flex; align-items: center; justify-content: space-between; }
.lang-opt[aria-checked="true"] { border-color: var(--brand); background: var(--brand-soft); color: var(--brand-strong); }
.lang-opt[aria-checked="true"]::after { content: "✓"; }
.safety { display: flex; gap: var(--s2); font-size: var(--fs-sm); color: var(--ink-2); background: var(--surface-2); border-radius: var(--r-md); padding: var(--s3); margin: 0; }
#signupErr, #loginErr { margin-bottom: var(--s4); }

/* ---- アバター ---- */
.avatar { --h: 220; width: 40px; height: 40px; flex: none; border-radius: 50%; display: grid; place-items: center; font-weight: 800; color: #fff; background: hsl(var(--h) 55% 48%); font-size: 16px; border: 0; }
.avatar--btn { cursor: pointer; width: 36px; height: 36px; }
.avatar--lg { width: 64px; height: 64px; font-size: 26px; }
.avatar--ai { background: linear-gradient(135deg, var(--mail-red), var(--brand)); }

/* ---- 投稿 ---- */
.composer { margin-bottom: var(--s4); }
.composer .n-textarea { border: 0; padding: var(--s2); min-height: 80px; box-shadow: none; }
.composer .n-textarea:focus { box-shadow: none; }
.composer__bar { display: flex; align-items: center; gap: var(--s3); border-top: 1px solid var(--line); padding-top: var(--s3); margin-top: var(--s2); }
.composer__hint { flex: 1; margin: 0; font-size: var(--fs-xs); }
.composer__bar .n-count { float: none; }
#postErr { margin-top: var(--s3); }
.feed { display: grid; gap: var(--s3); }
.post { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: var(--s4); }
.post--topic { border: 0; background: linear-gradient(135deg, #2f5bd3, #7a3fa0 70%, #b8404f); color: #fff; }
.post--topic .meta, .post--topic .act { color: rgb(255 255 255 / .85); }
.post--topic .act:hover { background: rgb(255 255 255 / .15); color: #fff; }
.post__head { display: flex; gap: var(--s3); align-items: center; margin-bottom: var(--s2); }
.post__who { min-width: 0; }
.post__name { font-weight: 700; line-height: 1.3; }
.meta { font-size: var(--fs-xs); color: var(--ink-3); line-height: 1.4; }
.post__body { font-size: var(--fs-md); white-space: pre-wrap; }
.post--topic .post__body { font-size: var(--fs-xl); font-weight: 800; line-height: 1.45; }
.note { display: flex; gap: var(--s2); background: var(--note-bg); color: var(--note-ink); border-radius: var(--r-md); padding: var(--s3); font-size: var(--fs-sm); margin-top: var(--s3); line-height: 1.6; }
.note b { flex: none; }
.orig { font-size: var(--fs-sm); color: var(--ink-2); border-left: 3px solid var(--line-strong); padding-left: var(--s3); margin-top: var(--s3); white-space: pre-wrap; }
.status { display: inline-flex; gap: 6px; align-items: center; font-size: var(--fs-xs); font-weight: 700; padding: 4px 10px; border-radius: var(--r-pill); margin-top: var(--s3); }
.status--pending { background: var(--brand-soft); color: var(--brand-strong); }
.status--rejected { background: var(--danger-soft); color: var(--danger); }
.acts { display: flex; gap: var(--s1); margin: var(--s3) calc(var(--s2) * -1) calc(var(--s2) * -1); }
.act { background: none; border: 0; color: var(--ink-2); font: inherit; font-size: var(--fs-sm); font-weight: 600; min-height: 40px; padding: 0 var(--s3); border-radius: var(--r-pill); cursor: pointer; display: inline-flex; gap: 6px; align-items: center; }
.act:hover { background: var(--surface-2); color: var(--ink); }
.act[aria-expanded="true"] { color: var(--brand-strong); }
.replies { margin-top: var(--s3); padding-top: var(--s3); border-top: 1px dashed var(--line); display: grid; gap: var(--s3); }
.replies .post { border: 0; padding: 0; background: none; }
.replies .avatar { width: 30px; height: 30px; font-size: 13px; }
.reply-form { display: flex; gap: var(--s2); align-items: flex-end; }
.reply-form .n-textarea { min-height: 48px; height: 48px; }
.more { text-align: center; margin: var(--s5) 0; }

/* スケルトン */
.post--skel .n-skel { margin-bottom: var(--s2); }

/* ---- 文通 ---- */
.pen-hero { overflow: hidden; }
.pen-hero h2 { font-size: var(--fs-xl); }
.pen-hero p { color: var(--ink-2); }
.waiting { display: grid; grid-template-columns: auto 1fr; gap: var(--s1) var(--s3); align-items: start; background: var(--brand-soft); border-radius: var(--r-md); padding: var(--s3) var(--s4); color: var(--brand-strong); }
.waiting #cancelBtn { grid-column: 2; justify-self: start; margin-left: calc(var(--s3) * -1); } .waiting b { display: block; } .waiting span { font-size: var(--fs-sm); }
.plane { font-size: 24px; animation: fly 2.4s ease-in-out infinite; }
@keyframes fly { 50% { transform: translate(6px, -4px) rotate(-8deg); } }
#penErr { margin-top: var(--s3); }
.match-list { display: grid; gap: var(--s2); }
.match { display: flex; gap: var(--s3); align-items: center; width: 100%; text-align: left; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: var(--s4); font: inherit; color: inherit; cursor: pointer; }
.match:hover { border-color: var(--brand); }
.match__main { flex: 1; min-width: 0; }
.match__name { font-weight: 700; }
.turn { background: var(--mail-red); color: #fff; font-size: var(--fs-xs); font-weight: 700; padding: 2px 10px; border-radius: var(--r-pill); white-space: nowrap; }
.common { font-size: var(--fs-xs); color: var(--brand-strong); font-weight: 600; }

.letter-head { display: flex; gap: var(--s3); align-items: center; padding: var(--s3) 0 var(--s4); border-bottom: 1px solid var(--line); margin-bottom: var(--s4); }
.letter-head .n-btn { margin-left: calc(var(--s3) * -1); }
.thread { display: grid; gap: var(--s3); margin-bottom: var(--s5); }
.letter { max-width: 88%; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg) var(--r-lg) var(--r-lg) 4px; padding: var(--s4); position: relative; }
.letter.mine { margin-left: auto; background: var(--brand-soft); border-color: transparent; border-radius: var(--r-lg) var(--r-lg) 4px var(--r-lg); }
.letter__text { white-space: pre-wrap; }
.letter .meta { margin-top: var(--s2); }
.writer { position: sticky; bottom: 72px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: var(--s3); box-shadow: var(--shadow-2); }
.writer .n-textarea { border: 0; padding: var(--s2); box-shadow: none; }
.idea { font-size: var(--fs-sm); color: var(--ink-2); background: var(--surface-2); border-radius: var(--r-md); padding: var(--s2) var(--s3); margin-bottom: var(--s2); }
.letter-tools { display: flex; gap: var(--s2); justify-content: center; margin: var(--s5) 0; }

/* ---- 自分 ---- */
.me-card { display: flex; gap: var(--s4); align-items: center; margin-bottom: var(--s3); }
.me-card h2 { margin: 0; }
#meView .n-card { margin-bottom: var(--s3); }
#meView .n-chips { margin: var(--s3) 0; }
.rules { padding-left: 1.2em; margin: 0; color: var(--ink-2); font-size: var(--fs-sm); }
.rules li + li { margin-top: var(--s2); }

/* PC では下部ナビを上のタブにする */
@media (min-width: 768px) {
  body { padding-bottom: 0; }
  .n-bottomnav { position: sticky; top: 56px; bottom: auto; max-width: var(--measure); margin: 0 auto; border: 0; background: var(--bg); padding: var(--s3) var(--gutter) 0; gap: var(--s2); }
  .n-bottomnav button { flex-direction: row; min-height: 44px; font-size: var(--fs-sm); border-radius: var(--r-pill); gap: var(--s2); background: var(--surface); border: 1px solid var(--line); }
  .n-bottomnav [aria-current="page"] { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); }
  .n-bottomnav .ico { font-size: 16px; }
  .n-dot { position: static; }
  .writer { bottom: var(--s4); }
  body:has(.n-bottomnav:not([hidden])) .n-header { border-bottom: 0; }
}

body:has(#bottomnav:not([hidden])) .n-toast { bottom: calc(76px + env(safe-area-inset-bottom)); }
.how { list-style: none; counter-reset: how; padding: 0; margin: var(--s4) 0 0; display: grid; gap: var(--s3); }
.how li { counter-increment: how; display: flex; gap: var(--s3); align-items: baseline; color: var(--ink-2); font-size: var(--fs-sm); }
.how li::before { content: counter(how); flex: none; width: 24px; height: 24px; border-radius: 50%; background: var(--brand-soft); color: var(--brand-strong); font-weight: 800; display: grid; place-items: center; font-size: 12px; }
@media (min-width: 768px) { body:has(#bottomnav:not([hidden])) .n-toast { bottom: var(--s5); } }

/* ロゴ: エアメールの切手のようなマークと、手紙の宛名のような斜体の英字 */
.n-logo { gap: 10px; color: var(--brand-strong); }
.n-logo img { flex: none; border-radius: 8px; }
.n-logo span { font-family: "Avenir Next", "Segoe UI", "Helvetica Neue", system-ui, sans-serif; font-style: italic; font-weight: 800; font-size: 21px; letter-spacing: -.01em; }
.n-logo span, .n-header .n-btn { white-space: nowrap; }
@media (max-width: 420px) { .n-logo span { font-size: 19px; } .n-logo img { width: 28px; height: 28px; } }
