:root {
  --bg: #FBF6EE; --card: #FFFFFF; --ink: #1E2726; --muted: #6B7775; --line: #E7DFD2;
  --accent: #0F6B5B; --accent-ink: #FFFFFF; --soft: #E4F1EC; --warm: #F2A65A; --bad: #B4472F; --good: #0F6B5B;
  --serif: ui-serif, "New York", Georgia, "Times New Roman", serif;
  --sans: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #141A1A; --card: #1D2625; --ink: #EEF2EF; --muted: #98A5A1; --line: #2C3836;
    --accent: #5CC9B0; --accent-ink: #0B1F1B; --soft: #1F3530; --warm: #F2A65A; --bad: #F08A70; --good: #5CC9B0; }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--ink); font: 17px/1.45 var(--sans); -webkit-text-size-adjust: 100%; }
body { overscroll-behavior-y: none; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; padding: 0; touch-action: manipulation; }
[hidden] { display: none !important; }

.screen { max-width: 520px; margin: 0 auto; min-height: 100dvh; display: flex; flex-direction: column; gap: 18px;
  padding: calc(env(safe-area-inset-top) + 22px) 20px calc(env(safe-area-inset-bottom) + 92px); }
#lesson, #wait { padding-bottom: calc(env(safe-area-inset-bottom) + 18px); }

.hello h1 { font: 600 34px/1.1 var(--serif); margin: 2px 0 0; letter-spacing: -0.01em; }
.eyebrow { margin: 0; color: var(--accent); font-size: 14px; font-weight: 600; min-height: 20px; }
.label { margin: 0 0 8px; font-size: 13px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); display: block; }
.label .muted { text-transform: none; letter-spacing: 0; font-weight: 400; }
.muted { color: var(--muted); } .small { font-size: 14px; } .center { text-align: center; margin: 0; }
.lead { margin: 0; font: 400 19px/1.4 var(--serif); }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: 16px 18px; }
.card + .card { margin-top: 12px; }
.today .small { margin: 10px 0 0; }

.setup { display: flex; flex-direction: column; }
.seg { display: grid; grid-template-columns: repeat(3, 1fr); background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 4px; margin-bottom: 18px; }
.seg button { padding: 11px 0; border-radius: 10px; font-weight: 600; color: var(--muted); }
.seg button.on { background: var(--soft); color: var(--accent); }
input[type=text] { width: 100%; padding: 14px; border-radius: 14px; border: 1px solid var(--line); background: var(--card); outline: none; }
input[type=text]:focus { border-color: var(--accent); }

.primary { background: var(--accent); color: var(--accent-ink); border-radius: 16px; font-weight: 700; }
.primary.big { padding: 18px; font-size: 19px; margin-top: auto; }
.primary:active { transform: scale(.985); }
.primary[disabled] { opacity: .5; }

.tabs { position: fixed; left: 0; right: 0; bottom: 0; display: grid; grid-template-columns: 1fr 1fr; background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); border-top: 1px solid var(--line); padding: 8px 20px calc(env(safe-area-inset-bottom) + 8px); z-index: 5; }
.tabs button { padding: 12px 0; font-weight: 600; color: var(--muted); border-radius: 12px; }
.tabs button.on { color: var(--accent); background: var(--soft); }

/* Lekcja */
.lessonTop { display: flex; justify-content: space-between; align-items: center; }
.timer { font-variant-numeric: tabular-nums; color: var(--muted); font-weight: 600; }
.chip { padding: 7px 14px; border-radius: 99px; border: 1px solid var(--line); font-size: 14px; font-weight: 600; color: var(--muted); background: var(--card); }
.chip[aria-pressed=true] { color: var(--accent); border-color: var(--accent); }
.stage { flex: 1 1 auto; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 22px; min-height: 240px; }
.state { margin: 0; font: 500 20px var(--serif); text-align: center; }

.orb { position: relative; width: 168px; height: 168px; }
.orb b { position: absolute; inset: 0; border-radius: 50%; background: radial-gradient(circle at 32% 28%, #8FE3CE, var(--accent) 62%, #0A4A40); box-shadow: 0 18px 50px -18px var(--accent); }
.orb i { position: absolute; inset: 0; border-radius: 50%; border: 2px solid var(--accent); opacity: 0; }
.orb.idle b, .orb.connecting b { animation: breathe 3.6s ease-in-out infinite; }
.orb.connecting b { filter: saturate(.4); }
.orb.listening b { background: radial-gradient(circle at 32% 28%, #FFD9A8, var(--warm) 62%, #C97A2B); box-shadow: 0 18px 50px -18px var(--warm); animation: breathe 1.6s ease-in-out infinite; }
.orb.listening i { border-color: var(--warm); animation: ring 1.6s ease-out infinite; }
.orb.listening i + i { animation-delay: .8s; }
.orb.speaking b { animation: talk .55s ease-in-out infinite alternate; }
.orb.speaking i { animation: ring 1.3s ease-out infinite; }
.orb.speaking i + i { animation-delay: .65s; }
.orb.thinking b { animation: breathe 1.1s ease-in-out infinite; filter: saturate(.7); }
.orb.muted b { filter: grayscale(1); animation: none; opacity: .6; }
@keyframes breathe { 50% { transform: scale(1.05); } }
@keyframes talk { from { transform: scale(.97); } to { transform: scale(1.09); } }
@keyframes ring { from { transform: scale(1); opacity: .55; } to { transform: scale(1.55); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .orb b, .orb i { animation: none !important; } }

.captions { flex: 0 1 34dvh; min-height: 96px; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; padding: 4px 2px; -webkit-overflow-scrolling: touch;
  mask-image: linear-gradient(to bottom, transparent, #000 22px); -webkit-mask-image: linear-gradient(to bottom, transparent, #000 22px); }
.captions.off { visibility: hidden; }
.bub { max-width: 88%; padding: 9px 13px; border-radius: 16px; font-size: 16px; line-height: 1.35; overflow-wrap: anywhere; }
.bub.a { background: var(--card); border: 1px solid var(--line); align-self: flex-start; border-bottom-left-radius: 5px; }
.bub.u { background: var(--soft); align-self: flex-end; border-bottom-right-radius: 5px; }
.bub:empty::after { content: "…"; color: var(--muted); }

.controls { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.ctl { padding: 14px 0; border-radius: 14px; background: var(--card); border: 1px solid var(--line); font-size: 14px; font-weight: 600; }
.ctl:active { background: var(--soft); }
.ctl[aria-pressed=true] { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.ctl.end { background: var(--bad); border-color: var(--bad); color: #fff; }

/* Raport i postępy */
.rep h2 { font: 600 27px/1.15 var(--serif); margin: 0 0 8px; }
.rep h3, #progressBody h3 { font-size: 13px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); margin: 22px 0 8px; }
.rep p { margin: 0 0 8px; }
.rep ul { margin: 0; padding-left: 20px; } .rep li { margin-bottom: 6px; }
.fix { padding: 12px 14px; border-radius: 14px; background: var(--card); border: 1px solid var(--line); margin-bottom: 8px; }
.fix .said { color: var(--bad); text-decoration: line-through; text-decoration-thickness: 1px; }
.fix .better { color: var(--good); font-weight: 600; display: block; margin: 2px 0 4px; }
.fix .why { color: var(--muted); font-size: 14px; display: block; }
.phrase { padding: 11px 14px; border-radius: 14px; background: var(--card); border: 1px solid var(--line); margin-bottom: 8px; }
.phrase b { display: block; } .phrase span { color: var(--muted); font-size: 14px; display: block; } .phrase em { font-size: 14px; display: block; margin-top: 3px; }
.phrase .tag { float: right; font-size: 12px; font-weight: 600; color: var(--accent); background: var(--soft); border-radius: 99px; padding: 2px 9px; margin-left: 8px; display: inline; }
.next { background: var(--soft); border-radius: 16px; padding: 14px 16px; margin: 18px 0 6px; }
.next p { margin: 0; }

.level { display: flex; gap: 16px; align-items: center; }
.level .badge { flex: none; width: 76px; height: 76px; border-radius: 22px; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; font: 700 28px var(--serif); }
.level p { margin: 0; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 12px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 12px; text-align: center; }
.stat b { display: block; font: 600 24px var(--serif); } .stat span { font-size: 13px; color: var(--muted); }
details { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; margin-bottom: 8px; }
summary { font-weight: 600; list-style: none; display: flex; justify-content: space-between; gap: 10px; }
summary::-webkit-details-marker { display: none; }
summary span { color: var(--muted); font-weight: 400; font-size: 14px; white-space: nowrap; }
details .rep { margin-top: 12px; } details .rep h2 { font-size: 20px; }
.settings .seg { grid-template-columns: 1fr 1fr; margin: 8px 0; }

.toast { position: fixed; left: 20px; right: 20px; bottom: calc(env(safe-area-inset-bottom) + 96px); background: var(--ink); color: var(--bg); padding: 13px 16px; border-radius: 14px; text-align: center; z-index: 9; font-size: 15px; }
