:root{
  --midnight:#141c2b; --midnight-2:#1c2739; --panel:#222f45; --line:#33415c;
  --brass:#c9a86a; --brass-bright:#e6c98a; --ivory:#f2eee6; --muted:#8b97ad;
  --ok:#7fc9a2; --warn:#e0a06a; --danger:#d98080; --radius:14px;
}
*{box-sizing:border-box;margin:0;padding:0;-webkit-tap-highlight-color:transparent;}
html,body{height:100%;}
body{
  background:var(--midnight); color:var(--ivory);
  font-family:"Hiragino Kaku Gothic ProN","Hiragino Sans","Noto Sans JP","Yu Gothic",Meiryo,sans-serif;
  font-size:15px; line-height:1.6;
  display:flex; flex-direction:column; max-width:560px; margin:0 auto; min-height:100dvh;
}
a{color:var(--brass-bright);}
code{font-family:ui-monospace,Menlo,monospace; color:var(--brass-bright); font-size:12px;}
pre{
  background:var(--midnight); border:1px solid var(--line); border-radius:8px;
  padding:8px 10px; margin-top:6px; font-family:ui-monospace,Menlo,monospace;
  font-size:12px; color:var(--brass-bright); overflow-x:auto;
}

/* ---------- header ---------- */
header{padding:14px 18px 10px; display:flex; align-items:center; justify-content:space-between; border-bottom:1px solid var(--line);}
.brand{display:flex; flex-direction:column; gap:1px;}
.brand .eyebrow{font-size:10px; letter-spacing:.28em; color:var(--brass); text-transform:uppercase; font-weight:600;}
.brand h1{font-size:17px; font-weight:700; letter-spacing:.04em;}
.icon-btn{background:var(--midnight-2); border:1px solid var(--line); color:var(--muted); border-radius:10px; padding:7px 11px; font-size:12px; cursor:pointer; font-family:inherit;}
.icon-btn:active{background:var(--panel);}

/* ---------- status ---------- */
.status-strip{display:flex; align-items:center; gap:8px; padding:8px 18px; font-size:12px; color:var(--muted); border-bottom:1px solid var(--line); background:var(--midnight-2);}
.dot{width:8px; height:8px; border-radius:50%; background:var(--muted); flex:none;}
.dot.open{background:var(--ok); animation:blink 2s infinite;}
.dot.listening{background:var(--brass-bright); animation:blink 1s infinite;}
.dot.thinking{background:var(--warn); animation:blink .6s infinite;}
.dot.error{background:var(--danger);}
@keyframes blink{50%{opacity:.35;}}
.status-strip select{margin-left:auto; background:var(--panel); color:var(--ivory); border:1px solid var(--line); border-radius:8px; padding:4px 8px; font-size:12px; font-family:inherit;}

/* ---------- feed ---------- */
main{flex:1; overflow-y:auto; padding:16px 18px 190px;}
.hint{color:var(--muted); font-size:13px; padding:18px; border:1px dashed var(--line); border-radius:var(--radius); margin-bottom:14px;}
.hint strong{color:var(--ivory);}
.hint .warn-inline{color:var(--warn);}
.danger-hint{border:1px solid var(--danger);}
.danger-hint strong{color:var(--danger);}

.exchange{margin-bottom:18px; animation:rise .25s ease;}
@keyframes rise{from{opacity:0; transform:translateY(8px);} to{opacity:1; transform:none;}}
.guest-said{background:var(--midnight-2); border:1px solid var(--line); border-radius:var(--radius) var(--radius) var(--radius) 4px; padding:10px 14px; margin-bottom:8px;}
.guest-said .label{font-size:10px; letter-spacing:.22em; color:var(--muted); font-weight:600;}
.soft-tag{
  display:inline-block; margin-left:6px; padding:1px 6px; border-radius:999px;
  background:rgba(224,160,106,.15); border:1px solid var(--warn); color:var(--warn);
  font-size:9px; letter-spacing:.05em; font-weight:700; text-transform:none;
}
.guest-said .original{font-size:14px; margin-top:2px;}
.guest-said .translated{font-size:12px; color:var(--muted); margin-top:2px;}

.answer-card{background:linear-gradient(160deg,var(--panel),var(--midnight-2)); border:1px solid var(--brass); border-radius:4px var(--radius) var(--radius) var(--radius); padding:14px 16px; box-shadow:0 6px 24px rgba(0,0,0,.35);}
.answer-card .label{font-size:10px; letter-spacing:.22em; color:var(--brass); font-weight:700;}
.phrase{font-size:21px; font-weight:700; line-height:1.45; margin-top:6px;}
.kana{margin-top:8px; padding:9px 12px; border-radius:10px; background:rgba(201,168,106,.10); border:1px solid rgba(201,168,106,.35); color:var(--brass-bright); font-size:16px; font-weight:600; letter-spacing:.06em; line-height:1.7;}
.kana .k-label{font-size:10px; letter-spacing:.2em; color:var(--brass); display:block; font-weight:700; margin-bottom:2px;}
.staff-note{margin-top:10px; font-size:13px; color:var(--muted); border-left:3px solid var(--line); padding-left:10px;}
.staff-note.miss{border-left-color:var(--warn); color:var(--warn);}
.card-actions{display:flex; gap:8px; margin-top:12px;}
.chip{flex:1; background:var(--midnight); border:1px solid var(--line); color:var(--ivory); border-radius:10px; padding:9px 0; font-size:13px; font-weight:600; cursor:pointer; font-family:inherit;}
.chip:active{background:var(--panel);}
.chip.playing{border-color:var(--brass); color:var(--brass-bright);}

.thinking-card{border:1px solid var(--line); border-radius:var(--radius); padding:14px 16px; color:var(--muted); font-size:13px; display:flex; align-items:center; gap:10px; background:var(--midnight-2);}
.spinner{width:16px; height:16px; border-radius:50%; flex:none; border:2px solid var(--line); border-top-color:var(--brass); animation:spin .8s linear infinite;}
@keyframes spin{to{transform:rotate(360deg);}}
.error-card{border:1px solid var(--danger); border-radius:var(--radius); padding:12px 16px; color:var(--danger); font-size:13px; background:var(--midnight-2); line-height:1.7;}
.error-card b{display:block; margin-bottom:4px; word-break:break-all;}
.error-card .guide{color:var(--warn);}

/* ---------- footer ---------- */
footer{position:fixed; bottom:0; left:50%; transform:translateX(-50%); width:100%; max-width:560px; background:linear-gradient(to top,var(--midnight) 78%,transparent); padding:10px 18px calc(14px + env(safe-area-inset-bottom));}
.type-row{display:flex; gap:8px; margin-bottom:10px;}
.type-row input{flex:1; background:var(--midnight-2); border:1px solid var(--line); border-radius:10px; padding:10px 12px; color:var(--ivory); font-size:14px; font-family:inherit;}
.type-row input::placeholder{color:var(--muted);}
.type-row button{background:var(--panel); border:1px solid var(--line); color:var(--ivory); border-radius:10px; padding:0 16px; font-size:13px; cursor:pointer; font-family:inherit;}

.line-wrap{display:flex; flex-direction:column; align-items:center; gap:6px;}

.meter-row{display:flex; align-items:center; gap:8px; width:100%; max-width:340px;}
.meter-label{font-size:10px; letter-spacing:.15em; color:var(--muted); flex:none;}
.meter-track{flex:1; height:8px; border-radius:999px; background:var(--midnight-2); border:1px solid var(--line); overflow:hidden;}
.meter-fill{height:100%; width:0%; background:linear-gradient(90deg,var(--ok),var(--brass-bright)); transition:width .08s linear;}
.engine-state{font-size:10px; color:var(--muted); flex:none; min-width:52px; text-align:right;}

.retry-btn{
  width:100%; max-width:340px; padding:9px 0; border-radius:10px;
  border:1px solid var(--danger); background:rgba(217,128,128,.12); color:var(--danger);
  font-size:12px; font-weight:700; cursor:pointer; font-family:inherit;
}
.retry-btn:active{background:rgba(217,128,128,.22);}
.line-btn{
  width:100%; max-width:340px; padding:15px 0; border-radius:999px;
  border:2px solid var(--line); background:var(--midnight-2); color:var(--muted);
  font-size:15px; font-weight:700; letter-spacing:.08em; cursor:pointer; font-family:inherit; transition:all .15s;
}
.line-btn:active{transform:scale(.98);}
.line-btn.open{border-color:var(--brass); color:var(--brass-bright); background:linear-gradient(180deg,#2f2a1c,#221d12); box-shadow:0 0 24px rgba(201,168,106,.25);}
.line-caption{font-size:11px; color:var(--muted); letter-spacing:.05em; text-align:center;}
.live-transcript{width:100%; max-width:340px; min-height:18px; font-size:12px; color:var(--brass-bright); text-align:center; opacity:.9;}

/* ---------- settings ---------- */
.panel-backdrop{position:fixed; inset:0; background:rgba(0,0,0,.55); z-index:10; display:none;}
.panel-backdrop.open{display:block;}
.settings{
  position:fixed; bottom:0; left:50%; transform:translate(-50%,100%);
  width:100%; max-width:560px; max-height:88dvh; overflow-y:auto;
  background:var(--midnight-2); border-top:1px solid var(--brass); border-radius:18px 18px 0 0;
  z-index:11; padding:18px 18px calc(18px + env(safe-area-inset-bottom));
  transition:transform .25s ease; display:flex; flex-direction:column; gap:14px;
}
.settings.open{transform:translate(-50%,0);}
.settings-head{display:flex; justify-content:space-between; align-items:center;}
.settings h2{font-size:14px; letter-spacing:.12em; color:var(--brass);}
.settings h3{font-size:13px; color:var(--ivory); margin-bottom:4px;}
.settings p{font-size:12px; color:var(--muted); margin-bottom:6px;}
.settings p.note{margin:4px 0 0;}
.settings textarea{width:100%; min-height:30dvh; resize:vertical; background:var(--midnight); border:1px solid var(--line); border-radius:10px; color:var(--ivory); font-size:13px; line-height:1.7; padding:12px; font-family:inherit;}
.settings input[type=password], .settings select{width:100%; background:var(--midnight); border:1px solid var(--line); border-radius:10px; padding:10px 12px; color:var(--ivory); font-size:13px; font-family:inherit; margin-bottom:8px;}
.field-label{display:block; font-size:12px; color:var(--muted); margin-bottom:4px;}
.settings-row{display:flex; gap:8px;}
.btn-primary{flex:1; background:var(--brass); color:var(--midnight); border:none; border-radius:10px; padding:11px 0; font-size:14px; font-weight:700; cursor:pointer; font-family:inherit;}
.btn-ghost{background:none; border:1px solid var(--line); color:var(--muted); border-radius:10px; padding:11px 16px; font-size:13px; cursor:pointer; font-family:inherit;}
.save-msg{font-size:12px; color:var(--ok); min-height:14px;}
.env-badge{font-size:11px; padding:2px 8px; border-radius:999px; border:1px solid var(--line); color:var(--muted);}

/* トグルスイッチ: labelで包むことでスライダーのクリックがinputに届く */
.toggle-row{display:flex; align-items:center; justify-content:space-between; gap:12px; font-size:13px;}
.switch{position:relative; display:inline-block; width:44px; height:24px; flex:none; cursor:pointer;}
.switch input{position:absolute; opacity:0; width:100%; height:100%; margin:0; cursor:pointer;}
.slider{position:absolute; inset:0; background:var(--panel); border:1px solid var(--line); border-radius:24px; transition:.2s; pointer-events:none;}
.slider:before{content:""; position:absolute; height:16px; width:16px; left:3px; top:3px; background:var(--muted); border-radius:50%; transition:.2s;}
.switch input:checked + .slider{background:rgba(201,168,106,.25); border-color:var(--brass);}
.switch input:checked + .slider:before{transform:translateX(20px); background:var(--brass-bright);}

.muted-text{color:var(--muted); font-style:normal;}

/* 質問ではない発話のスキップ表示 */
.skipped-line{
  color:var(--muted); font-size:11.5px; padding:4px 10px; margin-bottom:10px;
  border-left:2px solid var(--line); opacity:.75;
}

/* 回答カード: 日本語ライン・言語タグ・根拠 */
.phrase-ja{
  margin-top:6px; font-size:14px; color:var(--ivory);
  padding:7px 10px; border-radius:8px; background:rgba(255,255,255,.05);
}
.lang-tag{
  display:inline-block; margin-left:6px; padding:1px 8px; border-radius:999px;
  border:1px solid var(--brass); color:var(--brass-bright);
  font-size:9px; letter-spacing:.08em; font-weight:700;
}
.evidence{
  margin-top:8px; font-size:11.5px; color:var(--muted); opacity:.85;
  border-left:2px solid rgba(127,201,162,.5); padding-left:8px;
}
.status-strip #spotSelect{margin-left:auto;}

/* 汎用テキスト入力(インラインstyle排除・CSP対応のため) */
.settings .text-input{
  width:100%; background:var(--midnight); border:1px solid var(--line);
  border-radius:10px; padding:10px 12px; color:var(--ivory);
  font-size:13px; font-family:inherit;
}

/* プラン表示 */
.plan-badge{
  display:inline-block; margin-left:8px; padding:2px 10px; border-radius:999px;
  border:1px solid var(--line); color:var(--muted); font-size:10px; letter-spacing:.08em; font-weight:700;
}
.plan-badge.pro{border-color:var(--brass); color:var(--brass-bright); background:rgba(201,168,106,.12);}
.upgrade-link{
  display:block; text-align:center; text-decoration:none; margin-bottom:10px;
}
.limit-card{
  border:1px solid var(--brass); border-radius:var(--radius); padding:14px 16px;
  background:linear-gradient(160deg, rgba(201,168,106,.10), var(--midnight-2));
  font-size:13px; color:var(--ivory); line-height:1.7; margin-bottom:18px;
}
.limit-card b{color:var(--brass-bright);}
.limit-card a{
  display:inline-block; margin-top:8px; padding:8px 18px; border-radius:10px;
  background:var(--brass); color:var(--midnight); font-weight:700; text-decoration:none; font-size:13px;
}

/* 最終確認画面(特定商取引法12条の6対応) */
.final-confirm{
  border:1px solid var(--brass); border-radius:var(--radius); padding:14px 16px;
  background:rgba(201,168,106,.06); margin-top:6px;
}
.final-confirm h3{font-size:13px; color:var(--brass-bright); margin-bottom:8px;}
.confirm-table{width:100%; border-collapse:collapse; font-size:12px; margin-bottom:10px;}
.confirm-table th{
  text-align:left; color:var(--muted); font-weight:600; vertical-align:top;
  padding:6px 8px 6px 0; width:38%; white-space:nowrap;
}
.confirm-table td{padding:6px 0; color:var(--ivory); vertical-align:top;}
.confirm-legal-links{font-size:11px; color:var(--muted); margin-bottom:10px;}
.confirm-legal-links a{color:var(--brass-bright);}
#btnGoStripe{flex:1; text-align:center; text-decoration:none; display:flex; align-items:center; justify-content:center;}

/* 設定パネル下部の法定表記リンク */
.legal-links{
  display:flex; flex-wrap:wrap; gap:6px 14px; justify-content:center;
  padding-top:14px; margin-top:4px; border-top:1px solid var(--line);
}
.legal-links a{font-size:11px; color:var(--muted); text-decoration:none;}
.legal-links a:hover{color:var(--brass-bright);}
