:root {
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "Inter",
          "PingFang SC", "Microsoft YaHei", "HarmonyOS Sans SC",
          "Noto Sans SC", "Hiragino Sans GB", system-ui, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas,
          "Cascadia Mono", monospace;

  --step-time:     60ms;
  --collapse-time: 360ms;

  --p-deep: #5b2c87;
  --p-mid:  #6c3fc8;
  --p-soft: #b388e8;
}

body[data-theme="light"] {
  --bg:          #f7f4ef;
  --bg-elev:     #fdfbf7;
  --ink:         #181822;
  --ink-soft:    #4a4855;
  --ink-fade:    #8a8794;
  --accent:      #6c3fc8;
  --accent-hi:   #8456e0;
  --accent-soft: #ebe1f8;
  --rule:        #18182214;
  --shadow:      0 1px 0 #18182208, 0 14px 40px -20px #18182233;
}

body[data-theme="dark"] {
  --bg:          #0e0c12;
  --bg-elev:     #181620;
  --ink:         #ede1c8;
  --ink-soft:    #b8aea0;
  --ink-fade:    #6a6557;
  --accent:      #b388e8;
  --accent-hi:   #d9c4f3;
  --accent-soft: #2b1d3e;
  --rule:        #ede1c81f;
  --shadow:      0 0 0 1px #ede1c80f, 0 24px 60px -20px #00000099;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }

body {
  font-family: var(--sans);
  color: var(--ink);
  background: var(--bg);
  background-image: radial-gradient(1200px 500px at 50% -10%, color-mix(in srgb, var(--accent) 6%, transparent), transparent);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow: hidden;
  transition: background-color 360ms ease, color 360ms ease;
}

::selection { background: var(--accent); color: var(--bg); }

.masthead, .app { animation: fadeUp 420ms cubic-bezier(.16,1,.3,1) both; }
.app { animation-delay: 60ms; }
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.masthead {
  position: sticky;
  top: 0;
  z-index: 10;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  padding: 10px 20px;
  border-bottom: 1px solid var(--rule);
  transition: background-color 360ms ease, border-color 360ms ease;
  flex-shrink: 0;
}
.masthead-inner {
  max-width: 100%;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.wordmark {
  font-family: var(--mono);
  font-weight: 700;
  font-size: clamp(18px, 2.4vw, 26px);
  letter-spacing: 0;
  line-height: 1;
  margin: 0;
  color: var(--ink);
  white-space: nowrap;
  display: inline-flex;
  align-items: baseline;
  text-decoration: none;
}
.cell {
  display: inline-block;
  width: 1ch;
  text-align: center;
  flex-shrink: 0;
}
.fold, .letter-m, .slash-extra { overflow: hidden; }
.slash, .slash-extra { color: var(--accent); font-weight: 800; }
.slash { transform-origin: 50% 60%; }
.slash-extra { width: 0; opacity: 0; }

.fold, .letter-m, .slash-extra {
  transition: width var(--collapse-time) ease, opacity var(--collapse-time) ease;
}
.fold { transition-delay: calc((7 - var(--i)) * var(--step-time)); }
.wordmark.is-closed .fold {
  width: 0; opacity: 0;
  transition-delay: calc((var(--i) - 1) * var(--step-time));
}
body[data-end="A"] .letter-m { transition-delay: 0ms; }
body[data-end="A"] .wordmark.is-closed .letter-m {
  width: 0; opacity: 0;
  transition-delay: calc(7 * var(--step-time));
}
body[data-end="A"] .wordmark.is-closed .slash-extra {
  width: 1ch; opacity: 1;
  transition-delay: calc(7 * var(--step-time) + var(--collapse-time) * 0.45);
}
.slash { transition: transform var(--collapse-time) ease; }
.wordmark.is-closed .slash { transform: scale(1.08); }

.nav-right {
  display: flex;
  gap: 14px;
  align-items: center;
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.03em;
  color: var(--ink-fade);
}
.nav-right a {
  color: var(--ink-soft);
  text-decoration: none;
  transition: color 150ms;
}
.nav-right a:hover { color: var(--accent); }
.theme-toggle {
  appearance: none;
  background: transparent;
  border: 1px solid var(--rule);
  color: var(--ink-soft);
  padding: 4px 10px;
  border-radius: 999px;
  font: inherit;
  cursor: pointer;
  transition: border-color 150ms, color 150ms;
}
.theme-toggle:hover { border-color: var(--accent); color: var(--accent); }

/* ---- 3-column layout ---- */
.app {
  display: flex;
  height: calc(100% - 57px);
  width: 100%;
}

.left-sidebar {
  width: 220px;
  flex-shrink: 0;
  border-right: 1px solid var(--rule);
  padding: 16px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  transition: width 250ms cubic-bezier(.16, 1, .3, 1),
              padding 250ms ease, border-color 200ms ease;
  overflow: hidden;
}
.left-sidebar::-webkit-scrollbar { width: 6px; }
.left-sidebar::-webkit-scrollbar-track { background: transparent; }
.left-sidebar::-webkit-scrollbar-thumb {
  background: var(--rule);
  border-radius: 3px;
}
.left-sidebar.is-collapsed {
  width: 0;
  padding: 16px 0;
  border-right-color: transparent;
}

.chat-main {
  position: relative;
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  padding: 0 20px;
}

/* ---- scroll-to-bottom ---- */
.scroll-bottom-btn {
  position: absolute;
  right: 26px;
  bottom: 128px;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-elev);
  border: 1px solid var(--rule);
  color: var(--ink-soft);
  box-shadow: var(--shadow);
  cursor: pointer;
  opacity: 0;
  transform: translateY(8px) scale(0.92);
  pointer-events: none;
  transition: opacity 200ms ease, transform 220ms cubic-bezier(.16,1,.3,1), border-color 150ms, color 150ms;
  z-index: 5;
}
.scroll-bottom-btn.is-visible {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}
.scroll-bottom-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* ---- sidebars toggle buttons ---- */
.sidebar-toggle {
  flex-shrink: 0;
  width: 28px;
  align-self: stretch;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  color: var(--ink-fade);
  cursor: pointer;
  transition: color 150ms, background 150ms, border-color 200ms ease;
}
.sidebar-toggle:hover {
  color: var(--accent);
  background: var(--accent-soft);
}
.sidebar-toggle-left {
  border-right: 1px solid var(--rule);
}
.left-sidebar.is-collapsed + .sidebar-toggle-left {
  border-right-color: transparent;
}
.sidebar-toggle-right {
  border-left: 1px solid var(--rule);
  order: 1;
}
.right-sidebar.is-collapsed + .sidebar-toggle-right {
  border-left-color: transparent;
}
.toggle-icon {
  transition: transform 300ms cubic-bezier(.16, 1, .3, 1);
}
.right-sidebar.is-collapsed + .sidebar-toggle-right .toggle-icon {
  transform: rotate(45deg);
}

/* ---- right sidebar ---- */
.right-sidebar {
  width: 240px;
  flex-shrink: 0;
  border-left: 1px solid var(--rule);
  overflow: hidden;
  transition: width 250ms cubic-bezier(.16, 1, .3, 1),
              border-color 200ms ease;
}
.right-sidebar.is-collapsed {
  width: 0;
  border-left-color: transparent;
}

.sidebar-backdrop {
  position: fixed;
  inset: 0;
  z-index: 15;
  background: rgba(10, 8, 14, 0.45);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 220ms ease;
}
.sidebar-backdrop.is-active {
  opacity: 1;
  pointer-events: auto;
}

.sidebar-scroll {
  width: 240px;
  height: 100%;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}
.sidebar-scroll::-webkit-scrollbar { width: 6px; }
.sidebar-scroll::-webkit-scrollbar-track { background: transparent; }
.sidebar-scroll::-webkit-scrollbar-thumb {
  background: var(--rule);
  border-radius: 3px;
}

.sidebar-section { display: flex; flex-direction: column; gap: 8px; }
.sidebar-label {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-fade);
  font-weight: 600;
}

.history-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.history-item {
  padding: 8px 10px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 150ms ease;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.history-item:hover { background: var(--accent-soft); }
.history-item.is-active {
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  border: 1px solid color-mix(in srgb, var(--accent) 25%, transparent);
}
.history-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
  line-height: 1.3;
}
.history-preview {
  font-size: 11px;
  color: var(--ink-fade);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  line-height: 1.3;
}

.btn-new-chat {
  font-family: var(--mono);
  font-size: 11px;
  padding: 6px 10px;
  border-radius: 8px;
  border: 1px solid var(--rule);
  background: transparent;
  color: var(--ink-soft);
  cursor: pointer;
  transition: border-color 150ms, color 150ms, background 150ms;
}
.btn-new-chat:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-soft);
}

.model-tabs {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.model-tab {
  text-align: left;
  font-family: var(--sans);
  font-size: 13px;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--ink-soft);
  cursor: pointer;
  transition: border-color 150ms, color 150ms, background 150ms;
}
.model-tab:hover {
  background: var(--accent-soft);
  color: var(--ink);
}
.model-tab.is-active {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 10%, transparent);
  color: var(--accent);
  font-weight: 600;
}

.sidebar-params { flex: 1; min-height: 0; }

.param-group {
  border: 1px solid var(--rule);
  border-radius: 8px;
  padding: 8px 10px;
  background: var(--bg-elev);
}
.param-group + .param-group { margin-top: 8px; }
.param-group-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-soft);
  margin-bottom: 8px;
}

.btn-edit-prompt {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  font-family: var(--mono);
  font-size: 12px;
  padding: 6px 10px;
  border-radius: 6px;
  border: 1px solid var(--rule);
  background: transparent;
  color: var(--ink-soft);
  cursor: pointer;
  transition: border-color 150ms, color 150ms, background 150ms;
}
.btn-edit-prompt:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-soft);
}

.param-segmented {
  display: flex;
  gap: 4px;
}
.param-btn {
  flex: 1;
  font-family: var(--mono);
  font-size: 11px;
  padding: 5px 4px;
  border-radius: 6px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--ink-fade);
  cursor: pointer;
  text-align: center;
  transition: border-color 150ms, color 150ms, background 150ms;
}
.param-btn:hover {
  color: var(--ink);
  background: var(--accent-soft);
}
.param-btn.is-active {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  color: var(--accent);
  font-weight: 600;
}

.param-slider-wrap {
  margin-top: 8px;
  overflow: hidden;
  transition: max-height 250ms cubic-bezier(.16, 1, .3, 1), opacity 200ms ease;
  max-height: 40px;
  opacity: 1;
}
.param-slider-wrap.is-hidden {
  max-height: 0;
  opacity: 0;
  margin-top: 0;
}

.param-slider-row {
  display: flex;
  align-items: center;
  gap: 10px;
}
.param-slider {
  flex: 1;
  -webkit-appearance: none;
  appearance: none;
  height: 4px;
  border-radius: 2px;
  background: var(--rule);
  outline: none;
  cursor: pointer;
}
.param-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid var(--bg-elev);
  cursor: pointer;
  box-shadow: 0 0 0 1px var(--rule);
}
.param-slider::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid var(--bg-elev);
  cursor: pointer;
}
.param-value {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--accent);
  min-width: 3.5ch;
  text-align: right;
}

/* ---- modal ---- */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(0,0,0,0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 200ms ease;
}
.modal-overlay.is-hidden {
  display: none;
}
.modal-box {
  width: min(480px, 90vw);
  background: var(--bg-elev);
  border: 1px solid var(--rule);
  border-radius: 14px;
  padding: 20px;
  box-shadow: 0 24px 80px rgba(0,0,0,0.35);
}
.modal-head {
  font-family: var(--sans);
  font-size: 16px;
  font-weight: 600;
  color: var(--ink);
  margin-bottom: 14px;
}
.modal-textarea {
  width: 100%;
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.6;
  color: var(--ink);
  background: var(--bg);
  border: 1px solid var(--rule);
  border-radius: 8px;
  padding: 10px 12px;
  resize: vertical;
  transition: border-color 150ms ease;
}
.modal-textarea:focus {
  outline: none;
  border-color: var(--accent);
}
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 14px;
}
.modal-btn {
  font-family: var(--mono);
  font-size: 12px;
  padding: 7px 18px;
  border-radius: 8px;
  border: 1px solid var(--rule);
  cursor: pointer;
  transition: border-color 150ms, color 150ms, background 150ms;
}
.modal-btn-cancel {
  background: transparent;
  color: var(--ink-soft);
}
.modal-btn-cancel:hover {
  border-color: var(--ink-fade);
  color: var(--ink);
}
.modal-btn-save {
  background: var(--accent);
  color: var(--bg);
  border-color: var(--accent);
}
.modal-btn-save:hover {
  background: var(--accent-hi);
}

/* ---- messages ---- */
.messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px 0;
  display: flex;
  flex-direction: column;
  gap: 16px;
  scroll-behavior: smooth;
}
.messages::-webkit-scrollbar { width: 6px; }
.messages::-webkit-scrollbar-track { background: transparent; }
.messages::-webkit-scrollbar-thumb {
  background: var(--rule);
  border-radius: 3px;
}

.msg {
  display: flex;
  gap: 10px;
  max-width: 85%;
  animation: msgIn 0.35s cubic-bezier(.16, 1, .3, 1) both;
}
.msg-ai { align-self: flex-start; }
.msg-user {
  align-self: flex-end;
  flex-direction: row-reverse;
}
.msg.is-grouped { margin-top: -10px; }
.msg.is-grouped .msg-avatar { visibility: hidden; }
.msg.is-grouped .msg-head { display: none; }

.msg-avatar {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--mono);
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: -0.02em;
  background: var(--accent-soft);
  color: var(--accent);
  margin-top: 2px;
}
.msg-user .msg-avatar {
  background: var(--accent);
  color: var(--bg);
}

.msg-body {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}
.msg-head {
  display: flex;
  align-items: center;
  gap: 8px;
}
.msg-user .msg-head { flex-direction: row-reverse; }
.msg-sender {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--ink-fade);
  letter-spacing: 0.03em;
}
.msg-copy {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  padding: 0;
  border: none;
  border-radius: 5px;
  background: transparent;
  color: var(--ink-fade);
  cursor: pointer;
  opacity: 0;
  transform: translateY(-2px);
  transition: opacity 150ms ease, transform 150ms ease, color 150ms, background 150ms;
}
.msg:hover .msg-copy,
.msg-copy:focus-visible {
  opacity: 1;
  transform: translateY(0);
}
.msg-copy:hover {
  color: var(--accent);
  background: var(--accent-soft);
}
.msg-copy.is-copied {
  color: #2fa860;
  opacity: 1;
}
.msg-content {
  font-size: 14.5px;
  line-height: 1.6;
  padding: 10px 14px;
  border-radius: 12px;
  word-wrap: break-word;
  overflow-wrap: break-word;
}
.msg-ai .msg-content {
  background: var(--bg-elev);
  border: 1px solid var(--rule);
  border-bottom-left-radius: 4px;
  box-shadow: var(--shadow);
}
.msg-ai .msg-content.is-streaming::after {
  content: "";
  display: inline-block;
  width: 2px;
  height: 13px;
  margin-left: 2px;
  vertical-align: -2px;
  background: var(--accent);
  animation: caretBlink 0.9s steps(1) infinite;
}
@keyframes caretBlink {
  0%, 49% { opacity: 1; }
  50%, 100% { opacity: 0; }
}
.msg-user .msg-content {
  background: var(--accent);
  color: var(--bg);
  border-bottom-right-radius: 4px;
}
.msg-model .msg-content {
  background: transparent;
  border: 1px dashed var(--rule);
  color: var(--ink-fade);
  font-family: var(--mono);
  font-size: 12px;
  text-align: center;
}
.msg-time {
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--ink-fade);
  opacity: 0.6;
  padding: 0 2px;
}
.msg-user .msg-time { text-align: right; }

.msg-typing {
  align-self: flex-start;
  display: flex;
  align-items: center;
  gap: 10px;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 200ms ease, transform 200ms ease;
  pointer-events: none;
}
.msg-typing.is-active { opacity: 1; transform: translateY(0); }

.typing-dots {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 12px 16px;
  background: var(--bg-elev);
  border: 1px solid var(--rule);
  border-radius: 12px;
  border-bottom-left-radius: 4px;
  box-shadow: var(--shadow);
}
.typing-dots span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--ink-fade);
  animation: dotBounce 1.2s ease-in-out infinite;
}
.typing-dots span:nth-child(2) { animation-delay: 0.15s; }
.typing-dots span:nth-child(3) { animation-delay: 0.3s; }

@keyframes dotBounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-8px); opacity: 1; }
}

.input-area {
  flex-shrink: 0;
  padding: 12px 0 20px;
}

.input-form {
  display: flex;
  gap: 8px;
  align-items: center;
  background: var(--bg-elev);
  border: 1px solid var(--rule);
  border-radius: 14px;
  padding: 6px 6px 6px 16px;
  transition: border-color 200ms ease, box-shadow 200ms ease;
  box-shadow: var(--shadow);
}
.input-form:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 20%, transparent), var(--shadow);
}
.input-form.is-armed {
  border-color: var(--accent-hi);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 32%, transparent), var(--shadow);
}
.input-hint kbd.is-active {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-soft);
}

.model-select {
  flex-shrink: 0;
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 10%, transparent);
  border: 1px solid color-mix(in srgb, var(--accent) 25%, transparent);
  border-radius: 8px;
  padding: 4px 22px 4px 8px;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%238a8794' stroke-width='1.3' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 6px center;
  transition: border-color 150ms ease;
}
.model-select:hover {
  border-color: var(--accent);
}
.model-select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 20%, transparent);
}

.input-field {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  color: var(--ink);
  font-family: var(--sans);
  font-size: 14.5px;
  line-height: 1.5;
  padding: 6px 0;
}
.input-field::placeholder {
  color: var(--ink-fade);
  opacity: 0.5;
}

.btn-send {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  border: none;
  background: var(--accent);
  color: var(--bg);
  cursor: pointer;
  transition: opacity 200ms ease, transform 200ms cubic-bezier(.16, 1, .3, 1);
  flex-shrink: 0;
}
.btn-send:hover {
  opacity: 0.85;
  transform: scale(1.06);
}
.btn-send:active {
  transform: scale(0.95);
}
.btn-send:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

.context-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 4px 0;
}
.context-bar-track {
  flex: 1;
  height: 4px;
  border-radius: 2px;
  background: var(--rule);
  overflow: hidden;
}
.context-bar-fill {
  height: 100%;
  border-radius: 2px;
  background: var(--accent);
  opacity: 0.6;
  transition: width 350ms ease, opacity 200ms ease;
}
.context-bar-fill.is-full {
  opacity: 1;
  background: #e04040;
}
.context-label {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--ink-fade);
  opacity: 0.55;
  white-space: nowrap;
  flex-shrink: 0;
}

.input-hint {
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--ink-fade);
  opacity: 0.5;
  text-align: right;
  padding: 6px 4px 0;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
}
.input-hint kbd {
  font-family: var(--mono);
  font-size: 10px;
  padding: 1px 5px;
  border: 1px solid var(--rule);
  border-radius: 4px;
  background: var(--bg-elev);
}
.hint-icon {
  flex-shrink: 0;
  opacity: 0.7;
}

@keyframes msgIn {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

html[lang="en"] [lang="zh"] { display: none; }
html[lang="zh"] [lang="en"] { display: none; }

@media (max-width: 860px) {
  .chat-main { padding: 0 12px; }
  .model-select { font-size: 10px; padding: 4px 18px 4px 6px; max-width: 100px; }

  .left-sidebar,
  .right-sidebar {
    position: fixed;
    top: 57px;
    bottom: 0;
    width: min(78vw, 300px);
    z-index: 20;
    padding: 0;
    background: var(--bg-elev);
    box-shadow: 0 0 60px rgba(0,0,0,0.35);
    transition: transform 280ms cubic-bezier(.16, 1, .3, 1);
  }
  .left-sidebar {
    left: 0;
    transform: translateX(-100%);
    padding: 16px;
    border-right: 1px solid var(--rule);
  }
  .left-sidebar.is-drawer-open { transform: translateX(0); }
  .right-sidebar {
    right: 0;
    transform: translateX(100%);
    border-left: 1px solid var(--rule);
  }
  .right-sidebar.is-drawer-open { transform: translateX(0); }
  .sidebar-scroll { width: 100%; }

  .sidebar-toggle-left,
  .sidebar-toggle-right {
    border-color: transparent;
  }

  .sidebar-backdrop { top: 57px; z-index: 18; }

  .scroll-bottom-btn { right: 18px; }
}

@media (max-width: 540px) {
  .msg { max-width: 92%; }
  .msg-content { font-size: 14px; }
  .masthead { padding: 10px 14px; }
}

.history-unavailable {
  opacity: 0.45;
  cursor: default;
  pointer-events: none;
}

.model-info {
  padding: 8px 0;
}
.model-name {
  font-weight: 600;
  font-size: 13px;
  color: var(--ink);
}
.model-detail {
  font-size: 11px;
  color: var(--ink-fade);
  margin-top: 2px;
}

.param-note {
  font-size: 11px;
  color: var(--ink-fade);
  opacity: 0.55;
  margin-top: 6px;
  font-style: italic;
}

/* Remove model-select styles since we use model-info instead */
.model-select { display: none !important; }

.server-offline-banner {
  text-align: center;
  padding: 24px 16px 16px;
  font-size: 14px;
  font-weight: 500;
  color: var(--ink-soft);
  opacity: 0.7;
  border-bottom: 1px solid var(--rule);
  margin-bottom: 8px;
}

.msg-act {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  padding: 0;
  border: none;
  border-radius: 5px;
  background: transparent;
  color: var(--ink-fade);
  cursor: pointer;
  opacity: 0;
  transform: translateY(-2px);
  transition: opacity 150ms ease, transform 150ms ease, color 150ms, background 150ms;
  flex-shrink: 0;
}
.msg:hover .msg-act,
.msg-act:focus-visible {
  opacity: 1;
  transform: translateY(0);
}
.msg-act:hover {
  color: var(--accent);
  background: var(--accent-soft);
}
.msg-act.is-copied {
  color: #2fa860;
  opacity: 1;
}

@media (prefers-reduced-motion: reduce) {
  .fold, .letter-m, .slash-extra, .slash {
    transition-duration: 0ms !important;
    transition-delay: 0ms !important;
  }
  .msg { animation: none; }
  .typing-dots span { animation: none; }
  .right-sidebar, .left-sidebar { transition: none; }
  .masthead, .app { animation: none; }
  .msg-content.is-streaming::after { animation: none; }
}
