/* ACBC stylesheet. A green palette throughout: shades of emerald, moss, and mint. */
:root {
  --g50: #ecfdf5; --g100: #d1fae5; --g200: #a7f3d0; --g300: #6ee7b7; --g400: #34d399;
  --g500: #10b981; --g600: #059669; --g700: #047857; --g800: #065f46; --g900: #064e3b;
  --g950: #022c22; --bg: #04150e; --tx: #ecfdf5; --mut: #a7d8c1;
  --gl: rgba(16, 185, 129, .08); --bd: rgba(110, 231, 183, .2);
  --ink: #022c22;
}
* { box-sizing: border-box; margin: 0; font-family: 'Segoe UI', system-ui, -apple-system, 'Helvetica Neue', Arial, sans-serif; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; }
body {
  min-height: 100vh; min-height: 100dvh; color: var(--tx); overflow-x: hidden;
  background: radial-gradient(120% 90% at 50% 0, #0b3d2a, var(--bg) 70%);
  touch-action: manipulation; overscroll-behavior-y: none;
}
.bg i { position: fixed; border-radius: 50%; filter: blur(90px); opacity: .42; z-index: -1; animation: fl 18s ease-in-out infinite alternate; }
.bg i:nth-child(1) { width: 520px; height: 520px; background: var(--g600); top: -160px; left: -140px; }
.bg i:nth-child(2) { width: 460px; height: 460px; background: var(--g400); bottom: -160px; right: -120px; animation-delay: -7s; opacity: .25; }
.bg i:nth-child(3) { width: 340px; height: 340px; background: var(--g800); top: 45%; left: 55%; animation-delay: -12s; opacity: .4; }
@keyframes fl { to { transform: translate(110px, 70px) scale(1.2); } }

.wrap { max-width: 640px; margin: 0 auto; padding: calc(20px + env(safe-area-inset-top)) max(18px, env(safe-area-inset-right)) calc(60px + env(safe-area-inset-bottom)) max(18px, env(safe-area-inset-left)); }
.fade { animation: up .6s both; }
.glass {
  background: var(--gl); border: 1px solid var(--bd);
  backdrop-filter: blur(20px) saturate(150%); -webkit-backdrop-filter: blur(20px) saturate(150%);
  border-radius: 24px; box-shadow: 0 12px 40px rgba(0, 40, 25, .35), inset 0 1px 0 rgba(255, 255, 255, .08);
}
@keyframes up { from { opacity: 0; transform: translateY(24px) scale(.97); } }
h2 { font-size: 22px; margin-bottom: 14px; font-weight: 750; }
h3 { font-size: 17px; font-weight: 700; }
h4 { font-size: 15px; font-weight: 750; color: var(--g200); margin: 14px 0 4px; }
p { color: var(--mut); font-size: 15px; line-height: 1.6; }
ul, ol { color: #d1fae5; font-size: 15px; line-height: 1.6; padding-left: 22px; }
.small { font-size: 13px; }
.note { font-size: 13px; margin-top: 18px; }
.center { text-align: center; }
.warn { color: var(--g200); font-weight: 600; }

/* buttons and icons */
.ic { width: 46px; height: 46px; flex: none; display: grid; place-items: center; padding: 0; border-radius: 16px; border: 1px solid var(--bd); background: var(--gl); color: var(--tx); cursor: pointer; transition: .25s; }
.ic:hover { background: rgba(110, 231, 183, .18); transform: rotate(12deg) scale(1.06); }
.btn { border: 0; border-radius: 18px; padding: 13px 22px; font-size: 15px; font-weight: 750; color: var(--ink); cursor: pointer; background: linear-gradient(135deg, var(--g300), var(--g500)); box-shadow: 0 8px 22px rgba(16, 185, 129, .35); transition: .25s; position: relative; overflow: hidden; }
.btn:hover { transform: translateY(-2px); box-shadow: 0 12px 28px rgba(52, 211, 153, .45); }
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .55; pointer-events: none; }
.btn.ghost { background: var(--gl); color: var(--tx); border: 1px solid var(--bd); box-shadow: none; }
.btn.big { width: 100%; padding: 17px; font-size: 17px; }
.btn.sm { padding: 9px 16px; font-size: 14px; border-radius: 14px; }
.chip { border: 1px solid var(--bd); background: rgba(16, 185, 129, .1); color: var(--g100); border-radius: 999px; padding: 8px 13px; font-size: 13px; font-weight: 600; cursor: pointer; font-family: inherit; text-align: left; }
.chip:hover { background: rgba(110, 231, 183, .2); }
.chip.static { cursor: default; }
.spin { display: inline-block; width: 22px; height: 22px; flex: none; border-radius: 50%; border: 3px solid rgba(167, 243, 208, .2); border-top-color: var(--g300); animation: rot .8s linear infinite; vertical-align: middle; }
.spin.sm { width: 16px; height: 16px; border-width: 2px; }
@keyframes rot { to { transform: rotate(360deg); } }
.toast { position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 99; padding: 14px 20px; border-radius: 16px; max-width: 90vw; background: var(--g900); border: 1px solid var(--g500); color: var(--g50); box-shadow: 0 10px 30px rgba(0, 0, 0, .4); animation: up .4s both; }

/* home */
.homehead { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin: 6px 0 22px; }
.brand { font-size: 30px; font-weight: 850; letter-spacing: -.5px; color: var(--g200); }
.sub { color: var(--mut); font-size: 14px; margin-top: 2px; }
.hr { display: flex; align-items: center; gap: 10px; }
.total { padding: 9px 14px; border-radius: 999px; border: 1px solid var(--bd); background: var(--gl); font-size: 14px; color: var(--mut); }
.total b { color: var(--g200); }
.units { display: flex; flex-direction: column; gap: 14px; }
.ucard { padding: 18px; animation: up .6s both; animation-delay: calc(var(--d, 0) * 50ms); }
.uhead { display: flex; align-items: center; gap: 14px; }
.unum { width: 50px; height: 50px; flex: none; border-radius: 50%; display: grid; place-items: center; font-size: 20px; font-weight: 800; color: var(--g200); background: radial-gradient(circle at 30% 30%, rgba(110, 231, 183, .3), rgba(2, 44, 34, .9)); border: 1px solid var(--bd); }
.uinfo { flex: 1; min-width: 0; }
.uinfo h3 { line-height: 1.25; }
.uinfo p { font-size: 13px; margin-top: 3px; }
.upts { font-size: 13px; color: var(--mut); white-space: nowrap; }
.upts b { font-size: 20px; color: var(--g200); }
.ubtns { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 16px; }
.ubtns .btn { padding: 11px 8px; font-size: 14px; }

/* read */
.utitle { font-size: 24px; margin-bottom: 12px; line-height: 1.25; }
.meta { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.topics { padding: 14px 18px; margin-bottom: 14px; }
.topics summary { cursor: pointer; font-weight: 700; color: var(--g200); font-size: 15px; }
.topics ol { margin-top: 10px; font-size: 14px; color: var(--mut); }
.reader { display: flex; flex-direction: column; gap: 4px; }
.reader h3 { font-size: 19px; color: var(--g200); margin: 22px 0 8px; }
.reader p { color: #d1fae5; font-size: 15.5px; line-height: 1.7; margin: 6px 0; }
.reader .katex-display { margin: 10px 0; overflow-x: auto; overflow-y: hidden; padding: 4px 0; }
.reader .ex { padding: 12px 14px; border-radius: 16px; margin: 10px 0; background: rgba(255, 255, 255, .04); border: 1px solid var(--bd); font-size: 15px; line-height: 1.6; color: #ecfdf5; }
.reader .ex.a { background: rgba(16, 185, 129, .1); }
.reader .tip { padding: 12px 14px; border-left: 3px solid var(--g400); background: rgba(52, 211, 153, .1); border-radius: 0 14px 14px 0; font-size: 14px; line-height: 1.6; color: var(--g100); margin: 10px 0; }
.reader ul { margin: 6px 0 6px 2px; }
.sources { font-size: 12.5px; color: var(--mut); margin-top: 22px; line-height: 1.6; border-top: 1px solid var(--bd); padding-top: 14px; }
.rdbtns { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 18px; }

/* test start */
.tcard { padding: 22px; margin-bottom: 14px; }
.tcard h3 { font-size: 20px; margin-bottom: 8px; color: var(--g200); }
.tcard .lab { margin: 18px 0 8px; }
.rules { margin: 14px 0 20px; font-size: 14px; color: var(--mut); padding-left: 18px; }
.rules li { margin: 6px 0; }
.rules b { color: var(--g100); }
.lab { font-size: 12px; font-weight: 750; letter-spacing: .06em; text-transform: uppercase; color: var(--mut); display: block; }
.seg { display: flex; gap: 4px; padding: 5px; border-radius: 999px; background: rgba(16, 185, 129, .1); border: 1px solid var(--bd); }
.seg button { flex: 1; border: 0; background: transparent; color: var(--mut); font-size: 14px; font-weight: 700; padding: 10px 8px; border-radius: 999px; cursor: pointer; font-family: inherit; transition: .25s; }
.seg button.on { background: linear-gradient(135deg, var(--g300), var(--g500)); color: var(--ink); box-shadow: 0 6px 16px rgba(16, 185, 129, .35); }

/* run header and card */
.run { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; }
.rtop { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; }
.rstats { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 13px; color: var(--mut); flex: 1; justify-content: flex-end; }
.rstats b { color: var(--g200); }
.qcard { padding: 22px 20px; animation: up .5s both; }
.qcard .keypad { margin-bottom: 4px; }
.qcard.center { text-align: center; display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 44px 20px; }
.qcard.center .spin { width: 40px; height: 40px; border-width: 4px; }
.qhead { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 12px; }
.qno { font-size: 13px; font-weight: 800; color: var(--g200); margin-right: auto; }
.qtype { font-size: 12px; font-weight: 700; padding: 5px 11px; border-radius: 999px; background: rgba(16, 185, 129, .16); border: 1px solid var(--bd); color: var(--g100); }
.qtype.alt { background: rgba(163, 230, 53, .12); color: #d9f99d; }
.qprompt { font-size: 19px; line-height: 1.55; color: var(--tx); margin-bottom: 14px; }
.qprompt .katex { font-size: 1.05em; }
.qgraph { margin-bottom: 16px; }
.qactions { position: sticky; bottom: calc(10px + env(safe-area-inset-bottom)); z-index: 5; display: grid; grid-template-columns: auto 1fr; gap: 10px; margin-top: 16px; padding: 14px 0 6px; background: linear-gradient(to bottom, rgba(4, 21, 14, 0), rgba(4, 21, 14, .92) 30%); }
.qactions .btn.big { padding: 15px; }
.shake { animation: sk .5s; }
@keyframes sk { 20%, 60% { transform: translateX(-10px); } 40%, 80% { transform: translateX(10px); } }

/* choice */
.opts { display: flex; flex-direction: column; gap: 10px; }
.opt { display: flex; align-items: center; gap: 12px; padding: 14px 16px; border-radius: 18px; border: 1.5px solid var(--bd); background: rgba(255, 255, 255, .04); color: var(--tx); font-size: 17px; text-align: left; cursor: pointer; font-family: inherit; transition: .2s; }
.opt:hover:not(:disabled) { background: rgba(110, 231, 183, .12); transform: translateX(4px); }
.opt:disabled { cursor: default; }
.opt .ol { width: 32px; height: 32px; flex: none; border-radius: 50%; display: grid; place-items: center; font-weight: 800; font-size: 14px; background: rgba(16, 185, 129, .2); color: var(--g100); }
.opt .ot { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.opt.sel { border-color: var(--g300); background: rgba(110, 231, 183, .2); box-shadow: 0 0 22px rgba(52, 211, 153, .3); }
.opt.right { border-color: var(--g300); background: rgba(52, 211, 153, .24); }
.opt.right .ol { background: var(--g400); color: var(--ink); }
.opt.wrong { border-style: dashed; border-color: rgba(167, 243, 208, .55); background: rgba(2, 44, 34, .6); color: #cfe9dc; }

/* solve input and keypad */
.ansbox { display: flex; flex-direction: column; gap: 10px; }
#ans { width: 100%; font-size: 18px; padding: 15px 16px; border-radius: 18px; border: 1.5px solid var(--bd); background: rgba(255, 255, 255, .06); color: var(--tx); outline: 0; font-family: 'Cambria Math', 'Latin Modern Math', 'Times New Roman', serif; }
#ans:focus { border-color: var(--g300); box-shadow: 0 0 0 4px rgba(52, 211, 153, .2); }
#ans:disabled { opacity: .7; }
.preview { min-height: 58px; padding: 12px 14px; border-radius: 18px; background: rgba(2, 44, 34, .55); border: 1px dashed rgba(110, 231, 183, .35); overflow-x: auto; color: var(--g50); font-size: 18px; display: flex; align-items: center; }
.preview.muted { color: var(--mut); font-size: 14px; font-family: inherit; }
.preview.bad { color: var(--g200); font-family: ui-monospace, monospace; font-size: 15px; }
.keypad { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; margin-top: 12px; }
.key { border: 1px solid var(--bd); background: rgba(16, 185, 129, .1); color: var(--g50); border-radius: 13px; padding: 10px 2px; font-size: 16px; font-weight: 700; cursor: pointer; font-family: inherit; min-height: 44px; transition: .15s; }
.key:hover { background: rgba(110, 231, 183, .2); }
.key:active { transform: scale(.94); }
.key.fn { background: rgba(2, 44, 34, .6); font-size: 13px; color: var(--g200); }
@media (max-width: 480px) { .keypad { grid-template-columns: repeat(5, 1fr); } }

/* feedback */
.fb { margin-top: 16px; padding: 16px; border-radius: 20px; display: flex; flex-direction: column; gap: 8px; animation: up .4s both; }
.fb.ok { background: rgba(52, 211, 153, .18); border: 1px solid rgba(110, 231, 183, .6); }
.fb.no { background: rgba(2, 44, 34, .75); border: 1px dashed rgba(167, 243, 208, .55); }
.fb.wait { flex-direction: row; align-items: center; gap: 12px; background: rgba(16, 185, 129, .12); border: 1px solid var(--bd); color: var(--g100); }
.fbt { font-size: 18px; font-weight: 800; }
.fb.ok .fbt { color: var(--g200); }
.fb.no .fbt { color: var(--g100); }
.fba { font-size: 15px; color: var(--g50); }
.fbf { font-size: 14px; color: #d1fae5; line-height: 1.55; }
.mt .katex { font-size: 1.05em; }

/* result */
.res { text-align: center; padding-top: 30px; }
.pr { --p: 0; width: 190px; height: 190px; margin: 18px auto; border-radius: 50%; display: grid; place-items: center; background: conic-gradient(var(--g400) calc(var(--p) * 1%), rgba(110, 231, 183, .14) 0); box-shadow: 0 0 60px rgba(52, 211, 153, .3); }
.pr div { width: 158px; height: 158px; border-radius: 50%; background: var(--g950); display: grid; place-items: center; font-size: 40px; font-weight: 800; color: var(--g200); }
.res p { margin: 8px 0; }
.resbtns { display: flex; gap: 10px; justify-content: center; margin-top: 26px; flex-wrap: wrap; }
.resbtns .btn { min-width: 150px; }

/* explanation sheet */
.sheet-bg { position: fixed; inset: 0; z-index: 60; background: rgba(1, 18, 12, .72); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); display: flex; align-items: flex-end; justify-content: center; padding: 0; animation: fi .25s both; }
@keyframes fi { from { opacity: 0; } }
.sheet { width: 100%; max-width: 680px; height: min(88dvh, 880px); display: flex; flex-direction: column; border-radius: 28px 28px 0 0; padding: 18px 18px calc(12px + env(safe-area-inset-bottom)); animation: slideup .35s cubic-bezier(.2, .9, .3, 1); background: rgba(4, 30, 22, .96); }
@keyframes slideup { from { transform: translateY(40px); opacity: 0; } }
.sheet-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-bottom: 12px; border-bottom: 1px solid var(--bd); }
.sheet-top h3 { color: var(--g200); font-size: 19px; }
.sheet-body { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; padding: 14px 4px; }
.sheet-body h4 { font-size: 15px; margin-top: 16px; color: var(--g200); }
.sheet-body p { color: #e6fbf1; font-size: 15.5px; line-height: 1.7; margin: 6px 0; }
.sheet-body ul { margin: 6px 0; }
.sheet-body .katex-display { overflow-x: auto; overflow-y: hidden; padding: 4px 0; }
.qmsg { align-self: flex-end; background: rgba(16, 185, 129, .22); border: 1px solid var(--bd); border-radius: 18px 18px 4px 18px; padding: 10px 14px; margin: 14px 0 6px auto; max-width: 85%; color: var(--g50); font-size: 15px; }
.amsg { padding-bottom: 6px; }
.pend { display: flex; align-items: center; gap: 10px; color: var(--mut); padding: 14px 0; font-size: 15px; }
.emsg { color: var(--g100); font-size: 14px; padding: 12px 0; display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.sheet-ask { display: flex; gap: 10px; padding-top: 12px; border-top: 1px solid var(--bd); }
.sheet-ask input { flex: 1; min-width: 0; font-size: 16px; padding: 12px 14px; border-radius: 16px; border: 1.5px solid var(--bd); background: rgba(255, 255, 255, .06); color: var(--tx); outline: 0; }
.sheet-ask input:focus { border-color: var(--g300); }

/* tutor */
.tutor { display: flex; flex-direction: column; min-height: 100vh; min-height: 100dvh; }
.topbar { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.topbar .ttl { flex: 1; font-size: 19px; font-weight: 750; color: var(--g200); min-width: 0; }
.gcard { padding: 10px; margin-bottom: 12px; }
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 4px 2px 10px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chips .chip { flex: none; }
.chat { flex: 1; min-height: 160px; display: flex; flex-direction: column; gap: 10px; padding: 4px 2px 12px; }
.bub { max-width: 92%; padding: 12px 15px; border-radius: 18px; font-size: 15px; line-height: 1.6; color: #e6fbf1; animation: up .3s both; }
.bub.me { align-self: flex-end; background: rgba(16, 185, 129, .25); border: 1px solid var(--bd); border-bottom-right-radius: 6px; white-space: pre-wrap; }
.bub.ai { align-self: flex-start; background: rgba(255, 255, 255, .05); border: 1px solid var(--bd); border-bottom-left-radius: 6px; }
.bub.ai p { color: #e6fbf1; margin: 4px 0; font-size: 15px; }
.bub.ai h4 { margin-top: 10px; }
.bub.err { border-color: rgba(167, 243, 208, .6); }
.bub.pend { display: flex; align-items: center; gap: 10px; color: var(--mut); }
.bpic { margin-top: 12px; }
.bpic .gcv { border-radius: 14px; }
.composer { position: sticky; bottom: calc(10px + env(safe-area-inset-bottom)); display: flex; gap: 10px; padding: 10px; border-radius: 22px; background: rgba(4, 30, 22, .92); border: 1px solid var(--bd); backdrop-filter: blur(14px); }
.composer input { flex: 1; min-width: 0; font-size: 16px; padding: 12px 14px; border-radius: 16px; border: 1.5px solid var(--bd); background: rgba(255, 255, 255, .06); color: var(--tx); outline: 0; }
.composer input:focus { border-color: var(--g300); }

/* graphs */
.gbox { color: var(--tx); }
.gcv { position: relative; width: 100%; border-radius: 16px; overflow: hidden; background: rgba(2, 30, 22, .7); border: 1px solid var(--bd); }
.gcv canvas { display: block; width: 100%; height: 100%; touch-action: pan-y; cursor: grab; }
.gtools { display: flex; gap: 6px; margin: 8px 2px 4px; }
.gtools button { border: 1px solid var(--bd); background: var(--gl); color: var(--tx); border-radius: 12px; padding: 7px 13px; font-size: 14px; font-weight: 700; cursor: pointer; font-family: inherit; }
.gtools button:hover { background: rgba(110, 231, 183, .2); }
.glegend { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; font-size: 13.5px; }
.lrow { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; color: var(--mut); }
.lrow i { display: inline-block; width: 14px; height: 4px; border-radius: 3px; flex: none; }
.lrow i.pt { width: 11px; height: 11px; border-radius: 50%; background: transparent; border: 2px solid; }
.lrow b { color: var(--g100); }
.lrow code { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 13px; color: #d1fae5; background: rgba(2, 44, 34, .6); padding: 2px 7px; border-radius: 8px; }
.lrow .dom { color: var(--mut); font-size: 12.5px; }
.lrow .bad { color: var(--g200); }
.lrow .empty { color: var(--mut); }
.empty { color: var(--mut); font-size: 13px; }

/* modal (settings) */
.ov { position: fixed; inset: 0; z-index: 50; background: rgba(1, 18, 12, .66); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); display: grid; place-items: center; padding: 18px; z-index: 50; animation: fi .25s both; }
.modal { width: 100%; max-width: 440px; max-height: calc(100dvh - 36px); overflow-y: auto; padding: 22px; display: flex; flex-direction: column; gap: 14px; background: rgba(4, 30, 22, .97); }
.modal-top { display: flex; align-items: center; justify-content: space-between; }
.modal-top h3 { font-size: 20px; color: var(--g200); }
.kw { display: flex; gap: 10px; }
.kw input { flex: 1; min-width: 0; font-size: 16px; padding: 12px 14px; border-radius: 16px; border: 1.5px solid var(--bd); background: rgba(255, 255, 255, .06); color: var(--tx); outline: 0; }
.kw input:focus { border-color: var(--g300); }
.rowbtn { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 14px 16px; border-radius: 16px; background: rgba(16, 185, 129, .08); border: 1px solid var(--bd); cursor: pointer; color: var(--tx); font-size: 15px; }
.rowbtn:hover { background: rgba(110, 231, 183, .16); }
.rowbtn b { color: var(--g200); font-size: 14px; }
.rowbtn input[type=file] { max-width: 170px; font-size: 12px; color: var(--mut); }
.rowbtn input[type=file]::file-selector-button { border: 1px solid var(--bd); background: rgba(16, 185, 129, .18); color: var(--g100); border-radius: 12px; padding: 7px 11px; margin-right: 8px; cursor: pointer; font-family: inherit; font-weight: 700; }
.modal a { color: var(--g200); }

/* ---------- small screens ---------- */
@media (max-width: 600px) {
  .qprompt { font-size: 17px; }
  .opt { font-size: 16px; padding: 12px 14px; }
  .ubtns .btn { font-size: 13px; padding: 10px 6px; }
  .uhead { gap: 10px; }
  .unum { width: 42px; height: 42px; font-size: 17px; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: .01s !important; transition-duration: .01s !important; } }
