:root {
  color-scheme: light;
  --bg: #eef2f5;
  --surface: #ffffff;
  --surface-2: #f7f9fb;
  --text: #17202a;
  --muted: #657180;
  --line: #d9e1e8;
  --blue: #1f5f99;
  --teal: #16827a;
  --amber: #996b12;
  --red: #b64242;
  --shadow: 0 12px 32px rgba(19, 38, 58, 0.12);
}

* {
  box-sizing: border-box;
}

html {
  width: 100%;
  overflow-x: hidden;
}

body {
  margin: 0;
  width: 100%;
  min-height: 100vh;
  overflow-x: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", "Microsoft YaHei", system-ui, sans-serif;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

button,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.login-overlay {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: max(20px, env(safe-area-inset-top)) 20px max(20px, env(safe-area-inset-bottom));
  overflow: hidden;
  isolation: isolate;
  background: #050914;
  backdrop-filter: blur(18px);
}

.login-overlay::before {
  content: "";
  position: absolute;
  z-index: -2;
  left: 50%;
  top: 50%;
  translate: -50% -50%;
  width: max(150vw, 150vh);
  aspect-ratio: 1;
  background: url("./solar-system.jpg") center / cover no-repeat;
  opacity: 0.82;
  animation: solar-system-spin 420s linear infinite;
  transform-origin: center;
  will-change: transform;
}

.login-overlay::after {
  content: "";
  position: absolute;
  z-index: -1;
  inset: 0;
  background: rgba(3, 10, 20, 0.42);
  pointer-events: none;
}

@keyframes solar-system-spin {
  from {
    transform: rotate(0deg);
  }

  to {
    transform: rotate(360deg);
  }
}

.login-overlay[hidden] {
  display: none;
}

.login-card {
  position: relative;
  z-index: 1;
  display: grid;
  gap: 18px;
  width: min(460px, 100%);
  border: 1px solid rgba(255, 255, 255, 0.28);
  background: rgba(255, 255, 255, 0.16);
  box-shadow: 0 24px 60px rgba(7, 19, 31, 0.32);
  padding: 22px;
  backdrop-filter: blur(22px);
}

@media (prefers-reduced-motion: reduce) {
  .login-overlay::before {
    animation: none;
  }
}

.login-hero {
  display: flex;
  min-height: 210px;
  flex-direction: column;
  justify-content: space-between;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(18, 31, 43, 0.42);
  color: #f7fafc;
  padding: 22px 22px 24px;
}

.login-logo {
  width: 112px;
  height: 112px;
  overflow: hidden;
  flex: 0 0 112px;
  border: 1px solid rgba(255, 255, 255, 0.34);
  border-radius: 50%;
  background: #8f1020;
  box-shadow: 0 14px 30px rgba(4, 12, 20, 0.28);
}

.login-logo img,
.brand-mark img {
  display: block;
  width: 120%;
  height: 120%;
  max-width: none;
  transform: translate(-8.33%, -8.33%);
  object-fit: cover;
}

.login-hero h2 {
  margin: 26px 0 8px;
  font-size: clamp(24px, 6vw, 34px);
  line-height: 1.16;
  letter-spacing: 0;
}

.login-hero p {
  max-width: 360px;
  margin: 0;
  color: rgba(235, 242, 248, 0.78);
  line-height: 1.7;
}

.login-form {
  display: grid;
  align-content: start;
  gap: 14px;
  border: 1px solid rgba(255, 255, 255, 0.24);
  background: rgba(255, 255, 255, 0.72);
  padding: 18px;
  backdrop-filter: blur(18px);
}

.login-form label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
}

.login-form input {
  width: 100%;
  min-height: 46px;
  border: 1px solid rgba(31, 45, 59, 0.14);
  background: rgba(255, 255, 255, 0.76);
  color: var(--text);
  font: inherit;
  font-size: 16px;
  padding: 0 13px;
  outline: none;
}

.login-form input:focus {
  border-color: var(--blue);
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 0 0 3px rgba(31, 95, 153, 0.12);
}

.login-error {
  border: 1px solid #f0c7c7;
  background: #fff5f5;
  color: var(--red);
  padding: 10px 12px;
  font-size: 13px;
}

.login-submit {
  min-height: 46px;
  border: 1px solid var(--blue);
  background: var(--blue);
  color: #ffffff;
  font-weight: 700;
}

.login-submit:hover {
  background: #174d7d;
}

.shell {
  display: grid;
  grid-template-columns: 280px 1fr;
  min-height: 100vh;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 20px;
  background: #1f2d3b;
  color: #f4f7fa;
}

.brand {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
}

.brand-logo-container {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  color: rgba(255, 255, 255, 0.96);
  font-family: "Segoe UI", "Microsoft YaHei", system-ui, sans-serif;
  font-size: 21px;
  font-weight: 800;
  line-height: 1;
  letter-spacing: 0;
}

.brand-mark {
  width: 38px;
  height: 38px;
  overflow: hidden;
  flex: 0 0 38px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 50%;
  background: #8f1020;
}

.brand-wordmark {
  font-weight: 700;
  color: rgba(255, 255, 255, 0.94);
}

.brand-subtitle {
  margin-top: 1px;
  color: #b8c6d5;
  font-size: 11px;
}

.nav-tabs {
  display: grid;
  gap: 8px;
}

.nav-tab {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 42px;
  padding: 0 12px;
  border: 1px solid transparent;
  background: transparent;
  color: #d7e1ec;
  text-align: left;
}

.nav-tab.active {
  background: #f4f7fa;
  color: #1f2d3b;
}

.icon {
  width: 22px;
  text-align: center;
}

.main {
  display: flex;
  min-width: 0;
  flex-direction: column;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 24px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}

.topbar p {
  margin: 6px 0 0;
  display: inline-flex;
  align-items: center;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #edf4fb;
  color: var(--blue);
  font-size: 13px;
  font-weight: 700;
}

.topbar h1 {
  margin: 0;
  font-size: 20px;
}

.topbar p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.topbar-actions {
  display: flex;
  gap: 8px;
}

.icon-button {
  width: 38px;
  height: 38px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--blue);
  font-size: 20px;
}

.icon-button.danger {
  color: var(--red);
}

.view {
  display: none;
  min-height: 0;
}

.view.active {
  display: block;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 16px;
  height: calc(100vh - 196px);
  padding: 16px;
}

.conversation,
.context,
.archive-layout,
.directory-list {
  min-height: 0;
}

.conversation {
  overflow: hidden;
  border: 1px solid var(--line);
  background: var(--surface);
}

.messages {
  display: flex;
  height: 100%;
  flex-direction: column;
  gap: 14px;
  overflow: auto;
  padding: 18px;
}

.message {
  max-width: 780px;
  padding: 14px;
  border: 1px solid var(--line);
  background: var(--surface-2);
}

.message.own {
  margin-left: auto;
  border-color: #b8d5ef;
  background: #edf6ff;
}

.message.ai {
  border-color: #c6dfd8;
  background: #effaf7;
}

.message-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 12px;
}

.message-author {
  color: var(--text);
  font-weight: 700;
}

.message-body {
  white-space: pre-wrap;
  line-height: 1.55;
}

.workflow-status {
  display: inline-flex;
  width: fit-content;
  margin: 0 0 8px;
  padding: 4px 8px;
  border: 1px solid #9bc9bf;
  color: #176c60;
  background: #edf8f5;
  font-size: 12px;
  font-weight: 700;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.chip {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 0 8px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--muted);
  font-size: 12px;
}

.chip.ai-chip {
  border-color: #b7ded8;
  color: var(--teal);
}

.chip.file-chip {
  border-color: #e3c991;
  color: var(--amber);
}

.chip.mode-chip {
  font-weight: 700;
}

.chip.mode-fast {
  border-color: #9ed8c2;
  background: #edf9f3;
  color: #14735c;
}

.chip.mode-mid {
  border-color: #adc8ec;
  background: #eef6ff;
  color: #1f5f99;
}

.chip.mode-deep {
  border-color: #c7b9e8;
  background: #f5f0ff;
  color: #6343a6;
}

.chip.mode-dry-run {
  border-color: #d0d7df;
  background: #f5f7f9;
  color: var(--muted);
}

.context {
  display: grid;
  align-content: start;
  gap: 16px;
}

.panel {
  border: 1px solid var(--line);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.panel.compact {
  border-color: rgba(255, 255, 255, 0.16);
  background: rgba(255, 255, 255, 0.08);
  box-shadow: none;
}

.panel.wide {
  min-width: 0;
}

.panel-heading {
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  font-weight: 700;
}

.compact .panel-heading {
  border-color: rgba(255, 255, 255, 0.14);
}

.route-list {
  margin: 0;
  padding: 12px 14px 14px 34px;
  color: #d7e1ec;
  line-height: 1.7;
}

.session-panel {
  position: relative;
  padding: 10px;
}

.session-avatar-btn {
  display: none;
}

.session-dropdown {
  display: block;
  position: static;
  box-shadow: none;
  border: 0;
  padding: 0;
  background: transparent;
  color: inherit;
}

.dropdown-header {
  display: flex;
  flex-direction: column;
  padding: 0;
  border: 0;
  margin-bottom: 0;
}

.session-name {
  font-size: 14px;
  font-weight: 800;
  color: #ffffff;
}

.session-role {
  margin-top: 3px;
  color: #b8c6d5;
  font-size: 11px;
}

.dropdown-actions {
  display: flex;
  justify-content: space-between;
  margin-top: 10px;
}

.session-switch {
  min-height: 30px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  background: rgba(255, 255, 255, 0.1);
  color: #f4f7fa;
  font-size: 12px;
  padding: 0 10px;
  cursor: pointer;
}

.dev-actions-mobile {
  display: none;
}

.thread-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin-top: 10px;
}

.thread-tab {
  min-height: 32px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: transparent;
  color: #d7e1ec;
  font-size: 12px;
}

.thread-tab.active {
  background: #f4f7fa;
  color: #1f2d3b;
  font-weight: 700;
}

.recipient-grid {
  display: grid;
  gap: 8px;
  padding: 12px;
}

.recipient-picker-summary,
.recipient-picker-footer {
  display: none;
}

.recipient-options {
  display: grid;
  gap: 8px;
}

.fixed-recipient {
  display: grid;
  grid-template-columns: 28px 1fr;
  align-items: center;
  gap: 10px;
  min-height: 48px;
  border: 1px solid #b7ded8;
  background: #effaf7;
  padding: 8px;
}

.fixed-recipient strong {
  font-size: 13px;
}

.fixed-recipient span span {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 11px;
}

.recipient {
  display: grid;
  grid-template-columns: 28px 1fr auto;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  padding: 6px 8px;
  border: 1px solid var(--line);
  background: var(--surface-2);
}

.recipient.active {
  border-color: var(--blue);
  background: #edf6ff;
}

.avatar {
  display: grid;
  width: 28px;
  height: 28px;
  place-items: center;
  background: #dfe8f0;
  color: #1f3a5f;
  font-size: 12px;
  font-weight: 800;
}

.recipient-name {
  font-size: 14px;
  font-weight: 650;
}

.recipient-role {
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
}

.recipient-kind {
  color: var(--teal);
  font-size: 12px;
}

.segmented {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  padding: 12px;
}

.segmented button {
  min-height: 36px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--muted);
}

.segmented button.active {
  border-color: var(--blue);
  background: #edf6ff;
  color: var(--blue);
  font-weight: 700;
}

.json-preview {
  min-height: 180px;
  margin: 0;
  overflow: auto;
  padding: 12px;
  background: #101820;
  color: #d6f1e8;
  font-size: 12px;
  line-height: 1.5;
}

.composer {
  border-top: 1px solid var(--line);
  background: var(--surface);
  padding: 12px 16px 16px;
}

.composer textarea {
  display: block;
  width: 100%;
  resize: vertical;
  min-height: 76px;
  max-height: 160px;
  padding: 12px;
  border: 1px solid var(--line);
  outline: none;
}

.composer textarea:focus {
  border-color: var(--blue);
}

.attachment-row {
  display: grid;
  grid-template-columns: 44px 1fr 96px;
  align-items: center;
  gap: 10px;
  margin-top: 10px;
}

.attach-button {
  display: grid;
  width: 44px;
  height: 40px;
  place-items: center;
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--blue);
  font-size: 22px;
  cursor: pointer;
}

.attach-button input {
  display: none;
}

.attachment-list {
  display: flex;
  min-width: 0;
  gap: 6px;
  overflow: auto;
}

.attachment-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 220px;
  min-height: 34px;
  padding: 0 8px;
  border: 1px solid #e3c991;
  background: #fff8e6;
  color: #6d4b0b;
  white-space: nowrap;
}

.attachment-pill span {
  overflow: hidden;
  text-overflow: ellipsis;
}

.attachment-pill button {
  border: 0;
  background: transparent;
  color: var(--red);
}

.send-button {
  height: 40px;
  border: 0;
  background: var(--blue);
  color: white;
  font-weight: 700;
}

.archive-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 16px;
  padding: 16px;
}

.archive-list,
.directory-list,
.task-board {
  display: grid;
  gap: 12px;
}

.archive-list {
  padding: 14px;
}

.archive-item {
  padding: 12px;
  border: 1px solid var(--line);
  background: var(--surface-2);
}

.archive-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.archive-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  margin-top: 8px;
  color: var(--muted);
  font-size: 12px;
}

.archive-files {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.archive-files.empty {
  color: var(--muted);
  font-size: 12px;
}

.task-board {
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  align-items: start;
  padding: 16px;
}

.review-board {
  display: grid;
  gap: 12px;
  padding: 16px 16px 0;
}

.review-heading,
.review-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.review-heading {
  border: 1px solid #cbd8e6;
  background: var(--surface);
  padding: 12px;
}

.review-card {
  border: 1px solid #b7d6e6;
  background: #f4fbfd;
  padding: 12px;
}

.review-card p {
  margin: 8px 0;
  line-height: 1.5;
}

.review-body {
  margin: 8px 0;
  padding: 10px;
  border: 1px solid #d5e6ec;
  background: var(--surface);
  line-height: 1.55;
  white-space: pre-wrap;
}

.review-actions {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin-top: 10px;
}

.review-action {
  min-height: 34px;
  border: 1px solid var(--blue);
  background: var(--surface);
  color: var(--blue);
  font-weight: 700;
}

.review-empty {
  border: 1px solid var(--line);
  background: var(--surface);
  padding: 14px;
  color: var(--muted);
}

.task-notice {
  grid-column: 1 / -1;
  border: 1px solid #b7d6e6;
  background: #eef8fb;
  color: #24576b;
  padding: 10px 12px;
  line-height: 1.5;
}

.task-column {
  border: 1px solid var(--line);
  background: var(--surface);
}

.task-column-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px;
  border-bottom: 1px solid var(--line);
}

.task-list {
  display: grid;
  gap: 10px;
  padding: 12px;
}

.task-card {
  border: 1px solid var(--line);
  background: var(--surface-2);
  padding: 10px;
}

.task-card-head {
  display: flex;
  gap: 6px;
  justify-content: space-between;
}

.task-card p {
  margin: 8px 0;
  line-height: 1.5;
}

.task-meta {
  display: grid;
  gap: 4px;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 12px;
}

.task-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 10px;
}

.task-action {
  min-height: 32px;
  padding: 0 10px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  font-weight: 700;
  white-space: nowrap;
}

.task-action.primary {
  border-color: var(--blue);
  background: var(--blue);
  color: white;
}

.task-empty {
  grid-column: 1 / -1;
  border: 1px solid var(--line);
  background: var(--surface);
  padding: 14px;
  color: var(--muted);
}

.task-history {
  grid-column: 1 / -1;
  border: 1px solid var(--line);
  background: var(--surface);
}

.task-history summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 48px;
  padding: 0 14px;
  cursor: pointer;
  color: var(--ink);
  font-weight: 800;
  list-style: none;
}

.task-history summary::-webkit-details-marker {
  display: none;
}

.task-history summary::after {
  content: "展开";
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--muted);
  padding: 5px 10px;
  font-size: 12px;
  font-weight: 700;
}

.task-history[open] summary {
  border-bottom: 1px solid var(--line);
}

.task-history[open] summary::after {
  content: "收起";
}

.task-history summary strong {
  margin-left: auto;
  color: var(--muted);
  font-size: 13px;
}

.task-history-list {
  display: grid;
  gap: 8px;
  max-height: min(440px, 52vh);
  overflow: auto;
  padding: 10px;
  background: var(--surface-2);
}

.task-card-history {
  background: var(--surface);
  padding: 9px;
}

.task-card-history p {
  margin: 6px 0;
  font-size: 14px;
}

.archive-path {
  margin-top: 8px;
  color: var(--teal);
  font-family: Consolas, monospace;
  font-size: 12px;
  overflow-wrap: anywhere;
}

.plain-list {
  margin: 0;
  padding: 12px 14px 14px 30px;
  line-height: 1.75;
}

.directory-list {
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  padding: 16px;
}

.person-card {
  border: 1px solid var(--line);
  background: var(--surface);
  padding: 14px;
}

.person-card h3 {
  margin: 0;
  font-size: 16px;
}

.person-card p {
  margin: 6px 0 0;
  color: var(--muted);
  line-height: 1.5;
}

@media (max-width: 980px) {
  .shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    padding: 12px;
  }

  .nav-tabs {
    grid-template-columns: repeat(4, 1fr);
  }

  .workspace,
  .archive-layout {
    grid-template-columns: 1fr;
    height: auto;
  }

  .conversation {
    min-height: 48vh;
  }

  .context {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 620px) {
  :root {
    --shadow: 0 8px 22px rgba(19, 38, 58, 0.1);
  }

  html,
  body {
    min-height: 100%;
  }

  body {
    padding-bottom: calc(70px + env(safe-area-inset-bottom, 0px));
    background: #f2f5f7;
    overflow-x: hidden;
    overscroll-behavior-x: none;
    touch-action: pan-y;
  }

  .shell,
  .main,
  .view,
  .workspace,
  .composer,
  .nav-tabs {
    max-width: 100vw;
    overflow-x: hidden;
  }

  .shell {
    display: block;
  }

  .sidebar {
    position: sticky;
    top: 0;
    z-index: 14;
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    background: linear-gradient(180deg, #1f2d3b 0%, #243646 100%);
    box-shadow: 0 8px 22px rgba(19, 38, 58, 0.16);
  }

  .brand {
    padding: 0;
    gap: 0;
    justify-self: start;
  }

  .brand-logo-container {
    font-size: 17px;
  }

  .brand-subtitle {
    display: none;
  }

  .nav-tabs {
    position: fixed;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 20;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0;
    border-top: 1px solid var(--line);
    background: var(--surface);
    box-shadow: 0 -8px 24px rgba(19, 38, 58, 0.12);
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }

  .nav-tab {
    display: grid;
    justify-items: center;
    gap: 2px;
    min-height: 62px;
    padding: 7px 2px 8px;
    color: var(--muted);
    font-size: 12px;
    text-align: center;
  }

  .nav-tab.active {
    background: var(--surface);
    color: var(--blue);
  }

  .icon {
    width: auto;
    font-size: 16px;
  }

  .sidebar .panel.compact:not(.session-panel) {
    display: none;
  }

  .session-panel {
    display: inline-block;
    position: relative;
    padding: 0;
    border: 0;
    background: transparent;
    box-shadow: none;
    justify-self: end;
  }

  .session-avatar-btn {
    display: inline-flex;
    position: relative;
    width: 32px;
    height: 32px;
    border: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.12);
    color: #ffffff;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    padding: 0;
    outline: none;
    transition: background 0.2s ease;
  }

  .session-avatar-btn:active {
    background: rgba(255, 255, 255, 0.24);
  }
  
  .session-avatar {
    font-size: 13px;
    font-weight: 700;
    color: #ffffff;
  }
  
  .status-indicator {
    position: absolute;
    bottom: -1px;
    right: -1px;
    width: 9px;
    height: 9px;
    border-radius: 50%;
    border: 1.5px solid #243646;
    z-index: 2;
  }
  
  .status-indicator.online {
    background: #10b981;
    box-shadow: 0 0 4px #10b981;
  }
  
  .status-indicator.offline {
    background: #f59e0b;
  }

  .session-dropdown {
    display: none;
    position: absolute;
    top: calc(100% + 10px);
    right: -4px;
    z-index: 50;
    min-width: 220px;
    background: #ffffff;
    border: 1px solid var(--line);
    border-radius: 12px;
    box-shadow: 0 12px 36px rgba(7, 19, 31, 0.2);
    padding: 12px;
    color: var(--text);
  }

  .session-panel.open .session-dropdown {
    display: block;
    animation: fadeInDropdown 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  }

  @keyframes fadeInDropdown {
    from {
      opacity: 0;
      transform: translateY(-8px);
    }
    to {
      opacity: 1;
      transform: translateY(0);
    }
  }

  .dropdown-header {
    padding-bottom: 8px;
    border-bottom: 1px solid var(--line);
    margin-bottom: 8px;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
  }

  .session-name {
    font-size: 15px;
    font-weight: 700;
    color: var(--text);
    max-width: 100%;
    overflow: visible;
    text-overflow: clip;
    white-space: normal;
  }

  .session-role {
    font-size: 12px;
    color: var(--muted);
    margin-top: 2px;
    max-width: 100%;
    overflow: visible;
    text-overflow: clip;
    white-space: normal;
  }

  .dropdown-actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 0;
  }

  .session-switch {
    width: 100%;
    min-height: 38px;
    background: var(--blue);
    color: #ffffff;
    border: 0;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
  }

  .dev-actions-mobile {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
    border-top: 1px solid var(--line);
    padding-top: 8px;
    margin-top: 4px;
  }

  .dev-btn {
    min-height: 32px;
    border: 1px solid var(--line);
    background: var(--surface-2);
    color: var(--muted);
    font-size: 11px;
    font-weight: 600;
    border-radius: 4px;
    cursor: pointer;
  }

  .dev-btn.danger {
    color: var(--red);
    border-color: #f5c2c2;
    background: #fff5f5;
  }

  .thread-tabs {
    display: flex;
    margin-top: 0;
    gap: 0;
    height: 32px;
    background: rgba(0, 0, 0, 0.24);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 99px;
    padding: 2px;
    overflow: hidden;
    justify-self: center;
  }

  .thread-tab {
    min-height: 28px;
    height: 28px;
    border: 0;
    border-radius: 99px;
    background: transparent;
    color: rgba(255, 255, 255, 0.7);
    font-size: 12px;
    font-weight: 600;
    padding: 0 14px;
    white-space: nowrap;
    transition: all 0.2s ease;
  }

  .thread-tab + .thread-tab {
    border-left: none;
  }

  .thread-tab.active {
    background: #ffffff;
    color: #1f2d3b;
    font-weight: 700;
    box-shadow: 0 2px 6px rgba(0,0,0,0.15);
  }

  .topbar {
    display: none !important;
  }

  .workspace,
  .archive-layout,
  .directory-list,
  .task-board,
  .review-board {
    padding: 8px;
  }

  .workspace {
    display: flex;
    flex-direction: column;
    gap: 8px;
    height: calc(100dvh - 320px);
    min-height: 300px;
    padding-bottom: 0;
    overflow: hidden;
  }

  .context {
    order: -1;
    gap: 0;
    border: 1px solid var(--line);
    background: var(--surface);
    box-shadow: var(--shadow);
  }

  .context .panel:not(:first-child) {
    display: none;
  }

  .context .panel:first-child {
    border: 0;
    box-shadow: none;
  }

  .context .panel:first-child .panel-heading {
    padding: 7px 10px;
    font-size: 12px;
    border-bottom: 1px solid var(--line);
  }

  .recipient-grid {
    display: grid;
    grid-template-columns: 1fr;
    overflow-x: hidden;
    overflow-y: visible;
    gap: 8px;
    padding: 8px 10px;
    max-height: none;
  }

  .recipient-picker-summary {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 8px;
    min-height: 44px;
    border: 1px solid #b7ded8;
    background: #effaf7;
    padding: 8px;
  }

  .recipient-picker-summary strong {
    display: block;
    overflow: hidden;
    color: var(--teal);
    font-size: 13px;
    line-height: 1.25;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .recipient-summary-label {
    display: block;
    margin-bottom: 2px;
    color: var(--muted);
    font-size: 11px;
  }

  .recipient-picker-toggle,
  .recipient-picker-done {
    min-height: 34px;
    border: 1px solid var(--blue);
    background: var(--surface);
    color: var(--blue);
    font-size: 13px;
    font-weight: 700;
    white-space: nowrap;
  }

  .recipient-picker-toggle {
    padding: 0 10px;
  }

  .recipient-options {
    display: none;
  }

  .recipient-options.open {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    max-height: 176px;
    overflow-x: hidden;
    overflow-y: auto;
    padding-right: 2px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
  }

  .recipient-options::-webkit-scrollbar {
    width: 3px;
  }

  .recipient {
    grid-template-columns: 26px minmax(0, 1fr);
    width: 100%;
    min-width: 0;
    max-width: none;
    min-height: 54px;
    padding: 7px;
    gap: 7px;
  }

  .recipient-kind {
    display: none !important;
  }

  .recipient-name {
    display: block;
    overflow: hidden;
    font-size: 13px;
    line-height: 1.2;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .recipient-role {
    display: block;
    overflow: hidden;
    font-size: 11px;
    line-height: 1.25;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .fixed-recipient {
    width: 100%;
    min-width: 0;
  }

  .recipient-picker-footer.open {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    color: var(--muted);
    font-size: 12px;
  }

  .recipient-picker-done {
    min-width: 76px;
    background: var(--blue);
    color: white;
  }

  .conversation {
    flex: 1;
    min-height: 0;
    border: 1px solid var(--line);
    box-shadow: var(--shadow);
  }

  .messages {
    gap: 10px;
    padding: 10px;
  }

  .message {
    max-width: 94%;
    padding: 10px;
    font-size: 14px;
  }

  .message.own {
    max-width: 88%;
  }

  .message-head {
    margin-bottom: 6px;
  }

  .message-body {
    line-height: 1.55;
  }

  .chip {
    min-height: 24px;
    padding: 0 7px;
    font-size: 11px;
  }

  .composer {
    position: fixed;
    right: 0;
    bottom: calc(62px + env(safe-area-inset-bottom, 0px));
    left: 0;
    z-index: 15;
    border-top: 1px solid var(--line);
    box-shadow: 0 -8px 22px rgba(19, 38, 58, 0.12);
    padding: 8px 10px 9px;
  }

  .composer textarea {
    min-height: 46px;
    max-height: 96px;
    padding: 9px 10px;
    font-size: 16px;
    line-height: 1.45;
  }

  .attachment-row {
    grid-template-columns: 42px minmax(0, 1fr) 72px;
    gap: 8px;
    margin-top: 8px;
  }

  .attach-button {
    width: 42px;
    height: 38px;
    font-size: 24px;
  }

  .send-button {
    grid-column: auto;
    height: 38px;
    font-size: 16px;
  }

  .archive-layout {
    grid-template-columns: 1fr;
    padding-bottom: 86px;
  }

  .task-board,
  .directory-list {
    grid-template-columns: 1fr;
    padding-bottom: 86px;
  }

  .review-actions {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .review-action,
  .task-action,
  .segmented button {
    min-height: 42px;
  }

  .task-card-head,
  .archive-title-row,
  .review-card-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .login-overlay {
    padding: 14px;
    align-items: stretch;
    overflow-y: auto;
  }

  .login-overlay::before {
    width: max(100vw, 100vh);
    animation-duration: 240s;
  }

  .login-card {
    grid-template-columns: 1fr;
    gap: 14px;
    width: min(350px, calc(100vw - 28px));
    align-self: center;
    padding: 14px;
  }

  .login-hero {
    min-height: 0;
    padding: 16px;
  }

  .login-logo {
    width: 82px;
    height: 82px;
    flex-basis: 82px;
  }

  .login-hero h2 {
    margin: 16px 0 7px;
    font-size: 24px;
  }

  .login-hero p {
    font-size: 14px;
    line-height: 1.55;
  }

  .login-form {
    gap: 12px;
    padding: 15px;
  }
}
