:root {
  --room: #e9e4dc;
  --room-2: #ddd6cb;
  --ink: #1d2126;
  --muted: #5d636b;
  --panel: #f7f4ef;
  --line: #d3ccc0;
  --screen: #0f1720;
  --screen-2: #182330;
  --screen-ink: #f4f7fa;
  --screen-muted: #9fb0c0;
  --alexa: #1ad1ff;
  --high: #ff5a4e;
  --high-bg: #3a1513;
  --medium: #ffb938;
  --medium-bg: #3a2a0c;
  --low: #3ad18c;
  --low-bg: #0f3324;
  --sans: 'Figtree', 'Noto Sans JP', system-ui, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: var(--sans);
  color: var(--ink);
  background: radial-gradient(ellipse at 30% 20%, #f3efe8 0%, var(--room) 50%, var(--room-2) 100%);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
html[lang="ja"] body { font-family: 'Noto Sans JP', 'Figtree', system-ui, sans-serif; }
button { font: inherit; cursor: pointer; }

.topbar { display: flex; justify-content: space-between; align-items: center; padding: 14px 28px; }
.brand { font-weight: 800; font-size: 1.15rem; letter-spacing: .01em; display: flex; align-items: center; gap: 8px; }
.brand .dot { width: 12px; height: 12px; border-radius: 50%; background: var(--alexa); box-shadow: 0 0 10px var(--alexa); }
.brand .for { font-weight: 500; color: var(--muted); }
.top-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
select.lang { appearance: none; padding-right: 28px; background-image: linear-gradient(45deg, transparent 50%, var(--ink) 50%), linear-gradient(135deg, var(--ink) 50%, transparent 50%); background-position: calc(100% - 15px) 50%, calc(100% - 10px) 50%; background-size: 5px 5px; background-repeat: no-repeat; color: var(--ink); cursor: pointer; }
.lang { border: 1px solid var(--line); background: var(--panel); border-radius: 999px; padding: 6px 14px; font-weight: 600; }

.stage { flex: 1; display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 28px; padding: 8px 28px 20px; align-items: start; max-width: 1400px; width: 100%; margin: 0 auto; }

/* ── Echo Show ─────────────────────────────────── */
.device-wrap { display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px; min-width: 0; }
.device { position: relative; filter: drop-shadow(0 24px 30px rgba(40, 30, 20, .28)); }
.bezel { background: #121416; border-radius: 26px; padding: 16px; }
.speaker { height: 28px; margin: -6px 22px 0; border-radius: 0 0 22px 22px; background: repeating-linear-gradient(90deg, #2b2e31 0 2px, #222528 2px 4px); }
.screen { position: relative; aspect-ratio: 16 / 10; border-radius: 10px; overflow: hidden; background: linear-gradient(160deg, var(--screen-2), var(--screen)); color: var(--screen-ink); }
.view { position: absolute; inset: 0; padding: 4% 5% 7%; }
.view[hidden], .card[hidden], .actions[hidden], .flags[hidden] { display: none; }

.idle { display: flex; flex-direction: column; justify-content: center; }
.clock { font-size: clamp(3rem, 9vw, 7.5rem); font-weight: 300; letter-spacing: -.02em; line-height: 1; font-variant-numeric: tabular-nums; }
.date { font-size: clamp(1rem, 1.8vw, 1.5rem); color: var(--screen-muted); margin-top: 6px; }
.hint { margin-top: 8%; font-size: clamp(1rem, 1.9vw, 1.55rem); color: var(--screen-ink); opacity: .9; max-width: 34ch; line-height: 1.4; }

.convo { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr); grid-template-rows: auto 1fr; gap: 3% 4%; }
.you { grid-column: 1; font-size: clamp(.85rem, 1.25vw, 1.1rem); color: var(--screen-muted); line-height: 1.4; max-height: 5.6em; overflow: hidden; }
.you::before { content: '“'; } .you::after { content: '”'; }
.alexa { grid-column: 1; align-self: start; font-size: clamp(1.15rem, 2.15vw, 1.95rem); font-weight: 600; line-height: 1.32; min-width: 0; }
.alexa[data-size="m"] { font-size: clamp(1rem, 1.7vw, 1.55rem); }
.alexa[data-size="s"] { font-size: clamp(.95rem, 1.4vw, 1.3rem); }
.convo { overflow: hidden; }
.card { grid-column: 2; grid-row: 1 / span 2; align-self: center; background: rgba(255, 255, 255, .06); border: 1px solid rgba(255, 255, 255, .1); border-radius: 18px; padding: clamp(12px, 2vw, 24px); display: grid; gap: clamp(8px, 1.3vw, 16px); min-width: 0; }
.risk { display: flex; align-items: center; gap: 12px; font-weight: 800; font-size: clamp(1.2rem, 2.4vw, 2.1rem); border-radius: 12px; padding: 3% 4%; }
html[lang="ja"] .risk { font-size: clamp(1rem, 1.9vw, 1.7rem); }
.risk-icon { width: 1.3em; height: 1.3em; border-radius: 50%; display: grid; place-items: center; font-size: .8em; flex: none; color: #111; }
.card[data-risk="high"] .risk { background: var(--high-bg); color: var(--high); } .card[data-risk="high"] .risk-icon { background: var(--high); }
.card[data-risk="medium"] .risk { background: var(--medium-bg); color: var(--medium); } .card[data-risk="medium"] .risk-icon { background: var(--medium); }
.card[data-risk="low"] .risk { background: var(--low-bg); color: var(--low); } .card[data-risk="low"] .risk-icon { background: var(--low); }
.flags { margin: 0; padding: 0; list-style: none; display: grid; gap: .45em; font-size: clamp(.85rem, 1.35vw, 1.15rem); line-height: 1.35; }
.flags li { display: flex; gap: .55em; } .flags li::before { content: '⚠'; color: var(--medium); flex: none; }
.step { display: grid; gap: .2em; font-size: clamp(.9rem, 1.45vw, 1.25rem); line-height: 1.35; border-top: 1px solid rgba(255, 255, 255, .12); padding-top: clamp(8px, 1.2vw, 14px); }
.step-label { font-size: .72em; letter-spacing: .1em; text-transform: uppercase; color: var(--alexa); font-weight: 700; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; }
.who-line { flex: 1 1 100%; font-size: clamp(.8rem, 1.2vw, 1.05rem); color: var(--screen-muted); font-variant-numeric: tabular-nums; }
.who-line::before { content: '👤 '; }
.who-line:empty { display: none; }
.act { flex: 1 1 30%; white-space: nowrap; border: 0; border-radius: 999px; padding: .6em 1em; font-weight: 700; font-size: clamp(.85rem, 1.35vw, 1.15rem); }
.act.yes { background: var(--alexa); color: #04212b; } .act.call { background: #2fbf71; color: #062314; } .act.no { background: rgba(255, 255, 255, .14); color: var(--screen-ink); }

.home-btn { position: absolute; bottom: clamp(16px, 2vw, 26px); left: clamp(16px, 2.6vw, 44px); z-index: 6; display: inline-flex; align-items: center; gap: .35em; border: 0; border-radius: 999px; padding: .45em .95em; font: inherit; font-weight: 700; font-size: clamp(.8rem, 1.1vw, 1rem); background: rgba(255, 255, 255, .14); color: var(--screen-ink); cursor: pointer; }
.home-btn:hover, .home-btn:focus-visible { background: rgba(255, 255, 255, .24); }
.home-btn[hidden] { display: none; }
.lightbar { position: absolute; left: 0; right: 0; bottom: 0; height: 7px; background: var(--alexa); opacity: 0; transition: opacity .25s; }
.screen.listening .lightbar { opacity: 1; animation: pulse 1.1s ease-in-out infinite; }
.screen.thinking .lightbar { opacity: 1; background: linear-gradient(90deg, transparent, var(--alexa), transparent); background-size: 50% 100%; background-repeat: no-repeat; animation: sweep 1s linear infinite; }
.screen.speaking .lightbar { opacity: .85; }
@keyframes pulse { 50% { opacity: .45; } }
@keyframes sweep { from { background-position: -50% 0; } to { background-position: 150% 0; } }

/* ── talk bar ─────────────────────────────────── */
.talk { display: flex; gap: 10px; align-items: center; }
.mic { flex: none; width: 56px; height: 56px; border-radius: 50%; border: 0; background: var(--ink); display: grid; place-items: center; }
.mic svg { width: 26px; height: 26px; fill: #fff; }
.mic.on { background: var(--alexa); } .mic.on svg { fill: #04212b; }
.talk input { flex: 1; min-width: 0; height: 56px; border-radius: 28px; border: 1px solid var(--line); background: var(--panel); padding: 0 20px; font: inherit; font-size: 1.05rem; color: var(--ink); }
.send { height: 56px; padding: 0 24px; border-radius: 28px; border: 0; background: var(--ink); color: #fff; font-weight: 700; }
.samples { display: flex; flex-wrap: wrap; gap: 8px; }
.samples button { border: 1px solid var(--line); background: var(--panel); border-radius: 999px; padding: 7px 14px; font-size: .92rem; color: var(--ink); }
.samples button:hover { border-color: var(--ink); }

/* ── side ─────────────────────────────────────── */
.side { display: grid; gap: 18px; min-width: 0; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 16px 18px; min-width: 0; }
.panel h2 { margin: 0 0 10px; font-size: 1rem; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.empty { color: var(--muted); margin: 0; font-size: .92rem; }
.sms { background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; display: grid; gap: 4px; animation: pop .35s ease-out; }
.sms + .sms { margin-top: 10px; }
.sms .from { font-size: .78rem; font-weight: 700; color: var(--muted); display: flex; justify-content: space-between; }
.sms .tag { font-size: .72rem; font-weight: 800; padding: 1px 8px; border-radius: 999px; color: #fff; }
.sms .tag.high { background: #d23b30; } .sms .tag.medium { background: #c98710; } .sms .tag.low { background: #23905d; }
.sms p { margin: 0; font-size: .95rem; line-height: 1.4; }
@keyframes pop { from { transform: translateY(6px); opacity: 0; } }

.badge { font-size: .72rem; font-weight: 700; padding: 2px 9px; border-radius: 999px; background: var(--line); color: var(--muted); }
.badge.ok { background: #d5f2e4; color: #1d6b47; } .badge.err { background: #fbdcd9; color: #a3271e; }
.nw { white-space: nowrap; }
.mcp-sub { margin: -4px 0 10px; font-size: .8rem; color: var(--muted); }
.mcp-sub code { font-size: .78rem; }
.log { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; max-height: 46vh; overflow: auto; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: .76rem; }
.log li { background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px; overflow-wrap: anywhere; }
.log .dir { font-weight: 700; } .log .out .dir { color: #0b6f8f; } .log .in .dir { color: #1d6b47; } .log .err .dir { color: #a3271e; }
.log .body { color: var(--muted); display: block; margin-top: 2px; max-height: 5.2em; overflow: hidden; }

.foot { text-align: center; font-size: .78rem; color: var(--muted); padding: 10px 28px 18px; }

@media (max-width: 980px) {
  .stage { grid-template-columns: minmax(0, 1fr); padding: 8px 16px 16px; }
  .topbar, .foot { padding-left: 16px; padding-right: 16px; }
  .convo { grid-template-columns: 1fr; grid-template-rows: auto auto 1fr; }
  .card { grid-column: 1; grid-row: auto; }
  .screen { aspect-ratio: auto; min-height: 440px; }
  .view { position: relative; padding: 24px 20px 28px; }
  .idle { min-height: 440px; }
  .send { padding: 0 18px; }
  .home-btn { bottom: auto; top: 12px; left: auto; right: 12px; }
  .convo { padding-top: 52px; }
}
@media (max-width: 520px) {
  .topbar { gap: 10px; }
  .brand { font-size: 1rem; white-space: nowrap; flex-wrap: wrap; row-gap: 0; }
  .brand .for { font-size: .85rem; }
  .top-actions { flex-wrap: wrap; justify-content: flex-end; }
  .talk input { font-size: .98rem; padding: 0 16px; }
}

/* ── calling screen (demo) ─────────────────────── */
.calling { position: absolute; inset: 0; z-index: 5; background: linear-gradient(170deg, #0f2a22, #0b1716); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1.2%; text-align: center; padding: 4%; }
.calling[hidden] { display: none; }
.ring { width: clamp(84px, 13vw, 150px); aspect-ratio: 1; border-radius: 50%; background: #2fbf71; color: #062314; display: grid; place-items: center; font-size: clamp(2rem, 5vw, 4rem); font-weight: 800; box-shadow: 0 0 0 0 rgba(47, 191, 113, .6); animation: ring 1.6s ease-out infinite; margin-bottom: 2%; }
@keyframes ring { 70% { box-shadow: 0 0 0 28px rgba(47, 191, 113, 0); } 100% { box-shadow: 0 0 0 0 rgba(47, 191, 113, 0); } }
.call-name { font-size: clamp(1.4rem, 3vw, 2.6rem); font-weight: 700; }
.call-number { font-size: clamp(1.1rem, 2.2vw, 1.8rem); color: var(--screen-muted); font-variant-numeric: tabular-nums; }
.call-status { font-size: clamp(.95rem, 1.6vw, 1.3rem); color: #7ee2ad; }
.call-note { font-size: clamp(.8rem, 1.2vw, 1rem); color: var(--screen-muted); max-width: 40ch; }
.hangup { margin-top: 3%; border: 0; border-radius: 999px; background: #e5483d; color: #fff; font-weight: 700; padding: .7em 2.2em; font-size: clamp(.9rem, 1.4vw, 1.15rem); }

/* ── trusted contacts settings ─────────────────── */
.settings-panel { position: fixed; inset: 0; z-index: 50; background: rgba(20, 16, 12, .45); display: grid; place-items: center; padding: 16px; }
.settings-panel[hidden] { display: none; }
.sheet { width: min(520px, 100%); max-height: calc(100vh - 32px); overflow: auto; background: var(--panel); border-radius: 18px; padding: 22px; display: grid; gap: 12px; box-shadow: 0 20px 50px rgba(0, 0, 0, .25); }
.sheet h2 { margin: 0; font-size: 1.2rem; }
.set-note { margin: 0; color: var(--muted); font-size: .9rem; line-height: 1.5; }
.contact-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.contact-list li { display: flex; justify-content: space-between; align-items: center; gap: 10px; background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; }
.contact-list li div { display: grid; gap: 2px; min-width: 0; }
.contact-list li span { color: var(--muted); font-size: .88rem; font-variant-numeric: tabular-nums; }
.contact-list li em { font-style: normal; font-size: .72rem; font-weight: 700; color: #0b6f8f; }
.contact-list button { border: 1px solid var(--line); background: var(--panel); border-radius: 999px; padding: 5px 12px; color: var(--ink); }
.contact-list button:disabled { opacity: .4; cursor: default; }
.contact-form { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.contact-form input { min-width: 0; height: 44px; border: 1px solid var(--line); border-radius: 10px; padding: 0 12px; font: inherit; background: #fff; color: var(--ink); }
.contact-form #f-num { grid-column: 1 / 2; }
.contact-form button { height: 44px; border: 0; border-radius: 10px; background: var(--ink); color: #fff; font-weight: 700; }
.set-err { margin: 0; color: #a3271e; font-size: .88rem; min-height: 1.2em; }
.set-close { justify-self: end; border: 0; border-radius: 999px; background: var(--alexa); color: #04212b; font-weight: 700; padding: 9px 22px; }

/* ── add-contact confirmation card ─────────────── */
.add-title { font-size: clamp(1rem, 1.8vw, 1.5rem); font-weight: 700; }
.add-person { display: flex; align-items: center; gap: 14px; background: rgba(255, 255, 255, .06); border-radius: 12px; padding: 12px 14px; }
.add-icon { font-size: clamp(1.6rem, 3vw, 2.4rem); }
.add-person div { display: grid; gap: 2px; min-width: 0; }
.add-person b { font-size: clamp(1.1rem, 2vw, 1.6rem); }
.add-person span { color: var(--screen-muted); font-size: clamp(.9rem, 1.4vw, 1.2rem); font-variant-numeric: tabular-nums; }
