:root {
    --primary: #334155;
    --primary-dark: #1e293b;
    --accent: #ea580c;
    --accent-soft: #fff1e8;
    --background: #f1f5f9;
    --surface: #ffffff;
    --text: #0f172a;
    --muted: #526071;
    --border: #cbd5e1;
    --success: #15803d;
    --danger: #b91c1c;
    --shadow: 0 20px 60px rgba(15, 23, 42, .09);
    font-family: Inter, "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
    color: var(--text);
    background: var(--background);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; min-width: 320px; background: var(--background); }
button, input, textarea, select { font: inherit; }
button { cursor: pointer; }
a { color: inherit; }
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.skip-link { position: fixed; top: -50px; left: 16px; z-index: 100; padding: 10px 16px; color: #fff; background: var(--primary); }
.skip-link:focus { top: 8px; }

.site-header {
    height: 78px; padding: 0 max(24px, calc((100vw - 1440px) / 2)); display: flex; align-items: center;
    justify-content: space-between; gap: 28px; background: rgba(255,255,255,.94); border-bottom: 1px solid var(--border);
    position: sticky; top: 0; z-index: 20; backdrop-filter: blur(14px);
}
.brand { display: flex; align-items: center; gap: 12px; text-decoration: none; }
.brand-mark { width: 42px; height: 42px; display: grid; place-items: center; color: white; font-weight: 900; letter-spacing: -1px; background: var(--primary-dark); position: relative; }
.brand-mark::after { content: ""; position: absolute; right: -5px; bottom: 5px; width: 6px; height: 18px; background: var(--accent); }
.brand strong, .brand small { display: block; }
.brand strong { font-size: 18px; letter-spacing: .08em; }
.brand small { margin-top: 2px; font-size: 9px; letter-spacing: .18em; color: var(--muted); }
nav { display: flex; gap: 28px; margin-left: auto; }
nav a { font-size: 14px; color: var(--muted); text-decoration: none; }
nav a:hover, nav a:focus-visible { color: var(--accent); }
.user-strip { min-width: 130px; text-align: right; font-size: 13px; color: var(--muted); }
.text-button { border: 0; padding: 4px 0 4px 12px; color: var(--accent); background: transparent; }

main { max-width: 1440px; margin: 0 auto; padding: 0 28px 72px; }
.hero { min-height: 430px; padding: 78px 7% 66px; position: relative; overflow: hidden; background: var(--primary-dark); color: white; }
.hero::before { content: ""; position: absolute; inset: 0; opacity: .18; background-image: linear-gradient(rgba(255,255,255,.2) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.2) 1px, transparent 1px); background-size: 42px 42px; mask-image: linear-gradient(90deg, black, transparent 78%); }
.hero::after { content: "MACHINE / VISION / KNOWLEDGE"; position: absolute; right: -70px; top: 126px; transform: rotate(90deg); color: rgba(255,255,255,.17); font-size: 12px; letter-spacing: .42em; }
.hero > * { position: relative; z-index: 1; }
.eyebrow { display: flex; align-items: center; gap: 10px; color: #fed7aa; font-size: 13px; letter-spacing: .16em; }
.eyebrow span { width: 34px; height: 3px; background: var(--accent); }
.hero h1 { margin: 22px 0 18px; max-width: 780px; font-size: clamp(42px, 5.5vw, 76px); line-height: 1.08; letter-spacing: -.04em; }
.hero h1 em { color: #fb923c; font-style: normal; }
.hero > p { max-width: 670px; margin: 0; color: #dbe4ee; font-size: 17px; line-height: 1.9; }
.hero-facts { display: flex; gap: 56px; margin-top: 38px; }
.hero-facts div { display: flex; align-items: baseline; gap: 10px; }
.hero-facts b { color: #fb923c; font-size: 25px; }
.hero-facts span { color: #cbd5e1; font-size: 12px; }

.workspace { display: grid; grid-template-columns: 330px minmax(0, 1fr); gap: 22px; margin-top: -24px; position: relative; z-index: 2; }
.panel { background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow); }
.control-rail { display: flex; flex-direction: column; gap: 18px; }
.auth-panel, .safety-panel { padding: 24px; }
.panel-heading, .chat-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.panel-heading > div, .chat-header > div { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.panel-heading h2, .chat-header h2, .feedback-section h2 { margin: 0; font-size: 20px; }
.section-index { color: var(--accent); font-size: 11px; font-weight: 800; letter-spacing: .08em; }
.status-badge, .ai-label { padding: 4px 8px; border: 1px solid #fdba74; color: #9a3412; background: var(--accent-soft); font-size: 11px; font-weight: 700; }
.tabs { display: grid; grid-template-columns: 1fr 1fr; margin: 22px 0 16px; border-bottom: 1px solid var(--border); }
.tab { padding: 10px; border: 0; border-bottom: 2px solid transparent; color: var(--muted); background: transparent; }
.tab.active { color: var(--text); border-color: var(--accent); font-weight: 700; }
.auth-form { display: grid; gap: 13px; }
.auth-form label { display: grid; gap: 6px; color: var(--muted); font-size: 12px; }
input, textarea, select { width: 100%; border: 1px solid var(--border); border-radius: 0; padding: 11px 12px; color: var(--text); background: #fff; outline: none; }
input:focus, textarea:focus, select:focus, button:focus-visible, a:focus-visible { outline: 3px solid rgba(234,88,12,.25); outline-offset: 2px; border-color: var(--accent); }
.check-line { grid-template-columns: 18px 1fr !important; align-items: start; line-height: 1.6; }
.check-line input, .agreement-stack input { width: auto; margin-top: 3px; accent-color: var(--accent); }
.primary-button, .secondary-button, .send-button { border: 0; padding: 12px 16px; font-weight: 700; }
.primary-button { color: white; background: var(--primary); }
.primary-button:hover { background: var(--primary-dark); }
.secondary-button { color: white; background: var(--primary); }
.form-message { min-height: 18px; margin: 12px 0 0; color: var(--muted); font-size: 12px; line-height: 1.5; }
.form-message.error { color: var(--danger); }
.form-message.success { color: var(--success); }
.safety-panel { box-shadow: none; }
.compact { margin-bottom: 18px; }
.safety-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 15px; }
.safety-list li { display: grid; grid-template-columns: 30px 1fr; gap: 9px; align-items: start; color: var(--muted); font-size: 13px; line-height: 1.5; }
.safety-list span { color: var(--accent); font-size: 10px; font-weight: 800; border-top: 2px solid var(--accent); padding-top: 3px; }

.chat-panel { min-height: 800px; padding: 28px; }
.chat-header { padding-bottom: 20px; border-bottom: 1px solid var(--border); }
.chat-header p { flex-basis: 100%; margin: -3px 0 0 27px; color: var(--muted); font-size: 12px; }
.live-status { color: var(--success); font-size: 12px; white-space: nowrap; }
.live-status i { display: inline-block; width: 7px; height: 7px; margin-right: 5px; border-radius: 50%; background: var(--success); box-shadow: 0 0 0 4px #dcfce7; }
.provider-select { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 22px 0; }
.provider { display: grid; grid-template-columns: 34px 1fr; gap: 2px 10px; text-align: left; padding: 12px; border: 1px solid var(--border); background: white; color: var(--text); }
.provider > span { grid-row: 1 / 3; width: 34px; height: 34px; display: grid; place-items: center; color: white; background: var(--primary); font-weight: 800; }
.provider b { font-size: 13px; }
.provider small { color: var(--muted); }
.provider.active { border-color: var(--accent); box-shadow: inset 0 -3px var(--accent); }
.provider.active > span { background: var(--accent); }
.conversation { min-height: 320px; max-height: 470px; padding: 18px; overflow-y: auto; background: #f8fafc; border: 1px solid var(--border); }
.message { max-width: 86%; margin: 0 0 16px; padding: 15px 17px; border-left: 3px solid var(--border); background: white; box-shadow: 0 8px 24px rgba(15,23,42,.05); }
.message.user-message { margin-left: auto; border-left-color: var(--primary); background: #e9eef4; }
.message.ai-message { border-left-color: var(--accent); }
.message p { margin: 7px 0 0; white-space: pre-wrap; line-height: 1.75; font-size: 14px; }
.message-meta { display: flex; align-items: center; gap: 7px; color: var(--muted); font-size: 11px; font-weight: 700; }
.system-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); }
.copy-answer { margin-left: auto; border: 0; color: var(--accent); background: transparent; font-size: 11px; }
.markdown-content { margin-top: 11px; color: var(--text); font-size: 14px; line-height: 1.75; overflow-wrap: anywhere; }
.markdown-content > :first-child { margin-top: 0; }
.markdown-content > :last-child { margin-bottom: 0; }
.markdown-content h3, .markdown-content h4, .markdown-content h5, .markdown-content h6 {
    margin: 22px 0 9px; color: var(--primary-dark); line-height: 1.4;
}
.markdown-content h3 { padding-left: 10px; border-left: 3px solid var(--accent); font-size: 18px; }
.markdown-content h4 { font-size: 16px; }
.markdown-content h5, .markdown-content h6 { font-size: 14px; }
.markdown-content p { margin: 9px 0; white-space: normal; }
.markdown-content ul, .markdown-content ol { margin: 9px 0; padding-left: 24px; }
.markdown-content li { margin: 4px 0; padding-left: 2px; }
.markdown-content blockquote {
    margin: 12px 0; padding: 10px 13px; border-left: 3px solid #fb923c; color: #7c2d12; background: var(--accent-soft);
}
.markdown-content hr { height: 1px; margin: 18px 0; border: 0; background: var(--border); }
.markdown-content code { padding: 2px 5px; color: #9a3412; background: #fff1e8; font-family: Consolas, "SFMono-Regular", monospace; font-size: .92em; }
.markdown-content pre { margin: 12px 0; padding: 13px 15px; overflow-x: auto; color: #e2e8f0; background: var(--primary-dark); }
.markdown-content pre code { padding: 0; color: inherit; background: transparent; white-space: pre; }
.markdown-content a { color: #c2410c; text-decoration-thickness: 1px; text-underline-offset: 3px; }
.markdown-table-wrap { max-width: 100%; margin: 13px 0; overflow-x: auto; border: 1px solid var(--border); }
.markdown-table-wrap:focus-visible { outline: 3px solid rgba(234,88,12,.25); outline-offset: 2px; }
.markdown-content table { width: 100%; border-collapse: collapse; background: #fff; font-size: 13px; }
.markdown-content th, .markdown-content td { min-width: 110px; padding: 9px 11px; border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
.markdown-content th:last-child, .markdown-content td:last-child { border-right: 0; }
.markdown-content tr:last-child td { border-bottom: 0; }
.markdown-content th { color: var(--primary-dark); background: #f1f5f9; font-weight: 800; }
.thinking-message {
    width: min(520px, 86%); display: grid; grid-template-columns: 58px minmax(0, 1fr); gap: 14px;
    align-items: center; position: relative; overflow: hidden; background: linear-gradient(115deg, #fff 0%, #fff7ed 100%);
}
.thinking-message::after {
    content: ""; position: absolute; inset: 0; transform: translateX(-130%); pointer-events: none;
    background: linear-gradient(100deg, transparent 25%, rgba(255,255,255,.9) 48%, transparent 70%);
    animation: thinking-scan 2.4s ease-in-out infinite;
}
.thinking-visual-frame {
    width: 54px; height: 54px; display: grid; place-items: center; position: relative;
    border: 1px solid #fed7aa; background: #fff; box-shadow: inset 0 0 0 5px #fff7ed;
}
.thinking-visual-frame::after {
    content: ""; width: 7px; height: 7px; position: absolute; right: -3px; top: -3px;
    border-radius: 50%; background: var(--success); box-shadow: 0 0 0 4px #dcfce7;
    animation: thinking-signal 1.5s ease-in-out infinite;
}
.thinking-visual { width: 40px; height: 40px; animation: thinking-float 1.8s ease-in-out infinite; }
.thinking-content { min-width: 0; }
.thinking-meta { color: var(--text); font-size: 12px; }
.thinking-elapsed { margin-left: auto; color: var(--muted); font-variant-numeric: tabular-nums; font-weight: 500; }
.thinking-detail { color: var(--muted); }
.thinking-dots { display: inline-flex; align-items: end; gap: 3px; height: 10px; }
.thinking-dots i { width: 4px; height: 4px; border-radius: 50%; background: var(--accent); animation: thinking-dot 1.2s ease-in-out infinite; }
.thinking-dots i:nth-child(2) { animation-delay: .16s; }
.thinking-dots i:nth-child(3) { animation-delay: .32s; }
@keyframes thinking-scan { 0% { transform: translateX(-130%); } 60%, 100% { transform: translateX(130%); } }
@keyframes thinking-signal { 0%, 100% { opacity: .45; transform: scale(.8); } 50% { opacity: 1; transform: scale(1); } }
@keyframes thinking-float { 0%, 100% { transform: translateY(1px) rotate(-2deg); } 50% { transform: translateY(-3px) rotate(2deg); } }
@keyframes thinking-dot { 0%, 60%, 100% { opacity: .35; transform: translateY(0); } 30% { opacity: 1; transform: translateY(-3px); } }
.question-chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 16px 0; }
.question-chips button { padding: 7px 10px; border: 1px solid var(--border); color: var(--muted); background: white; font-size: 12px; }
.question-chips button:hover { border-color: var(--accent); color: var(--accent); }
.composer { border: 1px solid var(--primary); background: white; }
.composer textarea { min-height: 94px; border: 0; resize: vertical; }
.composer-footer { display: flex; justify-content: space-between; align-items: end; gap: 16px; padding: 11px 12px; border-top: 1px solid var(--border); }
.agreement-stack { display: grid; gap: 5px; color: var(--muted); font-size: 11px; }
.agreement-stack label { display: flex; gap: 7px; }
.send-area { display: flex; align-items: center; gap: 12px; }
.send-area > span { color: var(--muted); font-size: 10px; }
.send-button { color: white; background: var(--accent); }
.send-button b { padding-left: 8px; }
.send-button:disabled { cursor: wait; opacity: .72; }

.feedback-section { display: grid; grid-template-columns: 320px 1fr; gap: 35px; margin-top: 22px; padding: 28px; box-shadow: none; }
.feedback-section > div { display: flex; align-content: start; flex-wrap: wrap; gap: 10px; }
.feedback-section h2 { width: calc(100% - 34px); }
.feedback-section p { margin: 8px 0 0; color: var(--muted); line-height: 1.7; font-size: 13px; }
#feedback-form { display: grid; grid-template-columns: 180px 1fr 1fr auto; gap: 10px; }
#feedback-form textarea { min-height: 46px; resize: vertical; }
.feedback-section > .form-message { grid-column: 2; }

footer { padding: 34px max(28px, calc((100vw - 1384px) / 2)); display: flex; justify-content: space-between; gap: 30px; color: #cbd5e1; background: var(--primary-dark); }
footer strong, footer span { display: block; }
footer strong { color: white; }
footer > div span { margin-top: 6px; font-size: 11px; }
footer p { max-width: 640px; margin: 0; font-size: 12px; line-height: 1.7; }
footer .icp-record { white-space: nowrap; }
footer a { color: #fed7aa; text-decoration: none; }
footer a:hover { text-decoration: underline; }
footer .ai-label { display: inline-block; margin-right: 7px; color: #fed7aa; background: transparent; }

.legal-main { max-width: 1000px; margin: 42px auto 80px; padding: 0 28px; }
.legal-hero { padding: 42px; color: white; background: var(--primary-dark); }
.legal-hero h1 { margin: 8px 0 12px; font-size: 38px; }
.legal-hero p { color: #cbd5e1; line-height: 1.8; }
.legal-content { padding: 42px; background: white; border: 1px solid var(--border); }
.legal-content h2 { margin: 34px 0 12px; padding-left: 13px; border-left: 4px solid var(--accent); }
.legal-content h2:first-child { margin-top: 0; }
.legal-content p, .legal-content li { color: var(--muted); line-height: 1.9; }
.notice-box { padding: 18px; border: 1px solid #fdba74; background: var(--accent-soft); color: #9a3412 !important; }

@media (max-width: 980px) {
    nav { display: none; }
    .workspace { grid-template-columns: 1fr; }
    .control-rail { display: grid; grid-template-columns: 1fr 1fr; }
    .feedback-section { grid-template-columns: 1fr; }
    #feedback-form { grid-template-columns: 1fr 1fr; }
    .feedback-section > .form-message { grid-column: 1; }
}
@media (max-width: 640px) {
    .site-header { height: 68px; padding: 0 16px; }
    .brand small, .user-strip { display: none; }
    main { padding: 0 12px 46px; }
    .hero { min-height: 390px; padding: 58px 25px 70px; }
    .hero h1 { font-size: 42px; }
    .hero-facts { gap: 18px; justify-content: space-between; }
    .hero-facts div { display: grid; gap: 2px; }
    .workspace { margin-top: -24px; }
    .control-rail { grid-template-columns: 1fr; }
    .chat-panel { padding: 18px 14px; }
    .provider-select { grid-template-columns: 1fr; }
    .provider { grid-template-columns: 34px 1fr auto; align-items: center; }
    .provider > span { grid-row: auto; }
    .message { max-width: 96%; }
    .thinking-message { width: 96%; grid-template-columns: 48px minmax(0, 1fr); gap: 11px; }
    .thinking-visual-frame { width: 46px; height: 46px; }
    .thinking-visual { width: 34px; height: 34px; }
    .composer-footer { align-items: stretch; flex-direction: column; }
    .send-area { justify-content: space-between; }
    #feedback-form { grid-template-columns: 1fr; }
    footer { flex-direction: column; padding: 30px 20px; }
    .legal-main { margin-top: 20px; padding: 0 12px; }
    .legal-hero, .legal-content { padding: 26px 20px; }
}
@media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto; }
    .thinking-message::after, .thinking-visual-frame::after, .thinking-visual, .thinking-dots i { animation: none; }
    .thinking-dots i { opacity: 1; }
}
