:root {
  --bg: #0A0A0A;
  --surface: #161616;
  --surface-2: #202020;
  --line: #2C2C2C;
  --text: #F6F4EE;
  --muted: #A3A097;
  --yellow: #FFCC00;
  --yellow-ink: #0A0A0A;
  --good: #4CC38A;
  --bad: #FF6B5E;
  --radius: 18px;
  --tabs-h: 64px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  color-scheme: dark;
}
:root[data-look="light"] {
  --bg: #FAF8F2;
  --surface: #FFFFFF;
  --surface-2: #F1EEE5;
  --line: #E3DFD3;
  --text: #121212;
  --muted: #6B675E;
  --yellow-ink: #0A0A0A;
  color-scheme: light;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); }
body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", "Noto Sans Thai", "Noto Sans KR", "Noto Sans JP", "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 16px; line-height: 1.45; overflow: hidden;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; }
#app { display: flex; flex-direction: column; height: 100dvh; max-width: 640px; margin: 0 auto; }

/* Top bar */
.top { display: flex; align-items: center; justify-content: space-between; padding: calc(10px + var(--safe-t)) 16px 10px; }
.brand { display: flex; align-items: center; gap: 10px; }
.mark { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 10px; background: var(--yellow); color: var(--yellow-ink); font-weight: 800; font-size: 14px; letter-spacing: .5px; }
.brand-name { font-weight: 700; font-size: 18px; letter-spacing: .2px; }
.usage-pill { font-size: 12px; color: var(--muted); border: 1px solid var(--line); border-radius: 99px; padding: 4px 10px; }

main { flex: 1; overflow-y: auto; overflow-x: hidden; padding: 0 16px 16px; -webkit-overflow-scrolling: touch; }

/* Tabs */
.tabs { display: grid; grid-template-columns: repeat(4, 1fr); border-top: 1px solid var(--line); background: var(--bg); padding-bottom: var(--safe-b); }
.tab { height: var(--tabs-h); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; font-size: 12px; color: var(--muted); }
.tab svg { width: 24px; height: 24px; }
.tab { position: relative; }
.tab.on { color: var(--yellow); }
.tab.on::before { content: ""; position: absolute; top: -1px; left: 30%; right: 30%; height: 3px; border-radius: 0 0 3px 3px; background: var(--yellow); }
:root[data-look="light"] .tab.on { color: var(--text); font-weight: 700; }

/* Generic */
h2 { font-size: 22px; margin: 6px 0 12px; }
h3 { font-size: 15px; margin: 18px 0 8px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .6px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 12px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.row { display: flex; align-items: center; gap: 10px; }
.grow { flex: 1; min-width: 0; }
.btn { white-space: nowrap; display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 46px; padding: 0 18px; border-radius: 14px; font-weight: 700; background: var(--surface-2); border: 1px solid var(--line); }
.btn.primary { background: var(--yellow); color: var(--yellow-ink); border-color: var(--yellow); }
.btn.ghost { background: transparent; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .45; }
.icon-btn { width: 40px; height: 40px; display: grid; place-items: center; border-radius: 12px; color: var(--muted); }
.icon-btn svg { width: 22px; height: 22px; }
.icon-btn.on { color: var(--yellow); }
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 2px 0 10px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; padding: 8px 14px; border-radius: 99px; border: 1px solid var(--line); background: var(--surface); font-size: 14px; white-space: nowrap; }
.chip.on { background: var(--yellow); color: var(--yellow-ink); border-color: var(--yellow); font-weight: 700; }
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 4px; margin-bottom: 12px; }
.seg button { padding: 9px; border-radius: 10px; font-weight: 600; color: var(--muted); }
.seg button.on { background: var(--surface-2); color: var(--text); }
input[type=text], input[type=password], input[type=url], textarea, select {
  width: 100%; background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px; padding: 12px; outline: none;
}
input:focus, textarea:focus, select:focus { border-color: var(--yellow); }
label.field { display: block; margin-bottom: 12px; }
label.field > span { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.empty { text-align: center; color: var(--muted); padding: 28px 12px; }

/* Talk */
.talk { display: flex; flex-direction: column; height: 100%; }
.pair { display: grid; grid-template-columns: 1fr auto 1fr; gap: 8px; align-items: center; margin-bottom: 10px; }
.pair select { padding: 10px; font-weight: 700; text-align: center; }
.pair .swap { color: var(--muted); font-size: 18px; }
.convo { flex: 1; overflow-y: auto; padding: 4px 0 8px; }
.bubble { max-width: 88%; border-radius: 18px; padding: 12px 14px; margin: 8px 0; position: relative; }
.bubble.me { margin-left: auto; background: var(--yellow); color: var(--yellow-ink); border-bottom-right-radius: 6px; }
.bubble.them { margin-right: auto; background: var(--surface); border: 1px solid var(--line); border-bottom-left-radius: 6px; }
.bubble .src { font-size: 14px; opacity: .75; }
.bubble .main { font-size: 21px; font-weight: 600; line-height: 1.35; margin-top: 2px; word-break: break-word; }
.bubble .rom { font-size: 14px; font-style: italic; opacity: .8; margin-top: 2px; }
.bubble .back { font-size: 13px; opacity: .7; margin-top: 6px; }
.bubble .acts { display: flex; gap: 2px; margin: 6px -8px -6px; }
.bubble.me .icon-btn { color: rgba(10,10,10,.6); }
.bubble.me .icon-btn.on { color: #0A0A0A; }
.bubble .err { color: var(--bad); font-size: 14px; }
.bubble.me .err { color: #7A1A10; }
.interim { min-height: 22px; text-align: center; color: var(--muted); font-size: 15px; padding: 4px 0; }
.typebar { display: flex; gap: 8px; margin-bottom: 8px; }
.typebar input { flex: 1; }
.typebar .btn { min-height: 46px; padding: 0 14px; }
.speakers { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; padding-bottom: 6px; }
.speak-btn { height: 92px; border-radius: 22px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; font-weight: 800; font-size: 17px; }
.speak-btn svg { width: 28px; height: 28px; }
.speak-btn small { font-weight: 600; font-size: 13px; opacity: .8; }
.speak-btn.me { background: var(--yellow); color: var(--yellow-ink); }
.speak-btn.them { background: var(--surface); border: 2px solid var(--yellow); color: var(--text); }
.speak-btn.live { animation: pulse 1.1s ease-in-out infinite; }
@keyframes pulse { 0%,100% { box-shadow: 0 0 0 0 rgba(255,204,0,.55); } 50% { box-shadow: 0 0 0 12px rgba(255,204,0,0); } }
.talk-tools { display: flex; justify-content: space-between; align-items: center; margin-bottom: 4px; }
.link { color: var(--muted); font-size: 14px; padding: 6px 2px; text-decoration: underline; text-underline-offset: 3px; }

/* Big show overlay */
#overlay { position: fixed; inset: 0; z-index: 50; background: var(--bg); display: flex; flex-direction: column; padding: calc(20px + var(--safe-t)) 20px calc(20px + var(--safe-b)); }
#overlay[hidden] { display: none; }
.big-text { flex: 1; display: flex; flex-direction: column; justify-content: center; text-align: center; gap: 14px; }
.big-text .t { font-size: clamp(34px, 9vw, 60px); font-weight: 700; line-height: 1.25; word-break: break-word; }
.big-text .r { font-size: 20px; color: var(--muted); font-style: italic; }
.sheet { background: var(--surface); border-radius: 22px; padding: 18px; max-height: 80dvh; overflow-y: auto; }
.overlay-dim { background: rgba(0,0,0,.6) !important; justify-content: flex-end; }

/* Learn */
.phrase { display: flex; align-items: center; gap: 8px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.phrase:last-child { border-bottom: 0; }
.phrase .t { font-size: 19px; font-weight: 600; word-break: break-word; }
.phrase .r { font-size: 13px; color: var(--muted); font-style: italic; }
.phrase .m { font-size: 14px; color: var(--muted); }
.badge { font-size: 11px; padding: 2px 8px; border-radius: 99px; background: var(--surface-2); color: var(--muted); white-space: nowrap; }
details.cat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 10px; padding: 0 14px; }
details.cat summary { list-style: none; padding: 14px 0; font-weight: 700; display: flex; justify-content: space-between; }
details.cat summary::-webkit-details-marker { display: none; }
details.cat summary::after { content: "+"; color: var(--yellow); font-size: 20px; line-height: 1; }
details.cat[open] summary::after { content: "–"; }

/* Practice */
.streak { display: flex; align-items: center; gap: 14px; }
.streak .n { font-size: 40px; font-weight: 800; color: var(--yellow); line-height: 1; }
.bar { height: 8px; border-radius: 99px; background: var(--surface-2); overflow: hidden; margin-top: 8px; }
.bar > i { display: block; height: 100%; background: var(--yellow); border-radius: 99px; }
.mode { display: flex; align-items: center; gap: 14px; width: 100%; text-align: left; }
.mode .ico { width: 46px; height: 46px; border-radius: 14px; background: var(--surface-2); display: grid; place-items: center; color: var(--yellow); flex: none; }
.mode .ico svg { width: 24px; height: 24px; }
.mode b { display: block; font-size: 17px; }
.flash { text-align: center; padding: 26px 16px; }
.flash .front { font-size: 22px; font-weight: 600; }
.flash .t { font-size: 30px; font-weight: 700; margin-top: 14px; word-break: break-word; }
.flash .r { color: var(--muted); font-style: italic; margin-top: 4px; }
.grade .btn { white-space: normal; text-align: center; line-height: 1.2; padding: 6px 10px; min-width: 0; }
.grade { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 12px; }
.diff { font-size: 26px; font-weight: 600; letter-spacing: .5px; word-break: break-word; }
.diff .ok { color: var(--good); }
.diff .miss { color: var(--bad); text-decoration: underline wavy; text-underline-offset: 5px; }
.score { font-size: 44px; font-weight: 800; }
.score.good { color: var(--good); } .score.mid { color: var(--yellow); } .score.low { color: var(--bad); }
.actions .btn { padding: 0 14px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; margin-top: 14px; }
.coach-out .c { font-size: 22px; font-weight: 700; margin: 6px 0 2px; }

/* Settings */
.lang-list .item { display: flex; align-items: center; gap: 10px; padding: 11px 0; border-bottom: 1px solid var(--line); }
.lang-list .item:last-child { border-bottom: 0; }
.lang-list .num { width: 24px; height: 24px; border-radius: 99px; background: var(--yellow); color: var(--yellow-ink); font-size: 12px; font-weight: 800; display: grid; place-items: center; }
.check { width: 24px; height: 24px; border-radius: 7px; border: 2px solid var(--line); display: grid; place-items: center; flex: none; }
.check.on { background: var(--yellow); border-color: var(--yellow); color: var(--yellow-ink); }
.warn { border-left: 3px solid var(--yellow); padding: 8px 12px; background: var(--surface-2); border-radius: 8px; font-size: 14px; margin: 8px 0; }
.switch { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 0; }
.toggle { width: 50px; height: 30px; border-radius: 99px; background: var(--surface-2); border: 1px solid var(--line); position: relative; flex: none; }
.toggle::after { content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 99px; background: var(--muted); transition: left .15s; }
.toggle.on { background: var(--yellow); border-color: var(--yellow); }
.toggle.on::after { left: 23px; background: var(--yellow-ink); }
input[type=range] { width: 100%; accent-color: var(--yellow); }

#toast { position: fixed; left: 50%; bottom: calc(var(--tabs-h) + 18px + var(--safe-b)); transform: translateX(-50%) translateY(20px); background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 12px; font-size: 14px; opacity: 0; pointer-events: none; transition: all .2s; max-width: calc(100% - 32px); z-index: 60; }
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* Inside a claude.ai page the frame already pads for the phone's bars */
html.art { --safe-t: 0px; --safe-b: 0px; }
html.art, html.art body { height: 100%; }
html.art #app { height: 100%; }
