/* 음성 채팅 — Claude 대화 화면의 배치와 입력창 흐름을 참고한 공개 페이지 */
:root {
  --bg: rgb(255, 253, 254); --surface: #ffffff; --bubble: #f4e9ef; --hover: rgba(91, 55, 74, .06);
  --text: #261d23; --text-2: #655760; --text-3: #786772;
  --border: rgba(91, 55, 74, .16); --border-strong: rgba(91, 55, 74, .32);
  --accent: #a14f72; --accent-hover: #893f5f; --on-accent: #ffffff;
  --wave: #dac8d2; --wave-played: #33242d;
  --danger: #af334f; --danger-bg: #fceef2; --warn: #76581c; --warn-bg: #fbf2e7;
  --focus: #aa5279;
  --shadow: 0 4px 20px rgba(91, 55, 74, .04), 0 0 0 .5px rgba(91, 55, 74, .06);
  --menu-shadow: 0 12px 32px rgba(61, 35, 49, .12);
  --sans: Inter, Pretendard, -apple-system, BlinkMacSystemFont, "Segoe UI", "Apple SD Gothic Neo", "Noto Sans KR", sans-serif;
  --serif: "Noto Serif KR", "Nanum Myeongjo", AppleMyungjo, ui-serif, Georgia, serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #282128; --surface: #332a31; --bubble: #211a21; --hover: rgba(244, 225, 235, .08);
    --text: #fefafc; --text-2: #d2c2cd; --text-3: #b6a2ae;
    --border: rgba(244, 225, 235, .15); --border-strong: rgba(244, 225, 235, .3);
    --accent: #d994b2; --accent-hover: #e7abc6; --on-accent: #281922;
    --wave: #67515f; --wave-played: #fefafc;
    --danger: #ffabbc; --danger-bg: #432530; --warn: #ead09b; --warn-bg: #393027;
    --focus: #e4a4c1;
    --shadow: 0 4px 20px rgba(15, 8, 13, .2), 0 0 0 .5px rgba(244, 225, 235, .1);
    --menu-shadow: 0 12px 32px rgba(15, 8, 13, .45);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; background: var(--bg); color: var(--text); font: 15px/1.6 var(--sans); font-synthesis: none; }
button { font: inherit; color: inherit; }
svg { display: block; flex: none; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

/* 상단 */
.top { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 16px; height: 56px; padding: 0 20px; background: var(--bg); border-bottom: 1px solid transparent; transition: border-color .2s; }
.top.scrolled { border-bottom-color: var(--border); }
.brand { font-size: 17px; font-weight: 800; letter-spacing: -.4px; color: var(--text); text-decoration: none; white-space: nowrap; }
.brand span { font-weight: 500; }
.top nav { display: flex; gap: 2px; }
.top nav a { padding: 6px 10px; border-radius: 8px; color: var(--text-2); text-decoration: none; font-size: 13.5px; white-space: nowrap; }
.top nav a:hover { background: var(--hover); color: var(--text); }
.top nav a[aria-current="page"] { color: var(--text); font-weight: 600; }
.new { margin-left: auto; display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 12px; border: 1px solid var(--border); border-radius: 10px; background: transparent; font-size: 13.5px; cursor: pointer; }
.new:hover { background: var(--hover); }

/* 접고 펼칠 수 있는 좌측 대화 목록 */
body.history-open { padding-left: 272px; }
.history { position: fixed; inset: 0 auto 0 0; z-index: 30; display: flex; flex-direction: column; width: 272px; padding: 22px 16px 16px; border-right: 1px solid var(--border); background: var(--bg); visibility: hidden; transform: translateX(-100%); transition: transform .18s ease, visibility .18s; }
body.history-open .history { visibility: visible; transform: translateX(0); }
.history-heading { display: flex; align-items: center; justify-content: space-between; margin-bottom: 22px; }
.history-heading h2 { margin: 0; font-size: 14px; font-weight: 600; }
.history .new { flex: none; justify-content: flex-start; width: 100%; height: 40px; margin: 0 0 22px; background: var(--surface); }
.history .new span { display: inline; }
.history-scroll { flex: 1; min-height: 0; overflow-y: auto; margin: 0 -6px; padding: 0 6px; }
.history-empty { margin: 22px 10px; color: var(--text-3); font-size: 13px; line-height: 1.8; }
.session-list { margin: 0; padding: 0; list-style: none; }
.session-row { display: flex; align-items: center; gap: 2px; margin: 3px 0; border-radius: 10px; }
.session-row:hover { background: var(--hover); }
.session-row.selected { background: var(--bubble); }
.session-open { flex: 1; min-width: 0; padding: 11px 10px; border: 0; border-radius: 10px; background: none; text-align: left; cursor: pointer; }
.session-open strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; font-weight: 500; }
.session-open small { display: block; margin-top: 3px; color: var(--text-3); font-size: 11.5px; }
.session-delete { display: grid; place-items: center; flex: none; width: 30px; height: 30px; margin-right: 5px; padding: 0; border: 0; border-radius: 7px; background: none; color: var(--text-3); cursor: pointer; }
.session-delete:hover:not(:disabled) { background: var(--danger-bg); color: var(--danger); }
.history-more { width: 100%; margin-top: 12px; padding: 8px; border: 1px solid var(--border); border-radius: 8px; background: none; color: var(--text-2); font-size: 12px; cursor: pointer; }
.history button:disabled { cursor: default; opacity: .5; }
.history-note { margin: 14px 4px 0; font-size: 11.5px; line-height: 1.7; color: var(--text-3); }
.history-note.error { color: var(--danger); }
.history-toggle, .history-close { display: grid; place-items: center; flex: none; width: 32px; height: 32px; padding: 0; border: 0; border-radius: 8px; background: none; cursor: pointer; }
.history-close { font-size: 25px; line-height: 1; }
.history-toggle:hover, .history-close:hover { background: var(--hover); }
.history-backdrop { position: fixed; inset: 0; z-index: 25; border: 0; background: rgba(38, 29, 35, .24); }
@media (max-width: 1000px) {
  body.history-open { padding-left: 0; overflow: hidden; }
  .history { width: min(300px, 86vw); box-shadow: var(--menu-shadow); }
}
@media (max-width: 380px) { .brand span { display: none; } }

/* 페이지 색상과 동일한 삭제 확인창 */
body.dialog-open { overflow: hidden; }
.delete-dialog { width: min(500px, calc(100vw - 32px)); max-height: calc(100dvh - 32px); margin: auto; padding: 28px; border: 1px solid var(--border); border-radius: 26px; background: var(--bg); color: var(--text); box-shadow: 0 24px 80px rgba(61,35,49,.18), var(--shadow); font: inherit; }
.delete-dialog[open] { animation: dialog-enter .18s ease-out; }
.delete-dialog::backdrop { background: rgba(38, 29, 35, .22); backdrop-filter: blur(5px); }
@keyframes dialog-enter { from { opacity: 0; transform: translateY(8px) scale(.98); } to { opacity: 1; transform: translateY(0) scale(1); } }
.delete-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.delete-close { display: grid; place-items: center; width: 32px; height: 32px; margin-right: -6px; border: 0; border-radius: 9px; background: transparent; color: var(--text-3); font-size: 25px; cursor: pointer; }
.delete-close:hover { background: var(--hover); }
.delete-dialog h2 { margin: 0; font-size: 22px; font-weight: 600; letter-spacing: -.6px; }
#delete-description { margin: 0; color: var(--text-3); font-size: 13px; line-height: 1.8; }
.delete-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 24px; }
.delete-actions button { min-width: 0; height: 44px; padding: 0 16px; border: 1px solid var(--border); border-radius: 12px; font-size: 13.5px; font-weight: 600; cursor: pointer; }
.delete-cancel { background: var(--surface); color: var(--text-2); }
.delete-cancel:hover { background: var(--hover); }
.delete-actions .delete-confirm { border-color: var(--border); background: var(--bubble); color: var(--accent); }
.delete-actions .delete-confirm:hover { background: color-mix(in srgb, var(--bubble) 85%, var(--accent)); }

/* 본문 배치 */
main { flex: 1; display: flex; flex-direction: column; width: 100%; }
.col { width: 100%; max-width: 768px; margin-left: auto; margin-right: auto; padding-left: 16px; padding-right: 16px; }
main.empty { justify-content: center; padding-bottom: 10vh; }
main:not(.empty) .welcome, main.empty .thread { display: none; }
.welcome { text-align: center; margin-bottom: 26px; }
.welcome h1 { display: flex; align-items: center; justify-content: center; gap: 12px; margin: 0 0 6px; font: 400 clamp(25px, 4.2vw, 36px)/1.3 var(--serif); letter-spacing: -.3px; }
.welcome p { margin: 0; color: var(--text-2); font-size: 14.5px; }
.mark { color: var(--accent); display: inline-flex; }

/* 대화 */
.thread { list-style: none; margin-top: 0; margin-bottom: 0; padding-top: 28px; padding-bottom: 20px; flex: 1; display: flex; flex-direction: column; gap: 22px; }
.msg.user { display: flex; justify-content: flex-end; }
.bubble { max-width: min(85%, 600px); background: var(--bubble); border-radius: 18px; padding: 10px 16px; white-space: pre-wrap; overflow-wrap: anywhere; }
.msg.bot { display: flex; flex-direction: column; align-items: flex-start; gap: 10px; }
.who { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-2); }
.who .mark svg { width: 20px; height: 20px; }
.msg.bot.busy .who .mark { animation: breathe 1.4s ease-in-out infinite; }
.state { display: flex; align-items: center; gap: 10px; font-size: 14px; color: var(--text-2); }
.dots { display: inline-flex; gap: 4px; }
.dots i { width: 6px; height: 6px; border-radius: 50%; background: var(--text-3); animation: dot 1.2s infinite ease-in-out; }
.dots i:nth-child(2) { animation-delay: .15s; }
.dots i:nth-child(3) { animation-delay: .3s; }
@keyframes dot { 0%, 80%, 100% { opacity: .25; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-2px); } }
@keyframes breathe { 50% { opacity: .35; } }

.player { display: flex; align-items: center; gap: 12px; width: 100%; max-width: 560px; padding: 9px 14px 9px 9px; border: 1px solid var(--border); border-radius: 18px; background: var(--surface); box-shadow: var(--shadow); }
.play { flex: none; display: grid; place-items: center; width: 38px; height: 38px; border: 0; border-radius: 50%; background: var(--text); color: var(--bg); cursor: pointer; }
.play:hover { opacity: .88; }
.wave { flex: 1; min-width: 0; height: 36px; border-radius: 4px; cursor: pointer; touch-action: none; }
.time { font-size: 12.5px; color: var(--text-2); font-variant-numeric: tabular-nums; white-space: nowrap; }
.meta { display: flex; flex-wrap: wrap; row-gap: 2px; margin: 0; font-size: 12.5px; color: var(--text-3); font-variant-numeric: tabular-nums; }
.meta span { white-space: nowrap; }
.meta span + span::before { content: "·"; margin: 0 7px; }
.meta .stall { color: var(--warn); }
.actions { display: flex; flex-wrap: wrap; gap: 2px; margin-left: -8px; }
.act { display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 8px; border: 0; border-radius: 8px; background: none; color: var(--text-3); font-size: 12.5px; cursor: pointer; }
.act:hover:not(:disabled) { background: var(--hover); color: var(--text); }
.act:disabled { opacity: .4; cursor: default; }
.err { display: flex; gap: 8px; align-items: flex-start; margin: 0; padding: 10px 14px; border-radius: 12px; background: var(--danger-bg); color: var(--danger); font-size: 14px; }
.err svg { margin-top: 3px; }

/* 입력창 */
.dock { position: sticky; bottom: 0; z-index: 5; padding-bottom: max(14px, env(safe-area-inset-bottom)); background: linear-gradient(to bottom, transparent, var(--bg) 22px); }
main.empty .dock { position: static; background: none; }
.composer { position: relative; padding: 14px 12px 10px 18px; background: var(--surface); border: 1px solid var(--border); border-radius: 20px; box-shadow: var(--shadow); transition: border-color .15s; }
.composer:focus-within { border-color: var(--border-strong); }
textarea { display: block; width: 100%; min-height: 28px; max-height: 220px; margin: 0; padding: 2px 6px 10px 0; border: 0; outline: 0; resize: none; background: transparent; color: var(--text); font: inherit; font-size: 16px; line-height: 1.6; }
textarea:focus-visible { outline: none; }
textarea::placeholder { color: var(--text-3); }
.bar { display: flex; align-items: center; gap: 6px; margin-left: -8px; }
.pickers { flex: 1; min-width: 0; display: flex; flex-wrap: wrap; align-items: center; gap: 2px; }
.pick { display: inline-flex; align-items: center; gap: 6px; min-width: 0; height: 32px; padding: 0 9px; border: 0; border-radius: 9px; background: transparent; color: var(--text-2); font-size: 13.5px; cursor: pointer; }
.pick span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pick:hover:not(:disabled), .pick[aria-expanded="true"] { background: var(--hover); color: var(--text); }
.pick:disabled { opacity: .45; cursor: default; }
.pick .chev { opacity: .65; }
.pick.off span { text-decoration: line-through; text-decoration-color: var(--text-3); }
.count { font-size: 12px; color: var(--text-3); font-variant-numeric: tabular-nums; white-space: nowrap; }
.count.over { color: var(--danger); font-weight: 600; }
.send { flex: none; display: grid; place-items: center; width: 34px; height: 34px; border: 0; border-radius: 10px; background: var(--accent); color: var(--on-accent); cursor: pointer; transition: background .15s, opacity .15s; }
.send:hover:not(:disabled) { background: var(--accent-hover); }
.send:disabled { opacity: .35; cursor: default; }
.send.stop { background: var(--text); color: var(--bg); }

.menu { position: absolute; left: 8px; bottom: calc(100% + 8px); z-index: 20; width: 300px; max-width: calc(100vw - 48px); max-height: min(420px, 60vh); overflow-y: auto; padding: 6px; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--menu-shadow); }
.menu-title { padding: 6px 10px 4px; font-size: 12px; color: var(--text-3); }
.item { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 9px; cursor: pointer; outline: 0; }
.item:hover, .item:focus { background: var(--hover); }
.item:focus-visible { box-shadow: inset 0 0 0 2px var(--focus); }
.item .txt { min-width: 0; }
.item .txt.row { display: flex; align-items: baseline; gap: 8px; }
.item .txt.row small { display: inline; }
.menu.down { bottom: auto; top: calc(100% + 8px); }
.item b { display: block; font-size: 14px; font-weight: 600; }
.item small { display: block; font-size: 12px; color: var(--text-3); overflow-wrap: anywhere; }
.item .check { margin-left: auto; color: var(--accent); visibility: hidden; }
.item[aria-checked="true"] .check { visibility: visible; }
.item[aria-disabled="true"] { cursor: not-allowed; }
.item[aria-disabled="true"] b { color: var(--text-3); }

.notice { display: flex; align-items: center; gap: 10px; margin: 0 0 10px; padding: 9px 14px; border-radius: 12px; background: var(--warn-bg); color: var(--warn); font-size: 13.5px; }
.notice button { margin-left: auto; height: 28px; padding: 0 10px; border: 1px solid currentColor; border-radius: 8px; background: none; cursor: pointer; font-size: 12.5px; }

@media (max-width: 560px) {
  .top { gap: 8px; padding: 0 12px; }
  .brand { font-size: 15px; }
  .top nav a { padding: 6px 7px; font-size: 13px; }
  .new { padding: 0 9px; }
  .new span { display: none; }
  .bubble { max-width: 90%; }
  .player { padding-right: 10px; gap: 10px; }
  .act span { display: none; }
  .act { width: 34px; justify-content: center; padding: 0; }
  .pick { padding: 0 7px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}

.menu-help { margin: 5px 10px; padding-top: 8px; border-top: 1px solid var(--border); color: var(--text-3); font-size: 12px; }

/* Fish 참조 음성 첨부 */
.reference { margin: 4px 4px 12px 0; padding: 10px 12px; border: 1px solid var(--border); border-radius: 12px; background: var(--bg); }
.reference-head { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 600; }
.reference-head > span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.reference-head .act { width: auto; }
.reference-help { margin: 3px 0; font-size: 12px; color: var(--text-3); }
.reference-help.error { color: var(--danger); }
.reference audio { display: block; width: 100%; height: 34px; margin: 7px 0 10px; }
.reference label { display: block; margin-bottom: 4px; color: var(--text-2); font-size: 12px; }
.reference textarea { min-height: 58px; max-height: 100px; padding: 7px 9px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); font-size: 14px; resize: vertical; }
.reference textarea:focus { border-color: var(--border-strong); }
