:root {
  font-family: Inter, "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  font-synthesis: none;
  line-height: 1.55;
  color: #202c24;
  background: #f5f6f1;
  --ink: #202c24;
  --muted: #58675d;
  --line: #dce3d8;
  --accent: #225440;
  --accent-strong: #183d30;
  --accent-muted: #e5efe6;
  --surface: #fff;
  --canvas: #f5f6f1;
  --focus: #267657;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-width: 280px; }
button, input, textarea, select { font: inherit; }
button { cursor: pointer; }
a { color: var(--accent); }
button:focus-visible, a:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}
button, .quiet, .primary { -webkit-tap-highlight-color: transparent; }

.shell {
  width: min(1200px, 100%);
  min-height: 100dvh;
  margin-inline: auto;
  padding: clamp(18px, 4vw, 44px);
}
.header, .identity, .header-actions, .bar, .aside-title, .compose-controls, .modes {
  display: flex;
  align-items: center;
}
.header { justify-content: space-between; padding-bottom: 24px; gap: 12px; }
.identity { gap: 11px; min-width: 0; }
.mark {
  width: 42px;
  height: 42px;
  border-radius: 13px;
  display: grid;
  place-content: center;
  gap: 3px;
  background: var(--accent-strong);
  box-shadow: inset 0 0 0 1px #ffffff2c, 0 2px 5px #173b302b;
  flex: none;
}
.mark i { width: 17px; height: 2px; border-radius: 2px; background: #e4f2df; display: block; }
.mark i:nth-child(2) { width: 12px; }
.mark i:nth-child(3) { width: 7px; }
.brand { display: block; font-size: 9px; font-weight: 800; letter-spacing: .2em; color: var(--muted); }
h1 { font-size: 27px; letter-spacing: -.035em; line-height: 1.05; margin: 3px 0 0; }
h2 { font-size: 16px; margin: 0; }
h3 { font-size: 14px; margin: 13px 0 7px; }
.header-actions { justify-content: flex-end; gap: 5px; font-size: 13px; }
.header-actions form { margin: 0; }
.icon-close { font-size: 24px; line-height: 1; width: 36px; }
.quiet, .primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-height: 36px;
  padding: 6px 10px;
  border-radius: 8px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--accent);
  text-decoration: none;
  white-space: nowrap;
}
.quiet:hover { color: var(--accent-strong); border-color: var(--line); background: var(--accent-muted); }
.primary {
  background: var(--accent);
  color: white;
  font-weight: 620;
  padding: 6px 14px;
}
.primary:hover { background: var(--accent-strong); }
.primary:disabled { opacity: .52; cursor: wait; }

.modes { justify-content: space-between; gap: 8px; margin-bottom: 13px; }
.mode-switch { display: inline-flex; gap: 2px; border: 1px solid var(--line); border-radius: 12px; background: #e9ede6; padding: 3px; }
.mode-switch button {
  border: 1px solid transparent;
  padding: 6px 14px;
  min-height: 34px;
  min-width: 106px;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  white-space: nowrap;
}
.mode-switch button:hover { color: var(--accent-strong); }
.mode-switch button[aria-pressed="true"] {
  background: var(--surface);
  color: var(--accent-strong);
  border-color: #e0e6dc;
  font-weight: 650;
  box-shadow: 0 1px 2px #23383014;
}
.manage[aria-pressed="true"] { background: var(--accent-muted); border-color: var(--line); font-weight: 620; }
.layout { display: grid; grid-template-columns: minmax(200px, 245px) minmax(0, 1fr); gap: 12px; }
aside, .main, .notice { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; min-width: 0; }
aside { padding: 15px 10px; }
.notice { padding: 18px; }
.aside-title { justify-content: space-between; gap: 6px; padding: 0 5px 10px; }
.new-record { font-size: 13px; }
.record-link {
  display: block;
  width: 100%;
  min-height: 50px;
  padding: 8px 9px;
  color: var(--ink);
  border: 1px solid transparent;
  border-radius: 9px;
  background: transparent;
  text-align: left;
  overflow-wrap: anywhere;
}
.record-link:hover, .record-link.active { background: #eef3ed; border-color: #dce7dc; }
.record-link small { display: block; color: var(--muted); font-size: 11px; margin-top: 2px; }
#records { max-height: min(68vh, 650px); overflow: auto; scrollbar-width: thin; }

.main { display: flex; flex-direction: column; min-height: min(610px, 74dvh); min-width: 0; padding: 13px 15px 10px; box-shadow: 0 2px 9px #2b422509; }
.bar { flex: none; justify-content: flex-start; gap: 7px; min-height: 35px; margin-bottom: 7px; }
.context {
  display: inline-flex;
  min-width: 0;
  align-items: center;
  gap: 6px;
  max-width: 100%;
  padding: 4px 8px;
  border: 1px solid #dce8dc;
  border-radius: 20px;
  background: #f1f6ef;
  color: #3d5a48;
  font-size: 12px;
  overflow-wrap: anywhere;
}
.context::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: #518169; flex: none; }
.context-clear { font-size: 12px; min-height: 29px; padding: 3px 6px; }
.muted, .meta { color: var(--muted); font-size: 13px; }
.detail { max-height: 62dvh; min-height: 100px; flex: 1 1 auto; overflow: auto; overflow-wrap: anywhere; scrollbar-width: thin; }
.example {
  align-self: center;
  max-width: 330px;
  margin: clamp(18px, 6vh, 70px) auto;
  padding: 13px 15px;
  border: 1px solid #e4eae2;
  border-radius: 13px;
  background: #f8faf7;
}
.example p { margin: 0 0 7px; font-size: 12px; color: var(--muted); }
.example .quiet { justify-content: flex-start; text-align: left; white-space: normal; padding: 3px 0; font-size: 14px; }
.example .quiet:hover { border-color: transparent; background: transparent; text-decoration: underline; }
.message, .draft, .review { padding: 12px 13px; margin: 8px 0 12px; border: 1px solid #e3eae1; border-radius: 13px; background: #f7f9f5; }
.message.user { margin-left: min(15%, 78px); background: #eaf2ea; border-color: #dce8dc; }
.message > strong { display: block; color: #435e4e; font-size: 12px; margin-bottom: 3px; }
.message p, .review p { margin: 4px 0; white-space: pre-wrap; }
.detail-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 7px; margin: 4px 0 8px; }

textarea, input:not([type="file"]), select {
  width: 100%;
  padding: 8px;
  color: var(--ink);
  border: 1px solid #cbd8cd;
  border-radius: 8px;
  background: var(--surface);
}
textarea { resize: vertical; }
#compose {
  flex: none;
  padding: 8px;
  border: 1px solid #cbd7cc;
  border-radius: 13px;
  background: #fff;
  box-shadow: 0 2px 7px #2649260a;
  margin-top: 7px;
}
#compose:focus-within { border-color: #7ea88b; }
#compose.dragging { border-color: var(--focus); box-shadow: 0 0 0 3px #22765622; }
#question { display: block; min-height: 61px; max-height: 220px; border: 0; padding: 6px 7px; background: transparent; }
#question:focus { outline: 0; }
.compose-controls { justify-content: flex-start; gap: 4px; flex-wrap: wrap; }
.compose-controls .quiet { font-size: 13px; }
.mic { gap: 5px; }
.mic-icon { width: 8px; height: 12px; border: 1.5px solid currentColor; border-radius: 6px; display: inline-block; }
#time-hint { font-size: 11px; margin-left: 2px; }
.recording { background: #f9e9e4; color: #87352c; }
.send { margin-left: auto; min-width: 62px; }
.files { display: flex; flex-wrap: wrap; gap: 6px; padding: 1px 4px; }
.files:empty { padding: 0; }
.file {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 100%;
  padding: 4px 7px;
  border-radius: 7px;
  background: #edf3ed;
  color: var(--accent-strong);
  font-size: 12px;
  overflow-wrap: anywhere;
}
.file button { border: 0; background: none; color: var(--accent); min-height: 24px; padding: 0 4px; font-size: 13px; }
.file img { width: 30px; height: 27px; object-fit: cover; border-radius: 4px; }
#status { flex: none; margin: 5px 1px 0; color: var(--muted); font-size: 13px; }
#status:empty { display: none; }
#voice { padding: 7px; font-size: 13px; }
#voice audio { width: 100%; height: 36px; }

.fields, .actions-list { display: grid; gap: 9px; }
.fields label { display: block; color: var(--muted); font-size: 13px; }
.fields label input, .fields label textarea, .fields label select { margin-top: 2px; }
.action-row { display: grid; gap: 6px; padding: 9px; border: 1px solid var(--line); border-radius: 9px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
#show-history { display: none; }

html.panel .shell { display: flex; flex-direction: column; width: 100%; height: 100dvh; min-height: 0; padding: 14px; }
html.panel .header { flex: none; padding-bottom: 10px; }
html.panel h1 { font-size: 22px; }
html.panel .mark { width: 35px; height: 35px; border-radius: 11px; }
html.panel #workspace { display: flex; flex-direction: column; flex: 1 1 auto; min-height: 0; }
html.panel .modes { flex: none; margin-bottom: 9px; }
html.panel .layout { display: flex; flex-direction: column; flex: 1 1 auto; min-height: 0; gap: 7px; }
html.panel #history { display: none; }
html.panel #show-history { display: inline-flex; }
html.panel.history-open #history { display: block; flex: none; }
html.panel #records { max-height: min(20dvh, 165px); }
html.panel .main { flex: 1 1 auto; min-height: 0; padding: 9px; }
html.panel .detail { min-height: 0; max-height: none; }
html.panel #compose { margin-top: 4px; }

@media(max-width: 740px) {
  .shell { padding: 13px; }
  .header { padding-bottom: 14px; }
  .layout { grid-template-columns: minmax(0, 1fr); }
  #history { display: none; }
  #show-history { display: inline-flex; }
  html.history-open #history { display: block; }
  #records { max-height: 205px; }
  .modes { margin-bottom: 9px; }
  .quiet, .primary, .mode-switch button { min-height: 40px; }
  .main { min-height: 410px; padding: 10px; }
  .detail { max-height: 54dvh; }
  .message.user { margin-left: 5%; }
}
@media(max-width: 420px) {
  html.panel .shell { padding: 10px; }
  .header-actions { gap: 1px; }
  .header-actions .quiet { min-width: 35px; padding-inline: 5px; }
  .mode-switch button { min-width: 92px; padding-inline: 8px; }
  .manage { padding-inline: 5px; font-size: 13px; }
  .compose-controls .quiet { padding-inline: 5px; }
  .standalone { display: none; }
  #time-hint { margin-left: 0; }
}
