/* Smart21brain AI — extras: modals, prompt library, My style, voice chat, flashcards & quizzes */
.top, .composer-wrap, .composer { position: relative; }
#styleBtn { position: relative; }
#styleBtn.x-on::after { content: ''; position: absolute; top: 7px; right: 7px; width: 8px; height: 8px; border-radius: 50%; background: var(--brand); border: 2px solid var(--bg); }
.x-dim { opacity: .45; }
.modes { overflow-x: auto; scrollbar-width: none; flex-wrap: nowrap; }
.modes::-webkit-scrollbar { display: none; }
.modes > * { flex: 0 0 auto; }

/* ---------- modal ---------- */
.x-modal { position: fixed; inset: 0; z-index: 200; background: rgba(5,12,9,.55); backdrop-filter: blur(3px); display: grid; place-items: center; padding: 1rem; animation: xFade .15s ease; }
.x-box { width: min(520px, 100%); max-height: min(90dvh, 760px); display: flex; flex-direction: column; background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow); overflow: hidden; }
.x-box.x-wide, .x-modal.x-wide .x-box { width: min(720px, 100%); }
.x-head { display: flex; align-items: center; gap: .6rem; padding: .85rem 1rem; border-bottom: 1px solid var(--line); font-family: var(--display); font-weight: 600; }
.x-head i { color: var(--brand); }
.x-head .x-title, .x-head span { flex: 1; }
.x-close { margin-left: auto; }
.x-body { padding: 1rem; overflow-y: auto; display: flex; flex-direction: column; gap: .9rem; }
.x-desc { margin: 0; color: var(--soft); font-size: .88rem; line-height: 1.5; }
.x-field { display: flex; flex-direction: column; gap: .4rem; }
.x-field > label, .x-rng > span { font-size: .8rem; font-weight: 600; color: var(--soft); }
.x-seg { display: flex; gap: 4px; padding: 4px; background: var(--side); border: 1px solid var(--line); border-radius: 12px; }
.x-seg button { flex: 1; border: 0; background: transparent; border-radius: 9px; padding: .5rem .6rem; font-size: .85rem; color: var(--soft); font-weight: 600; }
.x-seg button.on { background: var(--panel); color: var(--brand); box-shadow: 0 1px 4px rgba(0,0,0,.15); }
.x-ta { width: 100%; resize: vertical; min-height: 90px; padding: .7rem .8rem; border-radius: 12px; border: 1px solid var(--line); background: var(--bg); color: var(--text); font: inherit; font-size: .92rem; line-height: 1.5; }
.x-ta:focus, .xp-q:focus { outline: 2px solid var(--brand); outline-offset: 1px; }
.x-chips { display: flex; flex-wrap: wrap; gap: .4rem; align-items: center; font-size: .78rem; color: var(--soft); }
.x-chip { border: 1px solid var(--line); background: var(--side); border-radius: 999px; padding: .28rem .7rem; font-size: .78rem; }
.x-chip:hover { border-color: var(--brand); color: var(--brand); }
.x-tg { display: flex; align-items: center; gap: .55rem; font-size: .9rem; cursor: pointer; }
.x-tg input { width: 18px; height: 18px; accent-color: var(--brand); }
.x-rng { display: grid; grid-template-columns: 1fr auto; gap: .3rem .6rem; align-items: center; margin-top: .3rem; }
.x-rng input[type=range] { grid-column: 1 / -1; width: 100%; accent-color: var(--brand); }
.x-rng output { font-weight: 700; color: var(--brand); font-size: .85rem; }
.x-row { display: flex; gap: .6rem; justify-content: flex-end; flex-wrap: wrap; }
.pill-btn { display: inline-flex; align-items: center; gap: .45rem; padding: .55rem 1rem; border-radius: 999px; border: 1px solid var(--line); background: var(--panel); font-size: .88rem; font-weight: 600; transition: border-color .15s, background .15s; }
.pill-btn:hover:not(:disabled) { border-color: var(--brand); }
.pill-btn.primary { background: var(--brand); color: var(--on-brand); border-color: var(--brand); }
.pill-btn:disabled { opacity: .45; cursor: not-allowed; }

/* ---------- popovers (prompt library, share) ---------- */
.x-pop { position: absolute; z-index: 60; bottom: calc(100% + 8px); left: 0; right: 0; background: var(--panel); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow); max-height: 56vh; display: flex; flex-direction: column; overflow: hidden; }
.x-pop[hidden] { display: none; }
.x-share { left: auto; right: 0; bottom: auto; top: calc(100% + 6px); width: 240px; padding: .35rem; max-height: none; }
.x-share button { display: flex; gap: .7rem; align-items: center; width: 100%; background: transparent; border: 0; padding: .6rem .7rem; border-radius: 10px; text-align: left; font-size: .9rem; }
.x-share button:hover { background: var(--hover); }
.x-share i { width: 18px; color: var(--brand); }
.xp-head { display: flex; gap: .4rem; padding: .6rem; border-bottom: 1px solid var(--line); align-items: center; }
.xp-search { flex: 1; position: relative; }
.xp-search i { position: absolute; left: .75rem; top: 50%; transform: translateY(-50%); color: var(--soft); font-size: .8rem; }
.xp-q { width: 100%; padding: .5rem .7rem .5rem 2rem; border-radius: 10px; border: 1px solid var(--line); background: var(--bg); color: var(--text); font: inherit; font-size: .9rem; }
.xp-tabs { display: flex; gap: .3rem; padding: .5rem .6rem; overflow-x: auto; scrollbar-width: none; }
.xp-tabs button { flex: 0 0 auto; border: 1px solid var(--line); background: transparent; border-radius: 999px; padding: .25rem .75rem; font-size: .78rem; font-weight: 600; color: var(--soft); }
.xp-tabs button.on { background: var(--brand); border-color: var(--brand); color: var(--on-brand); }
.xp-list { overflow-y: auto; padding: .3rem .4rem; flex: 1; }
.xp-item { display: flex; align-items: center; gap: .5rem; padding: .55rem .7rem; border-radius: 10px; cursor: pointer; font-size: .9rem; }
.xp-item:hover, .xp-item.sel { background: var(--hover); }
.xp-item.sel { outline: 1px solid var(--brand); }
.xp-t { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.xp-del { border: 0; background: transparent; color: var(--soft); width: 28px; height: 28px; border-radius: 8px; }
.xp-del:hover { color: #e5484d; background: var(--hover); }
.xp-empty { padding: 1.2rem; text-align: center; color: var(--soft); font-size: .88rem; }
.xp-foot { display: flex; gap: .5rem; align-items: center; padding: .5rem .6rem; border-top: 1px solid var(--line); }
.xp-save { border: 0; background: transparent; color: var(--brand); font-weight: 600; font-size: .82rem; }
.xp-hint { margin-left: auto; font-size: .72rem; color: var(--soft); }

/* ---------- voice chat ---------- */
.vc { position: fixed; inset: 0; z-index: 300; display: flex; flex-direction: column; align-items: center; justify-content: space-between; padding: 1.2rem; background: radial-gradient(circle at 50% 38%, color-mix(in srgb, var(--brand) 22%, var(--bg)), var(--bg) 70%); color: var(--text); animation: xFade .2s ease; }
.vc-x { align-self: flex-end; }
.vc-mid { display: flex; flex-direction: column; align-items: center; gap: .9rem; text-align: center; max-width: 560px; width: 100%; }
.vc-orb { position: relative; width: 128px; height: 128px; border-radius: 50%; border: 0; background: linear-gradient(135deg, var(--brand-2), var(--brand)); color: #fff; font-size: 2.2rem; display: grid; place-items: center; box-shadow: 0 10px 40px rgba(0,0,0,.35); transition: transform .2s; }
.vc-orb:hover { transform: scale(1.04); }
.vc-ring { position: absolute; inset: 0; border-radius: 50%; border: 2px solid var(--brand); opacity: 0; pointer-events: none; }
.vc[data-state=listening] .vc-ring { animation: vcPulse 1.6s ease-out infinite; }
.vc[data-state=listening] .vc-ring.r2 { animation-delay: .8s; }
.vc[data-state=speaking] .vc-orb { animation: vcBeat .9s ease-in-out infinite; }
.vc[data-state=thinking] .vc-orb { animation: vcSpin 1.2s linear infinite; background: conic-gradient(var(--brand), var(--brand-2), var(--brand)); }
.vc[data-state=thinking] .vc-orb i { animation: vcSpin 1.2s linear infinite reverse; }
.vc[data-state=error] .vc-orb { background: #c2410c; }
.vc-status { margin: 0; font-family: var(--display); font-weight: 600; font-size: 1.15rem; }
.vc-hint { margin: 0; color: var(--soft); font-size: .85rem; }
.vc-you, .vc-ai { margin: 0; padding: .7rem 1rem; border-radius: 14px; font-size: .95rem; line-height: 1.5; max-width: 100%; max-height: 22vh; overflow-y: auto; }
.vc-you { background: var(--user); }
.vc-ai { background: var(--panel); border: 1px solid var(--line); }
.vc-end { background: #c2410c; border-color: #c2410c; color: #fff; }
@keyframes vcPulse { from { transform: scale(1); opacity: .7; } to { transform: scale(1.9); opacity: 0; } }
@keyframes vcBeat { 50% { transform: scale(1.1); } }
@keyframes vcSpin { to { transform: rotate(360deg); } }
@keyframes xFade { from { opacity: 0; } }

/* ---------- study ---------- */
.st-opts { display: flex; flex-direction: column; gap: .8rem; }
.st-msg { color: var(--soft); font-size: .88rem; }
.st-msgline { color: #e5484d; font-size: .85rem; margin: 0; }
.st-h { margin: .4rem 0 0; font-size: .85rem; color: var(--soft); text-transform: uppercase; letter-spacing: .05em; }
.st-list { display: flex; flex-direction: column; gap: .4rem; }
.st-item { display: flex; align-items: center; gap: .8rem; padding: .65rem .8rem; border: 1px solid var(--line); border-radius: 12px; background: var(--bg); }
.st-item > i { color: var(--brand); }
.st-info { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.st-info b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .92rem; }
.st-info span { font-size: .78rem; color: var(--soft); }
.st-open { border: 1px solid var(--brand); color: var(--brand); background: transparent; border-radius: 999px; padding: .3rem .8rem; font-size: .8rem; font-weight: 600; }
.st-del { border: 0; background: transparent; color: var(--soft); width: 30px; height: 30px; border-radius: 8px; }
.st-del:hover { color: #e5484d; }
.st-empty { color: var(--soft); text-align: center; padding: .8rem; font-size: .88rem; }
.st-load { display: flex; flex-direction: column; align-items: center; gap: .8rem; padding: 2rem 1rem; color: var(--soft); }
.st-spin { width: 34px; height: 34px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--brand); animation: vcSpin .8s linear infinite; }
.st-warn { display: flex; gap: .6rem; padding: .7rem .9rem; border-radius: 12px; background: rgba(229,72,77,.12); color: #e5484d; font-size: .88rem; align-items: center; }
.st-bar { height: 6px; border-radius: 999px; background: var(--line); overflow: hidden; }
.st-bar i { display: block; height: 100%; background: linear-gradient(90deg, var(--brand-2), var(--brand)); transition: width .25s; }
.st-end { text-align: center; display: flex; flex-direction: column; align-items: center; gap: .6rem; padding: .6rem 0; }
.st-end > i { font-size: 2.4rem; color: var(--brand); }
.st-end h3 { margin: 0; font-family: var(--display); }
.st-end p { margin: 0; color: var(--soft); }
.fc-top { display: flex; align-items: center; gap: .6rem; }
.fc-n { margin-right: auto; margin-left: auto; font-size: .85rem; color: var(--soft); font-weight: 600; }
.fc-card { perspective: 800px; display: flex; flex-direction: column; justify-content: center; align-items: center; gap: .6rem; min-height: 230px; padding: 1.4rem; border-radius: 18px; border: 1px solid var(--line); background: var(--bg); text-align: center; position: relative; transition: transform .25s, background .2s, border-color .2s; }
.fc-card:hover { border-color: var(--brand); }
.fc-card.flipped { background: var(--user); border-color: var(--brand); }
.fc-side { position: absolute; top: .7rem; left: .9rem; font-size: .72rem; font-weight: 800; color: var(--brand); letter-spacing: .1em; }
.fc-text { font-size: 1.15rem; line-height: 1.5; font-weight: 600; color: var(--text); }
.fc-tip { position: absolute; bottom: .6rem; font-size: .72rem; color: var(--soft); }
.fc-act { display: flex; gap: .5rem; justify-content: center; flex-wrap: wrap; }
.fc-yes { background: var(--brand); color: var(--on-brand); border-color: var(--brand); }
.fc-no { color: #e5484d; border-color: #e5484d; }
.qz-score { margin-left: auto; font-size: .85rem; color: var(--soft); }
.qz-score b { color: var(--brand); font-size: 1rem; }
.qz-fire { color: #f59e0b; font-weight: 700; }
.qz-q { margin: .2rem 0; font-size: 1.05rem; line-height: 1.5; font-family: var(--display); }
.qz-opts { display: flex; flex-direction: column; gap: .5rem; }
.qz-opt { display: flex; gap: .8rem; align-items: center; text-align: left; padding: .7rem .9rem; border-radius: 12px; border: 1px solid var(--line); background: var(--bg); font-size: .92rem; transition: border-color .15s, background .15s; }
.qz-opt:hover:not(:disabled) { border-color: var(--brand); }
.qz-opt:disabled { cursor: default; opacity: .9; }
.qz-l { flex: 0 0 auto; width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center; background: var(--side); font-weight: 700; font-size: .8rem; }
.qz-opt.right { border-color: #16a34a; background: rgba(22,163,74,.14); }
.qz-opt.right .qz-l { background: #16a34a; color: #fff; }
.qz-opt.wrong { border-color: #e5484d; background: rgba(229,72,77,.12); }
.qz-opt.wrong .qz-l { background: #e5484d; color: #fff; }
.qz-fb { padding: .7rem .9rem; border-radius: 12px; font-size: .88rem; line-height: 1.5; }
.qz-fb[hidden] { display: none; }
.qz-fb.ok { background: rgba(22,163,74,.12); }
.qz-fb.bad { background: rgba(229,72,77,.1); }
.qz-ring { --p: 0; width: 120px; height: 120px; border-radius: 50%; display: grid; place-items: center; background: conic-gradient(var(--brand) calc(var(--p) * 1%), var(--line) 0); position: relative; }
.qz-ring::before { content: ''; position: absolute; inset: 10px; border-radius: 50%; background: var(--panel); }
.qz-ring b { position: relative; font-size: 1.5rem; font-family: var(--display); }
.qz-rev { display: flex; flex-direction: column; gap: .5rem; text-align: left; width: 100%; }
.qz-ri { display: flex; flex-direction: column; gap: .2rem; padding: .7rem .9rem; border: 1px solid var(--line); border-radius: 12px; font-size: .85rem; }
.qz-ri .bad { color: #e5484d; }
.qz-ri .ok { color: #16a34a; }

/* ---------- small screens ---------- */
@media (max-width: 600px) {
  .top .model-chip, #exportChat { display: none; }
  .x-modal { padding: 0; align-items: end; }
  .x-box, .x-modal.x-wide .x-box { width: 100%; max-height: 92dvh; border-radius: 18px 18px 0 0; }
  .fc-card { min-height: 190px; }
  .vc-orb { width: 108px; height: 108px; }
  .xp-hint { display: none; }
}
@media (prefers-reduced-motion: reduce) { .vc *, .vc, .x-modal, .st-spin, .st-bar i { animation: none !important; transition: none !important; } }
@media print { .x-modal, .vc, .x-pop { display: none !important; } }
