
:root {
  color-scheme: light;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  color: var(--ink);
  background: var(--paper);
  --white: #fff;
  --danger: #a63832;
  --shadow: 0 12px 36px var(--shadow-ink);
}
* { box-sizing: border-box }
[hidden] { display: none !important }
html { min-height: 100%; scroll-behavior: smooth }
body { margin: 0; min-width: 280px; min-height: 100vh; font-size: 15px; line-height: 1.6 }
button, input, textarea, select { font: inherit }
button { min-height: 40px; border: 1px solid var(--line); border-radius: 9px; padding: .46rem .78rem; background: var(--white); color: var(--pine-dark); font-weight: 570; cursor: pointer; transition: background .18s, border-color .18s, box-shadow .18s }
button:hover { border-color: var(--soft-edge); background: var(--soft-paper) }
button:disabled { cursor: wait; opacity: .6 }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px }
.primary, .primary:hover { color: #fff; background: var(--pine); border-color: var(--pine) }
.primary:hover { background: var(--hover) }
label { display: grid; gap: .38rem; color: var(--muted); font-size: .875rem; font-weight: 580 }
input, select, textarea { width: 100%; min-width: 0; border: 1px solid var(--soft-edge); border-radius: 8px; padding: .53rem .65rem; background: #fff; color: var(--ink) }
textarea { resize: vertical; min-height: 88px }
h1, h2, p { margin: 0 }
h1 { font-size: clamp(1.55rem, 2.3vw, 2.15rem); line-height: 1.25; letter-spacing: -.025em }
h2 { font-size: 1rem; line-height: 1.4 }
.quiet { color: var(--muted) }
form { display: grid; gap: .85rem }
.actions { display: flex; flex-wrap: wrap; align-items: center; gap: .55rem }
.topbar { background: var(--pine-dark); color: #fff; border-bottom: 1px solid var(--pine-dark) }
.topbar-inner { max-width: 1336px; min-height: 68px; margin: auto; display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: .75rem clamp(1rem, 3.4vw, 2.8rem) }
.brand { display: flex; align-items: center; gap: .68rem; min-width: 0; line-height: 1.2; font-weight: 670 }
.brand-mark { flex: 0 0 34px; display: grid; place-items: center; height: 34px; border-radius: 9px; background: var(--brand-wash); color: var(--pine-dark); font-family: "Songti SC", SimSun, serif; font-size: 1.13rem; font-weight: 700 }
.topbar-actions { display: flex; align-items: center; gap: .72rem }
.environment { padding: .19rem .55rem; background: #ffffff15; border-radius: 999px; color: var(--header-text); font-size: .75rem; white-space: nowrap }


main { max-width: 1336px; margin: 0 auto; padding: clamp(1.15rem, 3vw, 2.45rem) clamp(1rem, 3.4vw, 2.8rem) 2.4rem }
#notice { padding: .7rem .9rem; margin-bottom: .95rem; border: 1px solid #e5d6b7; background: #fffbef; color: #684b21; border-radius: 10px }
#workspace { display: grid; grid-template-columns: 186px minmax(0, 1fr); align-items: start; gap: clamp(1rem, 2.1vw, 1.8rem) }
.sidebar { min-width: 0; padding: .1rem .2rem .8rem 0 }
.identity { display: flex; gap: .55rem; align-items: center; min-height: 48px; margin-bottom: .75rem; padding: .15rem .4rem; font-size: .875rem; font-weight: 650 }
.avatar { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; background: var(--active-wash); color: var(--colored-ink); flex-shrink: 0 }
nav { display: grid; gap: .32rem }
nav button { width: 100%; display: flex; align-items: center; gap: .65rem; padding: .58rem .7rem; min-height: 42px; border-color: transparent; background: transparent; color: var(--muted); text-align: left }
nav button:hover { border-color: var(--line); background: var(--green-50) }
nav button[aria-current="page"] { background: var(--active-wash); color: var(--pine-dark); border-color: var(--line); font-weight: 690 }
.nav-icon { width: 17px; margin: 0; font-size: .94rem; color: var(--colored-ink); text-align: center }
.history { border-top: 1px solid var(--line); margin-top: 1.3rem; padding-top: 1rem }
.history h2 { font-size: .8rem; font-weight: 600; color: var(--muted); margin: 0 0 .55rem .4rem }
#new-chat { width: 100%; text-align: left; background: var(--soft-paper) }
#chats { display: grid; gap: .28rem; margin-top: .55rem; max-height: 50vh; overflow: auto }
#chats button { display: block; width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-align: left; background: transparent; border-color: transparent; font-size: .83rem; color: var(--muted); min-height: 34px; padding-block: .26rem }
#chats button:hover, #chats button[aria-current] { background: var(--green-50); color: var(--pine) }
.page { min-width: 0 }
.page-head { min-width: 0; margin: 0 0 1.08rem; display: flex; justify-content: space-between; align-items: end; flex-wrap: wrap; gap: .65rem }
.page-head p { margin-top: .4rem; font-size: .9rem; color: var(--muted) }
.chat-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(190px, 230px); gap: clamp(.8rem, 1.4vw, 1.25rem); align-items: start }
.conversation, .knowledge-side, .card, #login, .document-list { min-width: 0; background: var(--white); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow) }
.conversation { display: flex; flex-direction: column; min-height: 530px; overflow: hidden }
.conversation-head { display: flex; justify-content: space-between; align-items: center; padding: 1.05rem 1.2rem; border-bottom: 1px solid var(--line); gap: .55rem }
.conversation-head h2 { font-size: .95rem }
#delete-chat { min-height: 33px; padding: .22rem .55rem; font-size: .78rem }
.conversation-body { display: flex; flex: 1; flex-direction: column; min-height: 0 }
.welcome { padding: clamp(1.45rem, 4vw, 2.6rem) 1.2rem .55rem }
.welcome .mini-mark { display: grid; place-items: center; width: 35px; height: 35px; margin-bottom: .75rem; border-radius: 10px; color: var(--pine); background: var(--green-50); font-size: 1.1rem; font-weight: 700 }
.welcome h2 { font-size: 1.3rem; margin-bottom: .4rem }
.welcome p { color: var(--muted); font-size: .88rem }
.samples { padding: .6rem 1.2rem 1rem; align-items: start }
.samples button { text-align: left; color: var(--colored-ink); font-size: .81rem; min-height: 34px; border-color: var(--line); background: var(--soft-paper); font-weight: 590; border-radius: 999px; max-width: 100% }
.samples button:hover { background: var(--green-50); border-color: var(--soft-edge) }
#messages { flex: 1; min-height: 0; max-height: 48vh; overflow: auto; display: flex; flex-direction: column; gap: .68rem; padding: .9rem 1.2rem .8rem }
#messages:empty { padding-top: 0; padding-bottom: 0 }
.conversation-body:has(#messages:not(:empty)) .welcome { display: none }
.conversation-body:has(#messages:not(:empty)) .samples { padding-top: .85rem; border-bottom: 1px solid var(--line) }
.bubble { white-space: pre-wrap; overflow-wrap: anywhere; width: fit-content; max-width: 92%; background: var(--bubble); border: 1px solid var(--line); border-radius: 5px 13px 13px 13px; padding: .6rem .78rem }
.bubble.user { align-self: end; color: var(--colored-ink); background: var(--active-wash); border-color: var(--line); border-radius: 13px 5px 13px 13px }
.citation { display: block; margin-top: .45rem; max-width: 100%; text-align: left; white-space: normal; font-size: .77rem; color: var(--colored-ink); min-height: 31px; border-color: var(--line) }
.composer { margin: .8rem; padding: .72rem; border: 1px solid var(--line); border-radius: 12px; background: var(--soft-paper); gap: .38rem }
.composer textarea { border: 0; min-height: 72px; padding: .25rem .35rem .3rem; background: transparent }
.composer label { font-size: .82rem }
.composer label > span { padding: 0 .35rem }
.composer-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: .35rem }
.composer-toolbar .tools { display: flex; flex-wrap: wrap; align-items: center; gap: .42rem; margin-right: auto }
.composer-toolbar label { display: block }
.composer-toolbar select { width: auto; font-size: .82rem; padding: .32rem .45rem; border-color: var(--line) }
.composer-toolbar button { min-height: 34px; font-size: .82rem; padding: .26rem .65rem }
#send { padding-inline: .98rem }
.knowledge-side { padding: 1rem .9rem }
.knowledge-side h2 { margin-bottom: .2rem }
.side-summary { color: var(--muted); font-size: .8rem; margin-bottom: .82rem }
#side-docs { display: grid; gap: .4rem }
#side-docs button { width: 100%; display: grid; text-align: left; min-height: 42px; font-size: .8rem; background: var(--soft-paper); line-height: 1.42; overflow-wrap: anywhere }
#side-docs button:hover { background: var(--green-50) }
#side-docs small { font-size: .73rem; font-weight: 450; color: var(--muted) }
.knowledge-side .quiet { font-size: .79rem }
.card, .document-list { padding: 1.05rem; margin-bottom: .65rem }
.cards { display: grid; gap: .65rem; min-width: 0 }
.card h2 { margin-bottom: .5rem }
.card p + p { margin-top: .42rem }
.document-list { max-width: 700px }
.document-list .cards { margin-top: .8rem }
.document-list .cards button { text-align: left; min-height: 54px; background: var(--soft-paper) }
#feedback-form { max-width: 700px }
#feedback-form textarea { min-height: 130px }
#feedback-form button { justify-self: start }
#suggestions { margin-top: 1rem }
.admin-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .9rem }
.admin-grid > * { align-self: start; margin: 0 }
#limits .limit-fields { display: grid; grid-template-columns: 1fr 1fr; gap: .65rem }
#switch[data-enabled="true"] { border-color: #edceca; background: #fff2ef; color: var(--danger) }
#switch[data-enabled="true"]:hover { background: #fbe4e1 }
#submitted, #staff { grid-column: 1 / -1; margin-top: .25rem }
#staff { grid-template-columns: repeat(auto-fit, minmax(155px, 1fr)) }
#staff > h2 { grid-column: 1 / -1 }
#staff p, #audit p, #usage p { font-size: .85rem; color: var(--muted) }
#audit { grid-column: 1 / -1 }
.muted-box { color: var(--muted); padding: .65rem .75rem; border-radius: 8px; background: var(--soft-paper); font-size: .86rem }
#login { max-width: 25rem; margin: 8vh auto; padding: 1rem }
dialog { width: min(41rem, calc(100% - 1.8rem)); border: 1px solid var(--line); border-radius: 16px; padding: 1.2rem; color: var(--ink); box-shadow: 0 18px 80px var(--dialog-shadow) }
dialog::backdrop { background: var(--backdrop) }
dialog button { justify-self: end }
dialog h2 { font-size: 1.25rem; margin: .3rem 0 }
dialog p { color: var(--muted); font-size: .83rem }
pre { white-space: pre-wrap; overflow-wrap: anywhere; font: inherit; margin-bottom: 0 }
@media (max-width: 1030px) {
  #workspace { grid-template-columns: 158px minmax(0, 1fr) }
  .chat-layout { grid-template-columns: minmax(0, 1fr) }
  #side-docs { grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)) }
}
@media (max-width: 650px) {
  .topbar-inner { min-height: 59px; gap: .45rem; padding: .62rem .75rem }
  .topbar-actions { gap: .4rem }
  .brand { font-size: .93rem; gap: .4rem }
  .brand-mark { width: 28px; height: 28px; flex-basis: 28px; font-size: .94rem }

  .environment { font-size: .67rem }

  main { padding: .85rem .75rem 1.4rem }
  #workspace { display: block }
  .sidebar { padding: 0; margin-bottom: .85rem }
  .identity { display: none }
  nav { display: flex; border-bottom: 1px solid var(--line); overflow-x: auto; padding-bottom: .35rem }
  nav button { width: auto; min-width: max-content; padding: .35rem .47rem; min-height: 39px; font-size: .82rem; gap: .25rem }
  .nav-icon { width: .85rem }
  .history { margin: .5rem 0 0; padding: 0; border: 0; display: flex; align-items: center; gap: .4rem }
  .history h2 { display: none }
  #new-chat { width: auto; min-height: 34px; padding: .2rem .45rem; flex-shrink: 0; font-size: .79rem }
  #chats { max-height: none; margin: 0; display: flex; gap: .3rem }
  #chats button { width: auto; max-width: 10rem }
  .page-head { margin-bottom: .8rem }
  .page-head p { font-size: .82rem }
  .conversation { min-height: 470px; border-radius: 12px }
  .conversation-head { padding: .76rem }
  .welcome { padding-left: .8rem; padding-right: .8rem }
  .samples, #messages { padding-left: .8rem; padding-right: .8rem }
  .composer { margin: .55rem }
  .chat-layout { gap: .65rem }
  .admin-grid { grid-template-columns: minmax(0, 1fr); gap: .65rem }
}
@media (max-width: 345px) {
  .environment { display: none }
  nav button { font-size: .76rem }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important }
}


:root {
  --paper: #f0f4f9;
  --ink: #203047;
  --muted: #4f6076;
  --pine: #234a79;
  --pine-dark: #16283f;
  --green-50: #e7eff9;
  --line: #dbe5f1;
  --soft-edge: #a8bad3;
  --soft-paper: #f7faff;
  --focus: #477cb6;
  --hover: #305d92;
  --brand-wash: #d9e8fc;
  --header-text: #e4effc;
  --header-field: #f8fbff;
  --header-border: #d4e3f3;
  --active-wash: #dfebfa;
  --colored-ink: #244d78;
  --bubble: #eff4fb;
  --shadow-ink: #152f520d;
  --dialog-shadow: #132e5240;
  --backdrop: #18283fa6;
}



#logout { background: transparent; color: #fff; border-color: var(--header-border); min-height: 35px; }
#logout:hover { background: #ffffff15; }
#staff-form { grid-column: 1 / -1; }
#login form { margin-top: 1rem; }
