:root {
  --primary: #4f46e5;
  --primary-2: #7c3aed;
  --text: #0f172a;
  --muted: #64748b;
  --border: #e2e8f0;
  --bg: #ffffff;
  --bg-alt: #f8fafc;
  --radius: 14px;
  --shadow: 0 10px 30px -12px rgba(15, 23, 42, .18);
  --code-bg: #0d1117;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Segoe UI", Roboto, sans-serif;
  color: var(--text); background: var(--bg); line-height: 1.65; -webkit-font-smoothing: antialiased;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { line-height: 1.25; margin: 0 0 .5em; }
.container { max-width: 1160px; margin: 0 auto; padding: 0 20px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.center { text-align: center; }

/* buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid transparent; border-radius: 10px; padding: 10px 18px; font-size: 15px; font-weight: 600; cursor: pointer; transition: .15s; text-decoration: none !important; font-family: inherit; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: linear-gradient(135deg, var(--primary), var(--primary-2)); color: #fff; box-shadow: 0 6px 16px -6px rgba(79, 70, 229, .6); }
.btn-primary:hover:not(:disabled) { filter: brightness(1.08); transform: translateY(-1px); }
.btn-outline { background: #fff; border-color: var(--border); color: var(--text); }
.btn-outline:hover { border-color: var(--primary); color: var(--primary); }
.btn-ghost { background: transparent; color: var(--text); border-color: var(--border); }
.btn-light { background: #fff; color: var(--primary); }
.btn-lg { padding: 13px 26px; font-size: 16px; }
.btn-sm { padding: 6px 14px; font-size: 14px; }
.btn-block { width: 100%; }
.icon-btn { background: none; border: 0; font-size: 18px; cursor: pointer; padding: 6px 8px; border-radius: 8px; color: inherit; }
.icon-btn:hover { background: rgba(127, 127, 127, .15); }
.pill { display: inline-block; padding: 5px 12px; border-radius: 99px; background: #eef2ff; color: var(--primary); font-size: 13px; font-weight: 600; }
.pill-light { background: rgba(255, 255, 255, .22); color: #fff; }

/* nav */
.nav { position: sticky; top: 0; z-index: 50; background: rgba(255, 255, 255, .86); backdrop-filter: saturate(180%) blur(12px); border-bottom: 1px solid var(--border); }
.nav-inner { display: flex; align-items: center; justify-content: space-between; height: 62px; }
.logo { display: inline-flex; align-items: center; gap: 10px; font-weight: 800; font-size: 18px; color: var(--text); text-decoration: none !important; }
.logo-mark { display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: 9px; background: linear-gradient(135deg, var(--primary), var(--primary-2)); color: #fff; font: 700 13px/1 ui-monospace, Menlo, monospace; }
.logo-mark.big { width: 64px; height: 64px; font-size: 24px; border-radius: 18px; margin: 0 auto 16px; }
.nav-links { display: flex; align-items: center; gap: 26px; }
.nav-links a { color: #334155; font-weight: 500; font-size: 15px; }
.nav-links a.active, .nav-links a:hover { color: var(--primary); text-decoration: none; }
.nav-links a.btn-primary { color: #fff; }
.nav-toggle { display: none; background: none; border: 0; font-size: 22px; cursor: pointer; }
@media (max-width: 760px) {
  .nav-toggle { display: block; }
  .nav-links { display: none; position: absolute; top: 62px; left: 0; right: 0; flex-direction: column; align-items: stretch; gap: 0; background: #fff; border-bottom: 1px solid var(--border); padding: 8px 20px 16px; }
  .nav-links a { padding: 10px 0; }
  .nav-open .nav-links { display: flex; }
}

/* hero */
.hero { background: radial-gradient(1000px 500px at 85% -10%, #ede9fe 0%, transparent 60%), radial-gradient(800px 400px at -10% 10%, #e0f2fe 0%, transparent 60%); padding: 72px 0 80px; }
.hero-inner { display: grid; grid-template-columns: 1.05fr 1fr; gap: 48px; align-items: center; }
.hero h1 { font-size: clamp(34px, 5vw, 54px); font-weight: 800; letter-spacing: -.02em; margin: 18px 0; }
.grad { background: linear-gradient(135deg, var(--primary), #db2777); -webkit-background-clip: text; background-clip: text; color: transparent; }
.lead { font-size: 18px; color: #475569; max-width: 540px; }
.hero-cta { display: flex; gap: 12px; flex-wrap: wrap; margin: 28px 0 12px; }
.demo-window { background: var(--code-bg); border-radius: 16px; box-shadow: 0 30px 60px -20px rgba(30, 27, 75, .45); overflow: hidden; color: #e2e8f0; }
.demo-bar { display: flex; align-items: center; gap: 7px; padding: 12px 16px; background: #161b22; font-size: 13px; color: #8b949e; }
.demo-bar i { width: 11px; height: 11px; border-radius: 50%; background: #ff5f57; }
.demo-bar i:nth-child(2) { background: #febc2e; } .demo-bar i:nth-child(3) { background: #28c840; }
.demo-bar span { margin-left: 8px; }
.demo-body { padding: 20px; font-size: 14px; }
.demo-user { background: #4f46e5; color: #fff; padding: 10px 14px; border-radius: 12px 12px 2px 12px; margin-left: auto; width: fit-content; max-width: 85%; margin-bottom: 14px; }
.demo-ai pre { background: #161b22; padding: 14px; border-radius: 10px; margin: 0 0 10px; overflow: auto; font: 13px/1.6 ui-monospace, Menlo, Consolas, monospace; }
.demo-ai p { margin: 0; color: #c9d1d9; }
.demo-ai .k { color: #ff7b72; } .demo-ai .f { color: #d2a8ff; }
@media (max-width: 900px) { .hero-inner { grid-template-columns: 1fr; } .hero { padding: 48px 0; } }

/* sections */
.section { padding: 72px 0; }
.section-alt { background: var(--bg-alt); }
.section-title { text-align: center; font-size: 32px; font-weight: 800; }
.section-sub { text-align: center; color: var(--muted); margin: -4px 0 36px; }
.features { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; margin-top: 36px; }
.feature { background: #fff; border: 1px solid var(--border); border-radius: var(--radius); padding: 26px; transition: .2s; }
.feature:hover { box-shadow: var(--shadow); transform: translateY(-2px); }
.feature p { color: var(--muted); margin: 0; }
.ficon { font-size: 28px; margin-bottom: 10px; }
@media (max-width: 900px) { .features { grid-template-columns: 1fr 1fr; } }
@media (max-width: 600px) { .features { grid-template-columns: 1fr; } }
.cta-band { background: linear-gradient(135deg, var(--primary), var(--primary-2)); color: #fff; text-align: center; padding: 64px 0; }
.cta-band h2 { font-size: 28px; margin-bottom: 22px; }

.page-head { background: linear-gradient(135deg, #eef2ff, #faf5ff); padding: 56px 0 44px; text-align: center; }
.page-head h1 { font-size: 36px; font-weight: 800; }
.page-head p { color: var(--muted); margin: 0; font-size: 17px; }

/* cards */
.card { background: #fff; border: 1px solid var(--border); border-radius: var(--radius); padding: 28px; }

/* plans */
.plans { display: grid; grid-template-columns: repeat(3, 1fr); gap: 22px; max-width: 980px; margin: 0 auto; }
.plan { position: relative; background: #fff; border: 1px solid var(--border); border-radius: 18px; padding: 32px 28px; display: flex; flex-direction: column; }
.plan-hot { border: 2px solid var(--primary); box-shadow: 0 20px 40px -18px rgba(79, 70, 229, .45); }
.plan-badge { position: absolute; top: -13px; left: 50%; transform: translateX(-50%); background: linear-gradient(135deg, var(--primary), var(--primary-2)); color: #fff; font-size: 12px; font-weight: 700; padding: 4px 14px; border-radius: 99px; }
.plan-price { font-size: 44px; font-weight: 800; margin: 6px 0; }
.plan-price .cur { font-size: 22px; vertical-align: top; margin-right: 2px; }
.plan-price .per { font-size: 15px; color: var(--muted); font-weight: 500; }
.perks { list-style: none; padding: 0; margin: 18px 0 24px; flex: 1; }
.perks li { padding: 6px 0 6px 26px; position: relative; }
.perks li::before { content: "✓"; position: absolute; left: 0; color: #10b981; font-weight: 800; }
@media (max-width: 860px) { .plans { grid-template-columns: 1fr; max-width: 420px; } }
.compare { max-width: 980px; margin: 36px auto 0; }
.compare table { width: 100%; border-collapse: collapse; margin: 10px 0; }
.compare th, .compare td { padding: 12px; border-bottom: 1px solid var(--border); text-align: center; }
.compare td:first-child, .compare th:first-child { text-align: left; }

/* courses */
.courses { display: grid; grid-template-columns: repeat(4, 1fr); gap: 20px; }
.course { display: flex; flex-direction: column; background: #fff; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; color: inherit; transition: .2s; text-decoration: none !important; }
.course:hover { transform: translateY(-3px); box-shadow: var(--shadow); }
.course-cover { height: 130px; display: grid; place-items: center; position: relative; }
.course-cover span { font-size: 46px; }
.course-cover em { position: absolute; top: 10px; left: 10px; font-style: normal; font-size: 12px; background: rgba(0, 0, 0, .25); color: #fff; padding: 2px 9px; border-radius: 99px; }
.course-body { padding: 18px; display: flex; flex-direction: column; flex: 1; }
.course-body h3 { font-size: 16px; }
.course-body p { font-size: 14px; flex: 1; margin: 0 0 14px; }
.course-foot { display: flex; justify-content: space-between; align-items: center; }
.price { color: #e11d48; font-weight: 800; font-size: 22px; }
.price.big { font-size: 38px; }
@media (max-width: 1000px) { .courses { grid-template-columns: 1fr 1fr; } }
@media (max-width: 560px) { .courses { grid-template-columns: 1fr; } }
.course-hero { color: #fff; padding: 48px 0 56px; }
.course-hero h1 { font-size: 34px; margin-top: 14px; }
.course-hero p { max-width: 680px; opacity: .95; font-size: 17px; }
.course-hero .back { color: #fff; opacity: .9; display: block; margin-bottom: 18px; }
.course-layout { display: grid; grid-template-columns: 1fr 320px; gap: 24px; align-items: start; }
.chapters { list-style: none; padding: 0; margin: 0; }
.chapters li { display: flex; align-items: center; gap: 14px; padding: 14px 4px; border-bottom: 1px solid var(--border); }
.ch-no { font: 700 14px ui-monospace, monospace; color: var(--primary); }
.ch-title { flex: 1; }
.ch-state { font-size: 13px; color: var(--muted); }
.buy-card { position: sticky; top: 84px; }
.owned { background: #ecfdf5; color: #047857; padding: 12px; border-radius: 10px; text-align: center; font-weight: 600; margin-bottom: 12px; }
@media (max-width: 860px) { .course-layout { grid-template-columns: 1fr; } .buy-card { position: static; } }

/* about */
.about { display: grid; gap: 24px; }
.about-intro p { font-size: 16px; color: #334155; }
.about-biz { margin-top: 0; }
.values { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.values div { background: var(--bg-alt); border-radius: 12px; padding: 18px; }
.values b { font-size: 18px; color: var(--primary); }
.values p { margin: 4px 0 0; color: var(--muted); }
.about-info dl { display: grid; grid-template-columns: 110px 1fr; gap: 12px; margin: 0; }
.about-info dt { color: var(--muted); }
.about-info dd { margin: 0; }
@media (max-width: 600px) { .values { grid-template-columns: 1fr; } }

/* account */
.account { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
.account .wide { grid-column: 1 / -1; }
.account table { width: 100%; border-collapse: collapse; font-size: 14px; }
.account th, .account td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--border); }
.tag { display: inline-block; font-size: 12px; padding: 2px 8px; border-radius: 6px; background: #f1f5f9; }
.tag.paid { background: #ecfdf5; color: #047857; }
.sub-active { color: #047857; font-weight: 700; font-size: 18px; }
#subInfo { margin-bottom: 16px; }
.table-wrap { overflow-x: auto; }
@media (max-width: 760px) { .account { grid-template-columns: 1fr; } }

/* auth */
.auth { min-height: calc(100vh - 62px - 180px); display: grid; place-items: center; padding: 48px 20px; background: radial-gradient(700px 400px at 50% 0%, #ede9fe, transparent 70%); }
.auth-card { width: 100%; max-width: 410px; box-shadow: var(--shadow); }
.auth-card h1 { font-size: 26px; }
.auth-card label { display: block; font-size: 14px; font-weight: 600; margin: 16px 0 0; }
.auth-card input { display: block; width: 100%; margin-top: 6px; padding: 11px 13px; border: 1px solid var(--border); border-radius: 10px; font-size: 15px; font-family: inherit; }
.auth-card input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(79, 70, 229, .15); }
.auth-card .btn-block { margin-top: 20px; }
.form-error { color: #e11d48; font-size: 14px; min-height: 20px; margin-top: 10px; }

/* footer */
.footer { background: #0f172a; color: #cbd5e1; padding: 44px 0 0; }
.footer .logo { color: #fff; }
.footer-inner { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 24px; padding-bottom: 28px; }
.footer-links { display: flex; gap: 24px; flex-wrap: wrap; }
.footer-links a, .footer-bottom a { color: #cbd5e1; }
.footer-bottom { border-top: 1px solid #1e293b; padding: 18px 20px; display: flex; justify-content: center; gap: 20px; flex-wrap: wrap; font-size: 13px; color: #94a3b8; }

/* toast & modal */
.toast { position: fixed; left: 50%; top: 80px; transform: translate(-50%, -20px); background: #0f172a; color: #fff; padding: 10px 18px; border-radius: 10px; font-size: 14px; opacity: 0; pointer-events: none; transition: .25s; z-index: 200; max-width: 90vw; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.modal { position: fixed; inset: 0; background: rgba(15, 23, 42, .55); display: none; align-items: center; justify-content: center; z-index: 150; padding: 16px; }
.modal.open { display: flex; }
.modal-box { background: #fff; border-radius: 16px; width: 100%; max-width: 420px; padding: 26px; box-shadow: 0 30px 60px -20px rgba(0, 0, 0, .4); }
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.pay-amount { font-size: 40px; font-weight: 800; color: #e11d48; text-align: center; margin: 8px 0; }
.pay-qr { width: 180px; height: 180px; margin: 12px auto; border: 2px dashed var(--border); border-radius: 12px; display: grid; place-items: center; text-align: center; color: var(--muted); font-size: 13px; padding: 12px; }
.pay-note { background: #fffbeb; color: #92400e; font-size: 13px; padding: 10px 12px; border-radius: 10px; margin: 12px 0; }
.pay-row { display: flex; justify-content: space-between; font-size: 14px; padding: 4px 0; }
.modal-actions { display: flex; gap: 10px; margin-top: 16px; }
.modal-actions .btn { flex: 1; }

/* ===== workspace ===== */
body.bare { height: 100vh; display: flex; flex-direction: column; overflow: hidden; }
.ws { flex: 1; display: flex; min-height: 0; }
.ws-side { width: 260px; background: var(--bg-alt); border-right: 1px solid var(--border); display: flex; flex-direction: column; padding: 14px; gap: 12px; }
.conv-list { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 2px; }
.conv { display: flex; align-items: center; gap: 6px; padding: 9px 10px; border-radius: 9px; cursor: pointer; font-size: 14px; color: #334155; }
.conv:hover { background: #eef2ff; }
.conv.active { background: #e0e7ff; color: var(--primary); font-weight: 600; }
.conv span { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conv button { opacity: 0; background: none; border: 0; cursor: pointer; color: var(--muted); font-size: 13px; }
.conv:hover button { opacity: 1; }
.ws-quota { font-size: 13px; color: var(--muted); border-top: 1px solid var(--border); padding-top: 12px; }
.ws-quota a { font-weight: 600; }
.ws-main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.ws-top { display: flex; align-items: center; gap: 12px; padding: 10px 18px; border-bottom: 1px solid var(--border); }
.ws-top select { padding: 7px 10px; border: 1px solid var(--border); border-radius: 9px; font-size: 14px; background: #fff; font-family: inherit; max-width: 60vw; }
#toggleSide { display: none; }
.switch { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; cursor: pointer; user-select: none; }
.ws-messages { flex: 1; overflow-y: auto; padding: 24px 0; }
.msg { max-width: 820px; margin: 0 auto 22px; padding: 0 20px; display: flex; gap: 12px; }
.avatar { flex: none; width: 32px; height: 32px; border-radius: 9px; display: grid; place-items: center; font-size: 13px; font-weight: 700; }
.msg-user .avatar { background: #e0e7ff; color: var(--primary); }
.msg-ai .avatar { background: linear-gradient(135deg, var(--primary), var(--primary-2)); color: #fff; font-family: ui-monospace, monospace; }
.bubble { flex: 1; min-width: 0; padding-top: 4px; }
.msg-user .bubble { white-space: pre-wrap; word-break: break-word; }
.bubble p { margin: 0 0 .8em; }
.bubble > :last-child { margin-bottom: 0; }
.bubble ul, .bubble ol { padding-left: 1.4em; }
.bubble table { border-collapse: collapse; margin: .8em 0; display: block; overflow-x: auto; }
.bubble th, .bubble td { border: 1px solid var(--border); padding: 6px 10px; }
.bubble :not(pre) > code { background: #f1f5f9; padding: 1px 6px; border-radius: 5px; font-size: .9em; font-family: ui-monospace, Menlo, Consolas, monospace; }
.codeblock { margin: .8em 0; border-radius: 10px; overflow: hidden; background: var(--code-bg); }
.code-head { display: flex; justify-content: space-between; align-items: center; padding: 6px 12px; background: #161b22; color: #8b949e; font-size: 12px; }
.code-head button { background: none; border: 1px solid #30363d; color: #c9d1d9; border-radius: 6px; padding: 2px 9px; font-size: 12px; cursor: pointer; margin-left: 6px; font-family: inherit; }
.code-head button:hover { background: #30363d; }
.codeblock pre { margin: 0; padding: 14px; overflow-x: auto; }
.codeblock code { font: 13.5px/1.6 ui-monospace, Menlo, Consolas, monospace; background: none !important; padding: 0 !important; }
.reasoning { border-left: 3px solid #c7d2fe; padding: 4px 12px; color: var(--muted); font-size: 14px; margin-bottom: 12px; white-space: pre-wrap; max-height: 260px; overflow-y: auto; }
.reasoning summary { cursor: pointer; font-weight: 600; }
.typing::after { content: "▍"; animation: blink 1s infinite; color: var(--primary); }
@keyframes blink { 50% { opacity: 0; } }
.msg-error { color: #e11d48; }
.welcome { max-width: 720px; margin: 8vh auto 0; text-align: center; padding: 0 20px; }
.welcome h2 { font-size: 26px; }
.examples { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 24px; }
.examples button { text-align: left; background: #fff; border: 1px solid var(--border); border-radius: 12px; padding: 14px; font-size: 14px; cursor: pointer; color: #334155; font-family: inherit; line-height: 1.5; }
.examples button:hover { border-color: var(--primary); background: #fafaff; }
.ws-input { display: flex; gap: 10px; align-items: flex-end; max-width: 860px; width: 100%; margin: 0 auto; padding: 12px 20px 18px; }
.ws-input textarea { flex: 1; resize: none; border: 1px solid var(--border); border-radius: 14px; padding: 12px 14px; font-size: 15px; font-family: inherit; max-height: 220px; line-height: 1.5; box-shadow: 0 4px 14px -8px rgba(15, 23, 42, .2); }
.ws-input textarea:focus { outline: none; border-color: var(--primary); }
.ws-input .btn { height: 46px; }
.preview-box { max-width: 1100px; height: 85vh; display: flex; flex-direction: column; padding: 14px; }
.preview-box iframe { flex: 1; border: 1px solid var(--border); border-radius: 10px; background: #fff; width: 100%; }
@media (max-width: 760px) {
  .ws-side { position: fixed; top: 62px; bottom: 0; left: 0; z-index: 40; transform: translateX(-100%); transition: .2s; box-shadow: var(--shadow); }
  .ws-side.open { transform: none; }
  #toggleSide { display: block; }
  .examples { grid-template-columns: 1fr; }
  .switch span { font-size: 13px; }
}
