/* ==========================================================================
   AI · /ai/ Ether & Xync 대화 (brand.css 의 duo 위에 얹는다)
   ========================================================================== */
.ai-app { width: min(100% - 32px, 820px); margin: clamp(40px, 5vw, 64px) auto 0; }
.ai-app > h2 { font-family: var(--f-display); font-weight: var(--w-display); font-size: clamp(1.7rem, 2.6vw, 2.1rem); letter-spacing: -0.02em; line-height: 1.25; margin-bottom: 18px; }

/* ---------- 문(동의·받기·오류) ---------- */
.ai-card { padding: clamp(22px, 3vw, 32px); border: 1px solid var(--line-2); border-radius: var(--r-lg); background: var(--card); box-shadow: var(--shadow-1); }
/* 상태 표시(확인하는 중, 열지 못했어요 …)는 머리표가 아니라 정보 배지 */
.ai-card-cap { display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 10px; border-radius: var(--r-pill); border: 1px solid var(--line-2); background: rgba(255, 255, 255, .03); color: var(--text-2); font-size: .78rem; font-weight: 650; white-space: nowrap; font-variant-numeric: tabular-nums; }
.ai-card-cap::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.ai-card h3 { margin-top: 12px; font-size: var(--t-h3); letter-spacing: -0.02em; }
.ai-card > p { margin-top: 12px; color: var(--text-2); max-width: 46em; }
.ai-card-actions { display: flex; flex-wrap: wrap; gap: 10px 12px; margin-top: 22px; }
.ai-line { font-family: var(--f-serif); font-size: 1.15rem; color: var(--text); margin-top: 22px !important; }
.ai-small { font-size: var(--t-small); color: var(--text-3); margin-top: 14px; }
.ai-small code { font-family: var(--f-mono); font-size: .78rem; overflow-wrap: anywhere; }

.ai-tiers { margin: 20px 0 0; padding: 0; border: 0; display: grid; gap: 8px; }
.ai-tiers legend { font-size: var(--t-small); color: var(--text-3); margin-bottom: 8px; }
.ai-tier { display: grid; grid-template-columns: auto 1fr; column-gap: 12px; align-items: center; padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--r-md); cursor: pointer; transition: border-color var(--d-2), background var(--d-2); }
.ai-tier:hover { border-color: var(--line-2); }
.ai-tier.is-on { border-color: var(--ether); background: var(--ether-dim); }
.ai-tier input { margin: 0; accent-color: var(--ether); grid-row: span 2; }
.ai-tier-name { font-weight: 650; }
.ai-tier-name em { font-style: normal; font-weight: 500; color: var(--text-2); margin-left: 6px; font-variant-numeric: tabular-nums; }
.ai-tier-note { font-size: var(--t-small); color: var(--text-3); }

.ai-progress { position: relative; height: 6px; margin-top: 18px; border-radius: var(--r-pill); background: rgba(255,255,255,.06); overflow: hidden; }
.ai-progress span { position: absolute; inset: 0; transform-origin: left; transform: scaleX(0); background: linear-gradient(90deg, var(--ether), var(--xync)); transition: transform var(--d-2) linear; }
.ai-progress-text { margin-top: 10px; font-variant-numeric: tabular-nums; color: var(--text-2); }

/* ---------- 대화 ---------- */
.ai-chat { display: grid; gap: 12px; }
.ai-bar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.ai-seg { display: inline-flex; padding: 4px; border: 1px solid var(--line-2); border-radius: var(--r-pill); background: rgba(255,255,255,.03); }
.ai-seg button { height: 38px; padding: 0 18px; border: 0; border-radius: var(--r-pill); background: transparent; color: var(--text-2); font-weight: 650; transition: color var(--d-1), background var(--d-1); }
.ai-seg button:active { transform: scale(.97); }
.ai-seg button[data-persona="ether"].is-on { color: var(--ether-ink); background: var(--ether); }
.ai-seg button[data-persona="xync"].is-on { color: var(--xync-ink); background: var(--xync); }
.ai-tools { margin-left: auto; display: flex; gap: 4px; }
.ai-tools button { height: 36px; padding: 0 12px; border: 0; border-radius: var(--r-pill); background: transparent; color: var(--text-3); font-size: var(--t-small); font-weight: 600; transition: color var(--d-1), background var(--d-1); }
.ai-tools button:hover { color: var(--text); background: rgba(255,255,255,.05); }
.ai-cap { font-size: var(--t-mono); font-family: var(--f-mono); color: var(--text-3); }
.ai-notice { padding: 10px 14px; border-radius: var(--r-md); background: var(--xync-dim); color: var(--text-2); font-size: var(--t-small); }
.ai-notice a { color: var(--text); font-weight: 650; text-decoration: underline; text-underline-offset: 3px; }

.ai-log { display: grid; gap: 14px; align-content: start; max-height: min(62vh, 640px); min-height: 240px; overflow-y: auto; padding: 18px; border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--panel); overscroll-behavior: contain; }
.msg { max-width: 86%; display: grid; gap: 4px; animation: xy-in var(--d-2) var(--ease-out) both; }
.msg.is-user { justify-self: end; }
.msg-who { font-size: .8rem; font-weight: 650; color: var(--text-3); }
.ai-chat[data-who="ether"] .msg.is-ai .msg-who { color: var(--ether); }
.ai-chat[data-who="xync"] .msg.is-ai .msg-who { color: var(--xync); }
.msg-body { padding: 12px 16px; border-radius: 18px; line-height: 1.65; overflow-wrap: anywhere; }
.msg.is-ai .msg-body { background: var(--card-2); border: 1px solid var(--line); border-top-left-radius: 6px; }
.msg.is-user .msg-body { background: var(--text); color: var(--bg); border-top-right-radius: 6px; }
.msg-retry { justify-self: start; border: 0; background: none; padding: 2px 4px; color: var(--text-3); font-size: var(--t-small); font-weight: 600; transition: color var(--d-1); }
.msg-retry:hover { color: var(--text); }
.dots { display: inline-flex; gap: 5px; align-items: center; height: 1.2em; }
.dots i { width: 6px; height: 6px; border-radius: 50%; background: var(--text-3); animation: ai-dot 900ms ease-in-out infinite; }
.dots i:nth-child(2) { animation-delay: 150ms; } .dots i:nth-child(3) { animation-delay: 300ms; }
@keyframes ai-dot { 0%, 60%, 100% { opacity: .35; transform: translateY(0); } 30% { opacity: 1; transform: translateY(-3px); } }

.ai-crisis { padding: 14px 16px; border-radius: var(--r-md); border: 1px solid rgba(255, 138, 102, .45); background: var(--xync-dim); }
.ai-crisis strong { display: block; }
.ai-crisis p { margin-top: 6px; color: var(--text-2); font-size: var(--t-small); }
.ai-crisis ul { list-style: none; margin-top: 8px; display: grid; gap: 4px; font-size: var(--t-small); }
.ai-crisis a { font-weight: 750; color: var(--text); text-decoration: underline; text-underline-offset: 3px; font-variant-numeric: tabular-nums; }

.ai-composer { display: grid; grid-template-columns: 1fr auto; gap: 8px; align-items: end; }
.ai-composer textarea { width: 100%; min-height: 48px; max-height: 160px; padding: 12px 16px; resize: none; border: 1px solid var(--line-input); border-radius: 24px; background: var(--card); color: var(--text); line-height: 1.5; font-size: 16px; transition: border-color var(--d-2), box-shadow var(--d-2); }
.ai-composer textarea:focus { border-color: var(--ether); }
.ai-composer textarea:disabled { opacity: .6; }
.ai-composer .btn { height: 48px; }
.ai-foot { font-size: var(--t-small); color: var(--text-3); }
.ai-foot a { color: var(--text-2); text-decoration: underline; text-underline-offset: 3px; }

/* ---------- 어떻게 동작하나요 ---------- */
.ai-how { width: min(100% - 32px, 820px); margin-inline: auto; padding: clamp(56px, 7vw, 88px) 0 clamp(72px, 9vw, 120px); border-top: 1px solid var(--line); }
.ai-how h2 { font-family: var(--f-display); font-weight: var(--w-display); font-size: var(--t-h2); letter-spacing: -0.02em; line-height: 1.2; }
.ai-how ul { list-style: none; margin-top: 22px; display: grid; gap: 14px; }
.ai-how li { display: grid; gap: 4px; padding-left: 18px; border-left: 1px solid var(--line-2); }
.ai-how li strong { color: var(--text); }
.ai-how li span { color: var(--text-2); }

@media (max-width: 700px) {
  .ai-app { width: min(100% - 24px, 820px); }
  .ai-card { padding: 20px; border-radius: var(--r-md); }
  .ai-log { max-height: 56vh; padding: 12px; }
  .msg { max-width: 92%; }
  .ai-tools { margin-left: 0; width: 100%; justify-content: flex-end; }
}
