:root {
  color-scheme: dark;
  --ink: #f5f6fb;
  --muted: #aeb4c2;
  --line: rgba(255, 255, 255, 0.12);
  --surface: #121522;
  --panel: rgba(255, 255, 255, 0.055);
  --panel-2: rgba(255, 255, 255, 0.04);
  --panel-3: rgba(255, 255, 255, 0.08);
  --primary: #0f6f86;
  --primary-hover: #128aa3;
  --accent: #14b8a6;
  --accent-hover: #0f766e;
  --green: #2dd4bf;
  --green-glow: rgba(45, 212, 191, 0.16);
  --coral: #ef4444;
  --amber: #f59e0b;
  --shadow: 0 16px 34px rgba(0, 0, 0, 0.24);
  --card-border: rgba(255, 255, 255, 0.1);
  --side-panel-width: 380px;
}

* {
  box-sizing: border-box;
}

html {
  height: 100%;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body {
  margin: 0;
  height: 100%;
  font-family: 'Inter', 'Sarabun', 'Noto Sans Thai', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color: var(--ink);
  background:
    radial-gradient(ellipse at 50% 100%, rgba(20, 184, 166, 0.16) 0%, rgba(18, 21, 34, 0) 58%),
    linear-gradient(180deg, #17232d 0%, #111827 100%);
  position: relative;
  overflow: hidden;
  letter-spacing: 0;
  line-height: 1.7;
  font-size: 18px;
}

body.hermes-agent-mode {
  --primary: #374151;
  --primary-hover: #4b5563;
  --accent: #4b5563;
  --accent-hover: #6b7280;
  --green: #9ca3af;
  --green-glow: rgba(156, 163, 175, 0.14);
  background:
    radial-gradient(ellipse at 50% 100%, rgba(107, 114, 128, 0.22) 0%, rgba(17, 19, 24, 0) 58%),
    linear-gradient(180deg, #17191f 0%, #101114 100%);
}

body.hermes-agent-mode .glow-blob {
  opacity: 0.08;
}

/* Custom scrollbars */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 99px;
}
::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.2);
}

button,
textarea,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

/* Absolute glowing blobs for visual depth */
.glow-blob {
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  z-index: 0;
  pointer-events: none;
  opacity: 0.28;
}
.blob-1 {
  top: -10%;
  left: -10%;
  width: 400px;
  height: 400px;
  background: radial-gradient(circle, rgba(15, 111, 134, 0.08) 0%, rgba(20, 184, 166, 0.018) 70%, transparent 100%);
}
.blob-2 {
  bottom: 10%;
  right: -10%;
  width: 500px;
  height: 500px;
  background: radial-gradient(circle, rgba(20, 184, 166, 0.08) 0%, rgba(15, 111, 134, 0.018) 70%, transparent 100%);
}

.app-shell {
  height: 100vh;
  min-height: 0;
  display: grid;
  grid-template-columns: var(--side-panel-width) minmax(0, 1fr) var(--side-panel-width);
  position: relative;
  z-index: 1;
  overflow: hidden;
}

.tablet-panel-toggle {
  display: none;
}

.sidebar {
  min-width: 0;
  height: 100vh;
  min-height: 0;
  padding: 24px 20px;
  border-right: 1px solid var(--line);
  background: rgba(18, 21, 34, 0.78);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  display: grid;
  grid-template-rows: auto auto auto auto minmax(0, 1fr) auto;
  gap: 16px;
  overflow: hidden;
}

.brand-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  display: block;
  object-fit: cover;
  background: #061827;
  box-shadow: 0 4px 15px rgba(15, 111, 134, 0.22);
}

body.hermes-agent-mode .brand-mark {
  background: #061827;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.26);
}

.brand-row h1,
.brand-row p,
.chat-header h2,
.chat-header p {
  margin: 0;
}

.brand-row h1 {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0.01em;
}

.brand-row p,
.eyebrow {
  color: var(--muted);
  font-size: 13px;
}

.model-panel {
  display: grid;
  gap: 8px;
  padding: 12px;
  border: 1px solid rgba(20, 184, 166, 0.18);
  border-radius: 12px;
  background:
    linear-gradient(135deg, rgba(20, 184, 166, 0.065), rgba(15, 111, 134, 0.035)),
    rgba(8, 20, 28, 0.34);
}

body.hermes-agent-mode .model-panel {
  border-color: rgba(156, 163, 175, 0.32);
  background: rgba(255, 255, 255, 0.035);
}

.model-panel label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.model-meta {
  min-width: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.project-panel {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid rgba(20, 184, 166, 0.18);
  border-radius: 12px;
  background:
    linear-gradient(135deg, rgba(20, 184, 166, 0.065), rgba(15, 111, 134, 0.035)),
    rgba(8, 20, 28, 0.34);
}

.project-panel-header,
.project-panel-actions,
.project-select-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.project-panel-header {
  justify-content: space-between;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.project-panel-actions {
  flex: 0 0 auto;
}

.project-panel-actions .icon-button {
  width: 34px;
  height: 34px;
  border-radius: 9px;
}

.project-select-row {
  width: 100%;
}

.project-folder-preview {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

#project-select,
#model-select,
.image-popover select,
.project-form input,
.file-create-form input,
.project-form select,
.project-form textarea {
  width: 100%;
  min-width: 0;
  border: 1px solid rgba(20, 184, 166, 0.22);
  border-radius: 10px;
  color: var(--ink);
  color-scheme: dark;
  background:
    linear-gradient(135deg, rgba(20, 184, 166, 0.08), rgba(15, 111, 134, 0.045)),
    rgba(8, 20, 28, 0.9);
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
}

#project-select,
#model-select,
.image-popover select {
  appearance: none;
  -webkit-appearance: none;
  background-image:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18' viewBox='0 0 24 24' fill='none' stroke='%23a7f3d0' stroke-width='2.3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"),
    linear-gradient(135deg, rgba(20, 184, 166, 0.08), rgba(15, 111, 134, 0.045)),
    linear-gradient(rgba(8, 20, 28, 0.92), rgba(8, 20, 28, 0.92));
  background-repeat: no-repeat, no-repeat, no-repeat;
  background-position: right 12px center, 0 0, 0 0;
  background-size: 18px 18px, 100% 100%, 100% 100%;
}

#project-select,
#model-select {
  height: 46px;
  padding: 0 42px 0 12px;
  flex: 1 1 100%;
}

#project-select:focus,
#model-select:focus,
.image-popover select:focus,
.project-form input:focus,
.file-create-form input:focus,
.project-form select:focus,
.project-form textarea:focus {
  border-color: rgba(45, 212, 191, 0.62);
  box-shadow: 0 0 0 3px rgba(20, 184, 166, 0.16);
  background-color: rgba(9, 32, 42, 0.96);
}

#project-select:hover,
#model-select:hover,
.image-popover select:hover {
  border-color: rgba(45, 212, 191, 0.42);
  background-color: rgba(10, 32, 42, 0.95);
}

#project-select option,
#model-select option,
.image-popover select option,
.project-form select option {
  color: #ecfeff;
  background: #10212c;
}

#project-select option:checked,
#model-select option:checked,
.image-popover select option:checked,
.project-form select option:checked {
  color: #ffffff;
  background: #0f6f76;
}

#project-select option:disabled,
#model-select option:disabled,
.image-popover select option:disabled,
.project-form select option:disabled {
  color: #6f7f8f;
  background: #10212c;
}

.project-folder-field input[readonly] {
  color: #99f6e4;
  background: rgba(255, 255, 255, 0.03);
  cursor: default;
}

.icon-button {
  width: 36px;
  height: 36px;
  flex: 0 0 auto;
  border: 1px solid var(--line);
  border-radius: 10px;
  display: grid;
  place-items: center;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.03);
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.icon-button:hover {
  color: var(--ink);
  border-color: rgba(15, 111, 134, 0.45);
  background: rgba(15, 111, 134, 0.1);
}

.icon-button svg {
  width: 17px;
  height: 17px;
}

.label-button {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 11px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.03);
  font-size: 13px;
  font-weight: 600;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.label-button:hover {
  color: var(--ink);
  border-color: rgba(15, 111, 134, 0.45);
  background: rgba(15, 111, 134, 0.1);
}

.label-button svg {
  width: 16px;
  height: 16px;
  flex: 0 0 auto;
}

.project-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-height: 24px;
}

.template-badge {
  max-width: 100%;
  min-height: 24px;
  display: inline-flex;
  align-items: center;
  border: 1px solid rgba(15, 111, 134, 0.28);
  border-radius: 999px;
  padding: 2px 8px;
  color: #99f6e4;
  background: rgba(15, 111, 134, 0.1);
  font-size: 12px;
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
}

.template-badge.secondary {
  border-color: rgba(255, 255, 255, 0.1);
  color: var(--muted);
  background: rgba(255, 255, 255, 0.035);
}

.ghost-button,
.icon-text-button,
.session {
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
  color: var(--ink);
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.ghost-button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  font-weight: 500;
  background: rgba(255, 255, 255, 0.03);
}

.ghost-button:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: var(--primary);
  box-shadow: 0 0 12px rgba(15, 111, 134, 0.2);
  transform: translateY(-1px);
}

.ghost-button.compact {
  min-height: 36px;
  border-radius: 10px;
  padding: 0 10px;
  font-size: 13px;
}

.icon-text-button,
.archive-button,
.persona-button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-weight: 500;
}

.archive-button,
.persona-button {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--ink);
  background: var(--panel);
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.archive-button:hover,
.archive-button:active,
.persona-button:hover,
.persona-button:active {
  color: #ccfbf1;
  border-color: rgba(15, 111, 134, 0.45);
  background: rgba(15, 111, 134, 0.13);
  box-shadow: 0 0 12px rgba(15, 111, 134, 0.18);
  transform: translateY(-1px);
}

.sidebar-actions {
  min-width: 0;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.sidebar-actions #archive-sessions,
.sidebar-actions #persona-settings,
.sidebar-actions #logout {
  width: 100%;
  min-width: 0;
  min-height: 38px;
  padding: 0 8px;
  font-size: 13px;
  white-space: nowrap;
}

.icon-text-button {
  border-color: var(--line);
  background: var(--panel);
  color: var(--ink);
}

.icon-text-button:hover,
.icon-text-button:active {
  background: rgba(239, 68, 68, 0.12);
  border-color: #ef4444;
  color: #f87171;
  box-shadow: 0 0 12px rgba(239, 68, 68, 0.2);
  transform: translateY(-1px);
}

.ghost-button svg,
.icon-text-button svg,
.archive-button svg,
.persona-button svg {
  width: 18px;
  height: 18px;
}

.session-list {
  min-width: 0;
  display: grid;
  align-content: start;
  gap: 8px;
  overflow-y: auto;
  overflow-x: hidden;
}

.session-empty {
  padding: 10px 12px;
  color: var(--muted);
  font-size: 13px;
}

.session-container {
  position: relative;
  width: 100%;
  min-width: 0;
  display: flex;
  align-items: center;
}

.session-container.editing {
  z-index: 7;
}

.session {
  flex: 1;
  min-width: 0;
  padding: 0 14px;
  text-align: left;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  border-color: transparent;
  background: transparent;
  color: var(--muted);
  display: flex;
  align-items: center;
  font-size: 16px;
  min-height: 44px;
  border-radius: 12px;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.session-title {
  min-width: 0;
  max-width: 100%;
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.session-container.pinned .session,
.session-container:hover .session,
.session-container:focus-within .session,
.session-container.session-hover .session,
.session-container.menu-open .session {
  padding-right: 48px;
}

.session-container:hover .session-title,
.session-container:focus-within .session-title,
.session-container.session-hover .session-title,
.session-container.menu-open .session-title {
  text-overflow: clip;
}

@media (hover: none), (pointer: coarse) {
  .session {
    padding-right: 48px;
  }

  .session-title {
    text-overflow: clip;
  }
}

.session:hover,
.session-container.session-hover .session {
  background: rgba(255, 255, 255, 0.04);
  color: var(--ink);
  border-color: rgba(255, 255, 255, 0.05);
}

.session.active {
  background: rgba(15, 111, 134, 0.12);
  border-color: rgba(15, 111, 134, 0.25);
  color: #ffffff;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

.session-rename-form {
  width: 100%;
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 32px 32px;
  align-items: center;
  gap: 6px;
  padding: 4px 6px;
  border: 1px solid rgba(94, 234, 212, 0.3);
  border-radius: 12px;
  background: rgba(15, 111, 134, 0.1);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

.session-rename-input {
  min-width: 0;
  height: 34px;
  border: 1px solid rgba(94, 234, 212, 0.32);
  border-radius: 9px;
  padding: 0 10px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.055);
  font-size: 15px;
  font-weight: 600;
  outline: none;
}

.session-rename-input:focus {
  border-color: rgba(94, 234, 212, 0.62);
  box-shadow: 0 0 0 3px rgba(15, 111, 134, 0.16);
}

.session-rename-save,
.session-rename-cancel {
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 9px;
  display: grid;
  place-items: center;
  background: rgba(255, 255, 255, 0.035);
  transition: color 0.2s, background 0.2s;
}

.session-rename-save {
  color: #34d399;
}

.session-rename-cancel {
  color: #f87171;
}

.session-rename-save:hover {
  color: #bbf7d0;
  background: rgba(16, 185, 129, 0.14);
}

.session-rename-cancel:hover {
  color: #fecaca;
  background: rgba(239, 68, 68, 0.14);
}

.session-rename-save svg,
.session-rename-cancel svg {
  width: 15px;
  height: 15px;
}

.session-menu-button {
  position: absolute;
  right: 8px;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  border: 0;
  background: transparent;
  color: var(--muted);
  display: grid;
  place-items: center;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  z-index: 2;
  opacity: 0.68;
}

.session-menu-button svg {
  width: 15px;
  height: 15px;
  grid-area: 1 / 1;
}

.session-menu-button .session-pin-icon {
  display: none;
}

.session-container.pinned .session-menu-button .session-pin-icon {
  display: block;
}

.session-container.pinned .session-menu-button .session-more-icon {
  display: none;
}

.session-container.pinned:hover .session-menu-button .session-pin-icon,
.session-container.pinned:focus-within .session-menu-button .session-pin-icon,
.session-container.pinned.session-hover .session-menu-button .session-pin-icon,
.session-container.menu-open .session-menu-button .session-pin-icon {
  display: none;
}

.session-container.pinned:hover .session-menu-button .session-more-icon,
.session-container.pinned:focus-within .session-menu-button .session-more-icon,
.session-container.pinned.session-hover .session-menu-button .session-more-icon,
.session-container.menu-open .session-menu-button .session-more-icon {
  display: block;
}

.session-container:hover .session-menu-button,
.session-container:focus-within .session-menu-button,
.session-container.session-hover .session-menu-button,
.session-container.menu-open .session-menu-button {
  opacity: 1;
}

.session-menu-button:hover,
.session-menu-button[aria-expanded="true"] {
  background: rgba(15, 111, 134, 0.15);
  color: #99f6e4;
}

.session-actions-menu {
  position: absolute;
  right: 6px;
  top: calc(100% - 2px);
  min-width: 156px;
  max-width: calc(100% - 12px);
  display: grid;
  gap: 3px;
  padding: 6px;
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: 12px;
  background: rgba(18, 21, 34, 0.94);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.22);
  z-index: 6;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}

.session-actions-menu button {
  min-width: 0;
  min-height: 34px;
  border: 0;
  border-radius: 8px;
  padding: 0 9px;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  background: transparent;
  font-size: 13px;
  font-weight: 700;
  text-align: left;
  transition: color 0.2s, background 0.2s;
}

.session-actions-menu button:hover {
  color: var(--ink);
  background: rgba(255, 255, 255, 0.07);
}

.session-actions-menu button.danger {
  color: #f87171;
}

.session-actions-menu button.danger:hover {
  color: #fecaca;
  background: rgba(239, 68, 68, 0.12);
}

.session-actions-menu svg {
  width: 15px;
  height: 15px;
  flex: 0 0 auto;
}

.session-actions-menu span {
  min-width: 0;
}

@media (hover: hover) and (pointer: fine) {
  .session-menu-button {
    opacity: 0;
  }

  .session-container.pinned .session-menu-button {
    opacity: 0.68;
  }

  .session-container:hover .session-menu-button,
  .session-container:focus-within .session-menu-button,
  .session-container.session-hover .session-menu-button,
  .session-container.menu-open .session-menu-button {
    opacity: 1;
  }
}

.chat-panel {
  min-width: 0;
  height: 100vh;
  min-height: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  background: rgba(18, 21, 34, 0.38);
  overflow: hidden;
}

body.hermes-agent-mode .chat-panel {
  background: rgba(16, 17, 20, 0.48);
}

.chat-panel.file-mode {
  grid-template-rows: minmax(0, 1fr);
}

.chat-panel.file-mode .chat-header,
.chat-panel.file-mode .messages,
.chat-panel.file-mode .composer {
  display: none;
}

.files-panel {
  min-width: 0;
  position: relative;
  height: 100vh;
  min-height: 0;
  border-left: 1px solid var(--line);
  background: rgba(18, 21, 34, 0.76);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  display: grid;
  grid-template-rows: auto auto auto minmax(0, 1fr);
  gap: 12px;
  padding: 20px 16px;
  overflow: hidden;
}

body.hermes-agent-mode .files-panel {
  background: rgba(16, 17, 20, 0.82);
}



.files-header,
.file-editor-header,
.file-editor-actions,
.file-toolbar,
.library-header,
.library-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.files-header {
  display: flex;
  align-items: center;
  gap: 8px;
}

.files-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}

.files-heading {
  flex: 1 1 0;
  min-width: 0;
  overflow: hidden;
}

/* Mobile-only back button for the full-screen Files drawer. */
.mobile-files-back {
  display: none;
}

/* Brand label shown in the mobile Project drawer header. */
.mobile-brand {
  display: none;
}

.files-header h2 {
  margin: 0;
  font-size: 20px;
  line-height: 1.25;
}

.files-tabs {
  min-height: 40px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.03);
}

.files-tab {
  min-width: 0;
  min-height: 32px;
  border: 0;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  color: var(--muted);
  background: transparent;
  font-size: 13px;
  font-weight: 800;
  transition: color 0.2s, background 0.2s;
}

.files-tab.active {
  color: #ccfbf1;
  background: rgba(15, 111, 134, 0.18);
}

.files-tab:hover {
  color: var(--ink);
  background: rgba(255, 255, 255, 0.055);
}

.files-tab svg {
  width: 15px;
  height: 15px;
}

.files-view,
.assets-view {
  min-height: 0;
  display: grid;
  gap: 12px;
  overflow: hidden;
}

.files-view {
  grid-template-rows: minmax(200px, 1.2fr) minmax(180px, 0.8fr);
}

.assets-view {
  /* Give the asset grid the larger share and keep the preview short, matching
     the Files tab's tree/preview proportion (1.2fr / 0.8fr). */
  grid-template-rows: minmax(220px, 1.2fr) minmax(180px, 0.8fr);
}

.files-view[hidden],
.assets-view[hidden] {
  display: none;
}


.file-project-line {
  display: grid;
  gap: 3px;
  min-width: 0;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.045);
}

#file-project-name,
#file-project-path,
#current-file-label {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#file-project-name {
  color: var(--ink);
  font-weight: 700;
  font-size: 14px;
}

#file-project-path {
  color: var(--muted);
  font-size: 12px;
}

.full-text-tooltip {
  position: fixed;
  z-index: 2147483647;
  max-width: min(560px, calc(100vw - 24px));
  padding: 8px 10px;
  border: 1px solid rgba(94, 234, 212, 0.28);
  border-radius: 8px;
  color: #eef4ff;
  background: rgba(17, 24, 39, 0.98);
  box-shadow: 0 16px 34px rgba(0, 0, 0, 0.36);
  font-size: 12px;
  line-height: 1.45;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  pointer-events: none;
}

.full-text-tooltip[hidden] {
  display: none;
}

.full-text-hint-active {
  color: #ccfbf1;
}

.file-toolbar {
  flex-wrap: wrap;
}

.file-toolbar .icon-button {
  width: 38px;
  height: 38px;
}

.file-toolbar .label-button {
  flex: 1 1 auto;
}

.library-panel {
  min-height: 0;
  position: relative;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.035);
  overflow: hidden;
}

.library-header {
  justify-content: space-between;
}

.library-title-block {
  min-width: 0;
  display: grid;
  align-content: start;
  gap: 3px;
}

.library-header h3 {
  margin: 0;
  color: var(--ink);
  font-size: 15px;
  font-weight: 850;
  line-height: 1.2;
}

.library-actions {
  flex: 0 0 auto;
}

.library-actions .label-button.small,
.mobile-assets-actions .label-button.small {
  min-height: 32px;
  border-radius: 9px;
  gap: 6px;
  padding: 0 10px;
  font-size: 12px;
  white-space: nowrap;
}

.library-status {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.library-status.error {
  color: var(--muted);
}

.library-status.ok {
  color: var(--muted);
}

.library-status:empty,
.mobile-library-status:empty {
  display: none;
}

.library-filter-panel {
  gap: 8px;
  padding: 8px;
  border-radius: 10px;
}

.library-list {
  min-height: 0;
  overflow: auto;
  display: grid;
  align-content: start;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  /* Size rows to the square items' content. Without this, auto rows in this
     height-constrained scroll container collapse to ~height/rows, so the
     aspect-ratio:1 items overflow their track and overlap once there are
     enough to scroll. */
  grid-auto-rows: max-content;
  gap: 8px;
}

.library-empty {
  padding: 10px 2px;
  color: var(--muted);
  font-size: 13px;
}

.library-item {
  min-width: 0;
  aspect-ratio: 1;
  position: relative;
  display: block;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.085);
  border-radius: 10px;
  background: rgba(20, 24, 38, 0.7);
  overflow: hidden;
  cursor: pointer;
}

.library-item.selected {
  border-color: rgba(94, 234, 212, 0.78);
  background: rgba(15, 111, 134, 0.11);
  box-shadow: inset 0 0 0 1px rgba(94, 234, 212, 0.18);
}

.library-item.disabled {
  opacity: 0.52;
}

.library-item.previewing {
  border-color: rgba(94, 234, 212, 0.95);
  box-shadow: 0 0 0 2px rgba(94, 234, 212, 0.42), inset 0 0 0 1px rgba(94, 234, 212, 0.2);
}

.library-item-main {
  position: absolute;
  inset: 0;
  min-width: 0;
  display: grid;
  place-items: stretch;
  color: var(--ink);
}

.library-thumb {
  position: relative;
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  color: #5eead4;
  background: rgba(255, 255, 255, 0.045);
  overflow: hidden;
}

.library-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.library-thumb svg {
  width: 24px;
  height: 24px;
}

.library-audio-fallback {
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
  color: #5eead4;
  background: radial-gradient(circle at 50% 44%, rgba(20, 184, 166, 0.2), rgba(15, 23, 42, 0.06) 56%, rgba(255, 255, 255, 0.035));
}

.library-audio-fallback svg {
  width: 44px;
  height: 44px;
  filter: drop-shadow(0 12px 22px rgba(20, 184, 166, 0.28));
}

.library-document-thumb {
  width: 100%;
  height: 100%;
  display: block;
  padding: 7px;
  overflow: hidden;
  background: #f8fafc;
  color: #111827;
}

.library-document-thumb pre {
  margin: 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 7px;
  line-height: 1.35;
}

.library-file-ext-badge {
  position: absolute;
  right: 5px;
  bottom: 5px;
  z-index: 3;
  min-width: 28px;
  max-width: calc(100% - 10px);
  height: 20px;
  border: 1px solid rgba(204, 251, 241, 0.42);
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 7px;
  overflow: hidden;
  color: #ccfbf1;
  background: rgba(15, 23, 42, 0.72);
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.3);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  font-size: 10px;
  font-weight: 900;
  line-height: 1;
  text-transform: uppercase;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.library-item-state {
  position: absolute;
  left: 6px;
  bottom: 6px;
  width: 30px;
  height: 30px;
  border: 1px solid rgba(204, 251, 241, 0.42);
  border-radius: 999px;
  display: grid;
  place-items: center;
  color: #ccfbf1;
  background: rgba(15, 23, 42, 0.72);
  padding: 0;
  cursor: pointer;
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.3);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.library-item-state:hover {
  border-color: rgba(153, 246, 228, 0.82);
  color: #f0fdfa;
  background: rgba(20, 184, 166, 0.82);
}

.library-item-state svg {
  width: 18px;
  height: 18px;
}

.library-item-state.loading,
.mobile-library-state.loading,
.attach-asset-state.loading {
  color: #ccfbf1;
}

.asset-card-spinner {
  width: 15px;
  height: 15px;
  border: 2px solid rgba(204, 251, 241, 0.28);
  border-top-color: #ccfbf1;
  border-radius: 999px;
  animation: asset-card-spin 0.78s linear infinite;
}

@keyframes asset-card-spin {
  to {
    transform: rotate(360deg);
  }
}

.library-item-order {
  border-color: rgba(153, 246, 228, 0.82);
  color: #ffffff;
  background: rgba(15, 111, 134, 0.88);
  font-size: 13px;
  font-weight: 900;
  line-height: 1;
}

.library-item.selected .library-item-state:not(.library-item-order) {
  color: #34d399;
}

.library-item-actions {
  display: none;
}

.library-use-button,
.library-icon-button,
.library-delete-button {
  min-height: 30px;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.035);
  font-size: 12px;
  font-weight: 700;
}

.library-use-button {
  padding: 0 9px;
}

.library-use-button.active {
  color: #ccfbf1;
  border-color: rgba(15, 111, 134, 0.42);
  background: rgba(15, 111, 134, 0.18);
}

.library-icon-button,
.library-delete-button {
  width: 30px;
  padding: 0;
}

.library-use-button:hover,
.library-icon-button:hover {
  color: var(--ink);
  border-color: rgba(15, 111, 134, 0.45);
  background: rgba(15, 111, 134, 0.12);
}

.library-delete-button {
  margin-left: auto;
  color: #f87171;
  border-color: rgba(239, 68, 68, 0.18);
  background: rgba(239, 68, 68, 0.04);
}

.library-delete-button:hover {
  color: #fecaca;
  border-color: rgba(239, 68, 68, 0.42);
  background: rgba(239, 68, 68, 0.1);
}

.library-use-button svg,
.library-icon-button svg,
.library-delete-button svg {
  width: 14px;
  height: 14px;
  flex: 0 0 auto;
}

.library-delete-confirm {
  display: none;
  gap: 8px;
  padding: 9px;
  border: 1px solid rgba(239, 68, 68, 0.22);
  border-radius: 8px;
  color: #fecaca;
  background: rgba(239, 68, 68, 0.08);
  font-size: 12px;
  line-height: 1.45;
}

.asset-preview {
  min-height: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 10px;
}

.asset-preview-header {
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 12px;
}

.asset-preview-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: nowrap;
  gap: 6px;
}

.asset-preview-actions .library-use-button,
.asset-preview-actions .library-icon-button,
.asset-preview-actions .library-delete-button {
  flex: 0 0 auto;
}

.asset-preview-actions .library-delete-button {
  margin-left: 0;
}

.asset-preview-actions .library-delete-button.active {
  color: #fecaca;
  border-color: rgba(239, 68, 68, 0.42);
  background: rgba(239, 68, 68, 0.1);
}

.asset-preview-header > div:not(.asset-preview-actions) {
  min-width: 0;
  display: grid;
  gap: 2px;
}

#asset-preview-label,
#asset-preview-meta {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#asset-preview-label {
  color: var(--ink);
  font-size: 13px;
  font-weight: 800;
}

#asset-preview-meta {
  color: var(--muted);
  font-size: 11px;
}

#asset-preview-meta:empty {
  display: none;
}

.asset-preview-body {
  min-height: 0;
  overflow: auto;
  position: relative;
  display: grid;
  align-content: start;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(20, 24, 38, 0.9);
}

.asset-preview-switcher {
  position: absolute;
  top: 10px;
  left: 10px;
  z-index: 4;
  display: flex;
  align-items: center;
  gap: 4px;
  max-width: calc(100% - 20px);
  overflow-x: auto;
}

.asset-preview-switcher button {
  width: 22px;
  height: 22px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 7px;
  display: grid;
  place-items: center;
  padding: 0;
  color: #ccfbf1;
  background: rgba(15, 23, 42, 0.74);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  font-size: 11px;
  font-weight: 800;
  line-height: 1;
}

.asset-preview-switcher button:hover {
  border-color: rgba(94, 234, 212, 0.55);
  background: rgba(15, 111, 134, 0.28);
}

.asset-preview-switcher button.active {
  color: #ffffff;
  border-color: rgba(94, 234, 212, 0.72);
  background: rgba(15, 111, 134, 0.78);
}

.asset-preview-empty {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}

.asset-preview-empty.error {
  color: #f87171;
}

.asset-visual-preview {
  appearance: none;
  position: relative;
  box-sizing: border-box;
  width: 100%;
  min-height: 240px;
  height: 240px;
  display: grid;
  place-items: center;
  padding: 0;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.2);
  color: inherit;
  cursor: zoom-in;
}

.asset-visual-preview img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.asset-visual-preview.document {
  min-height: 240px;
  padding: 12px;
  background: rgba(0, 0, 0, 0.24);
}

.asset-document-page {
  width: min(100%, 390px);
  height: 210px;
  padding: 14px;
  overflow: hidden;
  border-radius: 4px;
  background: #f8fafc;
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.32);
}

.asset-document-page pre {
  margin: 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  color: #111827;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 8px;
  line-height: 1.45;
  text-align: left;
}

.asset-preview-open-cue {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  opacity: 0;
  background: rgba(2, 6, 23, 0.48);
  transition: opacity 0.16s ease;
}

.asset-preview-open-cue svg {
  width: 42px;
  height: 42px;
  padding: 10px;
  border: 1px solid rgba(204, 251, 241, 0.45);
  border-radius: 999px;
  color: #ccfbf1;
  background: rgba(15, 23, 42, 0.78);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.32);
}

.asset-preview-open-cue .asset-card-spinner {
  width: 42px;
  height: 42px;
  border-width: 3px;
  background: rgba(15, 23, 42, 0.72);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.32);
}

.asset-visual-preview:hover .asset-preview-open-cue,
.asset-visual-preview:focus-visible .asset-preview-open-cue,
.asset-visual-preview.loading .asset-preview-open-cue {
  opacity: 1;
}

.asset-visual-preview.loading {
  cursor: progress;
}

.asset-audio-preview {
  min-height: 240px;
  height: 240px;
  position: relative;
  box-sizing: border-box;
  display: grid;
  padding: 0;
  overflow: hidden;
  border: 1px solid rgba(94, 234, 212, 0.18);
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.2);
}

.asset-audio-visual {
  position: relative;
  min-width: 0;
  min-height: 0;
  display: grid;
  place-items: center;
  overflow: hidden;
}

.asset-audio-visual > img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.asset-audio-fallback {
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
  color: #5eead4;
  background: radial-gradient(circle at 50% 42%, rgba(20, 184, 166, 0.22), rgba(15, 23, 42, 0.5) 62%, rgba(0, 0, 0, 0.22));
}

.asset-audio-fallback svg {
  width: 82px;
  height: 82px;
  filter: drop-shadow(0 18px 32px rgba(20, 184, 166, 0.26));
}

.asset-audio-preview audio {
  position: absolute;
  left: 14px;
  right: 14px;
  bottom: 14px;
  z-index: 2;
  width: calc(100% - 28px);
  min-height: 42px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.72);
  box-shadow: 0 12px 34px rgba(0, 0, 0, 0.34);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.asset-audio-preview .asset-preview-empty {
  position: absolute;
  left: 14px;
  right: 14px;
  bottom: 14px;
  z-index: 2;
  padding: 10px 12px;
  border-radius: 12px;
  color: #cbd5e1;
  background: rgba(15, 23, 42, 0.76);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.asset-preview-details {
  display: grid;
  grid-template-columns: 74px minmax(0, 1fr);
  gap: 5px 10px;
  margin: 0;
  padding: 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.45;
}

.asset-preview-delete-confirm {
  display: grid;
  gap: 8px;
  padding: 9px;
  border: 1px solid rgba(239, 68, 68, 0.22);
  border-radius: 8px;
  color: #fecaca;
  background: rgba(239, 68, 68, 0.08);
  font-size: 12px;
  line-height: 1.45;
}

.asset-preview-details dt {
  color: #99f6e4;
  font-weight: 800;
}

.asset-preview-details dd {
  min-width: 0;
  margin: 0;
  overflow-wrap: anywhere;
}

.asset-preview-section {
  display: grid;
  gap: 6px;
}

.asset-preview-section h4 {
  margin: 0;
  color: #ccfbf1;
  font-size: 12px;
  line-height: 1.35;
}

.asset-preview-section-content {
  position: relative;
}

.asset-preview-section pre {
  max-height: 260px;
  margin: 0;
  overflow: auto;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  padding: 10px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  color: #e5e7eb;
  background: rgba(0, 0, 0, 0.22);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 12px;
  line-height: 1.6;
}

.asset-preview-section-content .file-expand-button {
  border-color: transparent;
  color: rgba(229, 231, 235, 0.9);
  background: transparent;
  box-shadow: none;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}

.asset-preview-section-content .file-expand-button:hover {
  color: #ffffff;
  border-color: transparent;
  background: transparent;
}

.file-status {
  min-height: 24px;
  line-height: 24px;
  color: var(--muted);
  font-size: 12px;
  display: block;
  min-width: 0;
  max-width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.file-status.error {
  color: var(--muted);
}

.file-status.ok {
  color: var(--muted);
}

.file-tree {
  min-height: 0;
  overflow: auto;
  display: grid;
  align-content: start;
  gap: 4px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.035);
}

.file-tree-empty {
  padding: 10px;
  color: var(--muted);
  font-size: 13px;
}

.file-row {
  min-width: 0;
  min-height: 34px;
  border: 1px solid transparent;
  border-radius: 8px;
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  padding: 0 8px;
  color: var(--muted);
  background: transparent;
  text-align: left;
}

.file-row:hover {
  color: var(--ink);
  background: rgba(255, 255, 255, 0.04);
}

.file-row.active {
  color: #ffffff;
  border-color: rgba(15, 111, 134, 0.32);
  background: rgba(15, 111, 134, 0.12);
}

.file-row.directory {
  cursor: default;
  color: #99f6e4;
}

.file-row svg {
  width: 16px;
  height: 16px;
}

.file-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
}

.file-extension-badge {
  min-width: 0;
  max-width: 64px;
  padding: 3px 7px;
  border: 1px solid rgba(94, 234, 212, 0.34);
  border-radius: 999px;
  color: #bffcf2;
  background: rgba(20, 184, 166, 0.16);
  font-size: 10px;
  font-weight: 800;
  line-height: 1;
  letter-spacing: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-editor {
  min-height: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 10px;
}

.file-editor-header {
  justify-content: space-between;
  min-width: 0;
  color: var(--muted);
  font-size: 12px;
}

#file-dirty-label {
  flex: 0 0 auto;
  color: var(--amber);
  font-weight: 700;
}

.file-content-shell {
  position: relative;
  min-height: 0;
  display: grid;
}

#file-content {
  width: 100%;
  min-height: 0;
  height: 100%;
  resize: none;
  border: 1px solid var(--line);
  border-radius: 12px;
  outline: none;
  padding: 12px;
  color: var(--ink);
  background: rgba(20, 24, 38, 0.9);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 13px;
  line-height: 1.65;
}

#file-content:focus {
  border-color: rgba(15, 111, 134, 0.55);
  box-shadow: 0 0 0 3px rgba(15, 111, 134, 0.14);
}

#file-content:disabled {
  opacity: 0.62;
}

.file-expand-button {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 34px;
  height: 34px;
  border: 1px solid transparent;
  border-radius: 9px;
  display: grid;
  place-items: center;
  color: rgba(229, 231, 235, 0.9);
  background: transparent;
  box-shadow: none;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  transition: color 0.2s, border-color 0.2s, background 0.2s, transform 0.2s;
}

.file-expand-button:hover {
  color: #ffffff;
  border-color: transparent;
  background: transparent;
  transform: translateY(-1px);
}

.file-expand-button svg {
  width: 16px;
  height: 16px;
}

.file-editor-actions {
  justify-content: flex-start;
}

.file-editor-actions .danger-icon-button {
  margin-left: auto;
}

.file-editor-actions .primary-button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 38px;
  min-height: 38px;
  padding: 0 14px;
  font-size: 14px;
}

.file-editor-actions .secondary-button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 38px;
  min-height: 38px;
  padding: 0 14px;
  font-size: 14px;
}

.file-editor-actions .primary-button svg,
.file-editor-actions .secondary-button svg {
  width: 16px;
  height: 16px;
}

.danger-icon-button {
  width: 38px;
  height: 38px;
  border: 1px solid rgba(239, 68, 68, 0.22);
  border-radius: 10px;
  display: grid;
  place-items: center;
  color: #f87171;
  background: rgba(239, 68, 68, 0.045);
  transition: color 0.2s, border-color 0.2s, background 0.2s, transform 0.2s;
}

.danger-icon-button:hover {
  color: #fecaca;
  border-color: rgba(239, 68, 68, 0.45);
  background: rgba(239, 68, 68, 0.12);
  transform: translateY(-1px);
}

.danger-icon-button svg {
  width: 16px;
  height: 16px;
}

.dialog-delete-button {
  width: 36px;
  height: 36px;
  border-radius: 9px;
  align-self: center;
}

.dialog-delete-button svg {
  width: 15px;
  height: 15px;
}

.inline-confirm {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid rgba(239, 68, 68, 0.22);
  border-radius: 12px;
  color: #fecaca;
  background: rgba(239, 68, 68, 0.08);
  font-size: 13px;
  line-height: 1.45;
}

.inline-confirm[hidden] {
  display: none;
}

.inline-confirm-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

.primary-button.small,
.secondary-button.small,
.danger-button.small {
  min-height: 34px;
  padding: 0 12px;
  font-size: 13px;
}

.file-workspace[hidden] {
  display: none;
}

.file-workspace {
  min-height: 0;
  height: 100%;
  display: grid;
  grid-template-rows: auto auto auto minmax(0, 1fr);
  gap: 14px;
  padding: clamp(16px, 2.6vw, 32px);
  overflow: hidden;
  background: rgba(18, 21, 34, 0.54);
}

.file-workspace-header {
  min-width: 0;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}

.file-workspace-header .label-button,
.file-workspace-actions .primary-button,
.file-workspace-actions .secondary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 38px;
  min-height: 38px;
  padding: 0 14px;
  font-size: 14px;
}

.file-workspace-header svg,
.file-workspace-actions svg,
.tool-button svg {
  width: 16px;
  height: 16px;
}

.file-workspace-title {
  min-width: 0;
}

.file-workspace-title h2 {
  margin: 0;
  max-width: 100%;
  color: #ffffff;
  font-size: clamp(19px, 2vw, 26px);
  line-height: 1.25;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-workspace-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}



.file-convert-wrap {
  position: relative;
  display: inline-flex;
}

.file-convert-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 20;
  width: 220px;
  display: grid;
  gap: 6px;
  padding: 8px;
  border: 1px solid rgba(156, 163, 175, 0.22);
  border-radius: 10px;
  background: rgba(18, 21, 34, 0.98);
  box-shadow: 0 18px 44px rgba(0, 0, 0, 0.34);
}

.file-convert-menu[hidden] {
  display: none;
}

.file-convert-menu button {
  min-width: 0;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 10px 12px;
  display: grid;
  gap: 2px;
  color: var(--ink);
  text-align: left;
  background: transparent;
}

.file-convert-menu button:hover {
  border-color: rgba(20, 184, 166, 0.34);
  background: rgba(20, 184, 166, 0.11);
}

.file-convert-menu span {
  font-size: 14px;
  font-weight: 800;
}

.file-convert-menu small {
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

.file-workspace-toolbar {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.segmented-control {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.035);
}

.segment,
.tool-button {
  min-height: 36px;
  border: 1px solid var(--line);
  color: var(--muted);
  background: rgba(255, 255, 255, 0.035);
  transition: color 0.2s, border-color 0.2s, background 0.2s;
}

.segment {
  min-width: 74px;
  border: 0;
  border-radius: 6px;
  padding: 0 12px;
  font-size: 13px;
  font-weight: 700;
}

.segment.active {
  color: #ffffff;
  background: rgba(15, 111, 134, 0.72);
}

.tool-button {
  min-width: 38px;
  border-radius: 8px;
  display: inline-grid;
  place-items: center;
  padding: 0 10px;
  font-size: 13px;
  font-weight: 800;
}

.tool-button:hover,
.segment:hover {
  color: var(--ink);
  border-color: rgba(15, 111, 134, 0.45);
  background: rgba(15, 111, 134, 0.12);
}

.file-workspace-status {
  min-height: 22px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.file-workspace-status.dirty {
  color: #fbbf24;
}

#file-workspace-content,
.file-workspace-preview {
  width: min(1280px, 100%);
  min-height: 0;
  height: 100%;
  margin: 0 auto;
  border: 1px solid var(--card-border);
  border-radius: 8px;
  outline: none;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.058);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

#file-workspace-content {
  resize: none;
  padding: clamp(16px, 2vw, 24px);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 16px;
  line-height: 1.75;
  color: var(--ink);
  background: rgba(4, 9, 20, 0.45);
  border: 1px solid var(--card-border);
  border-radius: 8px;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}

/* Match the assistant chat bubble surface in Hermes Agent Mode too. */
body.hermes-agent-mode .file-workspace-preview,
body.hermes-agent-mode #file-workspace-content {
  background: rgba(35, 36, 40, 0.94);
  border-color: rgba(156, 163, 175, 0.18);
}

#file-workspace-content:focus {
  border-color: rgba(15, 111, 134, 0.58);
  box-shadow: 0 0 0 3px rgba(15, 111, 134, 0.14);
}

#file-workspace-content[hidden],
.file-workspace-preview[hidden] {
  display: none;
}

.file-workspace-preview {
  overflow: auto;
  padding: clamp(20px, 3vw, 40px);
  font-size: 18px;
  line-height: 1.85;
}

.file-workspace-preview.html-preview {
  padding: 12px;
  line-height: 1.4;
}

.file-workspace-preview.native-text-preview {
  padding: 0;
  overflow: hidden;
}

.workspace-native-text-preview {
  display: block;
  box-sizing: border-box;
  width: 100%;
  height: 100%;
  min-height: 0;
  margin: 0;
  border: 0;
  outline: none;
  resize: none;
  overflow: auto;
  padding: clamp(20px, 3vw, 40px);
  color: var(--ink);
  background: transparent;
  font: inherit;
  line-height: inherit;
  white-space: pre-wrap;
  overflow-wrap: break-word;
  word-break: normal;
  -webkit-overflow-scrolling: touch;
}

/* Formatted markdown on mobile: the shell stays put and this inner element is
   the sole scroller, isolating the scroll from the mobile viewport-resize loop
   that used to freeze the preview. Block styling comes from the shared
   .file-workspace-preview descendant rules. */
.file-workspace-preview.native-markdown-preview {
  padding: 0;
  overflow: hidden;
}

.workspace-native-markdown-preview {
  box-sizing: border-box;
  width: 100%;
  height: 100%;
  min-height: 0;
  overflow: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  overflow-wrap: break-word;
  padding: clamp(20px, 3vw, 40px);
}

/* Long documents: skip layout/paint for offscreen blocks so viewport resizes
   (mobile URL bar show/hide) only reflow what's visible — this is what kept
   huge .md files freezing even after the scroll was isolated. Older engines
   ignore these harmlessly. */
.workspace-native-markdown-preview > * {
  content-visibility: auto;
  contain-intrinsic-block-size: auto 64px;
}

.html-preview-shell {
  min-height: 100%;
  height: 100%;
  display: grid;
  grid-template-rows: auto minmax(420px, 1fr);
  gap: 10px;
}

.html-preview-toolbar {
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.html-preview-toolbar .secondary-button.small {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 34px;
}

.html-preview-toolbar svg {
  width: 15px;
  height: 15px;
}

.html-preview-frame {
  width: 100%;
  min-width: 0;
  height: 100%;
  border: 1px solid rgba(156, 163, 175, 0.22);
  border-radius: 8px;
  background: #ffffff;
}

.file-workspace-preview h1,
.file-workspace-preview h2,
.file-workspace-preview h3,
.file-workspace-preview h4 {
  margin: 0 0 14px;
  color: #ffffff;
  line-height: 1.25;
}

.file-workspace-preview h1 {
  font-size: 30px;
}

.file-workspace-preview h2 {
  margin-top: 26px;
  font-size: 24px;
}

.file-workspace-preview h3 {
  margin-top: 22px;
  font-size: 20px;
}

.file-workspace-preview p,
.file-workspace-preview ul,
.file-workspace-preview blockquote,
.file-workspace-preview pre {
  margin: 0 0 16px;
}

.file-workspace-preview ul {
  padding-left: 24px;
}

.file-workspace-preview li {
  margin: 4px 0;
}

.file-workspace-preview blockquote {
  padding: 10px 14px;
  border-left: 3px solid rgba(15, 111, 134, 0.65);
  color: #d1d5db;
  background: rgba(15, 111, 134, 0.08);
}

.file-workspace-preview pre {
  overflow-x: auto;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.34);
}

.file-workspace-preview code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.9em;
}

.file-workspace-preview p code,
.file-workspace-preview li code,
.file-workspace-preview blockquote code {
  padding: 2px 6px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: #c4b5fd;
  background: rgba(0, 0, 0, 0.32);
}

.file-workspace-preview strong {
  color: #ffffff;
}

.file-workspace-preview hr {
  height: 1px;
  border: 0;
  margin: 24px 0;
  background: var(--line);
}

.file-workspace-preview table {
  width: 100%;
  min-width: min(520px, 100%);
  border-collapse: collapse;
  white-space: normal;
  font-size: 0.94em;
}
.file-workspace-preview th,
.file-workspace-preview td {
  padding: 10px 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  text-align: left;
  vertical-align: top;
}
.file-workspace-preview th {
  color: #f8fafc;
  font-weight: 720;
  background: rgba(255, 255, 255, 0.055);
}
.file-workspace-preview tr:last-child td {
  border-bottom: 0;
}

.workspace-preview-empty {
  color: var(--muted);
}

/* On narrow screens, opening a workspace becomes a true full-page mode inside
   the chat panel. This avoids the old fixed overlay + inner scroller stack that
   made long Markdown previews freeze on mobile browsers. */
@media (max-width: 1440px) {
  body.workspace-page-open {
    height: 100vh;
    height: var(--workspace-page-height, 100svh);
    overflow: hidden;
  }

  body.workspace-page-open .app-shell {
    height: 100vh;
    height: var(--workspace-page-height, 100svh);
    min-height: 0;
    grid-template-columns: minmax(0, 1fr);
    overflow: hidden;
  }

  body.workspace-page-open .sidebar,
  body.workspace-page-open .files-panel,
  body.workspace-page-open .mobile-controls-backdrop {
    display: none !important;
  }

  body.workspace-page-open .chat-panel {
    grid-column: 1 / -1;
    height: 100vh;
    height: var(--workspace-page-height, 100svh);
    min-height: 0;
    overflow: hidden;
  }

  .file-workspace:not([hidden]) {
    position: relative;
    inset: auto;
    z-index: auto;
    height: 100%;
    min-height: 0;
    border-radius: 0;
    background: #10131e;
    padding: max(12px, env(safe-area-inset-top)) 14px calc(16px + env(safe-area-inset-bottom));
    gap: 10px;
  }

  body.workspace-page-open .file-workspace:not([hidden]) {
    display: flex;
    flex-direction: column;
    overflow-y: hidden;
    overflow-x: hidden;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
  }
  
  body.workspace-page-open .file-workspace:not([hidden]):has(#file-workspace-content:not([hidden])),
  body.workspace-page-open .file-workspace:not([hidden]):has(.file-workspace-preview.html-preview:not([hidden])) {
    overflow-y: hidden;
  }

  body.workspace-page-open .file-workspace-header,
  body.workspace-page-open .file-workspace-toolbar,
  body.workspace-page-open .file-workspace-status {
    flex: 0 0 auto;
  }

  .file-workspace-header {
    gap: 8px;
    padding-bottom: 10px;
  }
  .file-workspace-title h2 {
    font-size: 16px;
  }
  .file-workspace-actions {
    gap: 6px;
  }

  .file-workspace-toolbar {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding-bottom: 2px;
  }
  .file-workspace-toolbar::-webkit-scrollbar {
    display: none;
  }
  .file-workspace-toolbar .tool-button,
  .file-workspace-toolbar .segmented-control {
    flex-shrink: 0;
  }

  #file-workspace-content,
  .file-workspace-preview {
    font-size: 15px;
  }

  body.workspace-page-open #file-workspace-content,
  body.workspace-page-open .file-workspace-preview {
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
  }

  body.workspace-page-open #file-workspace-content:not([hidden]) {
    flex: 1 1 auto;
    height: auto;
    min-height: 320px;
    overflow: auto;
    -webkit-overflow-scrolling: touch;
  }

  body.workspace-page-open .file-workspace-preview:not([hidden]) {
    display: block;
    align-self: stretch;
    flex: 1 1 auto;
    width: 100%;
    max-width: none;
    height: auto;
    min-height: 0;
    box-sizing: border-box;
    overflow: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    overflow-wrap: break-word;
    word-break: normal;
    padding-bottom: calc(28px + env(safe-area-inset-bottom));
  }

  body.workspace-page-open .file-workspace-preview h1,
  body.workspace-page-open .file-workspace-preview h2,
  body.workspace-page-open .file-workspace-preview h3,
  body.workspace-page-open .file-workspace-preview h4,
  body.workspace-page-open .file-workspace-preview p,
  body.workspace-page-open .file-workspace-preview li,
  body.workspace-page-open .file-workspace-preview blockquote,
  body.workspace-page-open .file-workspace-preview pre,
  body.workspace-page-open .file-workspace-preview table {
    max-width: 100%;
  }

  body.workspace-page-open .file-workspace-preview.html-preview:not([hidden]) {
    flex: 1 1 auto;
    height: auto;
    min-height: 320px;
    padding: 10px;
  }
  body.workspace-page-open .file-workspace-preview.native-text-preview:not([hidden]) {
    padding: 0;
  }
  body.workspace-page-open .file-workspace-preview.native-markdown-preview:not([hidden]) {
    padding: 0;
    overflow: hidden;
  }
  .html-preview-shell {
    grid-template-rows: auto minmax(0, 1fr);
  }
}

@media (max-width: 760px) {
  body.workspace-page-open .file-workspace:not([hidden]) {
    padding-left: 0;
    padding-right: 0;
  }

  /* Keep Back (with its label) prominent; compact the right-side actions to icons. */
  .file-workspace-actions .primary-button span,
  .file-workspace-actions .secondary-button span {
    display: none;
  }
  .file-workspace-actions .primary-button,
  .file-workspace-actions .secondary-button {
    padding: 8px 12px;
  }

  body.workspace-page-open .file-workspace-header,
  body.workspace-page-open .file-workspace-toolbar,
  body.workspace-page-open .file-workspace-status {
    margin-left: max(12px, env(safe-area-inset-left));
    margin-right: max(12px, env(safe-area-inset-right));
  }

  body.workspace-page-open .file-workspace-preview:not([hidden]) {
    margin: 0;
    border-left: 0;
    border-right: 0;
    border-radius: 0;
    padding: 18px max(14px, env(safe-area-inset-right)) calc(32px + env(safe-area-inset-bottom)) max(14px, env(safe-area-inset-left));
  }
  body.workspace-page-open .file-workspace-preview.native-text-preview:not([hidden]),
  body.workspace-page-open .file-workspace-preview.native-markdown-preview:not([hidden]) {
    padding: 0;
  }
  body.workspace-page-open .workspace-native-text-preview,
  body.workspace-page-open .workspace-native-markdown-preview {
    padding: 18px max(14px, env(safe-area-inset-right)) calc(32px + env(safe-area-inset-bottom)) max(14px, env(safe-area-inset-left));
  }

  body.workspace-page-open .file-workspace-preview h1 {
    font-size: 28px;
  }

  body.workspace-page-open .file-workspace-preview h2 {
    font-size: 23px;
  }
}

.primary-button:disabled,
.secondary-button:disabled,
.library-use-button:disabled,
.library-icon-button:disabled,
.library-delete-button:disabled,
.icon-button:disabled,
.danger-button:disabled,
.label-button:disabled,
.file-expand-button:disabled,
.danger-icon-button:disabled,
.tool-button:disabled,
.segment:disabled {
  cursor: not-allowed;
  opacity: 0.48;
  transform: none;
}

#attach-clear-assets:disabled,
#library-clear-assets:disabled,
#mobile-library-clear-assets:disabled {
  cursor: default;
}

.chat-header {
  min-width: 0;
  height: 82px;
  padding: 0 clamp(18px, 4vw, 44px);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(18, 21, 34, 0.72);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
}

.chat-title-block {
  min-width: 0;
}

.chat-header-actions {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 10px;
}

.mobile-control-bar,
.mobile-control-header,
.mobile-control-menu,
.mobile-assets-panel,
.mobile-controls-backdrop {
  display: none;
}

.mobile-menu-button {
  width: 38px;
  height: 38px;
  border: 1px solid rgba(148, 163, 184, 0.22);
  border-radius: 12px;
  display: grid;
  place-items: center;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.045);
  transition: color 0.2s, border-color 0.2s, background 0.2s, transform 0.2s;
}

.mobile-menu-button:hover {
  color: #ffffff;
  border-color: rgba(94, 234, 212, 0.36);
  background: rgba(15, 111, 134, 0.16);
  transform: translateY(-1px);
}

.mobile-menu-button svg {
  width: 18px;
  height: 18px;
}

.mobile-control-card {
  width: 100%;
  min-height: 76px;
  border: 1px solid rgba(148, 163, 184, 0.16);
  border-radius: 16px;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 14px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.045);
  text-align: left;
  transition: color 0.2s, border-color 0.2s, background 0.2s, transform 0.2s;
}

.mobile-control-card:hover,
.mobile-control-card.active {
  color: #ffffff;
  border-color: rgba(94, 234, 212, 0.34);
  background: rgba(15, 111, 134, 0.14);
  transform: translateY(-1px);
}

.mobile-control-card:disabled {
  cursor: not-allowed;
  opacity: 0.42;
  transform: none;
}

.mobile-control-card > svg {
  width: 22px;
  height: 22px;
  flex: 0 0 auto;
  color: #cbd5e1;
}

.mobile-control-card span {
  min-width: 0;
  display: grid;
  gap: 2px;
}

.mobile-control-card strong,
.mobile-control-card small {
  min-width: 0;
  overflow-wrap: anywhere;
}

.mobile-control-card strong {
  font-size: 16px;
  line-height: 1.25;
}

.mobile-control-card small {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}

.mobile-assets-panel {
  min-width: 0;
  min-height: 0;
  position: relative;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.04);
  overflow: hidden;
}

.mobile-assets-toolbar {
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.mobile-assets-toolbar h3 {
  margin: 0;
  color: var(--ink);
  font-size: 20px;
  font-weight: 850;
  line-height: 1.2;
}

.mobile-assets-actions {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 8px;
}

.mobile-library-status {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.mobile-library-status.error {
  color: var(--muted);
}

.mobile-library-status.ok {
  color: var(--muted);
}

.mobile-selected-library-assets {
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border: 1px solid rgba(94, 234, 212, 0.2);
  border-radius: 12px;
  color: #ccfbf1;
  background: rgba(15, 111, 134, 0.1);
  font-size: 13px;
  font-weight: 700;
}

.mobile-selected-library-assets[hidden] {
  display: none;
}

.mobile-library-clear {
  min-height: 30px;
  border: 1px solid rgba(94, 234, 212, 0.28);
  border-radius: 8px;
  padding: 0 10px;
  color: #ccfbf1;
  background: rgba(255, 255, 255, 0.04);
  font-size: 12px;
  font-weight: 800;
}

.mobile-library-list {
  min-width: 0;
  min-height: 0;
  display: grid;
  align-content: start;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  /* Match the desktop library grid: size rows to the square items so they
     don't collapse and overlap when the list scrolls. */
  grid-auto-rows: max-content;
  gap: 8px;
  overflow-y: auto;
  overflow-x: hidden;
  padding-right: 2px;
}

.mobile-library-empty {
  padding: 18px 2px;
  color: var(--muted);
  font-size: 14px;
}

.mobile-library-item {
  min-width: 0;
  aspect-ratio: 1;
  position: relative;
  display: block;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.085);
  border-radius: 12px;
  background: rgba(20, 24, 38, 0.72);
  overflow: hidden;
}

.mobile-library-item.selected {
  border-color: rgba(94, 234, 212, 0.78);
  background: rgba(15, 111, 134, 0.12);
  box-shadow: inset 0 0 0 1px rgba(94, 234, 212, 0.18);
}

.mobile-library-item.disabled {
  opacity: 0.52;
}

.mobile-library-item.previewing {
  border-color: rgba(94, 234, 212, 0.95);
  box-shadow: 0 0 0 2px rgba(94, 234, 212, 0.42), inset 0 0 0 1px rgba(94, 234, 212, 0.2);
}

.mobile-library-main {
  width: 100%;
  height: 100%;
  min-width: 0;
  border: 0;
  display: grid;
  grid-template-columns: 1fr;
  align-items: stretch;
  gap: 0;
  padding: 0;
  color: var(--ink);
  background: transparent;
  text-align: left;
  cursor: pointer;
}

.mobile-library-main:disabled {
  cursor: not-allowed;
  opacity: 0.52;
}

.mobile-library-main > svg {
  width: 18px;
  height: 18px;
  color: #cbd5e1;
}

.mobile-library-thumb {
  position: relative;
  width: 100%;
  height: 100%;
  border: 0;
  border-radius: 0;
  display: grid;
  place-items: center;
  overflow: hidden;
  color: #cbd5e1;
  background: rgba(255, 255, 255, 0.045);
}

.mobile-library-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.mobile-library-thumb svg {
  width: 20px;
  height: 20px;
}

.mobile-library-thumb .library-document-thumb {
  padding: 9px;
}

.mobile-library-thumb .library-document-thumb pre {
  font-size: 8px;
}

.mobile-library-thumb .library-file-ext-badge {
  right: 6px;
  bottom: 6px;
  min-width: 30px;
  height: 21px;
  font-size: 10px;
}

.mobile-library-thumb .library-audio-fallback svg {
  width: 48px;
  height: 48px;
}

.mobile-library-text {
  display: none;
}

.mobile-library-text strong,
.mobile-library-text small {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mobile-library-text strong {
  color: var(--ink);
  font-size: 15px;
  line-height: 1.3;
}

.mobile-library-text small {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

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

.mobile-library-action,
.mobile-library-icon {
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.04);
  font-size: 12px;
  font-weight: 800;
}

.mobile-library-action {
  padding: 0 11px;
}

.mobile-library-action.active {
  color: #ccfbf1;
  border-color: rgba(15, 111, 134, 0.42);
  background: rgba(15, 111, 134, 0.18);
}

.mobile-library-icon {
  width: 34px;
  padding: 0;
}

.mobile-library-icon.danger {
  color: #fca5a5;
  border-color: rgba(239, 68, 68, 0.2);
  background: rgba(239, 68, 68, 0.055);
}

.mobile-library-action svg,
.mobile-library-icon svg {
  width: 15px;
  height: 15px;
}

.mobile-library-delete-confirm {
  min-width: 0;
  display: none;
  gap: 8px;
  padding: 9px;
  border: 1px solid rgba(239, 68, 68, 0.24);
  border-radius: 12px;
  color: #fecaca;
  background: rgba(239, 68, 68, 0.075);
  font-size: 12px;
}

.mobile-library-state {
  position: absolute;
  left: 6px;
  bottom: 6px;
  width: 30px;
  height: 30px;
  padding: 0;
  border: 1px solid rgba(204, 251, 241, 0.42);
  border-radius: 999px;
  display: grid;
  place-items: center;
  color: #ccfbf1;
  background: rgba(15, 23, 42, 0.72);
  cursor: pointer;
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.3);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.mobile-library-state svg {
  width: 18px;
  height: 18px;
}

.mobile-library-order {
  border-color: rgba(153, 246, 228, 0.82);
  color: #ffffff;
  background: rgba(15, 111, 134, 0.88);
  font-size: 13px;
  font-weight: 900;
  line-height: 1;
}

.mobile-library-item.selected .mobile-library-state:not(.mobile-library-order) {
  color: #34d399;
}

.chat-header h2 {
  font-size: 22px;
  font-weight: 700;
  line-height: 1.25;
  background: linear-gradient(to right, #ffffff, #d1d5db);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#chat-project-line {
  max-width: min(64vw, 720px);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.status-pill {
  min-width: 86px;
  height: 32px;
  border: 1px solid rgba(16, 185, 129, 0.25);
  border-radius: 999px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  color: #10b981;
  background: rgba(16, 185, 129, 0.1);
  font-size: 13px;
  font-weight: 600;
  padding: 0 12px;
  box-shadow: 0 0 10px rgba(16, 185, 129, 0.1);
}

body.hermes-agent-mode .status-pill {
  border-color: rgba(156, 163, 175, 0.28);
  color: #d1d5db;
  background: rgba(156, 163, 175, 0.1);
  box-shadow: none;
}

.status-pill::before {
  content: "";
  display: block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #10b981;
  box-shadow: 0 0 8px #10b981;
}

body.hermes-agent-mode .status-pill::before {
  background: #9ca3af;
  box-shadow: 0 0 8px rgba(156, 163, 175, 0.6);
}

.status-pill.busy {
  border-color: rgba(245, 158, 11, 0.25);
  color: #f59e0b;
  background: rgba(245, 158, 11, 0.1);
  box-shadow: 0 0 10px rgba(245, 158, 11, 0.1);
}

.status-pill.busy::before {
  background: #f59e0b;
  box-shadow: 0 0 8px #f59e0b;
  animation: pulse-busy 1.5s infinite ease-in-out;
}

@keyframes pulse-busy {
  0%, 100% { opacity: 0.5; }
  50% { opacity: 1; }
}

.messages {
  min-width: 0;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  width: 100%;
  max-width: 1280px;
  margin: 0 auto;
  padding: 40px clamp(18px, 3vw, 32px) 56px;
  scroll-padding-bottom: 56px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.empty-state {
  margin: auto;
  text-align: center;
  max-width: 400px;
  color: var(--muted);
  padding: 40px 20px;
  animation: fadeIn 0.8s ease;
}

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

.empty-state h3 {
  margin: 0 0 12px;
  color: #ffffff;
  font-size: 28px;
  font-weight: 700;
  letter-spacing: 0.01em;
  background: linear-gradient(to right, #ffffff, #9ca3af);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.empty-state p {
  font-size: 17px;
  line-height: 1.6;
}

.message {
  position: relative;
  min-width: 0;
  max-width: min(760px, 88%);
  display: flex;
  flex-direction: column;
  animation: messageSlideIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

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

.message.user {
  align-self: flex-end;
}

.message.assistant {
  align-self: flex-start;
  max-width: min(1180px, 100%);
}

.message-activity {
  min-width: 0;
  max-width: calc(100% - 12px);
  margin: 8px 0 0 12px;
  border: 0;
  border-radius: 0;
  overflow: visible;
  color: #cbd5e1;
  background: transparent;
  transition: opacity 0.14s ease, visibility 0.14s ease;
}

.message.file-activity-collapsed > .message-activity {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  margin: 0 0 0 12px;
  z-index: 4;
}

.message.file-activity-collapsed > .message-activity .message-activity-toggle {
  min-height: 18px;
  line-height: 1.2;
}

/* When the working activity sits below the thinking bubble, give it the same
   gap above as the spacing between its own child lines (list gap: 5px). */
.message-activity-working {
  margin: 5px 0 8px 12px;
}

.message-activity-section + .message-activity-section {
  border-top: 0;
}

/* The working header under the thinking bubble should be quiet, not bold. */
.message-activity-working .message-activity-toggle {
  font-weight: 400;
}

.message-activity-toggle,
.message-activity-single {
  width: auto;
  min-height: 24px;
  border: 0;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 6px;
  padding: 0;
  color: #ccfbf1;
  background: transparent;
  font-size: 13px;
  font-weight: 400;
  text-align: left;
  cursor: pointer;
}

.message-activity-single {
  justify-content: flex-start;
}

.message-activity-single span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.message-activity-toggle:hover {
  color: #ffffff;
}

.message-activity-arrow {
  display: inline-flex;
  width: 12px;
  min-width: 12px;
  justify-content: center;
  flex: 0 0 auto;
  color: #5eead4;
  font-size: 12px;
  line-height: 1;
  transition: transform 0.18s ease;
}

/* Single chevron that rotates on expand instead of swapping ">"/"v" text. */
.message-activity-section.open .message-activity-arrow {
  transform: rotate(90deg);
}

.message-activity-list {
  display: grid;
  gap: 5px;
  margin: 0;
  padding: 3px 0 1px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
  list-style: none;
}

.message-activity-list li {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: normal;
}

.message-inline-diffs {
  min-width: 0;
  max-width: calc(100% - 12px);
  margin: 8px 0 0 12px;
  overflow: visible;
  transition: opacity 0.14s ease, visibility 0.14s ease;
}

/* Collapsed, the diff toggle floats in the inter-message gap (absolute, out of
   flow) exactly like the file-activity toggle — so a file-edit turn keeps the
   same height/spacing as every other message instead of gaining the toggle's
   row. Opening it drops back into flow to push the diff body down. */
.message-inline-diffs:not(.open) {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  margin: 0 0 0 12px;
  z-index: 4;
}

.message-inline-diffs-header {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 0;
  cursor: pointer;
  color: #ccfbf1;
  font-size: 13px;
  font-weight: 500;
  transition: color 0.14s ease;
}

.message-inline-diffs-header:hover {
  color: #5eead4;
}

.message-inline-diffs-title {
  flex: 0 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.message-inline-diffs-arrow {
  display: inline-flex;
  width: 12px;
  min-width: 12px;
  justify-content: center;
  flex: 0 0 auto;
  color: #5eead4;
  font-size: 12px;
  line-height: 1;
  transition: transform 0.18s ease;
}

.message-inline-diffs.open .message-inline-diffs-arrow {
  transform: rotate(90deg);
}

.message-inline-diffs-content {
  display: none;
  margin-top: 8px;
  border: 1px solid rgba(94, 234, 212, 0.2);
  border-radius: 8px;
  background: rgba(15, 23, 42, 0.4);
  max-height: 500px;
  overflow-y: auto;
}

.message-inline-diffs.open .message-inline-diffs-content {
  display: block;
}

.message-diff-block {
  border-bottom: 1px solid rgba(94, 234, 212, 0.1);
}

.message-diff-block:last-child {
  border-bottom: none;
}

.message-diff-path {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 6px 12px;
  background: rgba(94, 234, 212, 0.06);
  color: #5eead4;
  font-size: 12px;
  font-family: ui-monospace, 'SFMono-Regular', 'Menlo', 'Consolas', 'Liberation Mono', monospace;
  font-weight: 400;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.message-diff-path-text {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.message-diff-stats {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
  font-size: 12px;
  font-weight: 600;
}

.message-diff-stat-add {
  color: #86efac;
}

.message-diff-stat-delete {
  color: #fca5a5;
}

.message-diff-content {
  margin: 0;
  padding: 8px 0;
  background: rgba(15, 23, 42, 0.6);
  color: #cbd5e1;
  font-size: 12px;
  font-family: ui-monospace, 'SFMono-Regular', 'Menlo', 'Consolas', 'Liberation Mono', monospace;
  font-weight: 400;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
  overflow-x: auto;
}

.message-diff-line {
  display: block;
  min-height: 1.5em;
  padding: 0 12px;
}

.message-diff-line-add {
  color: #bbf7d0;
  background: rgba(34, 197, 94, 0.14);
}

.message-diff-line-delete {
  color: #fecaca;
  background: rgba(248, 113, 113, 0.14);
}

.message-diff-line-meta {
  color: #93c5fd;
  background: rgba(59, 130, 246, 0.08);
}

@media (min-width: 900px) {
  .message-diff-path,
  .message-diff-stats,
  .message-diff-content {
    font-size: 14px;
  }

  .message-diff-content {
    line-height: 1.68;
  }

  .message-diff-line {
    min-height: 1.68em;
  }
}

.message-label {
  margin: 0 0 6px 12px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0;
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 0;
}

.message-model-name {
  color: rgba(156, 163, 175, 0.72);
  font-size: 0.92em;
  font-weight: 500;
  margin-left: 6px;
}

.message.user .message-label {
  justify-content: flex-end;
  text-align: right;
  margin: 0 12px 6px 0;
}

.message-body {
  min-width: 0;
  max-width: 100%;
  padding: 18px 22px;
  border-radius: 20px;
  line-height: 1.75;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-size: 19px;
  box-shadow: var(--shadow);
}

.message.user .message-body {
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: #ffffff;
  border-bottom-right-radius: 4px;
  box-shadow: 0 8px 24px rgba(15, 111, 134, 0.25);
}

body.hermes-agent-mode .message.user .message-body {
  background: linear-gradient(135deg, #374151, #4b5563);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.22);
}

.message.assistant .message-body {
  background: rgba(255, 255, 255, 0.058);
  border: 1px solid var(--card-border);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  color: #f3f4f6;
  border-bottom-left-radius: 4px;
  box-shadow: 0 8px 26px rgba(0, 0, 0, 0.16), inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.message.compact-message .message-body {
  border-color: rgba(20, 184, 166, 0.34);
  background: rgba(15, 111, 134, 0.1);
}

.message-actions {
  position: absolute;
  top: calc(100% + 8px);
  z-index: 20;
  display: flex;
  align-items: center;
  flex-wrap: nowrap;
  gap: 7px;
  width: max-content;
  max-width: calc(100vw - 32px);
  white-space: nowrap;
  opacity: 0;
  overflow: visible;
  pointer-events: none;
  transition: opacity 0.14s ease;
}

.message.assistant .message-actions {
  left: 10px;
}

.message.user .message-actions {
  justify-content: flex-end;
  right: 10px;
}

.message.actions-open > .message-actions {
  opacity: 1;
  pointer-events: auto;
}

.message.actions-open > .message-activity,
.message.actions-open > .message-inline-diffs {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.session-sync-new-messages {
  position: sticky;
  z-index: 25;
  bottom: 16px;
  align-self: center;
  min-height: 34px;
  border: 1px solid rgba(94, 234, 212, 0.34);
  border-radius: 999px;
  padding: 0 14px;
  color: #c8fff4;
  background: rgba(15, 80, 91, 0.82);
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.28);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}

.session-sync-new-messages:hover {
  border-color: rgba(94, 234, 212, 0.62);
  background: rgba(17, 114, 121, 0.92);
}

.message-action-button {
  min-height: 32px;
  border: 1px solid rgba(148, 163, 184, 0.18);
  border-radius: 10px;
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 0 10px;
  color: #cbd5e1;
  background: rgba(18, 24, 38, 0.76);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  font-size: 12px;
  font-weight: 800;
  line-height: 1;
  transition: border-color 0.18s, background 0.18s, color 0.18s;
}

.message-action-button:hover {
  color: var(--ink);
  border-color: rgba(45, 212, 191, 0.42);
  background: rgba(20, 184, 166, 0.14);
}

.message-action-button svg {
  width: 14px;
  height: 14px;
}

.message-action-button.active.good {
  color: #99f6e4;
  border-color: rgba(45, 212, 191, 0.48);
  background: rgba(20, 184, 166, 0.16);
}

.message-action-button.feedback {
  color: #ccfbf1;
  border-color: rgba(45, 212, 191, 0.48);
  background: rgba(20, 184, 166, 0.16);
}

.message-action-button.active.bad {
  color: #fca5a5;
  border-color: rgba(248, 113, 113, 0.42);
  background: rgba(127, 29, 29, 0.18);
}

.message-save-action {
  position: relative;
}

.message-save-action:not(.save-open) .message-save-menu {
  display: none;
}

.message-save-menu {
  position: absolute;
  left: 0;
  bottom: calc(100% + 7px);
  z-index: 70;
  width: 172px;
  padding: 7px;
  border: 1px solid rgba(148, 163, 184, 0.18);
  border-radius: 12px;
  background: rgba(15, 23, 42, 0.96);
  box-shadow: 0 18px 42px rgba(0, 0, 0, 0.34);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  display: grid;
  gap: 5px;
}

.message.user .message-save-menu {
  left: auto;
  right: 0;
}

.message-save-menu button {
  width: 100%;
  min-height: 32px;
  border: 0;
  border-radius: 8px;
  padding: 0 9px;
  color: #cbd5e1;
  background: transparent;
  font-size: 12px;
  font-weight: 800;
  text-align: left;
}

.message-save-menu button:hover {
  color: #ccfbf1;
  background: rgba(20, 184, 166, 0.14);
}

.message-action-status {
  min-height: 28px;
  display: inline-flex;
  align-items: center;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.message-action-status.error {
  color: #fca5a5;
}

.message-action-status.warning {
  color: #fbbf24;
}

.message-error-retry {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.message-error-retry button {
  min-height: 34px;
  border: 1px solid rgba(45, 212, 191, 0.34);
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 0 12px;
  color: #ccfbf1;
  background: rgba(20, 184, 166, 0.12);
  font-size: 12px;
  font-weight: 850;
  cursor: pointer;
}

.message-error-retry .message-error-compact {
  border-color: rgba(125, 211, 252, 0.34);
  color: #dbeafe;
  background: rgba(56, 130, 246, 0.14);
}

.message-error-retry .message-error-compact:hover:not(:disabled) {
  border-color: rgba(147, 197, 253, 0.62);
  background: rgba(56, 130, 246, 0.24);
}

.message-error-retry button:hover:not(:disabled) {
  border-color: rgba(94, 234, 212, 0.62);
  background: rgba(20, 184, 166, 0.2);
}

.message-error-retry button:disabled {
  cursor: default;
  opacity: 0.68;
}

.message-error-retry svg {
  width: 15px;
  height: 15px;
}

.message-permission-card {
  margin-top: 12px;
  padding: 12px;
  border: 1px solid rgba(245, 158, 11, 0.36);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: #fde68a;
  background: rgba(120, 70, 18, 0.22);
}

.message-permission-copy {
  min-width: 0;
}

.message-permission-title {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #fcd34d;
  font-size: 13px;
  font-weight: 850;
}

.message-permission-title svg {
  width: 15px;
  height: 15px;
}

.message-permission-detail {
  margin-top: 4px;
  color: rgba(253, 230, 138, 0.78);
  font-size: 12px;
  line-height: 1.45;
}

.message-permission-approve {
  min-height: 34px;
  border: 1px solid rgba(245, 158, 11, 0.44);
  border-radius: 10px;
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 0 12px;
  color: #fffbeb;
  background: rgba(146, 64, 14, 0.42);
  font-size: 12px;
  font-weight: 850;
  cursor: pointer;
}

.message-permission-approve:hover:not(:disabled) {
  border-color: rgba(251, 191, 36, 0.72);
  background: rgba(146, 64, 14, 0.56);
}

.message-permission-approve:disabled {
  cursor: default;
  opacity: 0.68;
}

.message-permission-approve svg {
  width: 15px;
  height: 15px;
}

/* Placeholder bubbles shown while a heavy room renders (see renderMessagesSkeleton). */
.message-skeleton {
  display: flex;
  max-width: min(760px, 88%);
  margin-bottom: 18px;
}

.message-skeleton.assistant {
  align-self: flex-start;
}

.message-skeleton.user {
  align-self: flex-end;
  justify-content: flex-end;
}

.message-skeleton-bubble {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 120px;
  padding: 16px 18px;
  border-radius: 18px;
  border: 1px solid var(--card-border);
  background: rgba(255, 255, 255, 0.04);
}

.message-skeleton.user .message-skeleton-bubble {
  background: rgba(15, 111, 134, 0.16);
}

.message-skeleton-line {
  display: block;
  height: 10px;
  width: 220px;
  max-width: 60vw;
  border-radius: 6px;
  background: linear-gradient(
    90deg,
    rgba(255, 255, 255, 0.06) 25%,
    rgba(255, 255, 255, 0.14) 37%,
    rgba(255, 255, 255, 0.06) 63%
  );
  background-size: 400% 100%;
  animation: luluSkeletonShimmer 1.4s ease infinite;
}

.message-skeleton-line:nth-child(2) {
  width: 280px;
}

.message-skeleton-line:nth-child(3) {
  width: 180px;
}

@keyframes luluSkeletonShimmer {
  0% { background-position: 100% 50%; }
  100% { background-position: 0 50%; }
}

@media (prefers-reduced-motion: reduce) {
  .message-skeleton-line {
    animation: none;
  }
}

.inline-spinner {
  width: 14px;
  height: 14px;
  border: 2px solid rgba(204, 251, 241, 0.28);
  border-top-color: #ccfbf1;
  border-radius: 999px;
  animation: asset-card-spin 0.78s linear infinite;
}

/* Beautiful styles for parsed message content */
.message-body h1,
.message-body h2,
.message-body h3,
.message-body h4 {
  margin: 0 0 12px;
  color: #f8fafc;
  font-weight: 760;
  line-height: 1.3;
  letter-spacing: 0;
}
.message-body h1 {
  font-size: 1.35em;
}
.message-body h2 {
  font-size: 1.24em;
}
.message-body h3 {
  font-size: 1.14em;
}
.message-body h4 {
  font-size: 1.06em;
}
.message-body p {
  margin: 0 0 12px;
}
.message-empty-note {
  margin: 0;
  color: var(--muted);
  font-style: italic;
  font-size: 0.95em;
  opacity: 0.85;
}
.message-body p:last-child {
  margin-bottom: 0;
}
.message-body code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  background: rgba(0, 0, 0, 0.35);
  padding: 3px 6px;
  border-radius: 6px;
  font-size: 0.9em;
  color: #5eead4;
  border: 1px solid rgba(255, 255, 255, 0.05);
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: break-word;
}
.message-body a {
  color: #5eead4;
  text-decoration: underline;
  text-underline-offset: 2px;
  overflow-wrap: anywhere;
  word-break: break-word;
}
.message-body a:hover {
  color: #99f6e4;
}
.message-file-link {
  display: inline;
  padding: 0;
  border: 0;
  background: transparent;
  font: inherit;
  color: #5eead4;
  text-decoration: underline;
  text-underline-offset: 2px;
  cursor: pointer;
  overflow-wrap: anywhere;
  word-break: break-word;
  text-align: left;
}
.message-file-link:hover {
  color: #99f6e4;
}
.message-body pre {
  margin: 12px 0;
  padding: 16px;
  background: #171a2a;
  border: 1px solid var(--card-border);
  border-radius: 12px;
  overflow-x: auto;
}
.message-body pre code {
  background: transparent;
  padding: 0;
  border: 0;
  border-radius: 0;
  color: #e2e8f0;
  white-space: pre;
  overflow-wrap: normal;
  word-break: normal;
}
.message-code-wrap {
  position: relative;
  display: flex;
  flex-direction: column;
  margin: 12px 0;
}
.message-code-wrap > pre {
  margin: 0;
  padding-right: 48px;
}
.message-code-wrap > pre code {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
}
.message-code-copy {
  position: absolute;
  top: 8px;
  right: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: auto;
  min-width: 30px;
  height: 30px;
  gap: 5px;
  padding: 0 7px;
  border: 1px solid var(--card-border);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--muted);
  cursor: pointer;
  opacity: 0.65;
  transition: opacity 120ms ease, color 120ms ease, background 120ms ease, border-color 120ms ease;
}
.message-code-copy.bottom {
  top: auto;
  bottom: 8px;
}
.message-code-wrap:hover .message-code-copy,
.message-code-copy:hover,
.message-code-copy:focus-visible {
  opacity: 1;
}
.message-code-copy:hover {
  color: var(--ink);
  background: rgba(255, 255, 255, 0.14);
}
.message-code-copy svg {
  flex: 0 0 auto;
  width: 15px;
  height: 15px;
}
.message-code-copy-label {
  display: none;
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
}
.message-code-copy.copied {
  opacity: 1;
  color: var(--green);
  border-color: rgba(45, 212, 191, 0.45);
}
.message-code-copy.copy-failed {
  opacity: 1;
  color: #f87171;
  border-color: rgba(248, 113, 113, 0.45);
}
.message-code-copy.copied .message-code-copy-label,
.message-code-copy.copy-failed .message-code-copy-label {
  display: inline;
}
.message-body ul, 
.message-body ol {
  margin: 0 0 12px 20px;
  padding: 0;
}
.message-body ul:last-child, 
.message-body ol:last-child {
  margin-bottom: 0;
}
.message-body li {
  margin-bottom: 4px;
}
.message-body blockquote {
  margin: 12px 0;
  padding: 8px 0 8px 14px;
  border-left: 3px solid rgba(94, 234, 212, 0.55);
  color: #d1d5db;
}
.message-body hr {
  border: 0;
  border-top: 1px solid rgba(255, 255, 255, 0.14);
  margin: 16px 0;
}
.message-table-wrap {
  max-width: 100%;
  overflow-x: auto;
  margin: 12px 0;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 10px;
}
.message-body table {
  width: 100%;
  min-width: min(520px, 100%);
  border-collapse: collapse;
  white-space: normal;
  font-size: 0.94em;
}
.message-body th,
.message-body td {
  padding: 10px 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  text-align: left;
  vertical-align: top;
}
.message-body th {
  color: #f8fafc;
  font-weight: 720;
  background: rgba(255, 255, 255, 0.055);
}
.message-body tr:last-child td {
  border-bottom: 0;
}

.composer {
  width: min(760px, calc(100% - 32px));
  margin: 0 auto 24px;
  padding: 12px 14px 12px 16px;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: rgba(25, 29, 45, 0.78);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.22), inset 0 1px 0 rgba(255, 255, 255, 0.06);
  display: flex;
  flex-direction: column;
  gap: 10px;
  position: relative;
  z-index: 10;
  transition: all 0.3s ease;
}

.composer-resize-handle {
  position: absolute;
  top: -9px;
  left: 50%;
  width: 88px;
  height: 20px;
  border: 0;
  padding: 0;
  display: grid;
  place-items: center;
  color: transparent;
  background: transparent;
  cursor: ns-resize;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  transform: translateX(-50%);
  z-index: 2;
}

.composer-resize-handle::before {
  content: "";
  width: 54px;
  height: 5px;
  border: 1px solid rgba(148, 163, 184, 0.22);
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.28);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.18);
  transition: background 140ms ease, border-color 140ms ease, box-shadow 140ms ease;
}

.composer-resize-handle:hover::before,
.composer-resize-handle:focus-visible::before,
.composer.composer-resizing .composer-resize-handle::before {
  border-color: rgba(94, 234, 212, 0.54);
  background: rgba(45, 212, 191, 0.42);
  box-shadow: 0 8px 22px rgba(20, 184, 166, 0.22);
}

.composer-resize-handle:focus-visible {
  outline: none;
}

body.composer-input-resizing {
  cursor: ns-resize;
  user-select: none;
}

body.hermes-agent-mode .composer {
  border-color: rgba(156, 163, 175, 0.22);
  background: rgba(18, 19, 23, 0.9);
  box-shadow: 0 18px 46px rgba(0, 0, 0, 0.24);
}

body.hermes-agent-mode .context-tools-row {
  opacity: 0.42;
  filter: grayscale(1);
}

.composer-input-row {
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr) 52px;
  align-items: end;
  gap: 10px;
  width: 100%;
}

.compact-suggest-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  margin: 0 0 10px;
  padding: 8px 10px 8px 14px;
  border: 1px solid rgba(45, 212, 191, 0.34);
  border-radius: 14px;
  background: rgba(20, 184, 166, 0.1);
  color: #b6f1e7;
  font-size: 13px;
  line-height: 1.4;
}
.compact-suggest-banner[hidden] {
  display: none;
}
.compact-suggest-text {
  flex: 1;
  min-width: 0;
}
.compact-suggest-button {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 14px;
  border: 1px solid rgba(45, 212, 191, 0.5);
  border-radius: 10px;
  background: rgba(20, 184, 166, 0.18);
  color: #d7fbf3;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 120ms ease, border-color 120ms ease;
}
.compact-suggest-button:hover:not(:disabled) {
  background: rgba(20, 184, 166, 0.3);
  border-color: rgba(94, 234, 212, 0.65);
}
.compact-suggest-button:disabled {
  opacity: 0.6;
  cursor: default;
}
.compact-suggest-dismiss {
  flex-shrink: 0;
  width: 26px;
  height: 26px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #8fded0;
  font-size: 13px;
  cursor: pointer;
}
.compact-suggest-dismiss:hover {
  background: rgba(20, 184, 166, 0.16);
  color: #d7fbf3;
}

.mention-popover {
  position: absolute;
  left: 66px;
  right: 76px;
  bottom: calc(100% - 8px);
  z-index: 80;
  max-height: min(292px, 44vh);
  overflow: auto;
  display: grid;
  gap: 6px;
  padding: 8px;
  border: 1px solid rgba(94, 234, 212, 0.24);
  border-radius: 14px;
  background: rgba(24, 28, 43, 0.98);
  box-shadow: 0 22px 56px rgba(0, 0, 0, 0.46);
}

.mention-popover[hidden] {
  display: none;
}

.mention-option {
  min-width: 0;
  width: 100%;
  min-height: 54px;
  border: 1px solid rgba(148, 163, 184, 0.16);
  border-radius: 10px;
  padding: 8px 10px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.04);
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  text-align: left;
}

.mention-option:hover,
.mention-option.active {
  color: var(--ink);
  border-color: rgba(94, 234, 212, 0.5);
  background: rgba(20, 184, 166, 0.16);
}

.mention-option svg {
  width: 18px;
  height: 18px;
  color: #5eead4;
}

.mention-option-text {
  min-width: 0;
  display: grid;
  gap: 3px;
}

.mention-option-text strong,
.mention-option-text small {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mention-option-text strong {
  color: var(--ink);
  font-size: 13px;
  font-weight: 850;
}

.mention-option-text small,
.mention-option-state,
.mention-empty {
  color: var(--muted);
  font-size: 11px;
  font-weight: 760;
}

.mention-option-state {
  padding: 4px 7px;
  border: 1px solid rgba(148, 163, 184, 0.16);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.05);
}

.mention-empty {
  min-height: 48px;
  display: grid;
  place-items: center;
  text-align: center;
}

.context-tools-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 34px;
  padding-top: 2px;
}

.composer-mode-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  flex: 1 1 auto;
}

.context-pill,
.context-tool-button {
  border: 1px solid rgba(148, 163, 184, 0.22);
  background: rgba(255, 255, 255, 0.045);
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  height: 32px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
  white-space: nowrap;
  transition: border-color 0.18s ease, background 0.18s ease, color 0.18s ease, transform 0.18s ease;
}

.context-pill {
  min-width: 0;
  max-width: 100%;
  padding: 0 10px 0 11px;
}

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

.context-pill svg,
.context-tool-button svg {
  width: 15px;
  height: 15px;
  flex: 0 0 auto;
}

.context-chevron {
  transition: transform 0.18s ease;
}

.context-pill[aria-expanded="true"] .context-chevron {
  transform: rotate(180deg);
}

.context-pill:hover,
.context-tool-button:hover:not(:disabled) {
  color: var(--ink);
  border-color: rgba(94, 234, 212, 0.42);
  background: rgba(20, 184, 166, 0.1);
}

.context-pill.normal {
  color: #b8d5ff;
  border-color: rgba(20, 184, 166, 0.36);
}

.context-pill.watch {
  color: #fde68a;
  border-color: rgba(245, 158, 11, 0.45);
}

.context-pill.heavy {
  color: #fecaca;
  border-color: rgba(248, 113, 113, 0.48);
}

.context-quick-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 7px;
  flex: 0 0 auto;
}

.context-tool-button {
  padding: 0 10px;
}

.asset-counter-button {
  position: relative;
  min-width: 48px;
  padding: 0 8px;
  gap: 5px;
}

.asset-count-badge {
  min-width: 16px;
  height: 16px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
  color: #042f2e;
  background: #5eead4;
  font-size: 10px;
  font-weight: 900;
  line-height: 1;
  opacity: 0;
  visibility: hidden;
}

.asset-counter-button.has-count .asset-count-badge {
  opacity: 1;
  visibility: visible;
}

.composer-reset-button {
  width: 32px;
  padding: 0;
}

.composer-reset-button.mode-idle {
  color: var(--muted);
  border-color: rgba(148, 163, 184, 0.2);
  background: rgba(255, 255, 255, 0.035);
}

.composer-reset-button.mode-text {
  color: #fca5a5;
  border-color: rgba(248, 113, 113, 0.35);
  background: rgba(127, 29, 29, 0.12);
}

.composer-reset-button.mode-assets {
  color: #99f6e4;
  border-color: rgba(20, 184, 166, 0.38);
  background:
    linear-gradient(135deg, rgba(20, 184, 166, 0.14), rgba(15, 111, 134, 0.09)),
    rgba(8, 20, 28, 0.54);
}

.composer-reset-button.mode-assets:hover:not(:disabled) {
  color: #f0fdfa;
  border-color: rgba(45, 212, 191, 0.52);
  background:
    linear-gradient(135deg, rgba(20, 184, 166, 0.22), rgba(15, 111, 134, 0.14)),
    rgba(8, 20, 28, 0.64);
}

.context-tool-button[hidden],
.context-popover[hidden] {
  display: none;
}

.context-tool-button.danger {
  color: #fca5a5;
  border-color: rgba(248, 113, 113, 0.35);
}

.context-tool-button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.context-popover {
  border: 1px solid rgba(148, 163, 184, 0.24);
  border-radius: 16px;
  background: rgba(18, 22, 36, 0.92);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05);
  padding: 12px;
  max-height: min(360px, 45vh);
  overflow-y: auto;
}

.image-popover {
  border: 1px solid rgba(20, 184, 166, 0.24);
  border-radius: 16px;
  background: rgba(13, 30, 40, 0.92);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05);
  padding: 12px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 12px;
}

.image-popover[hidden] {
  display: none;
}

.image-popover label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.02em;
}

.image-popover select {
  width: 100%;
  min-width: 0;
  height: 38px;
  border: 1px solid rgba(20, 184, 166, 0.24);
  border-radius: 12px;
  background-color: rgba(8, 20, 28, 0.92);
  color: var(--ink);
  padding: 0 40px 0 12px;
  font: inherit;
  font-size: 13px;
  font-weight: 700;
}

.image-option-help {
  grid-column: 1 / -1;
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.context-popover-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: var(--ink);
  font-size: 13px;
  margin-bottom: 10px;
}

#context-status-label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.context-detail-list {
  display: grid;
  gap: 7px;
}

.context-detail-row {
  display: grid;
  grid-template-columns: minmax(120px, 1fr) auto;
  align-items: center;
  gap: 12px;
  color: var(--muted);
  font-size: 12px;
}

.context-detail-row strong {
  color: #d7e4ff;
  font-size: 12px;
  font-weight: 700;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.context-detail-row span {
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.context-help-text {
  margin: 10px 0 0;
  color: #9ea8bd;
  font-size: 12px;
  line-height: 1.45;
}

#attach-button {
  position: relative;
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: var(--muted);
  background: transparent;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  align-self: end;
  margin-bottom: 2px;
}

#attach-button:hover {
  color: var(--ink);
  background: rgba(255, 255, 255, 0.06);
  transform: scale(1.05);
}

#attach-button:active {
  transform: scale(0.95);
}

.mobile-attach-count-badge {
  display: none;
}

.attach-dialog-shell {
  display: grid;
  gap: 14px;
  padding: 24px;
  font-size: 16px;
}

.attach-dialog-title {
  margin: 0;
  color: var(--muted);
  font-size: 20px;
  font-weight: 850;
  line-height: 1.2;
  letter-spacing: 0;
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex-wrap: wrap;
}

.attach-dialog-title .attach-upload-status {
  min-width: 74px;
  color: #5eead4;
  font-size: 12px;
  font-weight: 500;
  line-height: 1.35;
}

.attach-dialog-title .attach-upload-status[hidden] {
  display: none;
}

.attach-dialog-title .attach-upload-status.error {
  color: #fecaca;
}

.attach-dialog-title .attach-upload-status.ok {
  color: #99f6e4;
}

.attach-dialog-shell .dialog-header {
  position: relative;
  display: flex;
  align-items: flex-end;
  padding-right: 58px;
}

.attach-dialog-shell .dialog-header .icon-button {
  position: absolute;
  top: -8px;
  right: 0;
}

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

.attach-action-card {
  min-width: 0;
  min-height: 78px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  padding: 11px 13px 15px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.04);
  text-align: left;
  transition: border-color 0.18s ease, background 0.18s ease, transform 0.18s ease;
}

.attach-action-card:hover:not(:disabled) {
  border-color: rgba(15, 111, 134, 0.48);
  background: rgba(15, 111, 134, 0.12);
  transform: translateY(-1px);
}

.attach-action-card:disabled {
  cursor: progress;
  opacity: 0.58;
}

.attach-action-card > svg {
  width: 22px;
  height: 22px;
  justify-self: center;
  color: #5eead4;
  transform: translateY(-2px);
}

.attach-action-card span {
  min-width: 0;
  display: grid;
  gap: 2px;
  transform: translateY(-2px);
}

.attach-action-card strong {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 15px;
  line-height: 1.3;
}

.attach-action-card small {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.attach-recent-section {
  min-height: 0;
  display: grid;
  gap: 10px;
  margin-top: 8px;
}

.attach-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.attach-section-title {
  min-width: 0;
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex-wrap: wrap;
}

.attach-section-title small {
  min-width: 74px;
  color: #5eead4;
  font-size: 12px;
  font-weight: 500;
}

.attach-section-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.attach-filter-panel {
  display: grid;
  gap: 10px;
  padding: 10px;
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.035);
}

.attach-filter-panel[hidden] {
  display: none;
}

.attach-filter-group {
  min-width: 0;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.attach-filter-label {
  min-width: 48px;
  color: rgba(156, 163, 175, 0.86);
  font-size: 12px;
  font-weight: 850;
}

.attach-filter-chip {
  min-height: 30px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  padding: 0 10px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.035);
  font-size: 12px;
  font-weight: 800;
  transition: border-color 0.18s ease, color 0.18s ease, background 0.18s ease;
}

.attach-filter-chip:hover {
  border-color: rgba(94, 234, 212, 0.34);
  color: #dffdf8;
  background: rgba(20, 184, 166, 0.1);
}

.attach-filter-chip.active {
  border-color: rgba(94, 234, 212, 0.46);
  color: #ccfbf1;
  background: rgba(20, 184, 166, 0.18);
}

.library-panel .library-filter-panel,
.mobile-assets-panel .library-filter-panel {
  position: absolute;
  top: var(--library-filter-top, 72px);
  left: 10px;
  right: 10px;
  z-index: 15;
  display: grid;
  gap: 12px;
  padding: 12px;
  border-color: rgba(94, 234, 212, 0.18);
  border-radius: 12px;
  background: rgba(31, 35, 52, 0.98);
  box-shadow: 0 18px 44px rgba(0, 0, 0, 0.42);
}

.mobile-assets-panel .library-filter-panel {
  top: var(--library-filter-top, 78px);
  left: 14px;
  right: 14px;
}

.library-panel .library-filter-panel[hidden],
.mobile-assets-panel .library-filter-panel[hidden] {
  display: none;
}

.library-panel .library-filter-panel .attach-filter-group,
.mobile-assets-panel .library-filter-panel .attach-filter-group {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: stretch;
  gap: 8px 12px;
}

.library-panel .library-filter-panel .attach-filter-label,
.mobile-assets-panel .library-filter-panel .attach-filter-label {
  grid-column: 1 / -1;
  min-width: 0;
  min-height: 20px;
  align-self: auto;
  display: flex;
  align-items: center;
}

.library-panel .library-filter-panel .attach-filter-chip,
.mobile-assets-panel .library-filter-panel .attach-filter-chip {
  width: 100%;
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 8px;
  text-align: center;
}

.label-button.small {
  min-height: 30px;
  border-radius: 8px;
  gap: 6px;
  padding: 0 9px;
  font-size: 12px;
}

.label-button.small.teal {
  border-color: rgba(94, 234, 212, 0.42);
  color: #ccfbf1;
  background: rgba(20, 184, 166, 0.18);
}

.label-button.small svg {
  width: 14px;
  height: 14px;
}

.attach-recent-assets {
  margin-top: 6px;
  min-height: 148px;
  max-height: min(360px, calc(100vh - 330px));
  overflow: auto;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-content: start;
  gap: 8px;
}

.attach-empty {
  grid-column: 1 / -1;
  min-height: 118px;
  border: 1px dashed rgba(255, 255, 255, 0.14);
  border-radius: 12px;
  display: grid;
  place-items: center;
  padding: 18px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.025);
  font-size: 14px;
  text-align: center;
}

.attach-asset-card {
  min-width: 0;
  min-height: 76px;
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: 10px;
  display: grid;
  grid-template-columns: 54px minmax(0, 1fr) 18px;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  color: var(--ink);
  background: rgba(20, 24, 38, 0.82);
  text-align: left;
  touch-action: manipulation;
  -webkit-touch-callout: none;
}

.attach-asset-card:hover:not(:disabled) {
  border-color: rgba(94, 234, 212, 0.46);
  background: rgba(15, 111, 134, 0.12);
}

.attach-asset-card.selected {
  border-color: rgba(15, 111, 134, 0.48);
  background: rgba(15, 111, 134, 0.16);
}

.attach-asset-card:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.attach-asset-icon {
  position: relative;
  width: 54px;
  height: 54px;
  border: 1px solid rgba(94, 234, 212, 0.18);
  border-radius: 9px;
  display: grid;
  place-items: center;
  color: #5eead4;
  background: rgba(94, 234, 212, 0.08);
}

.attach-asset-thumb {
  position: relative;
  width: 54px;
  height: 54px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 9px;
  overflow: hidden;
  display: block;
  background: rgba(0, 0, 0, 0.22);
}

.attach-asset-thumb img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

.attach-asset-thumb .library-document-thumb {
  padding: 5px;
}

.attach-asset-thumb .library-document-thumb pre {
  font-size: 4.5px;
  line-height: 1.3;
}

.attach-asset-thumb .library-file-ext-badge,
.attach-asset-icon .library-file-ext-badge {
  right: 3px;
  bottom: 3px;
  min-width: 23px;
  height: 16px;
  padding: 0 5px;
  font-size: 8px;
}

.attach-asset-thumb .library-audio-fallback svg,
.attach-asset-icon .library-audio-fallback svg {
  width: 30px;
  height: 30px;
}

.attach-asset-icon .library-audio-fallback {
  border-radius: inherit;
}

.attach-asset-icon > .library-file-ext-badge + svg {
  margin-top: 8px;
}

.attach-asset-icon svg,
.attach-asset-state {
  width: 16px;
  height: 16px;
}

.attach-asset-state {
  display: grid;
  place-items: center;
  color: #99f6e4;
}

.attach-asset-order {
  width: 24px;
  height: 24px;
  border: 1px solid rgba(94, 234, 212, 0.42);
  border-radius: 999px;
  display: grid;
  place-items: center;
  justify-self: center;
  color: #ccfbf1;
  background: rgba(20, 184, 166, 0.18);
  font-size: 12px;
  font-weight: 900;
  line-height: 1;
}

.attach-asset-text {
  min-width: 0;
  display: grid;
  gap: 2px;
}

.attach-asset-text strong,
.attach-asset-text small {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.attach-asset-text strong {
  color: var(--ink);
  font-size: 13px;
  font-weight: 800;
  line-height: 1.35;
}

.attach-asset-text small {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.35;
}

.attachment-preview-container {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  width: 100%;
  max-height: 200px;
  overflow-y: auto;
  padding-bottom: 4px;
}

.preview-item {
  position: relative;
  width: 72px;
  height: 72px;
  border-radius: 12px;
  border: 1px solid var(--card-border);
  background: rgba(255, 255, 255, 0.04);
  backdrop-filter: blur(10px);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 6px;
  font-size: 10px;
  text-align: center;
  color: var(--ink);
  animation: fadeIn 0.2s ease;
}

.preview-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 8px;
}

.preview-item .file-icon {
  font-size: 20px;
  color: var(--primary);
  margin-bottom: 4px;
}

.preview-item .file-name {
  width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 10px;
  color: var(--muted);
}

.preview-item .delete-btn {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.3);
  color: #fff;
  border: 0;
  display: grid;
  place-items: center;
  cursor: pointer;
  font-size: 10px;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.7);
  transition: background 0.2s;
  z-index: 5;
}

.preview-item .delete-btn:hover {
  background: #ef4444;
}

/* Bigger tap target for the remove (X) on touch devices. On mobile the per-chip
   X is the main way to remove an attachment (the context-tools row is hidden),
   and 18px is too small for a finger. Icon stays in the top-right corner. */
@media (pointer: coarse) {
  .preview-item .delete-btn {
    width: 30px;
    height: 30px;
    font-size: 15px;
  }
}

/* Attachment still processing (paste / drop / pick): spinner + dimmed content,
   send button stays disabled until it clears. */
.preview-item.is-loading {
  background: rgba(255, 255, 255, 0.06);
}

.preview-item.is-loading img,
.preview-item.is-loading .file-icon,
.preview-item.is-loading .file-name {
  opacity: 0.35;
}

.preview-spinner {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 22px;
  height: 22px;
  margin: -11px 0 0 -11px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.25);
  border-top-color: var(--primary);
  animation: lulu-spin 0.7s linear infinite;
  z-index: 4;
}

@keyframes lulu-spin {
  to { transform: rotate(360deg); }
}

/* Preview chips can be dragged to reorder (renumbering on drop). */
.preview-item {
  cursor: grab;
}
.preview-item:active {
  cursor: grabbing;
}
.preview-item.dragging {
  opacity: 0.4;
}

/* Insertion indicator shown while dragging to reorder. Uses ::after (above the
   thumbnail image) since an inset shadow would be hidden behind the <img>. */
.preview-item.drop-before::after,
.preview-item.drop-after::after {
  content: "";
  position: absolute;
  top: 2px;
  bottom: 2px;
  width: 3px;
  border-radius: 2px;
  background: var(--primary);
  z-index: 7;
  pointer-events: none;
}
.preview-item.drop-before::after { left: 0; }
.preview-item.drop-after::after { right: 0; }

/* Drag-and-drop overlay on the chat column. */
.chat-panel.drag-active {
  position: relative;
}

.chat-panel.drag-active::after {
  content: "วางไฟล์เพื่อแนบ";
  position: absolute;
  inset: 10px;
  z-index: 40;
  display: grid;
  place-items: center;
  border: 2px dashed var(--primary);
  border-radius: 18px;
  background: rgba(10, 12, 20, 0.55);
  backdrop-filter: blur(2px);
  color: var(--ink);
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.01em;
  pointer-events: none;
}

/* Styles for files inside chat messages */
.message-attachments {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 10px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  padding-top: 10px;
}

.message.user .message-attachments {
  border-top-color: rgba(255, 255, 255, 0.15);
}

.message-audio-status {
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr);
  gap: 6px 8px;
  align-items: center;
  margin-top: 10px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}

.message-audio-status svg {
  width: 18px;
  height: 18px;
  color: var(--accent);
}

.message-audio-status small {
  grid-column: 2;
  color: var(--muted);
  font-size: 12px;
}

.message-audio-status.warning svg,
.message-audio-status.warning small {
  color: #fbbf24;
}

.message-image-preview {
  position: relative;
  width: min(100%, 360px);
  margin: 12px 0 0;
  overflow: hidden;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(0, 0, 0, 0.2);
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.15);
}

.message-inline-images {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 12px;
}
.message-inline-image {
  max-width: min(100%, 460px);
  max-height: 400px;
  object-fit: contain;
  border-radius: 12px;
  border: 1px solid var(--card-border);
  background: rgba(0, 0, 0, 0.2);
  cursor: zoom-in;
  transition: transform 0.2s ease;
}
.message-inline-image:hover {
  transform: scale(1.01);
}

.message-preview-image,
.chat-image-attachment {
  max-width: 100%;
  max-height: 240px;
  display: block;
  object-fit: contain;
  cursor: pointer;
  transition: transform 0.2s;
}

.message-preview-image {
  width: 100%;
}

.chat-image-attachment:hover {
  transform: scale(1.01);
}

.message-image-switcher {
  position: absolute;
  top: 8px;
  left: 8px;
  z-index: 3;
  display: flex;
  align-items: center;
  gap: 4px;
  max-width: calc(100% - 16px);
  overflow-x: auto;
}

.message-image-switcher button {
  width: 22px;
  height: 22px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 7px;
  display: grid;
  place-items: center;
  padding: 0;
  color: #ccfbf1;
  background: rgba(15, 23, 42, 0.74);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  font-size: 11px;
  font-weight: 800;
  line-height: 1;
}

.message-image-switcher button:hover {
  border-color: rgba(94, 234, 212, 0.55);
  background: rgba(15, 111, 134, 0.32);
}

.message-image-switcher button.active {
  color: #ffffff;
  border-color: rgba(255, 255, 255, 0.76);
  background: rgba(15, 111, 134, 0.82);
}

.generated-image-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.image-action-button {
  min-height: 36px;
  border: 1px solid rgba(148, 163, 184, 0.18);
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 0 12px;
  color: #cbd5e1;
  background: rgba(255, 255, 255, 0.045);
  font-size: 12px;
  font-weight: 800;
  line-height: 1;
  transition: border-color 0.18s, background 0.18s, color 0.18s, transform 0.18s;
}

.image-action-button:hover {
  color: var(--ink);
  border-color: rgba(45, 212, 191, 0.38);
  background: rgba(20, 184, 166, 0.12);
  transform: translateY(-1px);
}

.image-action-button svg {
  width: 15px;
  height: 15px;
}

.image-action-button.active.good {
  color: #99f6e4;
  border-color: rgba(45, 212, 191, 0.46);
  background: rgba(20, 184, 166, 0.16);
}

.image-action-button.active.bad {
  color: #fca5a5;
  border-color: rgba(248, 113, 113, 0.42);
  background: rgba(127, 29, 29, 0.18);
}

.image-viewer-overlay {
  position: fixed;
  inset: 0;
  z-index: 1200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(4, 9, 14, 0.92);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}

.image-viewer-full {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: 12px;
  box-shadow: 0 28px 90px rgba(0, 0, 0, 0.48);
  cursor: zoom-out;
}

.image-viewer-close {
  position: fixed;
  top: 18px;
  right: 18px;
  width: 44px;
  height: 44px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 13px;
  display: grid;
  place-items: center;
  color: var(--ink);
  background: rgba(15, 23, 42, 0.5);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.image-viewer-close:hover {
  border-color: rgba(45, 212, 191, 0.46);
  background: rgba(20, 184, 166, 0.14);
}

.image-viewer-actions {
  position: fixed;
  left: 50%;
  bottom: 22px;
  transform: translateX(-50%);
  width: min(calc(100vw - 32px), 620px);
  justify-content: center;
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
}

.image-viewer-actions .image-action-button {
  background: rgba(15, 23, 42, 0.5);
  border-color: rgba(255, 255, 255, 0.22);
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.28);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

.image-viewer-actions .image-action-button:hover {
  background: rgba(20, 184, 166, 0.5);
  border-color: rgba(153, 246, 228, 0.5);
}

.image-viewer-actions .image-action-button.active.good {
  background: rgba(20, 184, 166, 0.5);
}

.image-viewer-actions .image-action-button.active.bad {
  background: rgba(127, 29, 29, 0.5);
}

.document-viewer-overlay {
  position: fixed;
  inset: 0;
  z-index: 1210;
  display: grid;
  padding: 0;
  background: #050a12;
}

.document-viewer-shell {
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  min-height: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  overflow: hidden;
  border: 0;
  border-radius: 0;
  background: #0f172a;
  box-shadow: none;
}

.document-viewer-header {
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px;
  padding: 12px 14px 12px 18px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  background: #111827;
}

.document-viewer-header div {
  min-width: 0;
  display: grid;
  gap: 2px;
}

.document-viewer-header .document-viewer-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 16px;
}

.document-viewer-export {
  min-height: 38px;
  padding: 0 12px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

.document-viewer-export svg {
  width: 15px;
  height: 15px;
}

.document-viewer-header strong,
.document-viewer-header small {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.document-viewer-header strong {
  color: var(--ink);
  font-size: 16px;
  line-height: 1.35;
}

.document-viewer-header small {
  color: var(--muted);
  font-size: 12px;
}

.document-viewer-close {
  position: static;
}

.document-viewer-body {
  min-height: 0;
  display: grid;
  background: #202124;
}

.document-viewer-frame {
  width: 100%;
  height: 100%;
  border: 0;
  background: #ffffff;
}

.document-viewer-body.text-mode {
  overflow: auto;
  padding: 28px;
  background: #1f2937;
}

.document-viewer-body.document-download-mode {
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(circle at 50% 0%, rgba(20, 184, 166, 0.12), transparent 40%),
    #0f172a;
}

.document-text-reader {
  width: min(100%, 1100px);
  min-height: 100%;
  margin: 0 auto;
  padding: clamp(20px, 3vw, 42px);
  color: #111827;
  background: #f8fafc;
  box-shadow: 0 22px 70px rgba(0, 0, 0, 0.34);
}

.document-text-reader pre {
  margin: 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 15px;
  line-height: 1.62;
}

.document-viewer-message {
  margin: auto;
  color: var(--muted);
  font-size: 15px;
  font-weight: 700;
}

.document-viewer-message.error {
  color: #fecaca;
}

.document-download-card {
  width: min(460px, 100%);
  display: grid;
  justify-items: center;
  gap: 14px;
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 14px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.045);
  text-align: center;
}

.document-download-card > svg {
  width: 42px;
  height: 42px;
  color: #8ef7e8;
}

.document-download-card strong {
  max-width: 100%;
  color: var(--ink);
  font-size: 17px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.document-download-card p {
  margin: 0;
  font-size: 14px;
  line-height: 1.5;
}

.document-download-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
}

.chat-file-attachment {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.06);
  color: var(--ink);
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
  max-width: max-content;
}

.message.user .chat-file-attachment {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.15);
}

.chat-file-attachment svg {
  width: 16px;
  height: 16px;
  color: var(--primary);
}

.message.user .chat-file-attachment svg {
  color: #fff;
}

#message-input {
  width: 100%;
  min-height: 68px;
  max-height: min(540px, 58dvh);
  padding: 10px 0;
  resize: none;
  border: 0;
  outline: none;
  color: var(--ink);
  background: transparent;
  font-size: 19px;
  line-height: 1.5;
  overflow-y: hidden;
}

#message-input::placeholder {
  color: #555870;
}

#send-button {
  width: 52px;
  height: 68px;
  min-height: 0;
  border: 0;
  border-radius: 18px;
  display: grid;
  place-items: center;
  color: #ffffff;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  box-shadow: 0 4px 12px rgba(15, 111, 134, 0.3);
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  align-self: end;
}

#send-button svg {
  width: 22px;
  height: 22px;
}

#send-button:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(20, 184, 166, 0.5);
}

#send-button:active:not(:disabled) {
  transform: translateY(0);
}

#send-button.stop-mode {
  color: #fbbf24;
  background: rgba(44, 36, 24, 0.92);
  border: 1px solid rgba(180, 117, 12, 0.54);
  box-shadow: 0 6px 18px rgba(20, 14, 6, 0.28);
  cursor: pointer;
}

#send-button.stop-mode:hover:not(:disabled) {
  color: #ffd166;
  background: rgba(62, 45, 20, 0.95);
  border-color: rgba(217, 119, 6, 0.72);
  box-shadow: 0 8px 22px rgba(120, 53, 15, 0.28);
}

#send-button.stop-mode svg {
  width: 19px;
  height: 19px;
  stroke-width: 3;
}

#send-button.voice-mode {
  color: #ccfbf1;
  background: rgba(20, 184, 166, 0.18);
  border: 1px solid rgba(45, 212, 191, 0.34);
  box-shadow: 0 6px 18px rgba(20, 184, 166, 0.16);
}

#send-button.voice-mode:hover:not(:disabled) {
  background: rgba(20, 184, 166, 0.26);
  border-color: rgba(45, 212, 191, 0.54);
  box-shadow: 0 8px 22px rgba(20, 184, 166, 0.24);
}

#send-button.listening-mode {
  color: #042f2e;
  background: linear-gradient(135deg, #5eead4, #14b8a6);
  box-shadow: 0 8px 24px rgba(20, 184, 166, 0.34);
}

#send-button.listening-mode svg {
  width: 21px;
  height: 21px;
}

#send-button:disabled {
  opacity: 0.5;
  cursor: wait;
}

/* Login screen styles */
.login-screen {
  background:
    radial-gradient(ellipse at 50% 100%, rgba(20, 184, 166, 0.16) 0%, rgba(18, 21, 34, 0) 58%),
    linear-gradient(180deg, #17232d 0%, #111827 100%);
  position: relative;
  overflow: hidden;
}

.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  position: relative;
  z-index: 10;
}

.login-panel {
  width: 100%;
  max-width: 400px;
  padding: 40px 32px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--card-border);
  border-radius: 24px;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  box-shadow: 0 18px 44px rgba(0, 0, 0, 0.28), inset 0 1px 0 rgba(255, 255, 255, 0.06);
  text-align: center;
  animation: loginPanelFade 0.6s cubic-bezier(0.16, 1, 0.3, 1);
  font-weight: 400;
}

.login-panel-wide {
  max-width: 720px;
  text-align: left;
}

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

.login-panel .brand-mark {
  width: 56px;
  height: 56px;
  border-radius: 16px;
  margin: 0 auto 20px;
  font-size: 26px;
}

.login-panel h1 {
  margin: 0 0 8px;
  font-size: 26px;
  font-weight: 700;
  background: linear-gradient(to right, #ffffff, #d1d5db);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  text-align: center;
}

.login-subtitle {
  margin: 0;
  color: var(--text-muted);
  text-align: center;
  font-size: 15px;
  font-weight: 400;
}

.login-methods {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 26px;
}

.login-method {
  min-height: 82px;
  border: 1px solid rgba(148, 163, 184, 0.22);
  border-radius: 16px;
  padding: 16px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.045);
  text-align: left;
  cursor: pointer;
  transition: border-color 0.2s ease, background 0.2s ease, transform 0.2s ease;
}

.login-method:hover {
  transform: translateY(-1px);
  border-color: rgba(94, 234, 212, 0.45);
}

.login-method.active {
  border-color: rgba(94, 234, 212, 0.72);
  background: rgba(20, 184, 166, 0.16);
  box-shadow: inset 0 0 0 1px rgba(94, 234, 212, 0.2);
}

.login-method span {
  display: block;
  font-weight: 400;
  font-size: 16px;
}

.login-method small {
  display: block;
  margin-top: 6px;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 400;
  line-height: 1.35;
}

.login-form-note {
  margin: 0;
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 400;
  line-height: 1.45;
}

.login-form {
  display: grid;
  gap: 12px;
  margin-top: 24px;
}

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

.login-form label {
  display: block;
  font-size: 12px;
  font-weight: 400;
  color: #9ca3af;
  margin-bottom: 6px;
  text-align: left;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.login-fields {
  display: grid;
  gap: 12px;
}

.login-field {
  display: grid;
  gap: 6px;
}

.otp-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 112px;
  gap: 10px;
}

.login-field input,
.password-row input {
  min-width: 0;
  height: 48px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  padding: 0 16px;
  color: white;
  background: rgba(255, 255, 255, 0.05);
  font-size: 15px;
  font-weight: 400;
  outline: none;
  transition: all 0.3s;
}

.login-field input:focus,
.password-row input:focus {
  background: rgba(255, 255, 255, 0.08);
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(15, 111, 134, 0.2);
}

.login-submit,
.otp-row button,
.password-row button {
  height: 48px;
  border: 0;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: white;
  font-weight: 400;
  box-shadow: 0 4px 15px rgba(15, 111, 134, 0.25);
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  white-space: nowrap;
}

.login-submit:hover:not(:disabled),
.otp-row button:hover:not(:disabled),
.password-row button:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(20, 184, 166, 0.4);
}

.login-submit:active:not(:disabled),
.otp-row button:active:not(:disabled),
.password-row button:active {
  transform: translateY(0);
}

.login-submit:disabled,
.otp-row button:disabled {
  cursor: wait;
  opacity: 0.62;
  transform: none;
}

#login-status,
#login-error {
  min-height: 20px;
  margin: 8px 0 0;
  font-size: 14px;
  text-align: left;
}

#login-status {
  color: #34d399;
}

#login-error {
  color: #ef4444;
}

@media (max-width: 640px) {
  .login-shell {
    align-items: start;
    padding: max(20px, env(safe-area-inset-top, 0px)) 16px max(20px, env(safe-area-inset-bottom, 0px));
  }

  .login-panel,
  .login-panel-wide {
    max-width: none;
    padding: 28px 20px;
    border-radius: 20px;
  }

  .login-methods {
    grid-template-columns: 1fr;
  }

}

@media (max-width: 1180px) {
  body {
    height: auto;
    min-height: 100vh;
    overflow-y: auto;
    overflow-x: hidden;
  }

  .app-shell {
    height: auto;
    min-height: 100vh;
    overflow: visible;
    grid-template-columns: 300px minmax(0, 1fr);
  }

  .sidebar,
  .chat-panel {
    height: auto;
  }

  .chat-panel.file-mode {
    height: 100vh;
    min-height: 680px;
  }

  .files-panel {
    grid-column: 1 / -1;
    height: auto;
    min-height: 480px;
    border-left: 0;
    border-top: 1px solid var(--line);
    grid-template-rows: auto auto auto minmax(560px, auto);
  }

  .files-view {
    grid-template-rows: minmax(220px, 0.9fr) minmax(320px, 1.1fr);
  }

  .assets-view {
    grid-template-rows: 260px 340px;
  }
}

@media (min-width: 761px) and (max-width: 1180px) {
  body {
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
  }

  .app-shell {
    height: 100vh;
    height: 100dvh;
    min-height: 0;
    grid-template-columns: clamp(280px, 36vw, 320px) minmax(0, 1fr);
    overflow: hidden;
  }

  .sidebar,
  .chat-panel {
    height: 100vh;
    height: 100dvh;
    min-height: 0;
  }

  .sidebar {
    padding: 22px 16px;
  }

  .chat-header {
    min-width: 0;
    padding: 0 clamp(18px, 2.5vw, 28px);
  }

  .chat-title-block,
  .chat-header h2,
  #chat-project-line {
    max-width: 100%;
    min-width: 0;
  }

  .chat-header h2,
  #chat-project-line {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .messages {
    max-width: none;
    min-width: 0;
    padding: 32px clamp(16px, 2.4vw, 24px) 56px;
    scroll-padding-bottom: 56px;
  }

  .message {
    max-width: min(680px, 100%);
  }

  .message.user {
    max-width: min(560px, 88%);
  }

  .message-body {
    padding: 16px 18px;
    font-size: 18px;
  }

  .message-body ul,
  .message-body ol {
    max-width: 100%;
    min-width: 0;
  }

  .composer {
    width: min(720px, calc(100% - 28px));
    margin-bottom: 20px;
  }
}

@media (min-width: 900px) and (max-width: 1180px) {
  .app-shell {
    grid-template-columns: clamp(280px, 31vw, 330px) minmax(0, 1fr);
    grid-template-areas: "project chat";
  }

  .sidebar {
    grid-area: project;
  }

  .chat-panel {
    grid-area: chat;
  }

  .files-panel {
    grid-area: files;
    grid-column: auto;
    height: 100vh;
    height: 100dvh;
    min-height: 0;
    border-top: 0;
    border-left: 1px solid var(--line);
    grid-template-rows: auto auto auto minmax(0, 1fr);
  }

  body:not(.tablet-files-panel-open) .files-panel {
    display: none;
  }

  body.tablet-files-panel-open .app-shell {
    grid-template-columns: minmax(0, 1fr) clamp(280px, 31vw, 330px);
    grid-template-areas: "chat files";
  }

  body.tablet-files-panel-open .sidebar {
    display: none;
  }

  body.tablet-files-panel-open .files-panel {
    display: grid;
  }

  .files-view,
  .assets-view {
    grid-template-rows: minmax(0, 1fr) minmax(0, 1fr);
  }

  .files-view.no-file-selected,
  .files-view.preview-suppressed,
  .assets-view.no-asset-selected,
  .assets-view.preview-suppressed {
    grid-template-rows: minmax(0, 1fr);
  }

  .files-view.no-file-selected .file-editor,
  .files-view.preview-suppressed .file-editor,
  .assets-view.no-asset-selected .asset-preview,
  .assets-view.preview-suppressed .asset-preview {
    display: none;
  }

  .tablet-panel-toggle {
    display: none !important;
  }

  .tablet-panel-toggle-hint {
    display: none;
  }
}

.project-dialog,
.archive-dialog,
.persona-dialog,
.file-create-dialog,
.attach-dialog {
  width: min(720px, calc(100vw - 28px));
  max-height: calc(100vh - 32px);
  border: 1px solid var(--card-border);
  border-radius: 16px;
  padding: 0;
  color: var(--ink);
  background: #171a29;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.42);
}

.project-dialog::backdrop,
.archive-dialog::backdrop,
.persona-dialog::backdrop,
.file-create-dialog::backdrop,
.attach-dialog::backdrop {
  background: rgba(0, 0, 0, 0.52);
  backdrop-filter: blur(5px);
}

.file-create-dialog {
  width: min(520px, calc(100vw - 28px));
}

.attach-dialog {
  width: min(680px, calc(100vw - 28px));
}

@media (min-width: 900px) {
  .attach-dialog {
    width: min(1040px, calc(100vw - 56px));
    max-height: calc(100vh - 56px);
  }

  .attach-dialog-shell {
    gap: 14px;
    padding: 34px 36px 36px;
    font-size: 18px;
  }

  .attach-dialog-shell .dialog-header {
    min-height: 44px;
    padding-right: 72px;
  }

  .attach-dialog-shell .dialog-header .icon-button {
    top: -10px;
    width: 56px;
    height: 56px;
    border-radius: 18px;
  }

  .attach-actions-grid {
    gap: 16px;
    margin-top: 10px;
  }

  .attach-recent-section {
    margin-top: 18px;
  }

  .attach-action-card {
    min-height: 116px;
    grid-template-columns: 72px minmax(0, 1fr);
    gap: 18px;
    padding: 20px 24px;
  }

  .attach-action-card > svg {
    width: 34px;
    height: 34px;
  }

  .attach-action-card strong {
    font-size: 24px;
  }

  .attach-action-card small {
    font-size: 18px;
  }

  .attach-section-header {
    font-size: 20px;
  }

  .attach-dialog-title .attach-upload-status,
  .attach-section-title small {
    font-size: 14px;
  }

  .attach-section-actions .label-button.small {
    min-height: 44px;
    border-radius: 12px;
    gap: 8px;
    padding: 0 15px;
    font-size: 16px;
  }

  .attach-section-actions .label-button.small svg {
    width: 18px;
    height: 18px;
  }

  .attach-filter-panel {
    grid-template-columns: 1fr;
    gap: 14px;
    padding: 14px;
  }

  .attach-filter-group {
    gap: 10px;
  }

  .attach-filter-label {
    min-width: 52px;
    font-size: 14px;
  }

  .attach-filter-chip {
    min-height: 36px;
    padding: 0 12px;
    font-size: 14px;
  }

  .attach-recent-assets {
    min-height: 280px;
    max-height: min(560px, calc(100vh - 430px));
    grid-template-columns: repeat(auto-fill, minmax(285px, 1fr));
    gap: 12px;
  }

  .attach-asset-card {
    min-height: 96px;
    grid-template-columns: 68px minmax(0, 1fr) 24px;
    gap: 14px;
    padding: 12px 14px;
  }

  .attach-asset-icon,
  .attach-asset-thumb {
    width: 68px;
    height: 68px;
    border-radius: 10px;
  }

  .attach-asset-text {
    gap: 4px;
  }

  .attach-asset-text strong {
    font-size: 16px;
  }

  .attach-asset-text small {
    font-size: 13px;
  }
}

.project-form,
.file-create-form,
.archive-dialog-shell {
  display: grid;
  gap: 18px;
  padding: 26px;
  font-size: 17px;
}

.dialog-header {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 16px;
}

.dialog-header h2 {
  margin: 2px 0 0;
  font-size: 28px;
  font-weight: 700;
  line-height: 1.25;
}

.archive-bulk-actions {
  display: flex;
  justify-content: flex-end;
}

.archive-bulk-actions .danger-button {
  min-height: 42px;
}

.archive-bulk-confirm {
  margin-bottom: 2px;
}

.archive-list {
  min-height: 220px;
  max-height: min(520px, calc(100vh - 180px));
  overflow: auto;
  display: grid;
  align-content: start;
  gap: 10px;
}

.persona-dialog {
  width: min(920px, calc(100vw - 28px));
}

.persona-dialog-shell {
  display: grid;
  gap: 16px;
  padding: 26px;
}

.persona-dialog-title {
  margin: 0;
  font-size: 28px;
  line-height: 1.15;
}

.persona-tabs {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  overflow-x: auto;
  padding-bottom: 2px;
}

.persona-tab {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 38px;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 11px;
  padding: 0 13px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.035);
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
}

.persona-tab.active {
  color: #ccfbf1;
  border-color: rgba(20, 184, 166, 0.62);
  background: rgba(20, 184, 166, 0.18);
}

.persona-editor {
  min-width: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 10px;
}

.persona-editor-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.persona-editor-header h3 {
  display: none;
}

.persona-editor-header p,
.persona-editor-note,
.persona-status {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}

.persona-readonly-badge {
  display: none;
}

.persona-quick {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 0 0 4px;
  padding: 12px 14px;
  border: 1px solid rgba(148, 163, 184, 0.2);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.025);
}

/* The flex rule above would otherwise override the [hidden] attribute and leave
   an empty bordered box on non-agent tabs. */
.persona-quick[hidden] {
  display: none;
}

.persona-quick-heading {
  margin: 0;
  color: rgba(94, 234, 212, 0.92);
  font-size: 11px;
  font-weight: 850;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.persona-quick-group {
  gap: 6px;
}

.persona-apply-note {
  margin: 0;
  color: rgba(148, 163, 184, 0.82);
  font-size: 12px;
  line-height: 1.4;
}

.persona-apply-note strong {
  color: rgba(94, 234, 212, 0.9);
}

#persona-editor-content {
  min-height: min(420px, calc(100vh - 360px));
  border: 1px solid rgba(148, 163, 184, 0.24);
  border-radius: 13px;
  padding: 14px;
  color: var(--ink);
  background: rgba(4, 9, 20, 0.45);
  font: 16px/1.62 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  resize: vertical;
  outline: none;
}

#persona-editor-content:focus {
  border-color: rgba(20, 184, 166, 0.62);
  box-shadow: 0 0 0 1px rgba(20, 184, 166, 0.16);
}

#persona-editor-content[readonly] {
  color: var(--ink);
  cursor: default;
  background: rgba(255, 255, 255, 0.058);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.persona-dialog-actions {
  align-items: center;
}

.persona-status.error {
  color: #fecaca;
}

@media (max-width: 720px) {
  .persona-dialog {
    width: 100vw;
    max-height: 100dvh;
  }

  .persona-dialog-shell {
    gap: 12px;
    padding: 18px;
  }

  .persona-tabs {
    gap: 7px;
  }

  .persona-tab {
    height: 36px;
    min-height: 36px;
    padding: 0 12px;
    font-size: 12px;
  }

  #persona-editor-content {
    min-height: min(48dvh, 420px);
    font-size: 15px;
  }
}

.archive-empty {
  padding: 18px 4px;
  color: var(--muted);
  font-size: 16px;
}

.archive-item {
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 12px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.035);
}

.archive-item .inline-confirm {
  grid-column: 1 / -1;
}

.archive-item-main {
  min-width: 0;
  display: grid;
  gap: 4px;
}

.archive-item-main strong,
.archive-item-main span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.archive-item-main strong {
  color: var(--ink);
  font-size: 17px;
  line-height: 1.35;
}

.archive-item-main span {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}

.archive-item-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.archive-item-actions .secondary-button,
.archive-item-actions .danger-icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.archive-item-actions svg {
  width: 16px;
  height: 16px;
}

.danger-icon-button.small-icon {
  width: 34px;
  height: 34px;
  min-height: 34px;
  border-radius: 9px;
}

.project-form .eyebrow,
.file-create-form .eyebrow {
  font-size: 14px;
  font-weight: 500;
  letter-spacing: 0;
}

.project-form label,
.file-create-form label {
  display: grid;
  gap: 9px;
  color: #c5cbd8;
  font-size: 15px;
  font-weight: 600;
  line-height: 1.45;
}

.project-form input,
.file-create-form input,
.project-form select {
  height: 52px;
  padding: 0 14px;
  font-size: 17px;
  font-weight: 500;
  line-height: 1.45;
  background: rgba(255, 255, 255, 0.055);
}

.project-form textarea {
  min-height: 118px;
  padding: 13px 14px;
  resize: vertical;
  font-size: 17px;
  font-weight: 500;
  line-height: 1.65;
  background: rgba(255, 255, 255, 0.055);
}

.file-create-help,
.file-create-status {
  margin: -8px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.file-create-status:empty {
  display: none;
}

.file-create-status.error {
  color: #f87171;
}

.file-create-status.ok {
  color: #34d399;
}

.project-form fieldset {
  margin: 0;
  padding: 16px 14px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
}

.project-form legend {
  padding: 0 8px;
  color: #c5cbd8;
  font-size: 15px;
  font-weight: 600;
  line-height: 1.45;
}

.linked-template-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.project-form .template-check {
  min-height: 56px;
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 12px 14px;
  border-radius: 10px;
  color: #d9deea;
  background: rgba(255, 255, 255, 0.035);
  font-size: 16px;
  font-weight: 600;
  line-height: 1.45;
}

.project-form .template-check input {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
  accent-color: var(--primary);
}

.project-form .template-check span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.project-form .template-check.disabled {
  color: var(--muted);
  opacity: 0.62;
}

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

.dialog-action-spacer {
  flex: 1;
}

.primary-button,
.secondary-button,
.danger-button {
  min-height: 46px;
  border-radius: 10px;
  padding: 0 18px;
  font-size: 17px;
  font-weight: 700;
}

.primary-button {
  border: 0;
  color: #ffffff;
  background: linear-gradient(135deg, var(--primary), var(--accent));
}

.secondary-button {
  border: 1px solid var(--line);
  color: var(--ink);
  background: rgba(255, 255, 255, 0.04);
}

.danger-button {
  border: 1px solid rgba(239, 68, 68, 0.22);
  color: #f87171;
  background: rgba(239, 68, 68, 0.06);
}

@media (max-width: 899px) {
  .image-pill,
  .image-popover {
    display: none !important;
  }

  .document-viewer-header {
    padding: 12px;
  }

  .composer-mode-controls {
    min-width: 0;
  }

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

  .app-shell {
    height: 100vh;
    height: 100dvh;
    min-height: 0;
    grid-template-columns: 1fr;
    overflow: hidden;
  }

  .glow-blob {
    display: none;
  }

  .sidebar {
    position: fixed;
    inset: 0;
    z-index: 60;
    width: 100vw;
    max-width: 100vw;
    height: 100vh;
    height: 100dvh;
    max-height: none;
    min-height: 0;
    grid-template-columns: 1fr;
    grid-template-rows: auto minmax(0, 1fr) auto;
    gap: 12px;
    padding: max(14px, env(safe-area-inset-top)) max(14px, env(safe-area-inset-right)) max(14px, env(safe-area-inset-bottom)) max(14px, env(safe-area-inset-left));
    border: 0;
    border-radius: 0;
    background: rgba(18, 21, 34, 0.98);
    box-shadow: none;
    transform: translateX(-100%);
    opacity: 0;
    pointer-events: none;
    transition: transform 0.22s ease, opacity 0.22s ease;
  }

  body.mobile-controls-open .sidebar {
    transform: translateX(0);
    opacity: 1;
    pointer-events: auto;
  }

  .mobile-controls-backdrop {
    position: fixed;
    inset: 0;
    z-index: 55;
    border: 0;
    padding: 0;
    background: rgba(0, 0, 0, 0.46);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
  }

  body.mobile-controls-open .mobile-controls-backdrop {
    display: block;
    opacity: 1;
    pointer-events: auto;
  }

  .mobile-control-header {
    width: 100%;
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0;
  }

  .mobile-control-header > div {
    flex: 1;
    min-width: 0;
    text-align: left;
  }

  .mobile-control-header h2 {
    margin: 0;
    color: #ffffff;
    font-size: 20px;
    line-height: 1.2;
  }

  .mobile-control-header p {
    margin: 0 0 2px;
  }

  .mobile-control-back[hidden] {
    display: none;
  }

  .sidebar .brand-row,
  .sidebar .mobile-control-menu,
  .sidebar .mobile-assets-panel,
  .sidebar .project-panel,
  .sidebar .model-panel,
  .sidebar #new-chat,
  .sidebar .session-list,
  .sidebar .sidebar-actions,
  .sidebar #archive-sessions,
  .sidebar #persona-settings,
  .sidebar #logout {
    display: none;
  }

  body.mobile-controls-open[data-mobile-panel="menu"] .sidebar .mobile-control-menu {
    display: grid;
    align-content: start;
    gap: 10px;
    overflow-y: auto;
  }

  body.mobile-controls-open[data-mobile-panel="menu"] .sidebar .mobile-control-card[data-mobile-panel="project"],
  body.mobile-controls-open[data-mobile-panel="menu"] .sidebar .mobile-control-card[data-mobile-panel="model"] {
    display: none;
  }

  body.mobile-controls-open[data-mobile-panel="project"] .sidebar .project-panel,
  body.mobile-controls-open[data-mobile-panel="model"] .sidebar .model-panel {
    display: grid;
    overflow: auto;
  }

  body.mobile-controls-open[data-mobile-panel="assets"] .sidebar .mobile-assets-panel {
    display: grid;
  }

  body.mobile-controls-open[data-mobile-panel="session"] .sidebar {
    grid-template-rows: auto auto auto auto minmax(0, 1fr) auto;
  }

  body.mobile-controls-open[data-mobile-panel="session"] .sidebar .project-panel {
    display: grid;
    max-height: none;
    overflow: visible;
  }

  body.mobile-controls-open[data-mobile-panel="session"] .sidebar .model-panel {
    display: grid;
    max-height: none;
    overflow: visible;
  }

  body.mobile-controls-open[data-mobile-panel="session"] .sidebar #new-chat,
  body.mobile-controls-open[data-mobile-panel="session"] .sidebar .sidebar-actions,
  body.mobile-controls-open[data-mobile-panel="session"] .sidebar #archive-sessions,
  body.mobile-controls-open[data-mobile-panel="session"] .sidebar #persona-settings,
  body.mobile-controls-open[data-mobile-panel="session"] .sidebar #logout {
    display: flex;
  }

  body.mobile-controls-open[data-mobile-panel="session"] .sidebar .sidebar-actions {
    display: grid;
  }

  body.mobile-controls-open[data-mobile-panel="session"] .sidebar #new-chat {
    min-height: 42px;
  }

  body.mobile-controls-open[data-mobile-panel="session"] .sidebar .session-list {
    display: grid;
    min-height: 0;
    max-height: none;
    overflow-y: auto;
    overflow-x: hidden;
  }

  .sidebar #new-chat,
  .sidebar #archive-sessions,
  .sidebar #persona-settings,
  .sidebar #logout {
    width: 100%;
  }

  .sidebar #new-chat span,
  .sidebar #archive-sessions span,
  .sidebar #persona-settings span,
  .sidebar #logout span {
    display: inline;
  }

  .project-panel,
  .model-panel,
  .mobile-assets-panel {
    width: 100%;
    max-width: 100%;
    min-width: 0;
  }

  .project-panel,
  .model-panel {
    max-height: min(56vh, 460px);
    max-height: min(56dvh, 460px);
    overflow: auto;
  }

  .project-panel-header {
    min-width: 0;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
  }

  .project-panel-header > span {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .project-panel-actions {
    min-width: 0;
    justify-content: flex-end;
    flex-wrap: nowrap;
  }

  .project-select-row,
  #project-select,
  #model-select,
  .project-folder-preview,
  .project-meta,
  .model-meta {
    max-width: 100%;
    min-width: 0;
  }

  .mobile-assets-panel {
    max-height: none;
    overflow: hidden;
  }

  .chat-panel {
    height: 100vh;
    height: 100dvh;
    min-height: 0;
    grid-template-rows: auto minmax(0, 1fr) auto;
  }

  html.android-standalone body,
  html.android-standalone .app-shell,
  html.android-standalone .chat-panel,
  html.android-standalone .chat-panel.file-mode,
  html.android-standalone .sidebar,
  html.android-standalone .files-panel {
    height: var(--android-app-height, 100dvh);
    min-height: 0;
  }

  html.android-standalone body.workspace-page-open,
  html.android-standalone body.workspace-page-open .app-shell,
  html.android-standalone body.workspace-page-open .chat-panel,
  html.android-standalone body.workspace-page-open .chat-panel.file-mode {
    height: var(--workspace-page-height, 100svh);
    min-height: 0;
  }

  .files-panel {
    display: none;
  }

  .chat-header {
    height: auto;
    min-height: 78px;
    padding: 10px 12px;
    gap: 10px;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .chat-title-block {
    min-width: 0;
    flex: 1 1 auto;
    overflow: hidden;
  }

  .chat-header h2 {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 18px;
  }

  .chat-header-actions {
    gap: 8px;
    min-width: 0;
  }

  .mobile-control-bar {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 8px;
  }

  .status-pill {
    min-width: 0;
    width: 8px;
    height: 8px;
    flex: 0 0 8px;
    border: 0;
    padding: 0;
    gap: 0;
    background: transparent;
    box-shadow: none;
    font-size: 0;
  }

  body.hermes-agent-mode .status-pill,
  .status-pill.busy {
    border: 0;
    background: transparent;
    box-shadow: none;
  }

  .status-pill::before {
    width: 7px;
    height: 7px;
  }

  #chat-project-line {
    max-width: 100%;
    font-size: 12px;
  }

  .messages {
    max-width: none;
    padding: 18px 12px 54px;
    scroll-padding-bottom: 54px;
    gap: 18px;
  }

  .message {
    max-width: 96%;
  }

  .message.file-activity-collapsed > .message-activity {
    top: calc(100% + 8px);
  }

  .message.file-activity-collapsed > .message-activity .message-activity-toggle {
    min-height: 16px;
    font-size: 12px;
  }

  .message.actions-open > .message-actions {
    opacity: 1;
    pointer-events: auto;
  }

  .message-action-button {
    width: 34px;
    min-height: 34px;
    padding: 0;
  }

  .message-action-button.feedback {
    width: auto;
    min-width: 72px;
    padding: 0 10px;
  }

  .message-action-button span {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
  }

  .message-action-button.feedback span {
    position: static;
    width: auto;
    height: auto;
    overflow: visible;
    clip: auto;
  }

  .message-action-button svg {
    width: 16px;
    height: 16px;
  }

  .message-action-status {
    min-height: 30px;
    font-size: 11px;
  }

  .message-body {
    font-size: 18px;
  }

  .empty-state {
    padding: 22px 18px;
  }

  .empty-state h3 {
    font-size: 23px;
  }

  .empty-state p {
    font-size: 15px;
  }

  .composer {
    width: calc(100% - 16px);
    margin: 0 auto max(18px, env(safe-area-inset-bottom));
    padding: 8px 9px;
    border-radius: 18px;
    display: flex;
    flex-direction: column;
    gap: 7px;
  }

  .composer-input-row {
    grid-template-columns: 36px minmax(0, 1fr) 46px;
    gap: 8px;
  }

  .mention-popover {
    left: 10px;
    right: 10px;
    bottom: calc(100% + 6px);
    max-height: min(280px, 44vh);
    padding: 7px;
  }

  .mention-option {
    grid-template-columns: 22px minmax(0, 1fr) auto;
    min-height: 52px;
    padding: 8px;
    gap: 8px;
  }

  .context-tools-row {
    display: none;
  }

  .context-popover {
    left: 0;
    right: 0;
    bottom: calc(100% + 8px);
    max-height: 168px;
    padding: 10px;
  }

  #attach-button {
    width: 36px;
    height: 36px;
    margin-bottom: 0;
  }

  .mobile-attach-count-badge:not([hidden]) {
    position: absolute;
    top: -24px;
    left: 50%;
    min-width: 20px;
    height: 20px;
    box-sizing: border-box;
    border: 2px solid rgba(18, 19, 23, 0.95);
    border-radius: 999px;
    display: grid;
    place-items: center;
    padding: 0 5px;
    color: #042f2e;
    background: #5eead4;
    box-shadow: 0 8px 20px rgba(20, 184, 166, 0.26);
    font-size: 11px;
    font-weight: 900;
    line-height: 1;
    transform: translateX(-50%);
    z-index: 2;
  }

  #message-input {
    min-height: 60px;
    font-size: 18px;
    padding: 6px 0;
  }

  #send-button {
    width: 46px;
    height: 60px;
    min-height: 0;
    border-radius: 16px;
  }

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

  .archive-dialog,
  .project-dialog,
  .persona-dialog,
  .attach-dialog {
    width: calc(100vw - 20px);
    max-height: calc(100vh - 20px);
    max-height: calc(100dvh - 20px);
  }

  .archive-dialog,
  .persona-dialog {
    position: fixed;
    inset: 0;
    width: 100vw;
    max-width: 100vw;
    height: 100vh;
    height: 100dvh;
    max-height: none;
    margin: 0;
    border: 0;
    border-radius: 0;
    background: #171a29;
  }

  .project-dialog {
    position: fixed;
    inset: 0;
    width: 100vw;
    max-width: 100vw;
    height: 100vh;
    height: 100dvh;
    max-height: none;
    margin: 0;
    border: 0;
    border-radius: 0;
    background: #171a29;
  }

  .project-dialog::backdrop {
    background: #171a29;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
  }

  .archive-dialog::backdrop,
  .persona-dialog::backdrop {
    background: #171a29;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
  }

  .archive-dialog-shell,
  .persona-dialog-shell,
  .project-form,
  .attach-dialog-shell {
    padding: 18px;
  }

  .archive-dialog-shell,
  .persona-dialog-shell {
    min-height: 100%;
    max-height: 100%;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: max(18px, env(safe-area-inset-top)) max(18px, env(safe-area-inset-right)) max(18px, env(safe-area-inset-bottom)) max(18px, env(safe-area-inset-left));
  }

  .persona-dialog-shell {
    grid-template-rows: auto auto minmax(0, 1fr) auto;
    overflow: hidden;
  }

  .archive-dialog-shell {
    grid-template-rows: auto minmax(0, 1fr);
  }

  .persona-tabs {
    align-self: start;
  }

  .persona-editor {
    min-height: 0;
    overflow: hidden;
  }

  #persona-editor-content {
    min-height: 0;
    height: 100%;
    resize: none;
  }

  .archive-list {
    min-height: 0;
    max-height: none;
  }

  .project-form {
    min-height: 100%;
    max-height: 100%;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: max(18px, env(safe-area-inset-top)) max(18px, env(safe-area-inset-right)) max(18px, env(safe-area-inset-bottom)) max(18px, env(safe-area-inset-left));
  }

  .attach-actions-grid,
  .attach-recent-assets {
    grid-template-columns: 1fr;
  }

  .attach-section-header {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    justify-content: stretch;
    justify-items: stretch;
    gap: 6px 10px;
  }

  .attach-section-title {
    min-height: 0;
    display: grid;
    gap: 2px;
    align-content: center;
    align-self: center;
    justify-self: start;
  }

  .attach-section-title > span {
    white-space: nowrap;
    line-height: 1.2;
  }

  .attach-section-title small {
    min-width: 0;
    line-height: 1.25;
  }

  .attach-section-actions {
    grid-column: 2;
    grid-row: 1;
    width: auto;
    justify-self: end;
    align-self: center;
    justify-content: flex-end;
    flex-wrap: wrap;
  }

  .attach-filter-panel {
    gap: 12px;
    padding: 12px;
  }

  .attach-filter-group {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: stretch;
    gap: 8px;
  }

  .attach-filter-label {
    grid-column: 1 / -1;
    min-width: 0;
    min-height: 18px;
  }

  .attach-filter-chip {
    width: 100%;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 8px;
    text-align: center;
  }

  .attach-recent-assets {
    height: clamp(220px, calc(100dvh - 520px), 340px);
    max-height: none;
  }


  .chat-panel.file-mode {
    height: 100vh;
    height: 100dvh;
    min-height: 0;
    grid-template-rows: minmax(0, 1fr);
  }

  .chat-panel.file-mode .chat-header,
  .chat-panel.file-mode .messages,
  .chat-panel.file-mode .composer {
    display: none;
  }
}

/* Beautiful dynamic thinking bubble styles */
.message.assistant.thinking-bubble .message-body {
  background: rgba(255, 255, 255, 0.015);
  border: 1px dashed rgba(15, 111, 134, 0.35);
  box-shadow: 0 8px 32px rgba(15, 111, 134, 0.06), inset 0 1px 0 rgba(255, 255, 255, 0.02);
  /* Hug the "LuLu is thinking" content instead of stretching to the article
     width. The Working… activity list below (long file paths) can make the
     article wide; without this the dashed box would stretch to match it. */
  align-self: flex-start;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 14px 22px;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom-left-radius: 4px;
}

.message.assistant.remote-job-notice .message-body {
  padding: 12px 16px;
  background: rgba(15, 80, 91, 0.18);
  border: 1px solid rgba(94, 234, 212, 0.22);
  color: #cbd5e1;
}

.remote-job-stack {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  font-size: 14px;
  line-height: 1.4;
}

.remote-job-dot {
  width: 8px;
  height: 8px;
  flex: 0 0 auto;
  border-radius: 999px;
  background: #5eead4;
  box-shadow: 0 0 14px rgba(94, 234, 212, 0.55);
  animation: pulse-busy 1.5s infinite ease-in-out;
}

.thinking-stack {
  width: 100%;
  min-height: 88px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
}

.thinking-text {
  font-size: 18px;
  font-weight: 500;
  color: var(--muted);
  background: linear-gradient(90deg, var(--muted) 0%, #ffffff 50%, var(--muted) 100%);
  background-size: 200% auto;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  animation: shine 2s linear infinite;
  display: flex;
  align-items: center;
  text-align: center;
}

.thinking-dots {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.thinking-subtext {
  color: #8fa0b8;
  font-size: 12px;
  font-weight: 700;
  text-align: center;
}

/* Live tool-activity timeline (Hermes Agent Mode) */
.thinking-activity {
  margin: 6px 0 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 3px;
  max-width: 320px;
  text-align: left;
}
.thinking-activity li {
  position: relative;
  padding-left: 16px;
  color: #8fa0b8;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.45;
  opacity: 0.6;
}
.thinking-activity li::before {
  content: "";
  position: absolute;
  left: 4px;
  top: 7px;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--accent);
  opacity: 0.6;
}
.thinking-activity li:last-child {
  opacity: 1;
  color: #c3cee0;
}
.thinking-activity li:last-child::before {
  opacity: 1;
  box-shadow: 0 0 0 3px var(--green-glow);
}

.thinking-live-activity {
  max-width: min(520px, calc(100% - 12px));
}

/* Collapsed header shows the current action; keep it on one line and truncate. */
.thinking-live-activity .message-activity-toggle > span:first-child {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Expanded step list: bullet each action, brighten the most recent one. */
.thinking-live-activity .message-activity-list li {
  position: relative;
  padding-left: 14px;
  opacity: 0.7;
}

.thinking-live-activity .message-activity-list li::before {
  content: "";
  position: absolute;
  left: 3px;
  top: 8px;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.55;
}

.thinking-live-activity .message-activity-list li:last-child {
  color: #ccfbf1;
  opacity: 1;
}

.thinking-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  animation: bounce 1.4s infinite ease-in-out both;
}

.thinking-dot:nth-child(1) {
  animation-delay: -0.32s;
  background: linear-gradient(135deg, var(--primary), var(--primary-hover));
  box-shadow: 0 0 8px rgba(15, 111, 134, 0.5);
}

.thinking-dot:nth-child(2) {
  animation-delay: -0.16s;
  background: linear-gradient(135deg, var(--accent), var(--accent-hover));
  box-shadow: 0 0 8px rgba(20, 184, 166, 0.5);
}

.thinking-dot:nth-child(3) {
  background: linear-gradient(135deg, #10b981, #059669);
  box-shadow: 0 0 8px rgba(16, 185, 129, 0.5);
}

@keyframes shine {
  to {
    background-position: 200% center;
  }
}

@keyframes bounce {
  0%, 80%, 100% { 
    transform: scale(0.4);
    opacity: 0.4;
  } 40% { 
    transform: scale(1.1);
    opacity: 1;
  }
}

/* Terminal blinking block cursor during typing */
.message-body.typing-active::after {
  content: "▊";
  display: inline-block;
  margin-left: 4px;
  color: var(--primary);
  animation: blink 0.8s infinite;
  vertical-align: middle;
}

@keyframes blink {
  0%, 100% { opacity: 0; }
  50% { opacity: 1; }
}

/* Hermes Agent mode is intentionally neutral and separate from LuLu project work. */
body.hermes-agent-mode {
  --ink: #f3f4f6;
  --muted: #9ca3af;
  --line: rgba(156, 163, 175, 0.18);
  --surface: #101114;
  --panel: rgba(156, 163, 175, 0.08);
  --panel-2: rgba(156, 163, 175, 0.055);
  --panel-3: rgba(156, 163, 175, 0.12);
  --card-border: rgba(156, 163, 175, 0.18);
  --shadow: 0 16px 34px rgba(0, 0, 0, 0.28);
}

body.hermes-agent-mode .glow-blob {
  display: none;
}

body.hermes-agent-mode .sidebar,
body.hermes-agent-mode .chat-header,
body.hermes-agent-mode .files-panel {
  background: rgba(17, 18, 22, 0.9);
  border-color: rgba(156, 163, 175, 0.18);
}

body.hermes-agent-mode .chat-panel {
  background: linear-gradient(180deg, #141519 0%, #101114 100%);
}

body.hermes-agent-mode .model-panel,
body.hermes-agent-mode .project-panel,
body.hermes-agent-mode .file-project-line,
body.hermes-agent-mode .files-tabs,
body.hermes-agent-mode .file-tree,
body.hermes-agent-mode .file-editor,
body.hermes-agent-mode .library-panel,
body.hermes-agent-mode .asset-preview,
body.hermes-agent-mode .asset-preview-body,
body.hermes-agent-mode .context-popover {
  border-color: rgba(156, 163, 175, 0.18);
  background: rgba(156, 163, 175, 0.045);
  box-shadow: none;
}

body.hermes-agent-mode #project-select,
body.hermes-agent-mode #model-select,
body.hermes-agent-mode .project-form input,
body.hermes-agent-mode .file-create-form input,
body.hermes-agent-mode .project-form select,
body.hermes-agent-mode .project-form textarea,
body.hermes-agent-mode #message-input,
body.hermes-agent-mode #file-content,
body.hermes-agent-mode #file-workspace-content {
  color: #f3f4f6;
  border-color: rgba(156, 163, 175, 0.22);
  background: rgba(31, 33, 38, 0.82);
}

body.hermes-agent-mode #project-select,
body.hermes-agent-mode #model-select {
  background-image:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18' viewBox='0 0 24 24' fill='none' stroke='%23cbd5e1' stroke-width='2.3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"),
    linear-gradient(rgba(31, 33, 38, 0.82), rgba(31, 33, 38, 0.82));
  background-repeat: no-repeat, no-repeat;
  background-position: right 12px center, 0 0;
  background-size: 18px 18px, 100% 100%;
}

body.hermes-agent-mode #project-select:focus,
body.hermes-agent-mode #model-select:focus,
body.hermes-agent-mode .project-form input:focus,
body.hermes-agent-mode .file-create-form input:focus,
body.hermes-agent-mode .project-form select:focus,
body.hermes-agent-mode .project-form textarea:focus,
body.hermes-agent-mode #message-input:focus,
body.hermes-agent-mode #file-content:focus,
body.hermes-agent-mode #file-workspace-content:focus {
  border-color: rgba(209, 213, 219, 0.56);
  box-shadow: 0 0 0 3px rgba(156, 163, 175, 0.16);
  /* Use background-color (not the `background` shorthand) so the chevron
     background-image on #project-select / #model-select isn't wiped on focus.
     The transition: background 0.2s would otherwise animate the chevron's
     background-position from 0 0 back to "right 12px center", producing the
     "chevron disappears on click then slides back from the left" glitch. */
  background-color: rgba(39, 41, 46, 0.88);
}

body.hermes-agent-mode #message-input,
body.hermes-agent-mode #message-input:focus {
  background: transparent;
  border-color: transparent;
  box-shadow: none;
}

body.hermes-agent-mode #message-input::placeholder {
  color: #737985;
}

body.hermes-agent-mode .template-badge,
body.hermes-agent-mode .project-meta span,
body.hermes-agent-mode .session.active,
body.hermes-agent-mode .session:hover,
body.hermes-agent-mode .files-tab.active,
body.hermes-agent-mode .library-item.selected,
body.hermes-agent-mode .library-use-button,
body.hermes-agent-mode .attach-filter-chip.active,
body.hermes-agent-mode .context-pill.normal,
body.hermes-agent-mode .context-pill.watch,
body.hermes-agent-mode .context-pill.heavy,
body.hermes-agent-mode .context-tool-button,
body.hermes-agent-mode .chat-file-attachment {
  color: #d1d5db;
  border-color: rgba(156, 163, 175, 0.26);
  background: rgba(156, 163, 175, 0.1);
  box-shadow: none;
}

body.hermes-agent-mode #new-chat,
body.hermes-agent-mode #archive-sessions {
  color: #d1d5db;
  border-color: rgba(156, 163, 175, 0.22);
  background: rgba(156, 163, 175, 0.075);
  box-shadow: none;
}

body.hermes-agent-mode #new-chat:hover,
body.hermes-agent-mode #archive-sessions:hover {
  color: #ffffff;
  border-color: rgba(209, 213, 219, 0.34);
  background: rgba(156, 163, 175, 0.13);
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.18);
}

body.hermes-agent-mode .session {
  color: #aeb4bd;
  border-color: rgba(156, 163, 175, 0.08);
  background: rgba(156, 163, 175, 0.035);
}

body.hermes-agent-mode .session-container:hover .session-menu-button,
body.hermes-agent-mode .session-container:focus-within .session-menu-button,
body.hermes-agent-mode .session-container.session-hover .session-menu-button {
  opacity: 0.82;
}

body.hermes-agent-mode .icon-button,
body.hermes-agent-mode .ghost-button,
body.hermes-agent-mode .label-button,
body.hermes-agent-mode .secondary-button,
body.hermes-agent-mode .tool-button,
body.hermes-agent-mode .attach-filter-chip,
body.hermes-agent-mode .segment {
  color: #d1d5db;
  border-color: rgba(156, 163, 175, 0.18);
  background: rgba(156, 163, 175, 0.055);
}

body.hermes-agent-mode .icon-button:hover,
body.hermes-agent-mode .ghost-button:hover,
body.hermes-agent-mode .label-button:hover,
body.hermes-agent-mode .secondary-button:hover,
body.hermes-agent-mode .tool-button:hover,
body.hermes-agent-mode .attach-filter-chip:hover,
body.hermes-agent-mode .segment:hover {
  color: #ffffff;
  border-color: rgba(209, 213, 219, 0.32);
  background: rgba(156, 163, 175, 0.12);
}

body.hermes-agent-mode .primary-button,
body.hermes-agent-mode #send-button,
body.hermes-agent-mode .file-editor-actions .primary-button,
body.hermes-agent-mode .file-workspace-actions .primary-button {
  color: #ffffff;
  background: linear-gradient(135deg, #4b5563, #6b7280);
  border-color: rgba(209, 213, 219, 0.18);
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.24);
}

body.hermes-agent-mode #send-button.stop-mode {
  color: #fbbf24;
  background: rgba(44, 36, 24, 0.92);
  border-color: rgba(180, 117, 12, 0.54);
  box-shadow: 0 8px 20px rgba(20, 14, 6, 0.3);
}

body.hermes-agent-mode #send-button.voice-mode {
  color: #d1d5db;
  background: rgba(156, 163, 175, 0.08);
  border-color: rgba(209, 213, 219, 0.18);
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.22);
}

body.hermes-agent-mode #send-button.listening-mode {
  color: #042f2e;
  background: linear-gradient(135deg, #5eead4, #14b8a6);
  border-color: rgba(45, 212, 191, 0.42);
  box-shadow: 0 8px 24px rgba(20, 184, 166, 0.3);
}

body.hermes-agent-mode .message-body code,
body.hermes-agent-mode .message-body pre code,
body.hermes-agent-mode .message-activity-toggle,
body.hermes-agent-mode .message-activity-single,
body.hermes-agent-mode .message-activity-arrow,
body.hermes-agent-mode .file-tree-node.active,
body.hermes-agent-mode .file-tree-node:hover,
body.hermes-agent-mode .asset-detail-label,
body.hermes-agent-mode .library-item-meta {
  color: #d1d5db;
}

body.hermes-agent-mode .message.assistant .message-body {
  border-color: rgba(156, 163, 175, 0.18);
  background: rgba(35, 36, 40, 0.94);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.22), inset 0 1px 0 rgba(255, 255, 255, 0.035);
}

body.hermes-agent-mode .message.compact-message .message-body {
  border-color: rgba(156, 163, 175, 0.2);
  background: rgba(156, 163, 175, 0.075);
}

body.hermes-agent-mode .message-image-switcher button {
  color: #d1d5db;
  border-color: rgba(156, 163, 175, 0.24);
  background: rgba(17, 18, 22, 0.8);
}

body.hermes-agent-mode .message-image-switcher button:hover,
body.hermes-agent-mode .message-image-switcher button.active {
  color: #ffffff;
  border-color: rgba(209, 213, 219, 0.56);
  background: rgba(107, 114, 128, 0.82);
}

body.hermes-agent-mode .message.assistant.thinking-bubble .message-body {
  border-color: rgba(156, 163, 175, 0.24);
  background: rgba(156, 163, 175, 0.055);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.22), inset 0 1px 0 rgba(255, 255, 255, 0.025);
}

body.hermes-agent-mode .thinking-dot:nth-child(1),
body.hermes-agent-mode .thinking-dot:nth-child(2),
body.hermes-agent-mode .thinking-dot:nth-child(3) {
  background: linear-gradient(135deg, #9ca3af, #6b7280);
  box-shadow: 0 0 8px rgba(156, 163, 175, 0.36);
}

body.hermes-agent-mode .message-body.typing-active::after {
  color: #d1d5db;
}

.mobile-reply-spacer {
  display: none;
}

/* Reply anchor: keep the just-sent message pinned near the top with breathing
   room below while LuLu answers, so the view stays locked instead of following
   the reply to the bottom. Applies on desktop and mobile alike. */
.messages.mobile-reply-anchored,
.messages.mobile-reply-settled {
  scroll-padding-top: 12px;
}

.messages.mobile-reply-anchored .mobile-reply-spacer,
.messages.mobile-reply-settled .mobile-reply-spacer {
  display: block;
  flex: 0 0 var(--mobile-reply-spacer-height, 56vh);
  pointer-events: none;
}

/* Hermes Agent Mode Dialogs */
body.hermes-agent-mode .project-dialog,
body.hermes-agent-mode .archive-dialog,
body.hermes-agent-mode .persona-dialog,
body.hermes-agent-mode .file-create-dialog,
body.hermes-agent-mode .attach-dialog {
  background: rgba(17, 18, 22, 0.96);
  border-color: rgba(156, 163, 175, 0.18);
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.52);
}

body.hermes-agent-mode .attach-action-card,
body.hermes-agent-mode .attach-recent-assets,
body.hermes-agent-mode .mobile-assets-panel,
body.hermes-agent-mode .library-filter-panel,
body.hermes-agent-mode .attach-filter-panel {
  border-color: rgba(156, 163, 175, 0.18);
  background: rgba(156, 163, 175, 0.055);
}

body.hermes-agent-mode .library-panel .library-filter-panel,
body.hermes-agent-mode .mobile-assets-panel .library-filter-panel {
  background: rgba(31, 33, 38, 0.96);
}

body.hermes-agent-mode .attach-action-card:hover:not(:disabled) {
  border-color: rgba(209, 213, 219, 0.32);
  background: rgba(156, 163, 175, 0.12);
}

body.hermes-agent-mode .mobile-attach-count-badge:not([hidden]) {
  display: grid;
  position: absolute;
  top: -6px;
  right: -6px;
  min-width: 18px;
  height: 18px;
  box-sizing: border-box;
  /* Bright light-gray pill with dark text so the count actually pops on the
     very dark agent-mode composer — the previous #4b5563-on-#121317 was the
     same value range as the surrounding chrome and was easy to miss on a
     phone glance. Keep the dark border for clean definition against either
     light or dark backgrounds. */
  border: 2px solid rgba(17, 18, 22, 0.95);
  border-radius: 999px;
  place-items: center;
  padding: 0 4px;
  color: #111827;
  background: #e5e7eb;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.35);
  font-size: 10px;
  font-weight: 800;
  line-height: 14px;
  z-index: 2;
}

@media (max-width: 899px) {
  body.hermes-agent-mode .mobile-attach-count-badge:not([hidden]) {
    top: -24px;
    left: 50%;
    right: auto;
    transform: translateX(-50%);
    min-width: 20px;
    height: 20px;
    padding: 0 5px;
    font-size: 11px;
    line-height: 20px;
  }
}

/* App modal (confirm / prompt) — consistent replacement for native dialogs */
.app-modal {
  width: min(460px, calc(100vw - 28px));
  border: 1px solid var(--card-border);
  border-radius: 16px;
  padding: 0;
  color: var(--ink);
  background: #171a29;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.42);
}

.app-modal::backdrop {
  background: rgba(0, 0, 0, 0.52);
  backdrop-filter: blur(5px);
}

.app-modal-shell {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 24px;
  margin: 0;
}

.app-modal-message {
  margin: 0;
  color: var(--muted);
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
}

.app-modal-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.app-modal-field span {
  font-size: 14px;
  color: var(--muted);
}

.app-modal-field input {
  width: 100%;
  min-width: 0;
  padding: 11px 13px;
  border: 1px solid rgba(20, 184, 166, 0.22);
  border-radius: 10px;
  color: var(--ink);
  color-scheme: dark;
  background:
    linear-gradient(135deg, rgba(20, 184, 166, 0.08), rgba(15, 111, 134, 0.045)),
    rgba(8, 20, 28, 0.9);
  outline: none;
  font: inherit;
  transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
}

.app-modal-field input:focus {
  border-color: rgba(45, 212, 191, 0.62);
  box-shadow: 0 0 0 3px rgba(20, 184, 166, 0.16);
  background-color: rgba(9, 32, 42, 0.96);
}

/* Transient toast — replaces native alert() */
.app-toast-layer {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%);
  z-index: 1300;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
  pointer-events: none;
  width: min(440px, calc(100vw - 28px));
}

.app-toast {
  pointer-events: auto;
  max-width: 100%;
  padding: 11px 16px;
  border-radius: 12px;
  border: 1px solid var(--card-border);
  background: #1c2030;
  color: var(--ink);
  font-size: 15px;
  line-height: 1.45;
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.38);
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.app-toast.visible {
  opacity: 1;
  transform: translateY(0);
}

.app-toast.error {
  border-color: rgba(239, 68, 68, 0.5);
  background: #2a1b22;
}

.app-toast.ok {
  border-color: rgba(45, 212, 191, 0.5);
  background: #16282c;
}

/* Voice Overlay */
.voice-overlay {
  margin: auto;
  border: none;
  background: transparent;
  padding: 0;
  width: 100vw;
  height: 100vh;
  max-width: 100%;
  max-height: 100%;
}

.voice-overlay::backdrop {
  background: rgba(15, 23, 42, 0.85);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}

.voice-overlay-shell {
  display: flex;
  flex-direction: column;
  align-items: center;
  /* Symmetric column, vertically centered; "safe" keeps the top reachable
     when a short screen overflows (browsers without it use plain center). */
  justify-content: center;
  justify-content: safe center;
  width: 100%;
  height: 100%;
  gap: 20px;
  padding: 24px 0;
  overflow-y: auto;
  /* The overlay is stopped with tap/hold gestures: stop double-tap zoom,
     text selection, and the iOS long-press callout from hijacking them. */
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

/* LuLu's face during voice mode; the ring glows per state like the bars. */
.voice-avatar-ring {
  width: min(300px, 56vw);
  aspect-ratio: 1;
  border-radius: 50%;
  overflow: hidden;
  flex-shrink: 0;
  border: 3px solid rgba(94, 234, 212, 0.55);
  box-shadow: 0 0 40px rgba(94, 234, 212, 0.35);
  transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

.voice-avatar {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  -webkit-user-drag: none;
}

.voice-overlay[data-status="connecting"] .voice-avatar-ring,
.voice-overlay[data-status="reconnecting"] .voice-avatar-ring {
  border-color: rgba(148, 163, 184, 0.7);
  box-shadow: 0 0 32px rgba(148, 163, 184, 0.3);
  animation: avatar-breathe 1.2s ease-in-out infinite;
}

.voice-overlay[data-status="listening"] .voice-avatar-ring {
  border-color: #5eead4;
  box-shadow: 0 0 44px rgba(94, 234, 212, 0.45);
  animation: avatar-breathe 3s ease-in-out infinite;
}

.voice-overlay[data-status="thinking"] .voice-avatar-ring {
  border-color: #fcd34d;
  box-shadow: 0 0 44px rgba(252, 211, 77, 0.5);
}

.voice-overlay[data-status="speaking"] .voice-avatar-ring {
  border-color: #38bdf8;
  box-shadow: 0 0 56px rgba(56, 189, 248, 0.6);
  animation: avatar-talk 0.8s ease-in-out infinite alternate;
}

@keyframes avatar-breathe {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.03); }
}

@keyframes avatar-talk {
  0% { transform: scale(1); }
  100% { transform: scale(1.045); }
}

.voice-stop-hint {
  margin: 0;
  color: rgba(226, 232, 240, 0.55);
  font-size: 13px;
  text-align: center;
  padding: 0 24px;
}

/* The RPG dialogue box carries the name + status now in every mode; the old
   big centered status heading stays in the DOM but is never shown. */
.voice-status-block {
  display: none;
}

#voice-status-text {
  margin: 0;
  color: #ffffff;
  font-size: 28px;
  font-weight: 700;
  letter-spacing: 0.02em;
  background: linear-gradient(to right, #5eead4, #38bdf8);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  transition: all 0.3s ease;
}

/* Voice waveform: slim straight equalizer lines with a rainbow sweep. In
   voice mode it sits right BELOW LuLu's portrait, spanning the full image
   width; in camera mode it stays a compact centered row. Each bar carries
   its own hue (--bar-color), stagger slot (--i) and dance height (--amp);
   the status rules only change tempo and peak. */
.voice-wave-container {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  height: 36px;
  margin-top: 16px;
}

.voice-overlay:not(.camera-on) .voice-wave-container {
  width: min(300px, 56vw);
  justify-content: space-between;
  gap: 0;
  padding: 0 10px;
  margin-top: -4px;
  pointer-events: none;
}

/* Keep Gohan's box well clear below the avatar + waveform stack. */
.voice-overlay:not(.camera-on) .voice-rpg-gohan {
  margin-top: 36px;
}

.wave-bar {
  width: 3px;
  height: 32px;
  border-radius: 2px;
  background: var(--bar-color, #5eead4);
  transform: scaleY(0.22);
  transform-origin: center;
  opacity: 0.55;
}

.wave-bar:nth-child(1)  { --bar-color: #5eead4; --i: 0;  --amp: 0.45; }
.wave-bar:nth-child(2)  { --bar-color: #4ee3da; --i: 1;  --amp: 0.7; }
.wave-bar:nth-child(3)  { --bar-color: #41d9e3; --i: 2;  --amp: 0.55; }
.wave-bar:nth-child(4)  { --bar-color: #38cdee; --i: 3;  --amp: 0.9; }
.wave-bar:nth-child(5)  { --bar-color: #38bdf8; --i: 4;  --amp: 0.65; }
.wave-bar:nth-child(6)  { --bar-color: #4faefa; --i: 5;  --amp: 1; }
.wave-bar:nth-child(7)  { --bar-color: #60a5fa; --i: 6;  --amp: 0.8; }
.wave-bar:nth-child(8)  { --bar-color: #818cf8; --i: 7;  --amp: 0.95; }
.wave-bar:nth-child(9)  { --bar-color: #a78bfa; --i: 8;  --amp: 0.85; }
.wave-bar:nth-child(10) { --bar-color: #c084fc; --i: 9;  --amp: 1; }
.wave-bar:nth-child(11) { --bar-color: #d678fa; --i: 10; --amp: 0.7; }
.wave-bar:nth-child(12) { --bar-color: #e879f9; --i: 11; --amp: 0.9; }
.wave-bar:nth-child(13) { --bar-color: #f472b6; --i: 12; --amp: 0.6; }
.wave-bar:nth-child(14) { --bar-color: #fb7185; --i: 13; --amp: 0.8; }
.wave-bar:nth-child(15) { --bar-color: #fb923c; --i: 14; --amp: 0.5; }
.wave-bar:nth-child(16) { --bar-color: #fbbf24; --i: 15; --amp: 0.4; }

.voice-overlay[data-status="listening"] .wave-bar {
  --wave-peak: calc(var(--amp) * 0.5);
  animation: wave-line 1.8s ease-in-out calc(var(--i) * 0.11s) infinite;
}

.voice-overlay[data-status="thinking"] .wave-bar {
  --wave-peak: calc(var(--amp) * 0.32);
  animation: wave-line 2.4s ease-in-out calc(var(--i) * 0.16s) infinite;
}

.voice-overlay[data-status="speaking"] .wave-bar {
  --wave-peak: var(--amp);
  animation: wave-line 0.72s ease-in-out calc(var(--i) * 0.05s) infinite;
}

@keyframes wave-line {
  0%, 100% { transform: scaleY(0.22); opacity: 0.55; }
  50% { transform: scaleY(var(--wave-peak, 0.5)); opacity: 1; }
}

.voice-controls-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 24px;
  margin-top: 40px;
}

/* Selfie preview shown while the user shares their camera with LuLu. The
   mirror is visual only — captured frames are sent unmirrored. */
.voice-camera-preview {
  display: none;
  width: min(880px, 78vw);
  max-height: 56vh;
  border-radius: 16px;
  border: 1px solid rgba(94, 234, 212, 0.4);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.45);
  transform: scaleX(-1);
}

.voice-overlay.camera-on .voice-camera-preview {
  display: block;
}

/* Screen shares must not be mirrored — text would read backwards. */
.voice-overlay.screen-share .voice-camera-preview {
  transform: none;
}

/* With the camera on, the toggle would overflow small phone screens — and
   the stop gestures already end the whole session, so hide the controls. */
.voice-overlay.camera-on .voice-controls-row {
  display: none;
}

/* RPG-style dialogue boxes — every mode, every device. LuLu's box sits above
   the avatar and Gohan's box (live transcript of what the user says) below
   it, both centered columns so wide desktop screens read like the chat zone.
   Camera mode pins LuLu's bar to the top and Gohan's to the bottom; on
   phones the video fills the screen in portrait behind the two bars. */
.voice-rpg-bar {
  display: flex;
  width: min(720px, calc(100vw - 32px));
  gap: 10px;
  align-items: flex-start;
}

/* In voice mode the big centered avatar IS LuLu's portrait. */
.voice-overlay:not(.camera-on) .voice-rpg-lulu .voice-rpg-avatar {
  display: none;
}

/* Voice mode: both boxes hold their full two-line size at all times, so the
   layout never shifts as captions appear, stream, or fade away. */
.voice-overlay:not(.camera-on) .voice-rpg-box {
  height: 112px;
  min-height: 0;
  max-height: none;
  overflow: hidden;
}

.voice-overlay.camera-on .voice-rpg-bar {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  width: min(880px, calc(100vw - 24px));
  z-index: 2;
}

.voice-overlay.camera-on .voice-rpg-lulu {
  top: calc(12px + env(safe-area-inset-top, 0px));
}

.voice-overlay.camera-on .voice-rpg-gohan {
  bottom: calc(12px + env(safe-area-inset-bottom, 0px));
  align-items: flex-end;
}

.voice-overlay.camera-on .voice-avatar-ring {
  display: none;
}

.voice-overlay.camera-on .voice-overlay-shell {
  padding-top: calc(110px + env(safe-area-inset-top, 0px));
  padding-bottom: calc(120px + env(safe-area-inset-bottom, 0px));
}

/* Phones in camera mode: full-screen portrait video behind the dialogue
   bars; the wave bars and hint get out of the way. */
@media (max-width: 768px) {
  .voice-overlay.camera-on .voice-camera-preview {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    max-height: none;
    object-fit: cover;
    border-radius: 0;
    border: none;
    z-index: 1;
  }

  .voice-overlay.camera-on .voice-wave-container,
  .voice-overlay.camera-on .voice-stop-hint {
    display: none;
  }

  /* Phone voice mode: nudge the avatar + waveform down so the top isn't
     heavy, and let the camera button float centered in the empty space
     below (auto margins split the leftover height above and below it,
     while the hint stays pinned at the very bottom). */
  .voice-overlay:not(.camera-on) .voice-avatar-ring {
    margin-top: 5vh;
  }

  .voice-overlay:not(.camera-on) .voice-controls-row {
    margin-top: auto;
  }

  .voice-overlay:not(.camera-on) .voice-stop-hint {
    margin-top: auto;
  }
}

.voice-rpg-avatar {
  width: 64px;
  aspect-ratio: 1;
  border-radius: 14px;
  overflow: hidden;
  flex-shrink: 0;
  border: 2px solid rgba(94, 234, 212, 0.55);
  box-shadow: 0 0 18px rgba(94, 234, 212, 0.3);
  transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

.voice-rpg-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  -webkit-user-drag: none;
}

.voice-overlay[data-status="thinking"] .voice-rpg-lulu .voice-rpg-avatar {
  border-color: #fcd34d;
  box-shadow: 0 0 18px rgba(252, 211, 77, 0.45);
}

.voice-overlay[data-status="speaking"] .voice-rpg-lulu .voice-rpg-avatar {
  border-color: #38bdf8;
  box-shadow: 0 0 24px rgba(56, 189, 248, 0.55);
}

.voice-overlay[data-status="connecting"] .voice-rpg-lulu .voice-rpg-avatar,
.voice-overlay[data-status="reconnecting"] .voice-rpg-lulu .voice-rpg-avatar {
  border-color: rgba(148, 163, 184, 0.7);
  box-shadow: 0 0 14px rgba(148, 163, 184, 0.3);
}

.voice-rpg-box {
  flex: 1;
  min-height: 64px;
  max-height: 30vh;
  overflow-y: auto;
  background: rgba(15, 23, 42, 0.85);
  border: 1px solid rgba(94, 234, 212, 0.4);
  border-radius: 14px;
  padding: 10px 14px;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.4);
}

.voice-rpg-head {
  display: flex;
  align-items: baseline;
  gap: 10px;
}

.voice-rpg-name {
  color: #5eead4;
  font-weight: 700;
  font-size: 16px;
  letter-spacing: 0.03em;
}

.voice-rpg-name-gohan {
  color: #38bdf8;
}

.voice-rpg-gohan .voice-rpg-box {
  border-color: rgba(56, 189, 248, 0.4);
}

.voice-rpg-gohan .voice-rpg-avatar {
  border-color: rgba(56, 189, 248, 0.55);
  box-shadow: 0 0 18px rgba(56, 189, 248, 0.3);
}

#voice-rpg-status {
  color: rgba(226, 232, 240, 0.6);
  font-size: 12px;
}

/* Captions are two-line rolling subtitles everywhere: the caption is its own
   scroller (scrollbar hidden, JS pins the tail) so old words slide away as
   new ones stream in and the box never has to grow. */
#voice-rpg-caption,
#voice-rpg-user-caption {
  margin: 6px 0 0;
  color: #f1f5f9;
  font-size: 17px;
  line-height: 1.55;
  white-space: pre-wrap;
  overflow-wrap: break-word;
  max-height: calc(1.55em * 2);
  overflow-y: auto;
  scrollbar-width: none;
  opacity: 1;
  transition: opacity 1.2s ease;
}

#voice-rpg-caption::-webkit-scrollbar,
#voice-rpg-user-caption::-webkit-scrollbar {
  display: none;
}

/* Spoken text fades away shortly after the turn ends (JS clears it after
   the transition) so captions never linger on screen. */
#voice-rpg-caption.voice-caption-fade,
#voice-rpg-user-caption.voice-caption-fade {
  opacity: 0;
}

#voice-rpg-caption:empty,
#voice-rpg-user-caption:empty {
  display: none;
}

/* Camera mode: keep the dialogue layer airy so it never walls off the
   video — translucent boxes, lighter borders, shadowed text for legibility. */
.voice-overlay.camera-on .voice-rpg-box {
  background: rgba(15, 23, 42, 0.42);
  border-color: rgba(94, 234, 212, 0.22);
  box-shadow: none;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

.voice-overlay.camera-on .voice-rpg-gohan .voice-rpg-box {
  border-color: rgba(56, 189, 248, 0.22);
}

.voice-overlay.camera-on #voice-rpg-caption,
.voice-overlay.camera-on #voice-rpg-user-caption {
  color: rgba(241, 245, 249, 0.85);
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.7);
}

.voice-overlay.camera-on #voice-rpg-status {
  color: rgba(226, 232, 240, 0.55);
}

/* Phones and tablets: camera-mode boxes stay slim over the video. */
@media (max-width: 1024px) {
  .voice-overlay.camera-on .voice-rpg-box {
    min-height: 0;
  }
}

.voice-camera-button {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: rgba(94, 234, 212, 0.15);
  border: 1px solid rgba(94, 234, 212, 0.35);
  color: #5eead4;
  cursor: pointer;
  transition: all 0.2s ease;
}

.voice-camera-button:hover {
  background: rgba(94, 234, 212, 0.3);
  color: #ffffff;
  transform: scale(1.05);
}

.voice-camera-button.active {
  background: rgba(94, 234, 212, 0.5);
  border-color: rgba(94, 234, 212, 0.8);
  color: #0f172a;
}

.voice-camera-button svg {
  width: 24px;
  height: 24px;
}

/* Phones only (<=760px, below the tablet floor of 761px): nudge the main reading
   text from 18px down to 16px — base text, chat messages, and the composer input.
   Placed last so it wins over the <=899px (tablet+phone) 18px rules; tablets and
   desktop are unaffected. */
/* backdrop-filter blur on the scrollable file view causes severe scroll jank /
   freezes on mobile with long documents — drop it there (the faint surface tint
   is kept, so it looks the same minus the background blur). */
@media (max-width: 899px) {
  #file-workspace-content,
  .file-workspace-preview {
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
  }
  /* The workspace back button reads "Back to Chat" on desktop but just "Chat"
     on phones to save header width — hide the "Back to " prefix only. */
  .file-workspace-header .workspace-back-full {
    display: none;
  }
}

@media (max-width: 760px) {
  body { font-size: 16px; }
  .message-body { font-size: 16px; }
  #message-input { font-size: 16px; }
}

/* Mobile: Project Files as a right-side drawer (opened from the header Files
   button) instead of being stacked at the bottom of the page. Tap the dimmed
   backdrop to close. Reuses the same .files-panel + the shared backdrop. */
@media (max-width: 899px) {
  /* Full-screen Files drawer (matches the Chats/Project drawer), sliding in from
     the right. Overrides the ≤899 display:none so it can render. */
  .files-panel {
    display: grid;
    grid-template-rows: auto auto auto minmax(0, 1fr);
    gap: 10px;
    position: fixed;
    inset: 0;
    width: 100vw;
    max-width: 100vw;
    height: 100vh;
    height: 100dvh;
    min-height: 0;
    margin: 0;
    border: 0;
    border-radius: 0;
    background: rgba(18, 21, 34, 0.98);
    padding: max(14px, env(safe-area-inset-top)) max(14px, env(safe-area-inset-right)) max(14px, env(safe-area-inset-bottom)) max(14px, env(safe-area-inset-left));
    transform: translateX(102%);
    transition: transform 0.22s ease;
    z-index: 60;
    overflow: hidden;
  }
  body.hermes-agent-mode .files-panel {
    background: #111216;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
  }
  body.mobile-files-open .files-panel {
    transform: translateX(0);
  }
  body.mobile-files-open .mobile-controls-backdrop {
    display: block;
    opacity: 1;
    pointer-events: auto;
  }
  body.mobile-controls-open,
  body.mobile-files-open {
    overflow: hidden;
    overscroll-behavior: none;
  }
  body.mobile-controls-open .chat-panel,
  body.mobile-files-open .chat-panel {
    pointer-events: none;
  }
  body.mobile-controls-open .sidebar,
  body.mobile-files-open .files-panel {
    overscroll-behavior: contain;
  }
  /* Files drawer: show the back button, hide its title; hide the Project drawer
     header text too. */
  .mobile-files-back {
    display: grid;
  }
  .mobile-control-header .eyebrow,
  #mobile-control-title {
    display: none;
  }
  /* "LuLu The Bard" brand text on the left of the Project drawer header. */
  .mobile-brand {
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 8px;
    text-align: left;
    color: #fff;
    line-height: 1.2;
  }
  .mobile-brand img {
    width: 24px;
    height: 24px;
    flex: 0 0 auto;
    border-radius: 8px;
    object-fit: cover;
    background: #061827;
    box-shadow: 0 4px 14px rgba(15, 111, 134, 0.22);
  }
  .mobile-brand-copy {
    min-width: 0;
    display: inline-flex;
    align-items: baseline;
    gap: 6px;
    overflow: hidden;
    white-space: nowrap;
  }
  .mobile-brand-name {
    flex: 0 0 auto;
    font-size: 16px;
    font-weight: 700;
  }
  .mobile-brand-account {
    min-width: 0;
    color: var(--text-muted);
    font-size: 12px;
    font-weight: 400;
    text-overflow: ellipsis;
    white-space: nowrap;
    overflow: hidden;
  }
  .mobile-control-header > div {
    text-align: left;
  }
  /* Remove the green status dot on mobile. */
  .status-pill {
    display: none;
  }
  .files-header {
    display: flex;
    align-items: center;
    gap: 8px;
  }
  .files-heading {
    flex: 1 1 0;
    min-width: 0;
  }
  .files-header-actions {
    flex: 0 0 auto;
    min-width: 0;
    margin-left: 0;
  }
  #file-status {
    min-width: 0;
    width: 100%;
    max-width: 100%;
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .file-project-line {
    gap: 2px;
    padding: 8px 10px;
  }
  #file-project-name {
    font-size: 13px;
  }
  #file-project-path {
    font-size: 11px;
  }
  .files-tabs {
    min-height: 36px;
    padding: 3px;
  }
  .files-tab {
    min-height: 28px;
    font-size: 12px;
  }
  .files-view,
  .assets-view {
    gap: 10px;
    grid-template-rows: minmax(0, 1fr) minmax(150px, min(34dvh, 240px));
  }
  .files-view.no-file-selected,
  .files-view.preview-suppressed,
  .assets-view.no-asset-selected,
  .assets-view.preview-suppressed {
    grid-template-rows: minmax(0, 1fr);
  }
  .files-view.no-file-selected .file-editor,
  .files-view.preview-suppressed .file-editor,
  .assets-view.no-asset-selected .asset-preview,
  .assets-view.preview-suppressed .asset-preview {
    display: none;
  }
  .file-tree,
  .file-editor,
  .file-content-shell,
  .asset-preview,
  .asset-preview-body {
    min-height: 0;
  }
  .file-tree,
  .asset-preview-body,
  .library-list {
    overscroll-behavior: contain;
  }
  .file-editor {
    gap: 8px;
  }
  .file-editor-header {
    font-size: 11px;
  }
  #file-content {
    padding: 10px;
    font-size: 12px;
    line-height: 1.5;
  }
  .file-editor-actions {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 8px;
  }
  .file-editor-actions .primary-button,
  .file-editor-actions .secondary-button {
    flex: 0 0 auto;
    min-width: 0;
    height: 36px;
    min-height: 36px;
    padding: 0 10px;
    justify-content: center;
    font-size: 13px;
  }
  .file-editor-actions .danger-icon-button {
    width: 36px;
    height: 36px;
    margin-left: auto;
  }
  /* Files-drawer Assets filter: render in-flow instead of an absolute overlay
     that gets clipped on the small panel, so every option is reachable (like the
     attach dialog). The list scrolls below it. */
  .library-panel {
    display: flex;
    flex-direction: column;
  }
  .library-panel .library-list {
    flex: 1;
    min-height: 0;
  }
  .library-panel .library-filter-panel {
    position: static;
    inset: auto;
    z-index: auto;
    max-height: min(58dvh, 420px);
    overflow-y: auto;
    overscroll-behavior: contain;
  }
}

@media (min-width: 761px) and (max-width: 899px) {
  .files-view,
  .assets-view {
    grid-template-rows: minmax(0, 1fr) minmax(0, 1fr);
  }

  .files-view.no-file-selected,
  .files-view.preview-suppressed,
  .assets-view.no-asset-selected,
  .assets-view.preview-suppressed {
    grid-template-rows: minmax(0, 1fr);
  }

  .library-list {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .asset-visual-preview {
    height: 400px;
    min-height: 400px;
  }
}

@media (max-width: 600px) {
  .linked-template-list {
    grid-template-columns: 1fr;
  }
}

@media (min-width: 1181px) and (max-width: 1440px) {
  .app-shell {
    grid-template-columns: minmax(0, 25%) minmax(0, 50%) minmax(0, 25%);
  }
}

/* A deployed PWA can stay open for days. Keep update UI small and explicit so
   a stale shell never silently mixes with a newer backend. */
.app-update-banner {
  position: fixed;
  z-index: 12000;
  right: max(16px, env(safe-area-inset-right));
  bottom: max(16px, env(safe-area-inset-bottom));
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  color: var(--text, #eef6f8);
  background: #132733;
  border: 1px solid rgba(67, 213, 199, 0.42);
  border-radius: 8px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.3);
  font-size: 14px;
}

.app-update-banner button {
  min-height: 36px;
  padding: 0 12px;
  color: inherit;
  background: rgba(35, 178, 169, 0.18);
  border: 1px solid rgba(67, 213, 199, 0.44);
  border-radius: 7px;
  cursor: pointer;
}

.app-update-banner .app-update-dismiss {
  width: 36px;
  padding: 0;
  color: var(--muted, #9ba9b3);
  background: transparent;
  border-color: transparent;
  font-size: 20px;
}

@media (max-width: 640px) {
  .app-update-banner {
    left: 12px;
    right: 12px;
    bottom: max(12px, env(safe-area-inset-bottom));
  }

  .app-update-banner span {
    flex: 1;
  }
}

.activity-center-button {
  position: relative;
  width: 46px;
  height: 46px;
  flex: 0 0 46px;
}

.global-search-button {
  flex: 0 0 42px;
  width: 42px;
  height: 42px;
}

.global-search-dialog {
  width: min(720px, calc(100vw - 32px));
  max-height: min(760px, calc(100dvh - 32px));
  padding: 0;
  color: var(--text);
  background: #111827;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.global-search-shell {
  display: flex;
  flex-direction: column;
  min-height: min(620px, calc(100dvh - 34px));
  padding: 22px;
  background: #111827;
}

.global-search-field {
  display: grid;
  grid-template-columns: 20px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  margin-top: 16px;
  padding: 0 14px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 7px;
}

.global-search-field svg {
  width: 18px;
  height: 18px;
  color: var(--muted);
}

.global-search-field input {
  min-width: 0;
  height: 48px;
  padding: 0;
  color: var(--text);
  background: transparent;
  border: 0;
  outline: 0;
  font: inherit;
}

.global-search-status {
  min-height: 20px;
  margin: 10px 2px 8px;
  color: var(--muted);
  font-size: 0.78rem;
}

.global-search-results {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  gap: 6px;
  min-height: 0;
  overflow-y: auto;
}

.global-search-result {
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr) max-content;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 62px;
  padding: 10px 12px;
  color: var(--text);
  text-align: left;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 7px;
}

.global-search-result:hover,
.global-search-result:focus-visible {
  background: var(--panel-2);
  border-color: var(--line);
}

.global-search-result > svg {
  width: 18px;
  height: 18px;
  color: var(--accent-soft);
}

.global-search-result-copy {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 3px;
}

.global-search-result-copy strong,
.global-search-result-copy small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.global-search-result-copy strong {
  font-weight: 600;
}

.global-search-result-copy small,
.global-search-result-type,
.global-search-empty {
  color: var(--muted);
  font-size: 0.76rem;
}

.global-search-result-type {
  text-transform: capitalize;
}

.global-search-empty {
  margin: auto;
}

.activity-center-count {
  position: absolute;
  top: 3px;
  right: 3px;
  min-width: 17px;
  height: 17px;
  padding: 0 4px;
  display: grid;
  place-items: center;
  color: #062126;
  background: #55e3d2;
  border-radius: 9px;
  font-size: 10px;
  font-weight: 700;
  line-height: 1;
}

.activity-center-dialog {
  width: min(620px, calc(100vw - 32px));
  max-height: min(760px, calc(100dvh - 32px));
  padding: 0;
  color: var(--ink);
  background: #121827;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.activity-center-dialog::backdrop {
  background: rgba(2, 8, 16, 0.72);
}

.activity-center-shell {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  max-height: inherit;
  padding: 20px;
}

.activity-center-list {
  min-height: 180px;
  overflow: auto;
  display: grid;
  align-content: start;
  gap: 8px;
}

.activity-job {
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  min-height: 64px;
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.035);
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: 7px;
}

.activity-job-icon {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  color: #79e7da;
}

.activity-job-icon svg {
  width: 20px;
  height: 20px;
}

.activity-job.pending .activity-job-icon svg {
  animation: activity-spin 1.1s linear infinite;
}

@keyframes activity-spin {
  to { transform: rotate(360deg); }
}

.activity-job-copy {
  min-width: 0;
}

.activity-job-copy strong,
.activity-job-copy small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.activity-job-copy strong {
  font-size: 14px;
  font-weight: 500;
}

.activity-job-copy small {
  color: var(--muted);
  font-size: 12px;
}

.activity-job-state {
  color: var(--muted);
  font-size: 12px;
  text-transform: capitalize;
}

.activity-job-cancel {
  min-width: 44px;
  min-height: 36px;
  padding: 0 10px;
  color: #f0c77c;
  background: rgba(114, 78, 24, 0.22);
  border: 1px solid rgba(202, 145, 47, 0.42);
  border-radius: 7px;
}

.context-receipt {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 0.78rem;
}

.context-receipt summary {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 28px;
  cursor: pointer;
  list-style: none;
  color: var(--muted);
}

.context-receipt summary::-webkit-details-marker {
  display: none;
}

.context-receipt summary svg {
  width: 14px;
  height: 14px;
}

.context-receipt[open] summary {
  color: var(--accent-soft);
}

.context-receipt-list {
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr);
  gap: 5px 12px;
  margin: 4px 0 0;
  padding: 10px 12px;
  border-left: 1px solid rgba(94, 234, 212, 0.32);
}

.context-receipt-list dt {
  color: var(--accent-soft);
}

.context-receipt-list dd {
  min-width: 0;
  margin: 0;
  overflow-wrap: anywhere;
}

.activity-empty {
  padding: 40px 16px;
  color: var(--muted);
  text-align: center;
}

@media (max-width: 899px) {
  .global-search-dialog {
    width: 100vw;
    height: 100dvh;
    max-width: none;
    max-height: none;
    margin: 0;
    border: 0;
    border-radius: 0;
    background: #111827;
  }

  .global-search-shell {
    min-height: 100dvh;
    padding: max(16px, env(safe-area-inset-top)) 16px max(16px, env(safe-area-inset-bottom));
    background: #111827;
  }

  .activity-center-button {
    width: 42px;
    height: 42px;
    flex-basis: 42px;
  }

  .activity-center-dialog {
    width: 100vw;
    height: 100dvh;
    max-width: none;
    max-height: none;
    margin: 0;
    border: 0;
    border-radius: 0;
    background: #111827;
  }

  .activity-center-shell {
    background: #111827;
  }

  .activity-center-shell {
    height: 100%;
    padding: max(16px, env(safe-area-inset-top)) 16px max(16px, env(safe-area-inset-bottom));
  }
}
