:root {
  color-scheme: light;
  --bg: #f4f8ff;
  --surface: rgba(255, 255, 255, 0.96);
  --surface-strong: #ffffff;
  --surface-soft: #f6f9ff;
  --line: rgba(154, 180, 227, 0.34);
  --line-strong: rgba(111, 146, 215, 0.4);
  --text: #1c2a4d;
  --text-soft: #7384ab;
  --text-faint: #9aa7c7;
  --brand-blue: #2f7cff;
  --brand-blue-strong: #185ee3;
  --danger: #f06a88;
  --success: #36c277;
  --shadow: 0 26px 60px rgba(48, 92, 180, 0.12);
  --shadow-soft: 0 12px 28px rgba(44, 82, 160, 0.08);
  --radius-xl: 26px;
  --radius-lg: 20px;
  --radius-md: 16px;
  --radius-sm: 12px;
  --sidebar-width: 250px;
  --memory-width: 228px;
  --chat-lane-width: 1120px;
  --app-max-width: 1710px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  min-height: 100%;
  background:
    radial-gradient(circle at top left, rgba(47, 124, 255, 0.11), transparent 24%),
    linear-gradient(180deg, #fdfefe 0%, #f4f8ff 100%);
  color: var(--text);
  font-family: Inter, "Plus Jakarta Sans", "Anuphan", system-ui, sans-serif;
}

body {
  min-height: 100dvh;
  overflow: hidden;
}

button,
textarea,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

img {
  display: block;
  max-width: 100%;
}

.app-shell {
  --agent-accent: #2f7cff;
  --agent-accent-soft: rgba(47, 124, 255, 0.12);
  --agent-accent-border: rgba(47, 124, 255, 0.22);
  --agent-accent-glow: rgba(47, 124, 255, 0.18);
  width: min(100%, var(--app-max-width));
  height: 100dvh;
  min-height: 0;
  margin: 0 auto;
  display: grid;
  grid-template-columns: var(--sidebar-width) minmax(0, 1fr) var(--memory-width);
  gap: 12px;
  padding: 8px;
  overflow: hidden;
}

.app-shell[data-agent-theme="violet"] {
  --agent-accent: #8c5bff;
  --agent-accent-soft: rgba(140, 91, 255, 0.12);
  --agent-accent-border: rgba(140, 91, 255, 0.24);
  --agent-accent-glow: rgba(140, 91, 255, 0.2);
}

.sidebar,
.main-panel,
.memory-panel {
  background: var(--surface);
  border: 1px solid rgba(219, 231, 251, 0.9);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
}

.sidebar {
  padding: 18px 14px 16px;
  display: flex;
  flex-direction: column;
  height: calc(100dvh - 16px);
  min-height: 0;
  overflow: hidden;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 2px 6px 14px;
}

.brand-mark {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  padding: 8px;
  background: linear-gradient(180deg, #eef4ff 0%, #e4eeff 100%);
  border: 1px solid rgba(111, 146, 215, 0.18);
}

.brand-wordmark {
  width: 132px;
  height: auto;
}

.brand-copy p {
  margin: 4px 0 0;
  font-size: 12px;
  line-height: 1.5;
  color: var(--text-soft);
}

.new-chat-button,
.send-button,
.agent-start-button {
  border: 0;
  border-radius: 14px;
  color: #ffffff;
  font-size: 14px;
  font-weight: 700;
}

.new-chat-button {
  min-height: 48px;
  width: 100%;
  margin: 4px 0 18px;
  background: linear-gradient(180deg, #3580ff 0%, var(--brand-blue) 100%);
  box-shadow: 0 16px 32px rgba(47, 124, 255, 0.25);
}

.sidebar-section {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.sidebar-section-compact {
  flex: 0 0 auto;
  margin-bottom: 18px;
}

.sidebar-section:not(.sidebar-section-compact) {
  flex: 1 1 auto;
}

.section-label {
  padding: 0 8px 10px;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-soft);
}

.agent-list,
.conversation-list,
.memory-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.conversation-list,
.memory-list {
  overflow: auto;
  padding-right: 2px;
}

.agent-chip,
.conversation-item,
.memory-item {
  width: 100%;
  border-radius: 18px;
  background: linear-gradient(180deg, rgba(244, 248, 255, 0.92), rgba(250, 252, 255, 0.98));
  border: 1px solid rgba(211, 223, 245, 0.9);
  box-shadow: var(--shadow-soft);
}

.agent-chip {
  display: grid;
  grid-template-columns: 54px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  text-align: left;
  padding: 12px 12px;
  transition: border-color 180ms ease, transform 180ms ease, box-shadow 180ms ease;
}

.agent-chip:hover,
.conversation-item:hover {
  transform: translateY(-1px);
  border-color: var(--agent-accent-border);
}

.agent-chip.active,
.conversation-item.active {
  border-color: var(--agent-accent-border);
  box-shadow: 0 16px 34px var(--agent-accent-glow);
}

.agent-avatar,
.conversation-avatar,
.message-avatar {
  overflow: hidden;
  border-radius: 16px;
  background: #eef4ff;
  border: 1px solid rgba(180, 196, 229, 0.7);
  flex: 0 0 auto;
}

.agent-avatar,
.conversation-avatar {
  width: 54px;
  height: 54px;
}

.agent-avatar img,
.conversation-avatar img,
.message-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.agent-info,
.conversation-info {
  min-width: 0;
  display: grid;
  gap: 4px;
}

.agent-name,
.conversation-item-title,
.memory-item-title {
  font-size: 14px;
  font-weight: 800;
  color: var(--text);
}

.agent-role,
.conversation-item-agent,
.conversation-item-preview,
.memory-item-detail,
.memory-header p,
.composer-hint,
.composer-meta,
.status-line,
.conversation-subtitle {
  color: var(--text-soft);
}

.agent-role {
  font-size: 13px;
}

.agent-status {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  font-weight: 700;
  color: #425579;
}

.agent-status-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: var(--success);
  box-shadow: 0 0 0 3px rgba(54, 194, 119, 0.16);
}

.conversation-item {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr);
  gap: 12px;
  text-align: left;
  padding: 12px 12px;
  transition: border-color 180ms ease, transform 180ms ease, box-shadow 180ms ease;
}

.conversation-avatar {
  width: 48px;
  height: 48px;
  border-radius: 14px;
}

.conversation-item-agent {
  font-size: 12px;
  font-weight: 700;
}

.conversation-item-preview {
  font-size: 12px;
  line-height: 1.5;
  display: -webkit-box;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.conversation-item-time,
.memory-item-meta {
  font-size: 11px;
  color: var(--text-faint);
}

.conversation-empty,
.memory-empty {
  padding: 16px;
  border-radius: 18px;
  border: 1px dashed rgba(180, 196, 229, 0.9);
  background: rgba(248, 251, 255, 0.9);
  font-size: 13px;
  line-height: 1.6;
  color: var(--text-soft);
}

.main-panel {
  min-width: 0;
  height: calc(100dvh - 16px);
  min-height: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  overflow: hidden;
}

.topbar {
  padding: 20px 24px 18px;
  border-bottom: 1px solid rgba(219, 231, 251, 0.95);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
}

.conversation-title {
  font-size: 22px;
  font-weight: 800;
  line-height: 1.1;
}

.conversation-subtitle {
  margin-top: 5px;
  font-size: 13px;
  line-height: 1.5;
}

.status-line {
  margin-top: 5px;
  font-size: 12px;
  font-weight: 600;
}

.topbar-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}

.toggle-chip,
.quiet-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  border-radius: 12px;
  border: 1px solid rgba(206, 220, 246, 0.92);
  background: rgba(255, 255, 255, 0.94);
  padding: 0 13px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  text-decoration: none;
  white-space: nowrap;
}

.home-button {
  color: var(--brand-blue-strong);
}

.toggle-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.toggle-chip input {
  margin: 0;
}

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

.message-list {
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 24px 22px 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
}

.showcase-view {
  width: min(100%, 1240px);
  display: grid;
  gap: 22px;
}

.draft-chat-view {
  width: min(100%, var(--chat-lane-width));
  display: grid;
  grid-template-columns: minmax(280px, 360px) minmax(0, 1fr);
  gap: 24px;
  border-radius: 24px;
  overflow: hidden;
  border: 1px solid var(--agent-accent-border);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(248, 251, 255, 0.99));
  box-shadow: 0 22px 46px rgba(39, 79, 157, 0.1);
}

.draft-chat-visual {
  min-height: 380px;
  background: linear-gradient(90deg, rgba(255, 255, 255, 0) 0%, rgba(255, 255, 255, 0.1) 58%, rgba(255, 255, 255, 0.56) 100%);
}

.draft-chat-visual img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center top;
}

.draft-chat-copy {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 16px;
  padding: 28px;
}

.draft-chat-badge {
  display: inline-flex;
  width: fit-content;
  align-items: center;
  padding: 8px 12px;
  border-radius: 999px;
  background: var(--agent-accent-soft);
  color: var(--agent-accent);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.draft-chat-title {
  font-size: 28px;
  font-weight: 800;
  line-height: 1.12;
  color: var(--text);
}

.draft-chat-body {
  font-size: 15px;
  line-height: 1.75;
  color: var(--text-soft);
}

.draft-chat-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.draft-chat-pill {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 0 12px;
  border-radius: 999px;
  background: rgba(245, 248, 255, 0.96);
  border: 1px solid rgba(206, 220, 246, 0.92);
  color: #61739b;
  font-size: 12px;
  font-weight: 700;
}

.draft-chat-note {
  font-size: 13px;
  font-weight: 700;
  color: var(--agent-accent);
}

.agent-showcase-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(300px, 1fr));
  gap: 24px;
}

.agent-showcase-card {
  display: grid;
  grid-template-columns: minmax(240px, 0.92fr) minmax(0, 1fr);
  min-height: 446px;
  border-radius: 24px;
  overflow: hidden;
  border: 1px solid rgba(215, 225, 246, 0.95);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(249, 251, 255, 0.98));
  box-shadow: 0 22px 46px rgba(39, 79, 157, 0.1);
  transition: transform 180ms ease, border-color 180ms ease, box-shadow 180ms ease;
}

.agent-showcase-card:hover {
  transform: translateY(-2px);
}

.agent-showcase-card[data-theme="cherry"] {
  border-color: rgba(131, 177, 255, 0.5);
}

.agent-showcase-card[data-theme="violet"] {
  border-color: rgba(195, 153, 255, 0.42);
}

.agent-showcase-card.selected {
  box-shadow: 0 24px 56px var(--agent-accent-glow);
  border-color: var(--agent-accent-border);
}

.agent-showcase-visual {
  position: relative;
  min-height: 100%;
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0) 0%, rgba(255, 255, 255, 0.08) 58%, rgba(255, 255, 255, 0.6) 100%);
}

.agent-showcase-visual::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, rgba(255, 255, 255, 0) 62%, rgba(255, 255, 255, 0.42) 100%);
  pointer-events: none;
}

.agent-showcase-visual img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center top;
}

.agent-showcase-copy {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 16px;
  padding: 28px 28px 28px 22px;
}

.agent-kicker {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  padding: 8px 12px;
  border-radius: 999px;
  background: var(--agent-accent-soft);
  color: var(--agent-accent);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.agent-showcase-card[data-theme="violet"] .agent-kicker {
  background: rgba(140, 91, 255, 0.1);
  color: #8c5bff;
}

.agent-showcase-name {
  font-size: 24px;
  font-weight: 800;
  color: var(--agent-accent);
  line-height: 1.08;
}

.agent-showcase-card[data-theme="violet"] .agent-showcase-name {
  color: #8c5bff;
}

.agent-showcase-role {
  font-size: 14px;
  font-weight: 600;
  color: #90a0c2;
}

.agent-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.agent-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 700;
  color: #6f7ea3;
}

.agent-showcase-divider {
  height: 1px;
  background: rgba(218, 228, 247, 0.95);
}

.agent-summary-title {
  font-size: 16px;
  font-weight: 800;
  color: var(--text);
}

.agent-summary-body {
  font-size: 14px;
  line-height: 1.7;
  color: var(--text-soft);
}

.agent-card-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.agent-start-button {
  min-height: 40px;
  padding: 0 16px;
  background: linear-gradient(180deg, color-mix(in srgb, var(--agent-accent) 88%, white 12%), var(--agent-accent) 100%);
  box-shadow: 0 14px 28px var(--agent-accent-glow);
}

.agent-start-button[data-theme="violet"] {
  background: linear-gradient(180deg, #9c6bff 0%, #8c5bff 100%);
}

.agent-card-note {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-faint);
}

.message-row {
  width: min(100%, var(--chat-lane-width));
  display: flex;
  gap: 12px;
  align-items: flex-start;
}

.message-row.user {
  justify-content: flex-end;
}

.message-avatar {
  width: 38px;
  height: 38px;
  border-radius: 14px;
}

.message-user-avatar {
  display: grid;
  place-items: center;
  font-size: 12px;
  font-weight: 800;
  color: #ffffff;
  background: linear-gradient(180deg, var(--brand-blue) 0%, var(--brand-blue-strong) 100%);
  border: 0;
  box-shadow: 0 10px 20px rgba(47, 124, 255, 0.22);
}

.message-bubble {
  min-width: 0;
  max-width: min(1000px, calc(100% - 50px));
  border-radius: 22px;
  padding: 14px 16px;
  border: 1px solid rgba(218, 228, 247, 0.95);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(249, 251, 255, 0.98));
  box-shadow: 0 16px 32px rgba(43, 82, 161, 0.08);
}

.message-row.assistant .message-bubble {
  border-color: var(--agent-accent-border);
}

.message-row.user .message-bubble {
  max-width: min(620px, calc(100% - 50px));
  background: linear-gradient(180deg, #3580ff 0%, var(--brand-blue) 100%);
  color: #ffffff;
  border-color: transparent;
  box-shadow: 0 18px 36px rgba(47, 124, 255, 0.2);
}

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

.message-row.user .message-meta {
  color: rgba(255, 255, 255, 0.8);
}

.message-phase {
  font-weight: 700;
  color: var(--agent-accent);
}

.message-agent-label {
  display: inline-flex;
  align-items: center;
  padding: 6px 10px;
  border-radius: 999px;
  background: var(--agent-accent-soft);
  color: var(--agent-accent);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.02em;
}

.message-content {
  min-width: 0;
  font-size: 14px;
  line-height: 1.72;
  color: inherit;
  word-break: break-word;
}

.message-content p {
  margin: 0 0 10px;
}

.message-content p:last-child {
  margin-bottom: 0;
}

.message-content pre {
  max-width: 100%;
  margin: 14px 0 0;
  padding: 14px;
  overflow: auto;
  overscroll-behavior-x: contain;
  border-radius: 16px;
  background: #101731;
  color: #f1f6ff;
  font-size: 12.5px;
  line-height: 1.65;
}

.message-content code {
  font-family: "JetBrains Mono", "SFMono-Regular", ui-monospace, monospace;
}

.message-content .inline-code {
  display: inline-block;
  padding: 0 6px;
  border-radius: 8px;
  background: rgba(28, 42, 77, 0.08);
  color: #225ee8;
  font-size: 0.95em;
}

.message-row.user .message-content .inline-code {
  background: rgba(255, 255, 255, 0.2);
  color: #ffffff;
}

.message-stream-indicator {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: 999px;
  background: rgba(245, 249, 255, 0.98);
  border: 1px solid rgba(215, 225, 246, 0.95);
}

.stream-label {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-soft);
}

.stream-dots {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.stream-dots span {
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: var(--agent-accent);
  animation: stream-pulse 1.15s infinite ease-in-out;
}

.stream-dots span:nth-child(2) {
  animation-delay: 0.15s;
}

.stream-dots span:nth-child(3) {
  animation-delay: 0.3s;
}

@keyframes stream-pulse {
  0%,
  80%,
  100% {
    opacity: 0.28;
    transform: translateY(0);
  }

  40% {
    opacity: 1;
    transform: translateY(-1px);
  }
}

.message-images,
.attachment-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.message-image,
.attachment-card img {
  width: 140px;
  height: 108px;
  object-fit: cover;
  border-radius: 14px;
  border: 1px solid rgba(205, 219, 246, 0.9);
}

.attachment-strip {
  width: min(100%, var(--chat-lane-width));
  margin-bottom: 12px;
}

.attachment-card {
  position: relative;
}

.attachment-card button {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 28px;
  height: 28px;
  border: 0;
  border-radius: 999px;
  background: rgba(21, 31, 53, 0.78);
  color: #ffffff;
}

.reasoning-box {
  margin-top: 14px;
  border-top: 1px solid rgba(215, 225, 246, 0.95);
  padding-top: 12px;
}

.live-thinking-box {
  margin-top: 4px;
  padding: 12px 14px;
  border-radius: 16px;
  background: rgba(246, 249, 255, 0.98);
  border: 1px solid rgba(215, 225, 246, 0.95);
}

.live-thinking-label {
  margin-bottom: 8px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--agent-accent);
}

.live-thinking-text {
  font-size: 13px;
  line-height: 1.7;
  color: var(--text-soft);
}

.live-thinking-text p {
  margin: 0 0 10px;
}

.live-thinking-text p:last-child {
  margin-bottom: 0;
}

.reasoning-box details {
  padding: 10px 12px;
  border-radius: 14px;
  background: rgba(246, 249, 255, 0.98);
  border: 1px solid rgba(215, 225, 246, 0.95);
}

.reasoning-box summary {
  cursor: pointer;
  font-size: 12px;
  font-weight: 800;
  color: var(--agent-accent);
}

.reasoning-text {
  margin-top: 10px;
  white-space: pre-wrap;
  font-size: 12.5px;
  line-height: 1.65;
  color: var(--text-soft);
}

.composer-panel {
  padding: 0 20px 18px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.composer {
  width: min(100%, var(--chat-lane-width));
  border-radius: 24px;
  border: 1px solid rgba(218, 228, 247, 0.95);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.99), rgba(250, 252, 255, 0.99));
  box-shadow: 0 18px 36px rgba(42, 79, 154, 0.08);
  padding: 14px 16px 12px;
}

.composer-toolbar,
.composer-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.composer-toolbar {
  margin-bottom: 8px;
}

.composer-hint,
.composer-meta {
  font-size: 12px;
  line-height: 1.5;
}

.composer-input {
  width: 100%;
  min-height: 54px;
  max-height: 240px;
  resize: none;
  border: 0;
  outline: none;
  background: transparent;
  padding: 8px 0 10px;
  font-size: 15px;
  line-height: 1.72;
  color: var(--text);
}

.composer-input::placeholder {
  color: #8fa0c5;
}

.send-button {
  min-height: 42px;
  min-width: 94px;
  padding: 0 16px;
  background: linear-gradient(180deg, #4d91ff 0%, var(--agent-accent, var(--brand-blue)) 100%);
  box-shadow: 0 14px 28px rgba(47, 124, 255, 0.24);
}

.memory-panel {
  padding: 18px 16px;
  display: flex;
  flex-direction: column;
  height: calc(100dvh - 16px);
  min-height: 0;
  overflow: hidden;
}

.memory-header {
  padding: 4px 2px 14px;
  border-bottom: 1px solid rgba(219, 231, 251, 0.95);
}

.memory-title {
  font-size: 20px;
  font-weight: 800;
}

.memory-header p {
  margin: 8px 0 0;
  font-size: 13px;
  line-height: 1.65;
}

.memory-list {
  flex: 1;
  padding-top: 14px;
}

.memory-item {
  padding: 14px;
}

.memory-item-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.memory-item-detail {
  margin-top: 8px;
  font-size: 13px;
  line-height: 1.65;
}

.memory-item-meta {
  margin-top: 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.hidden {
  display: none !important;
}

.new-chat-button[disabled],
.send-button[disabled],
.quiet-button[disabled] {
  opacity: 0.6;
  cursor: default;
}

@media (max-width: 1320px) {
  .app-shell {
    grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
  }

  .memory-panel {
    position: fixed;
    top: 8px;
    right: 8px;
    bottom: 8px;
    height: auto;
    max-height: calc(100dvh - 16px);
    width: min(320px, calc(100vw - 16px));
    z-index: 30;
    box-shadow: 0 30px 80px rgba(20, 43, 92, 0.28);
  }
}

@media (max-width: 1080px) {
  body {
    overflow-x: hidden;
    overflow-y: auto;
  }

  .app-shell {
    grid-template-columns: 1fr;
    height: auto;
    min-height: 100dvh;
    overflow: visible;
  }

  .sidebar,
  .main-panel {
    height: auto;
    min-height: 0;
    overflow: visible;
  }

  .main-panel {
    min-height: calc(100dvh - 16px);
  }

  .agent-showcase-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 760px) {
  .app-shell {
    width: 100%;
    padding: 6px;
    gap: 10px;
  }

  .topbar {
    padding: 18px 16px 16px;
    flex-direction: column;
    align-items: stretch;
  }

  .message-list {
    padding: 18px 14px 10px;
    align-items: stretch;
  }

  .message-row {
    width: 100%;
    gap: 8px;
  }

  .message-bubble {
    max-width: calc(100% - 46px);
    border-radius: 18px;
  }

  .message-row.user .message-bubble {
    max-width: 92%;
  }

  .composer-panel {
    padding: 0 14px 14px;
  }

  .memory-panel {
    top: 6px;
    right: 6px;
    bottom: 6px;
    left: 6px;
    width: auto;
    max-height: calc(100dvh - 12px);
    padding: 16px 14px;
    border-radius: 22px;
  }

  .agent-showcase-card {
    grid-template-columns: 1fr;
    min-height: 0;
  }

  .draft-chat-view {
    grid-template-columns: 1fr;
  }

  .draft-chat-visual {
    min-height: 320px;
  }

  .agent-showcase-visual {
    min-height: 320px;
  }

  .draft-chat-copy,
  .agent-showcase-copy {
    padding: 20px 18px 20px;
  }

  .topbar-actions,
  .composer-toolbar,
  .composer-actions {
    flex-wrap: wrap;
  }

  .toggle-chip,
  .quiet-button,
  .send-button {
    width: 100%;
    justify-content: center;
  }
}

/* ---- Agentic tools: tool steps + citations (Phase 1) ---- */
.tool-steps {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 4px 0 10px;
}

.tool-step {
  font-size: 12px;
  line-height: 1.4;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface-soft);
  color: var(--text-soft);
  white-space: nowrap;
}

.tool-step.running {
  border-color: var(--brand-blue);
  color: var(--brand-blue-strong);
  animation: tool-pulse 1.2s ease-in-out infinite;
}

.tool-step.done {
  border-color: rgba(54, 194, 119, 0.45);
  color: var(--success);
}

.tool-step.failed {
  border-color: rgba(240, 106, 136, 0.45);
  color: var(--danger);
}

@keyframes tool-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.55; }
}

.citations {
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px dashed var(--line);
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.citations-title {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-faint);
  margin-bottom: 2px;
}

.citation-link {
  font-size: 12.5px;
  color: var(--brand-blue-strong);
  text-decoration: none;
  word-break: break-word;
}

.citation-link:hover {
  text-decoration: underline;
}

/* ---- Knowledge base (Phase 2 RAG) ---- */
.knowledge-section {
  margin-top: 16px;
  border-top: 1px solid var(--line);
  padding-top: 12px;
}
.knowledge-section.hidden { display: none; }
.knowledge-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 12px;
}
.knowledge-input,
.knowledge-textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  font: inherit;
  font-size: 13px;
  color: var(--text);
  background: var(--surface-soft);
  box-sizing: border-box;
  resize: vertical;
}
.knowledge-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}
.document-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.document-item {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 10px;
  background: var(--surface);
}

/* ---- Message actions (regenerate) Phase 3 ---- */
.message-actions {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}
.message-action-button {
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface-soft);
  color: var(--text-soft);
  cursor: pointer;
}
.message-action-button:hover:not(:disabled) {
  border-color: var(--brand-blue);
  color: var(--brand-blue-strong);
}
.message-action-button:disabled {
  opacity: 0.5;
  cursor: default;
}

/* ---- token usage + inline edit + device sync (Phase 3/4) ---- */
.message-usage {
  font-size: 11px;
  color: var(--text-faint);
  margin-top: 6px;
}
.edit-box { margin-top: 4px; }
.edit-textarea {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  font: inherit;
  font-size: 14px;
  color: var(--text);
  background: var(--surface-strong);
  box-sizing: border-box;
  resize: vertical;
  margin-bottom: 6px;
}
.sync-section {
  margin-top: 16px;
  border-top: 1px solid var(--line);
  padding-top: 12px;
}
.auth-section {
  margin-top: 16px;
  border-top: 1px solid var(--line);
  padding-top: 12px;
}
.auth-signed-in {
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: flex-start;
}
.auth-signed-in.hidden,
#auth-signed-out.hidden {
  display: none;
}
.auth-email-label {
  font-size: 13px;
  color: var(--text);
  font-weight: 600;
}

/* ---- Auth modal (centered) ---- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(20, 35, 70, 0.45);
  backdrop-filter: blur(3px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
}
.modal-overlay.hidden { display: none; }
.modal-card {
  position: relative;
  width: 100%;
  max-width: 430px;
  max-height: calc(100vh - 40px);
  background: var(--surface-strong);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 26px 24px 24px;
  overflow-y: auto;
  overflow-x: hidden;
}
.modal-card::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 5px;
  background: linear-gradient(90deg, #ff7a59 0%, #ffb347 34%, #4d91ff 68%, #7a63ff 100%);
}
.modal-close {
  position: absolute;
  top: 10px;
  right: 12px;
  border: none;
  background: transparent;
  font-size: 24px;
  line-height: 1;
  color: var(--text-faint);
  cursor: pointer;
}
.modal-close:hover { color: var(--text); }
.modal-title { font-size: 20px; font-weight: 700; color: var(--text); }
.modal-sub { font-size: 13px; color: var(--text-soft); line-height: 1.55; margin: 6px 0 16px; }
.modal-sub strong { color: var(--text); }
.auth-form { display: flex; flex-direction: column; gap: 14px; }
.auth-option {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 14px;
  border-radius: 18px;
  border: 1px solid rgba(172, 193, 235, 0.38);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(246, 249, 255, 0.98));
}
.auth-option-google {
  background:
    radial-gradient(circle at top right, rgba(255, 190, 92, 0.14), transparent 36%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.99), rgba(246, 249, 255, 0.99));
}
.auth-option-email {
  background:
    radial-gradient(circle at top left, rgba(77, 145, 255, 0.12), transparent 36%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.99), rgba(246, 249, 255, 0.99));
}
.auth-option-header {
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.auth-option-kicker {
  margin: 0;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-faint);
}
.auth-option-title {
  margin: 0;
  font-size: 16px;
  line-height: 1.3;
  color: var(--text);
}
.auth-divider {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text-faint);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.auth-divider::before,
.auth-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--line);
}
.google-signin-shell {
  display: flex;
  justify-content: center;
  padding: 10px 12px;
  border-radius: 18px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(246, 249, 255, 0.96)),
    linear-gradient(135deg, rgba(77, 145, 255, 0.18), rgba(255, 179, 71, 0.18));
  border: 1px solid rgba(154, 180, 227, 0.28);
}
.google-signin-button {
  width: 100%;
  min-height: 42px;
  display: flex;
  justify-content: center;
}
.auth-helper {
  margin: 0;
  font-size: 12px;
  line-height: 1.5;
  color: var(--text-soft);
}
.auth-helper strong {
  color: var(--text);
}
.auth-message {
  margin: 0;
  padding: 10px 12px;
  border-radius: 12px;
  font-size: 12px;
  line-height: 1.45;
  font-weight: 700;
}
.auth-message-error {
  color: #8d2d21;
  background: #fff0ed;
  border: 1px solid rgba(255, 122, 89, 0.34);
}
.auth-message-success {
  color: #145a37;
  background: #eafaf1;
  border: 1px solid rgba(54, 194, 119, 0.32);
}
.auth-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.auth-field-label {
  font-size: 12px;
  font-weight: 700;
  color: var(--text);
}
.modal-input {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  padding: 11px 12px;
  font: inherit;
  font-size: 14px;
  color: var(--text);
  background: var(--surface-soft);
  box-sizing: border-box;
}
.modal-input[aria-invalid="true"] {
  border-color: rgba(255, 122, 89, 0.9);
  background: #fff7f5;
  box-shadow: 0 0 0 3px rgba(255, 122, 89, 0.12);
}
.modal-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 6px;
  align-items: start;
}
.auth-action-block {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.modal-actions .quiet-button,
.modal-actions .send-button {
  width: 100%;
  min-width: 0;
  justify-content: center;
}
.modal-actions .quiet-button {
  background: linear-gradient(180deg, #f8fbff 0%, #edf3ff 100%);
  border-color: rgba(141, 171, 229, 0.62);
  color: #24427d;
}
.modal-actions .send-button {
  background: linear-gradient(135deg, #ff7a59 0%, #ff9b45 52%, #ffbf3c 100%);
  box-shadow: 0 14px 30px rgba(255, 134, 74, 0.28);
  color: #ffffff;
}
.auth-action-copy {
  margin: 0;
  font-size: 11px;
  line-height: 1.45;
  color: var(--text-soft);
  text-align: center;
}
