:root {
  color-scheme: light;
  --paper: #f8f7f2;
  --panel: #fffefa;
  --ink: #243631;
  --muted: #546862;
  --line: #d5dbd2;
  --dark: #123c34;
  --green: #286754;
  --light: #e7eee5;
  --serif: "STIX Two Text","Noto Serif CJK SC","Songti SC","SimSun",serif;
  --sans: "Inter","Noto Sans CJK SC","Microsoft YaHei",sans-serif;
  font-family: var(--sans);
  color: var(--ink);
  background: var(--paper);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-size: 15px;
}

button,input,textarea,select {
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: wait;
  opacity: .62;
}

button:focus-visible,input:focus-visible,select:focus-visible,textarea:focus-visible {
  outline: 3px solid #a77130;
  outline-offset: 2px;
}

button {
  color: inherit;
}

input,select,textarea {
  color: var(--ink);
}

[hidden] {
  display: none!important;
}

.shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 234px minmax(0,1fr);
}

.rail {
  background: #173b33;
  color: #f5f2e8;
  padding: 30px 20px 20px;
  display: flex;
  flex-direction: column;
  min-width: 0;
  height: 100dvh;
  position: sticky;
  top: 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  font: 34px var(--serif);
  letter-spacing: .08em;
  padding: 2px 5px 31px;
}

.seal {
  width: 32px;
  height: 32px;
  background: repeating-radial-gradient(ellipse at 20% 90%,transparent 0 4px,#efe5bb 5px 6px,transparent 7px 10px);
  border: 1px solid #dfd3a5;
  border-radius: 12px 3px 12px 3px;
  display: inline-block;
}

.scope-label,.side-head,.rail-foot {
  font-size: 12px;
  color: #d0dad0;
}

.rail select {
  appearance: auto;
  margin: 7px 0 23px;
  background: #254c42;
  color: #fffefa;
  border: 1px solid #527365;
  border-radius: 7px;
  padding: 9px 10px;
  width: 100%;
}

.rail nav {
  display: grid;
  gap: 5px;
}

.nav {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 13px;
  background: transparent;
  color: #dceaDF;
  border: 0;
  border-radius: 7px;
  text-align: left;
}

.nav.active,.nav:hover {
  background: #345c4e;
  color: white;
}

.nav i {
  font-family: serif;
  font-style: normal;
  width: 16px;
  text-align: center;
  font-size: 20px;
  line-height: 16px;
}

.side-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 27px;
  border-top: 1px solid #4e695c;
  padding: 18px 4px 8px;
}

.side-head button,.close {
  background: transparent;
  color: inherit;
  border: 0;
  font-size: 22px;
  line-height: 1;
}

.topics {
  overflow: auto;
  min-height: 40px;
}

.topic {
  display: block;
  background: transparent;
  border: 0;
  color: #dde8df;
  text-align: left;
  padding: 8px 7px;
  width: 100%;
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  border-radius: 5px;
}

.topic:hover,.topic.current {
  background: #2c5145;
}

.rail-foot {
  margin-top: auto;
  padding: 20px 4px 0;
  display: flex;
  align-items: center;
  gap: 8px;
}

.dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #a7c8a8;
}

.top {
  height: 63px;
  border-bottom: 1px solid var(--line);
  padding: 0 clamp(20px,5vw,76px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--muted);
  font-size: 13px;
}

.mode {
  font-size: 12px;
  background: var(--light);
  border: 1px solid #ccd9cb;
  color: #305c49;
  padding: 4px 10px;
  border-radius: 99px;
  max-width: 60%;
  overflow-wrap: anywhere;
}

.view {
  max-width: 940px;
  margin: 0 auto;
  padding: 36px clamp(20px,4.5vw,68px) 45px;
}

.page-head,.subhead,.row,.composer-foot {
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
}

.page-head {
  margin-bottom: 25px;
}

.page-head h1,.view h2,dialog h2 {
  font-family: var(--serif);
  font-weight: 650;
  color: var(--dark);
  margin: 0;
}

.page-head h1 {
  font-size: clamp(32px,4vw,46px);
  line-height: 1.24;
}

.view h2,dialog h2 {
  font-size: 23px;
}

.switch {
  padding: 3px;
  display: flex;
  gap: 3px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.switch button {
  border: 0;
  background: transparent;
  border-radius: 5px;
  padding: 6px 11px;
  color: var(--muted);
  font-size: 13px;
}

.switch button[aria-pressed=true] {
  background: var(--dark);
  color: #fff;
}

.switch span {
  font-size: 11px;
  margin-left: 2px;
}

.chat-view {
  min-height: calc(100dvh - 63px);
  display: flex;
  flex-direction: column;
}

.conversation {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 17px;
}

.welcome {
  flex: 1;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  flex-direction: column;
  min-height: 200px;
  padding: 22px 0 35px;
}

.welcome h2 {
  font-size: clamp(29px,3.8vw,43px);
  letter-spacing: -.02em;
}

.welcome p,.lead,.panel p,.muted,.empty {
  color: var(--muted);
  line-height: 1.75;
}

.welcome p {
  margin: 10px 0 20px;
  max-width: 37em;
}

.actions,.refs {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.primary,.secondary,.link,.ref {
  border-radius: 7px;
  padding: 8px 13px;
  font-size: 14px;
}

.primary {
  background: var(--dark);
  color: #fff;
  border: 1px solid var(--dark);
}

.primary:hover {
  background: #245642;
}

.secondary,.ref {
  background: var(--panel);
  border: 1px solid var(--line);
}

.secondary:hover,.ref:hover {
  border-color: #64806a;
  background: #f0f3ec;
}

.link {
  border: 0;
  background: transparent;
  color: var(--green);
  padding: 5px 2px;
}

.ref {
  color: #305b49;
  font-size: 12px;
  line-height: 1.6;
  padding: 3px 9px;
  max-width: 100%;
  text-align: left;
  overflow-wrap: anywhere;
}

.composer {
  margin: 23px 0 0;
  background: var(--panel);
  border: 1px solid #b8c5b7;
  border-radius: 12px;
  padding: 14px 16px 12px;
  box-shadow: 0 7px 24px #16352b08;
}

.composer textarea {
  display: block;
  width: 100%;
  resize: vertical;
  min-height: 54px;
  max-height: 260px;
  border: 0;
  line-height: 1.7;
  background: transparent;
}

.composer-foot {
  margin-top: 5px;
}

.composer-foot span,.meta,.date {
  font-size: 12px;
  color: var(--muted);
}

.composer-foot b {
  margin-left: 5px;
}

.message,.card,.panel {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
  padding: 18px 20px;
}

.message {
  max-width: 92%;
  align-self: flex-start;
}

.message.user {
  align-self: flex-end;
  background: #eaf0e7;
}

.message p,.card p,.passage p {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  line-height: 1.8;
  margin: 6px 0;
}

.card,.panel {
  margin: 12px 0;
}

.card h3 {
  font-size: 18px;
  color: var(--dark);
  margin: 6px 0 10px;
  line-height: 1.6;
}

.card .actions,.card .refs,.message .refs {
  margin-top: 12px;
}

.panel h2,.panel .subhead {
  margin-bottom: 12px;
}

.subhead h2 {
  margin: 0;
}

.row input {
  flex: 1;
  min-width: 0;
}

.empty,.lead {
  font-size: 14px;
}

.panel label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 9px 0;
}

.pref input {
  width: 18px;
  height: 18px;
  accent-color: var(--green);
}

.listrow {
  padding: 9px 0;
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid #e2e6de;
}

.listrow:last-child {
  border-bottom: 0;
}

.listrow button {
  text-align: left;
}

.error {
  color: #8d332b;
  font-size: 13px;
  white-space: pre-line;
}

.sr {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
}

dialog {
  width: min(650px,92vw);
  max-height: 82dvh;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--paper);
  color: var(--ink);
  padding: 26px;
  box-shadow: 0 24px 90px #12382d40;
}

dialog::backdrop {
  background: #132b24a0;
}

dialog label {
  display: grid;
  gap: 5px;
  margin: 15px 0;
}

input:not([type=checkbox]),dialog textarea {
  background: var(--panel);
  border: 1px solid #b9c5b8;
  border-radius: 6px;
  padding: 9px 10px;
}

.passage {
  border-left: 3px solid var(--line);
  padding: 5px 12px;
  margin: 13px 0;
}

.passage.selected {
  border-color: var(--green);
  background: #e7eee3;
}

.toast {
  position: fixed;
  bottom: 20px;
  right: 20px;
  max-width: min(420px,90vw);
  border-radius: 8px;
  background: #15382f;
  color: white;
  padding: 12px 16px;
  font-size: 14px;
  z-index: 5;
  box-shadow: 0 4px 22px #15382f30;
}

.quiet {
  border-left: 3px solid #a8b4a5;
}

.finding {
  border-left: 3px solid #517d58;
}

.topic-title {
  font: 20px var(--serif);
  color: #385b49;
  margin: 0 0 5px;
}

.mobile-select {
  display: none;
}

@media(max-width:720px) {
  .shell {
    display: block;
  }
  .rail {
    height: auto;
    position: static;
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: center;
    padding: 12px 16px 7px;
    gap: 6px 12px;
  }
  .brand {
    font-size: 26px;
    gap: 9px;
    padding: 0;
  }
  .seal {
    width: 25px;
    height: 25px;
  }
  .rail select {
    margin: 0;
    width: 124px;
    padding: 5px;
  }
  .rail nav {
    grid-column: 1/-1;
    display: flex;
    gap: 8px;
  }
  .nav {
    padding: 6px 10px;
    font-size: 13px;
    gap: 5px;
  }
  .nav i {
    font-size: 15px;
  }
  .scope-label,.side-head,.topics,.rail-foot {
    display: none;
  }
  .top {
    height: 44px;
  }
  .view {
    padding: 22px 16px;
  }
  .page-head {
    margin-bottom: 15px;
  }
  .chat-view {
    min-height: calc(100dvh - 142px);
  }
  .message {
    max-width: 98%;
  }
  .panel,.card,.message {
    padding: 13px 14px;
  }
  .welcome {
    min-height: 170px;
  }
  .mobile-select {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 10px;
  }
  .mobile-select select {
    min-width: 0;
    max-width: 68%;
    border: 1px solid var(--line);
    border-radius: 5px;
    padding: 5px;
    background: var(--panel);
  }
  .composer-foot span {
    font-size: 10px;
  }
  .top,.meta,.date {
    font-size: 12px;
  }
}

.field-grid { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:0 14px; }
.field-grid label, .field-grid select, .field-grid input { min-width:0; }
#timeForm { padding:0 0 1rem; }
#currentMemory { padding:1rem 1.15rem; margin:.4rem 0 1.4rem; border-left:3px solid #537767; background:#f0f4ef; }
#currentMemory p, .version-item p { margin:.35rem 0; white-space:pre-wrap; overflow-wrap:anywhere; }
.version-item { padding:.9rem 0; border-top:1px solid #dce3db; }
.version-item .meta, .pack-detail { font-size:.78rem; color:#4e6559; }
.pack-detail { margin:.65rem 0; }
.pack-detail summary { width:fit-content; cursor:pointer; }
.critical { color:#87432f; }
#forgetMemory:not(:empty), .forget-notice { border:1px solid #d7c0b8; border-radius:8px; padding:.8rem; margin-top:1rem; }
#originInfo, #lineActions { margin:.7rem 0; }
.memory-entry { display:grid; grid-template-columns:minmax(0,1fr) auto; align-items:center; gap:.8rem; border-top:1px solid #dce3db; padding:.7rem 0; }
.memory-entry:first-child { border-top:0; }
.memory-entry .link { text-align:left; }
.memory-entry p { margin:.15rem 0 0; color:#53685c; font-size:.88rem; overflow-wrap:anywhere; }
#timelineDialog, #revisionDialog { width:min(600px,calc(100% - 28px)); }
@media(max-width:580px){.field-grid{grid-template-columns:1fr;} .memory-entry{grid-template-columns:1fr;gap:0;} }

.activity-switch { margin:.25rem 0 1.3rem; }
.research-tile { border-top:1px solid var(--line); padding:1rem 0; }
.research-tile:first-child { border-top:0; }
.research-tile:last-child { padding-bottom:.2rem; }
.research-tile h3 { margin:.35rem 0; }
.research-title { background:transparent; border:0; color:var(--dark); padding:0; text-align:left; font:inherit; }
.research-title:hover { text-decoration:underline; }
.research-tile p { color:var(--muted); margin:.3rem 0; line-height:1.7; overflow-wrap:anywhere; }
.interest-line { display:flex; flex-wrap:wrap; align-items:baseline; gap:.5rem 1rem; border-top:1px solid var(--line); padding:.55rem 0; }
#researchDialog { width:min(720px,calc(100% - 24px)); }
#researchCurrent { border-left:3px solid var(--green); background:#edf2e9; margin:1rem 0; padding:.9rem 1.1rem; }
#researchCurrent p,.research-round p { margin:.35rem 0; line-height:1.65; overflow-wrap:anywhere; }
.changed-evidence { border-top:1px solid #cbd7c9; margin-top:.8rem; padding-top:.75rem; }
.research-round { border-top:1px solid var(--line); padding:.6rem 0; }
.research-round summary { cursor:pointer; display:list-item; }
.research-round summary .meta { display:inline-block; margin-left:.85rem; }
#researchActions { margin-top:1rem; }
@media(max-width:560px){.research-round summary .meta{display:block; margin-left:1rem;} #researchCurrent{padding:.65rem .8rem;}}

.pair-page {min-height:100vh;display:grid;place-items:center;padding:1.25rem;background:var(--dark);}
.pair-card {background:var(--paper);color:var(--ink);width:min(100%,29rem);padding:clamp(1.6rem,5vw,3rem);border-radius:14px;}
.pair-card .brand {color:var(--dark);margin:0 0 1.4rem;}
.pair-card h1 {font-family:var(--serif);font-size:2rem;margin:0 0 .6rem;}
.pair-card p {line-height:1.65;}
.pair-card form,.pair-card label,#hubView form,#deviceDialog form {display:grid;gap:.8rem;}
#hubView .panel {padding:1.2rem 1.4rem; margin:0 0 1rem;}
#hubView label,#deviceDialog label {display:grid;gap:.45rem;}
#hubView .consent-line {display:flex;align-items:flex-start;gap:.5rem;font-size:.9rem;}
#hubView select,#hubView input:not([type=checkbox]),#hubView textarea,#deviceDialog input,.pair-card input {width:100%;min-width:0;}
#hubView form button:not(.link) {justify-self:start;}
#hubView .actions,#deviceDialog form {margin-top:.8rem;}
.handoff-item {padding:.55rem 0;border-bottom:1px solid var(--line);}
.handoff-item p {margin:.25rem 0;white-space:pre-wrap;overflow-wrap:anywhere;}
#issuedCode code {display:block;user-select:all;overflow-wrap:anywhere;font-size:1.1rem;padding:.8rem;background:var(--light);}
@media(max-width:720px){
  .rail nav{display:grid;grid-template-columns:auto auto minmax(0,1fr) minmax(0,1fr);gap:3px;}
  .rail nav button{justify-content:center;padding-inline:5px;white-space:nowrap;}
  #hubView .panel{padding:.85rem;}
  #hubView .page-head{flex-wrap:wrap;}
}
@media(max-width:365px){.rail nav i{display:none;}}
