html, body {
  margin: 0;
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #1a1a1a;
}

#root, .layout {
  height: 100%;
}

#almo-shell-body {
  display: flex;
  height: 100%;
}

#almo-content-pane {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-width: 0;
}

#almo-content-pane iframe {
  flex: 1;
  border: none;
  width: 100%;
  height: 100%;
}

#almo-content-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: #888;
}

.almo-chat-modal-anchor {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  width: 2.75rem;
  height: 2.75rem;
  z-index: 60;
}

button.almo-chat-modal-trigger {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  border: none;
  background: #1a1a1a;
  color: white;
  cursor: pointer;
  box-shadow: 0 1px 6px rgba(0, 0, 0, 0.3);
  transition: transform 0.15s ease;
}

.almo-chat-modal-trigger:hover {
  transform: scale(1.1);
}

.almo-chat-modal-trigger:active {
  transform: scale(0.9);
}

.almo-chat-modal-trigger-icon {
  position: absolute;
  top: 50%;
  left: 50%;
  transition: transform 0.2s ease, opacity 0.2s ease;
}

.almo-chat-modal-trigger-icon-bot {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1) rotate(0deg);
}

.almo-chat-modal-trigger-icon-chevron {
  opacity: 0;
  transform: translate(-50%, -50%) scale(0) rotate(-90deg);
}

.almo-chat-modal-trigger[data-state="open"] .almo-chat-modal-trigger-icon-bot {
  opacity: 0;
  transform: translate(-50%, -50%) scale(0) rotate(90deg);
}

.almo-chat-modal-trigger[data-state="open"] .almo-chat-modal-trigger-icon-chevron {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1) rotate(0deg);
}

.almo-chat-modal-content {
  display: flex;
  flex-direction: column;
  width: 18rem;
  height: 25rem;
  background: #131316;
  color: #f2f2f2;
  border: 1px solid #2a2a2e;
  border-radius: 0.75rem;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
  overflow: hidden;
  outline: none;
  z-index: 60;
}

@media (min-width: 768px) {
  .almo-chat-modal-content {
    width: 26.25rem;
    height: 34.375rem;
  }
}

.almo-chat-modal-content[data-state="open"] {
  animation: almo-modal-content-in 0.2s ease-out;
}

.almo-chat-modal-content[data-state="closed"] {
  animation: almo-modal-content-out 0.2s ease-in;
}

@keyframes almo-modal-content-in {
  from {
    opacity: 0;
    transform: translate(50%, 50%) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translate(0, 0) scale(1);
  }
}

@keyframes almo-modal-content-out {
  from {
    opacity: 1;
    transform: translate(0, 0) scale(1);
  }
  to {
    opacity: 0;
    transform: translate(50%, 50%) scale(0.95);
  }
}

#almo-session-list {
  border-bottom: 1px solid #2a2a2e;
  max-height: 35%;
  overflow-y: auto;
  flex-shrink: 0;
}

#almo-session-list-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-weight: 600;
  padding: 0.75rem;
  color: #f2f2f2;
}

#almo-session-list-header button {
  border: none;
  border-radius: 999px;
  background: #2a2a2e;
  color: #f2f2f2;
  padding: 0.25rem 0.6rem;
  font-size: 0.78rem;
  cursor: pointer;
}

#almo-session-list ul {
  list-style: none;
  margin: 0;
  padding: 0 0.5rem 0.5rem;
}

#almo-session-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.2rem 0.25rem;
}

#almo-session-list li.active .almo-session-link {
  font-weight: 600;
  color: white;
}

.almo-session-link {
  background: none;
  border: none;
  color: #aaa;
  cursor: pointer;
  text-align: left;
  flex: 1;
  padding: 0;
  font-size: 0.85rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#almo-session-list li button[title="Delete chat"] {
  background: none;
  border: none;
  color: #777;
  cursor: pointer;
}

#almo-chat-error {
  color: #f88;
  font-size: 0.85rem;
  padding: 0.5rem 0.75rem;
}

.almo-thread-root {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

#almo-chat-messages {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

#almo-chat-inner {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 0.75rem;
  min-height: 100%;
}

#almo-chat-inner.almo-chat-inner-empty {
  justify-content: center;
}

#almo-chat-welcome {
  font-size: 1.15rem;
  font-weight: 700;
  color: #f2f2f2;
  text-align: center;
  margin: 0 0 1rem;
}

#almo-chat-message-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

#almo-chat-message-group:empty {
  display: none;
}

#almo-chat-footer {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  margin-top: 0.75rem;
}

#almo-chat-footer.almo-chat-footer-pinned {
  position: sticky;
  bottom: 0;
  margin-top: auto;
  padding-top: 0.5rem;
  padding-bottom: 0.75rem;
  background: #131316;
}

#almo-chat-suggestions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.5rem;
}

#almo-chat-suggestions button {
  border: 1px solid #333338;
  border-radius: 999px;
  background: transparent;
  color: #ccc;
  padding: 0.4rem 0.8rem;
  font-size: 0.78rem;
  cursor: pointer;
  white-space: nowrap;
}

#almo-chat-suggestions button:hover {
  background: #1d1d21;
}

.almo-message-root {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  width: 100%;
  max-width: 100%;
}

.almo-message-user {
  align-items: flex-end;
}

.almo-message-assistant {
  align-items: flex-start;
}

.almo-chat-bubble {
  width: fit-content;
  max-width: 100%;
  padding: 0.5rem 0.7rem;
  border-radius: 8px;
  font-size: 0.85rem;
  white-space: pre-wrap;
  word-break: break-word;
}

.almo-chat-user {
  max-width: 85%;
  background: #2a2a2e;
  color: #f2f2f2;
}

.almo-chat-assistant {
  background: transparent;
  color: #e2e2e2;
  white-space: normal;
}

@keyframes almo-markdown-pulse {
  50% {
    opacity: 0.5;
  }
}

:where(.almo-markdown[data-status="running"]):empty::after,
:where(.almo-markdown[data-status="running"])
  > :where(:not(ol):not(ul):not(pre)):last-child::after,
:where(.almo-markdown[data-status="running"]) > pre:last-child code::after,
:where(.almo-markdown[data-status="running"])
  > :where(:is(ol, ul):last-child)
  > :where(li:last-child:not(:has(* > li)))::after,
:where(.almo-markdown[data-status="running"])
  > :where(:is(ol, ul):last-child)
  > :where(li:last-child)
  > :where(:is(ol, ul):last-child)
  > :where(li:last-child:not(:has(* > li)))::after,
:where(.almo-markdown[data-status="running"])
  > :where(:is(ol, ul):last-child)
  > :where(li:last-child)
  > :where(:is(ol, ul):last-child)
  > :where(li:last-child)
  > :where(:is(ol, ul):last-child)
  > :where(li:last-child)::after {
  animation: almo-markdown-pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
  font-family:
    ui-sans-serif, system-ui, sans-serif, "Apple Color Emoji", "Segoe UI Emoji",
    "Segoe UI Symbol", "Noto Color Emoji";
  content: "\25cf";
  margin-left: 0.25rem;
  margin-right: 0.25rem;
}

.almo-markdown > :first-child {
  margin-top: 0;
}

.almo-markdown > :last-child {
  margin-bottom: 0;
}

.almo-markdown p {
  margin: 0.5em 0;
  white-space: pre-wrap;
}

.almo-markdown h1,
.almo-markdown h2,
.almo-markdown h3,
.almo-markdown h4,
.almo-markdown h5,
.almo-markdown h6 {
  margin: 0.9em 0 0.4em;
  font-weight: 600;
  line-height: 1.3;
}

.almo-markdown h1 {
  font-size: 1.15em;
}

.almo-markdown h2 {
  font-size: 1.08em;
}

.almo-markdown h3,
.almo-markdown h4,
.almo-markdown h5,
.almo-markdown h6 {
  font-size: 1em;
}

.almo-markdown ul,
.almo-markdown ol {
  margin: 0.4em 0;
  padding-left: 1.4em;
}

.almo-markdown li {
  margin: 0.15em 0;
}

.almo-markdown a {
  color: #6ab0f3;
  text-decoration: underline;
}

.almo-markdown blockquote {
  margin: 0.5em 0;
  padding-left: 0.8em;
  border-left: 2px solid rgba(255, 255, 255, 0.2);
  color: #b8b8b8;
}

.almo-markdown hr {
  margin: 0.8em 0;
  border: none;
  border-top: 1px solid rgba(255, 255, 255, 0.15);
}

.almo-markdown code {
  background: rgba(255, 255, 255, 0.08);
  border-radius: 4px;
  padding: 0.1em 0.3em;
  font-size: 0.85em;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

.almo-markdown pre {
  background: rgba(255, 255, 255, 0.05);
  border-radius: 6px;
  padding: 0.6em 0.7em;
  margin: 0.5em 0;
  overflow-x: auto;
}

.almo-markdown pre code {
  background: none;
  padding: 0;
  font-size: 0.8em;
}

.almo-markdown table {
  border-collapse: collapse;
  margin: 0.5em 0;
  font-size: 0.9em;
}

.almo-markdown th,
.almo-markdown td {
  border: 1px solid rgba(255, 255, 255, 0.15);
  padding: 0.3em 0.6em;
}

.almo-chat-error {
  background: rgba(220, 60, 60, 0.18);
  color: #f88;
}

.almo-tool-fallback {
  align-self: flex-start;
  width: 100%;
}

.almo-tool-fallback-trigger {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.3rem 0;
  background: none;
  border: none;
  color: #9a9a9a;
  font-size: 0.8rem;
  cursor: pointer;
}

.almo-tool-fallback-trigger:hover {
  color: #d8d8d8;
}

.almo-tool-fallback-trigger b {
  color: inherit;
}

.almo-tool-fallback-trigger-icon {
  flex-shrink: 0;
  width: 13px;
  height: 13px;
}

.almo-tool-fallback-spin {
  animation: almo-tool-fallback-spin 1s linear infinite;
}

@keyframes almo-tool-fallback-spin {
  to {
    transform: rotate(360deg);
  }
}

.almo-tool-fallback-cancelled {
  text-decoration: line-through;
}

.almo-tool-fallback-trigger-chevron {
  flex-shrink: 0;
  width: 13px;
  height: 13px;
  transition: transform 0.15s ease-out;
}

.almo-tool-fallback-chevron-closed {
  transform: rotate(-90deg);
}

.almo-tool-fallback-content {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  padding: 0.1rem 0 0.4rem 1.2rem;
}

.almo-tool-fallback-pre {
  background: rgba(255, 255, 255, 0.05);
  color: #b8b8b8;
  border-radius: 6px;
  padding: 0.5rem 0.6rem;
  font-size: 0.75rem;
  white-space: pre-wrap;
  word-break: break-word;
  margin: 0;
}

.almo-tool-fallback-result-header,
.almo-tool-fallback-error-header {
  margin: 0 0 0.2rem;
  font-size: 0.72rem;
  font-weight: 600;
  color: #9a9a9a;
}

.almo-tool-fallback-error p {
  margin: 0;
  font-size: 0.78rem;
  color: #f88;
}

.almo-chat-cancelled {
  background: rgba(150, 150, 150, 0.15);
  color: #999;
  font-style: italic;
}

#almo-chat-turn-actions {
  display: flex;
  gap: 0.4rem;
  min-height: 0;
}

#almo-chat-turn-actions:empty {
  display: none;
}

#almo-chat-turn-actions button {
  padding: 0.3rem 0.6rem;
  border: 1px solid #333338;
  border-radius: 6px;
  background: transparent;
  color: #ccc;
  font-size: 0.78rem;
  cursor: pointer;
}

#almo-chat-form {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  padding: 0.6rem 0.6rem 0.5rem 0.9rem;
  background: #1c1c20;
  border: 1px solid #333338;
  border-radius: 1.25rem;
}

#almo-chat-form textarea {
  width: 100%;
  resize: none;
  overflow-y: auto;
  max-height: calc(0.85rem * 1.4 * 3 + 0.4rem);
  padding: 0.2rem 0;
  border: none;
  background: transparent;
  color: #f2f2f2;
  font-size: 0.85rem;
  line-height: 1.4;
  font-family: inherit;
}

#almo-chat-form textarea::placeholder {
  color: #888;
}

#almo-chat-form textarea:focus {
  outline: none;
}

#almo-chat-form-actions {
  display: flex;
  justify-content: flex-end;
}

.almo-chat-send {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 1.9rem;
  height: 1.9rem;
  flex-shrink: 0;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: #e6e6e6;
  color: #131316;
  cursor: pointer;
}

.almo-chat-send:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

#almo-mention-dropdown {
  position: absolute;
  bottom: 100%;
  left: 0;
  right: 0;
  margin-bottom: 0.4rem;
  max-height: 160px;
  overflow-y: auto;
  margin: 0;
  padding: 0.2rem 0;
  list-style: none;
  background: #1c1c20;
  border: 1px solid #333338;
  border-radius: 6px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.4);
  font-size: 0.8rem;
  z-index: 10;
  color: #f2f2f2;
}

#almo-mention-dropdown li {
  padding: 0.3rem 0.6rem;
  cursor: pointer;
}

#almo-mention-dropdown li:hover,
#almo-mention-dropdown li.almo-mention-active {
  background: #2a2a2e;
}

.almo-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.almo-modal {
  background: white;
  border-radius: 10px;
  width: 480px;
  max-height: 85vh;
  overflow-y: auto;
  padding: 1.25rem 1.5rem;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
}

.almo-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.5rem;
}

.almo-modal-header h2 {
  font-size: 1.2rem;
  margin: 0;
}

.almo-modal-close {
  background: none;
  border: none;
  font-size: 1.4rem;
  line-height: 1;
  color: #888;
  cursor: pointer;
}

.almo-modal h3 {
  font-size: 1rem;
  margin-top: 1.5rem;
}

.almo-modal section {
  margin-bottom: 0.75rem;
}

.almo-modal label {
  display: block;
  font-size: 0.85rem;
  color: #555;
  margin-bottom: 0.25rem;
}

.almo-modal select,
.almo-modal input[type="text"],
.almo-modal input[type="password"] {
  width: 100%;
  padding: 0.5rem 0.75rem;
  border: 1px solid #ccc;
  border-radius: 6px;
  font-size: 0.95rem;
  box-sizing: border-box;
  margin-bottom: 0.75rem;
}

.almo-modal button {
  padding: 0.5rem 1rem;
  border: none;
  border-radius: 6px;
  background: #1a1a1a;
  color: white;
  font-size: 0.95rem;
  cursor: pointer;
}

.almo-modal button.secondary {
  background: #888;
}

.almo-credential-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.almo-credential-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 0;
  border-bottom: 1px solid #eee;
}

.almo-credential-list li span.status {
  font-size: 0.8rem;
  color: #888;
}

.almo-modal .ok {
  color: #2a7a2a;
  font-size: 0.85rem;
}

.almo-modal .error {
  color: #c33;
  font-size: 0.85rem;
}

.almo-modal-hint {
  font-size: 0.85rem;
  color: #888;
  margin: 0;
}

.almo-connection-status {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.5rem 0 0.75rem;
}

.almo-connection-status .status {
  font-size: 0.8rem;
  color: #888;
}

.almo-tab-strip {
  display: flex;
  gap: 0.25rem;
  border-bottom: 1px solid #eee;
  margin-bottom: 0.75rem;
}

.almo-modal .almo-tab {
  padding: 0.4rem 0.85rem;
  border: none;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  background: transparent;
  color: #555;
  font-size: 0.9rem;
  cursor: pointer;
}

.almo-modal .almo-tab.active {
  color: #1a1a1a;
  border-bottom-color: #1a1a1a;
  font-weight: 600;
}
