:root {
  font-family: Inter, "Segoe UI", "Microsoft YaHei", sans-serif;
  color: #202124;
  background: #f7f8fa;
  font-synthesis: none;
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; min-height: 100vh; }
button, textarea, input, select { font: inherit; }
button { cursor: pointer; }

.shell { display: grid; grid-template-columns: 244px minmax(0, 1fr); min-height: 100vh; }
.sidebar { display: flex; flex-direction: column; min-height: 100vh; padding: 20px 14px 14px; background: #eef1f6; border-right: 1px solid #e1e5eb; }
.brand { display: flex; align-items: center; gap: 10px; padding: 0 8px 22px; font-size: 17px; }
.brand-mark, .welcome-mark { display: grid; place-items: center; color: white; background: #15171a; font-weight: 700; }
.brand-mark { width: 30px; height: 30px; border-radius: 7px; }
.new-chat { display: flex; align-items: center; justify-content: center; gap: 8px; height: 42px; border: 1px solid #d4d9e0; border-radius: 7px; background: white; color: #24262a; }
.new-chat:hover { background: #f9fafb; border-color: #bdc4cd; }
.history-label { padding: 24px 9px 9px; color: #858b94; font-size: 12px; }
.history { display: flex; flex: 1; flex-direction: column; gap: 3px; overflow: auto; }
.history-item { width: 100%; padding: 9px; overflow: hidden; border: 0; border-radius: 6px; color: #555b64; background: transparent; text-align: left; text-overflow: ellipsis; white-space: nowrap; }
.history-item:hover, .history-item.active { background: #e1e5eb; color: #22252a; }
.settings-button { display: flex; align-items: center; gap: 9px; width: 100%; padding: 11px 9px; border: 0; border-top: 1px solid #dde1e7; color: #555b64; background: transparent; text-align: left; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: #b4bac3; }
.status-dot.online { background: #2e9b64; }
.status-dot.warning { background: #d29a2e; }

.main { display: grid; grid-template-rows: 58px minmax(0, 1fr) auto; min-width: 0; height: 100vh; background: white; }
.topbar { display: flex; align-items: center; gap: 10px; padding: 0 22px; border-bottom: 1px solid #eceef1; }
.topbar select { max-width: 240px; padding: 7px 30px 7px 10px; border: 1px solid transparent; border-radius: 6px; color: #3e434a; background: #f4f5f7; }
.topbar #reasoning-effort { max-width: 110px; }
.topbar .icon-button:last-child { margin-left: auto; }
.icon-button { display: grid; width: 36px; height: 36px; place-items: center; border: 0; border-radius: 6px; color: #636971; background: transparent; font-size: 20px; }
.icon-button:hover { background: #f0f2f4; }
.menu-button { display: none; }
.conversation { min-height: 0; overflow-y: auto; scroll-behavior: smooth; }
.welcome { display: flex; min-height: 70vh; align-items: center; justify-content: center; flex-direction: column; padding: 32px; text-align: center; }
.welcome-mark { width: 52px; height: 52px; border-radius: 8px; font-size: 24px; }
.welcome h1 { margin: 22px 0 8px; font-size: 26px; font-weight: 600; letter-spacing: 0; }
.welcome p { margin: 0; color: #8a9098; font-size: 14px; }
.messages { width: min(820px, calc(100% - 40px)); margin: 0 auto; padding: 30px 0 80px; }
.message { display: grid; grid-template-columns: 32px minmax(0, 1fr); gap: 13px; margin-bottom: 28px; line-height: 1.72; }
.avatar { display: grid; width: 32px; height: 32px; place-items: center; border-radius: 6px; background: #181a1d; color: white; font-size: 13px; font-weight: 700; }
.message.user .avatar { background: #e8ebef; color: #545a63; }
.message-content { min-width: 0; padding-top: 3px; overflow-wrap: anywhere; }
.message-content p { margin: 0 0 12px; }
.message-content pre { overflow-x: auto; padding: 14px; border: 1px solid #e1e4e8; border-radius: 6px; background: #f6f8fa; line-height: 1.5; }
.message-content code { font-family: "Cascadia Code", Consolas, monospace; font-size: 13px; }
.message-content a { color: #1768b2; }
.message-files { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.message-files span { padding: 4px 7px; border: 1px solid #dce0e5; border-radius: 5px; color: #666d76; background: #f7f8f9; font-size: 12px; }
.cursor::after { content: ""; display: inline-block; width: 7px; height: 16px; margin-left: 3px; vertical-align: -2px; background: #777; animation: blink 1s step-end infinite; }
@keyframes blink { 50% { opacity: 0; } }

.composer-wrap { padding: 10px 24px 13px; background: linear-gradient(transparent, white 18%); }
.composer { display: flex; width: min(820px, 100%); align-items: flex-end; gap: 10px; margin: 0 auto; padding: 10px 10px 10px 16px; border: 1px solid #d8dce2; border-radius: 8px; background: white; box-shadow: 0 6px 24px rgb(34 38 45 / 8%); }
.composer:focus-within { border-color: #979da7; }
.composer textarea { flex: 1; max-height: 160px; resize: none; border: 0; outline: 0; line-height: 24px; }
.send-button { display: grid; flex: 0 0 36px; width: 36px; height: 36px; place-items: center; border: 0; border-radius: 6px; color: white; background: #181a1d; font-size: 21px; }
.send-button:disabled { cursor: default; background: #c8ccd2; }
.composer-tool { display: grid; flex: 0 0 34px; width: 34px; height: 34px; place-items: center; border: 0; border-radius: 6px; color: #60666f; background: transparent; font-size: 17px; }
.composer-tool:hover { background: #f0f2f4; }
.search-toggle { display: flex; flex: 0 0 auto; height: 34px; align-items: center; gap: 5px; padding: 0 8px; border-radius: 6px; color: #666d76; font-size: 12px; cursor: pointer; }
.search-toggle:hover { background: #f0f2f4; }
.search-toggle input { width: 14px; height: 14px; margin: 0; }
.pending-files { display: flex; width: min(820px, 100%); min-height: 0; flex-wrap: wrap; gap: 6px; margin: 0 auto 7px; }
.file-chip { display: inline-flex; max-width: 220px; align-items: center; gap: 6px; padding: 5px 7px; overflow: hidden; border: 1px solid #d8dce2; border-radius: 5px; background: white; color: #555b64; font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.file-chip button { border: 0; color: #8a9098; background: transparent; font-size: 16px; line-height: 1; }
.disclaimer { margin: 8px 0 0; color: #a0a5ad; font-size: 11px; text-align: center; }

dialog { width: min(440px, calc(100% - 32px)); padding: 0; border: 1px solid #dfe2e7; border-radius: 8px; box-shadow: 0 20px 70px rgb(0 0 0 / 18%); }
dialog::backdrop { background: rgb(30 33 38 / 34%); }
.settings-card { padding: 22px; }
.dialog-heading { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 24px; }
.dialog-heading h2 { margin: 0 0 5px; font-size: 18px; }
.dialog-heading p { margin: 0; color: #8a9098; font-size: 13px; }
.settings-card label { display: block; margin-bottom: 7px; font-size: 13px; font-weight: 600; }
.settings-card input { width: 100%; height: 42px; padding: 0 11px; border: 1px solid #ccd1d8; border-radius: 6px; outline: 0; }
.settings-card input:focus { border-color: #757b84; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 24px; }
.primary-button, .secondary-button { min-width: 72px; padding: 9px 13px; border-radius: 6px; }
.secondary-button { border: 1px solid #d2d6dc; background: white; }
.primary-button { border: 1px solid #181a1d; background: #181a1d; color: white; }

.admin-body { min-height: 100vh; background: #f5f6f8; }
.admin-header { display: flex; height: 58px; align-items: center; gap: 24px; padding: 0 28px; border-bottom: 1px solid #e1e4e8; background: white; }
.back-link { color: #555b64; text-decoration: none; }
.back-link:hover { color: #17191c; }
.admin-main { display: grid; grid-template-columns: minmax(0, 680px) 280px; gap: 28px; width: min(1040px, calc(100% - 40px)); margin: 40px auto; align-items: start; }
.admin-panel { padding: 28px; border: 1px solid #dde1e6; border-radius: 8px; background: white; }
.admin-title { display: flex; justify-content: space-between; gap: 20px; margin-bottom: 28px; }
.admin-title h1 { margin: 0 0 7px; font-size: 22px; letter-spacing: 0; }
.admin-title p { margin: 0; color: #7d838c; font-size: 13px; }
.admin-title h2 { margin: 0 0 7px; font-size: 18px; letter-spacing: 0; }
.compact-title { margin-bottom: 20px; }
.admin-subsection { margin-top: 30px; padding-top: 28px; border-top: 1px solid #e1e4e8; }
.proxy-grid { display: grid; grid-template-columns: minmax(0, 1fr) 130px; gap: 12px; }
.config-badge { align-self: flex-start; padding: 5px 8px; border-radius: 5px; color: #666d76; background: #eceff2; font-size: 12px; white-space: nowrap; }
.config-badge.ready { color: #17683f; background: #e1f3e9; }
.admin-panel label:not(.checkbox-row) { display: block; margin: 18px 0 7px; font-size: 13px; font-weight: 600; }
.admin-panel input:not([type="checkbox"]), .admin-panel select { width: 100%; height: 42px; padding: 0 11px; border: 1px solid #cdd2d9; border-radius: 6px; outline: 0; background: white; }
.admin-panel input:focus, .admin-panel select:focus { border-color: #777d86; }
.field-note { margin: 7px 0 0; color: #8a9098; font-size: 12px; }
.checkbox-row { display: flex; align-items: center; gap: 8px; margin-top: 18px; color: #555b64; font-size: 13px; }
.admin-actions { display: flex; justify-content: flex-end; gap: 9px; margin-top: 28px; }
.form-message { min-height: 20px; margin: 14px 0 0; color: #2c8055; font-size: 13px; text-align: right; }
.form-message.error { color: #b43f3f; }
.admin-help { padding: 4px 0; color: #60666f; font-size: 13px; line-height: 1.65; }
.admin-help h2 { margin: 0 0 8px; color: #25282d; font-size: 15px; letter-spacing: 0; }
.admin-help h2:not(:first-child) { margin-top: 28px; }
.admin-help a { color: #1768b2; }
.admin-help code { display: block; overflow-wrap: anywhere; color: #393e45; }

@media (max-width: 720px) {
  .shell { display: block; }
  .sidebar { position: fixed; z-index: 10; width: min(280px, 82vw); transform: translateX(-105%); transition: transform 180ms ease; box-shadow: 10px 0 30px rgb(0 0 0 / 14%); }
  .sidebar.open { transform: translateX(0); }
  .main { height: 100dvh; }
  .menu-button { display: grid; }
  .topbar { padding: 0 12px; }
  .topbar select { max-width: 135px; }
  .topbar #reasoning-effort { max-width: 92px; }
  .messages { width: calc(100% - 24px); }
  .composer-wrap { padding: 8px 10px 9px; }
  .composer { gap: 5px; padding-left: 8px; }
  .search-toggle span:last-child { display: none; }
  .admin-header { padding: 0 16px; }
  .admin-main { display: block; width: calc(100% - 24px); margin: 18px auto; }
  .admin-panel { padding: 20px 16px; }
  .admin-title { align-items: flex-start; }
  .proxy-grid { grid-template-columns: minmax(0, 1fr) 100px; }
  .admin-help { padding: 28px 4px; }
}
