:root {
  color-scheme: light;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #fff;
  color: #202123;
  font-synthesis: none;
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  background: inherit;
  color: inherit;
}

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

button {
  border: 0;
  border-radius: 0.65rem;
  background: #202123;
  color: #fff;
  cursor: pointer;
  padding: 0.7rem 1rem;
}

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

input,
select,
textarea {
  width: 100%;
  border: 1px solid #d9d9d6;
  border-radius: 0.75rem;
  background: #fff;
  color: inherit;
  outline: none;
}

input:focus,
select:focus,
textarea:focus {
  border-color: #888;
}

.login-shell {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 1.5rem;
  background: #f7f7f5;
}

.login-card {
  width: min(100%, 24rem);
  padding: 2rem;
  border: 1px solid #e6e6e2;
  border-radius: 1rem;
  background: #fff;
}

.login-card label {
  display: grid;
  gap: 0.4rem;
  margin-top: 1rem;
  font-size: 0.9rem;
}

.login-card .remember-option {
  display: flex;
  align-items: center;
  gap: 0.55rem;
}

.remember-option input {
  width: auto;
}

.connection-card .secondary-button {
  margin-top: 0.65rem;
}

.remote-connection {
  margin-top: 1rem;
}

.remote-connection summary {
  cursor: pointer;
  color: #555;
  font-size: 0.9rem;
}

.login-card input,
.login-card select {
  min-height: 2.8rem;
  padding: 0 0.8rem;
}

.password-input {
  position: relative;
}

.password-input input {
  padding-right: 3rem;
}

.login-card .password-toggle {
  position: absolute;
  top: 50%;
  right: 0.35rem;
  display: inline-flex;
  width: 2.2rem;
  min-width: 2.2rem;
  height: 2.2rem;
  align-items: center;
  justify-content: center;
  margin: 0;
  padding: 0;
  transform: translateY(-50%);
  background: transparent;
  color: #666;
}

.password-toggle svg {
  width: 1.2rem;
  height: 1.2rem;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.password-toggle .password-eye-closed {
  display: none;
}

.password-toggle.showing .password-eye-open {
  display: none;
}

.password-toggle.showing .password-eye-closed {
  display: block;
}

.login-card .auth-switch {
  margin-top: 0.65rem;
  background: transparent;
  color: #555;
  padding: 0.4rem;
}

.login-card button {
  width: 100%;
  margin-top: 1.2rem;
}

.brand {
  font-size: 1.7rem;
  font-weight: 700;
  letter-spacing: -0.04em;
}

.brand-small {
  font-size: 1.2rem;
}

.muted,
.connection-state,
.identity,
.empty-list {
  color: #777;
}

.form-error {
  min-height: 1.2rem;
  margin-bottom: 0;
  color: #a33;
  font-size: 0.85rem;
}

.workspace {
  display: grid;
  grid-template-columns: 17rem minmax(0, 1fr);
  height: 100vh;
  overflow: hidden;
}

.sidebar {
  display: flex;
  min-width: 0;
  flex-direction: column;
  border-right: 1px solid #e8e8e5;
  background: #f7f7f5;
}

.sidebar-top,
.sidebar-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.85rem;
}

.sidebar-bottom {
  margin-top: auto;
  border-top: 1px solid #e8e8e5;
}

.thread-list {
  display: flex;
  min-height: 0;
  flex: 1;
  flex-direction: column;
  gap: 0.15rem;
  overflow-y: auto;
  padding: 0 0.55rem;
}

.thread-group h2 {
  overflow: hidden;
  margin: 0.8rem 0.7rem 0.25rem;
  color: #777;
  font-size: 0.72rem;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.thread-group {
  display: grid;
  gap: 0.15rem;
}

.thread-button {
  overflow: hidden;
  width: 100%;
  border-radius: 0.55rem;
  background: transparent;
  color: #333;
  padding: 0.65rem 0.7rem;
  text-align: left;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.thread-button:hover,
.thread-button.active {
  background: #eaeae6;
}

.secondary-button,
.text-button,
.icon-button {
  background: transparent;
  color: #333;
}

.secondary-button {
  border: 1px solid #d7d7d2;
}

.text-button {
  padding: 0.4rem;
}

.icon-button {
  display: none;
  padding: 0.35rem 0.5rem;
  font-size: 1.15rem;
}

.chat {
  display: grid;
  min-width: 0;
  height: 100vh;
  grid-template-rows: auto minmax(0, 1fr) auto auto;
}

.chat-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-height: 3.6rem;
  border-bottom: 1px solid #ededeb;
  padding: 0.65rem 1rem;
}

.chat-header > div {
  display: flex;
  min-width: 0;
  flex-direction: column;
}

.chat-header strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.connection-state {
  font-size: 0.75rem;
}

.messages {
  overflow-y: auto;
  padding: 1.25rem max(1rem, calc((100% - 48rem) / 2));
}

.welcome {
  display: grid;
  min-height: 60%;
  place-content: center;
  text-align: center;
}

.welcome h1,
.welcome p {
  margin: 0;
}

.welcome p {
  margin-top: 0.65rem;
  color: #777;
}

.message {
  display: flex;
  margin: 1rem 0;
}

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

.message-body {
  max-width: min(42rem, 90%);
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.55;
}

.message-user .message-body {
  padding: 0.75rem 0.95rem;
  border-radius: 1.1rem;
  background: #f1f1ef;
}

.message-assistant .message-body {
  width: 100%;
}

.tool-item {
  margin: 0.7rem 0;
  border: 1px solid #e6e6e2;
  border-radius: 0.7rem;
  background: #fafaf8;
}

.tool-item summary {
  cursor: pointer;
  padding: 0.65rem 0.8rem;
  font-size: 0.9rem;
}

.tool-item pre {
  overflow-x: auto;
  margin: 0;
  border-top: 1px solid #e6e6e2;
  padding: 0.75rem;
  white-space: pre-wrap;
  font-size: 0.8rem;
}

.approvals {
  display: grid;
  gap: 0.5rem;
  padding: 0 max(1rem, calc((100% - 48rem) / 2));
}

.approval-card {
  border: 1px solid #d9c9a2;
  border-radius: 0.8rem;
  background: #fffaf0;
  padding: 0.85rem;
}

.approval-card pre {
  max-height: 10rem;
  overflow: auto;
  white-space: pre-wrap;
}

.approval-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
}

.composer {
  width: min(48rem, calc(100% - 2rem));
  margin: 0 auto;
  padding: 0.75rem 0 max(0.75rem, env(safe-area-inset-bottom));
}

.composer textarea {
  min-height: 3.3rem;
  max-height: 11rem;
  resize: none;
  padding: 0.9rem 1rem;
  box-shadow: 0 2px 12px rgb(0 0 0 / 0.05);
}

.composer-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-top: 0.45rem;
}

.hidden {
  display: none !important;
}

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

  .sidebar {
    position: fixed;
    z-index: 10;
    inset: 0 auto 0 0;
    width: min(85vw, 19rem);
    transform: translateX(-101%);
    transition: transform 160ms ease;
    box-shadow: 10px 0 30px rgb(0 0 0 / 0.12);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .icon-button {
    display: inline-flex;
  }

  .messages {
    padding-inline: 1rem;
  }
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    background: #212121;
    color: #ececec;
  }

  .login-shell,
  .sidebar {
    background: #171717;
  }

  .login-card,
  input,
  select,
  textarea {
    border-color: #3b3b3b;
    background: #212121;
  }

  .sidebar,
  .sidebar-bottom,
  .chat-header {
    border-color: #333;
  }

  .login-card .auth-switch,
  .thread-button,
  .secondary-button,
  .text-button,
  .icon-button {
    color: #ddd;
  }

  .login-card .password-toggle {
    color: #aaa;
  }

  .thread-button:hover,
  .thread-button.active,
  .message-user .message-body {
    background: #2f2f2f;
  }

  .tool-item {
    border-color: #3a3a3a;
    background: #262626;
  }

  .tool-item pre {
    border-color: #3a3a3a;
  }

  .approval-card {
    border-color: #685b3c;
    background: #2b271e;
  }

  .muted,
  .connection-state,
  .identity,
  .empty-list,
  .welcome p {
    color: #aaa;
  }
}


.message-read-button {
  align-self: flex-start;
  margin: 0.35rem 0 0 0.5rem;
  padding: 0.35rem 0.55rem;
  background: transparent;
  color: #777;
  font-size: 0.75rem;
}

.message-read-button:hover {
  background: #f1f1ef;
  color: #333;
}

@media (prefers-color-scheme: dark) {
  .message-read-button {
    color: #aaa;
  }

  .message-read-button:hover {
    background: #2f2f2f;
    color: #eee;
  }
}


.input-request-card {
  display: grid;
  gap: 0.8rem;
}

.input-question {
  display: grid;
  gap: 0.55rem;
  margin: 0;
  border: 0;
  padding: 0;
}

.input-question legend {
  font-weight: 600;
}

.input-question p {
  margin: 0;
  color: #666;
  font-size: 0.9rem;
}

.input-option {
  display: flex;
  align-items: flex-start;
  gap: 0.55rem;
  cursor: pointer;
}

.input-option input {
  width: auto;
  margin-top: 0.2rem;
}

.input-freeform {
  min-height: 2.5rem;
  padding: 0 0.7rem;
}

@media (prefers-color-scheme: dark) {
  .input-question p {
    color: #aaa;
  }
}


/* Shared top-bar pattern aligned with eqeqo/ui-erp. */
.app-shell {
  display: grid;
  grid-template-rows: 3.25rem minmax(0, 1fr);
  height: 100vh;
  overflow: hidden;
}

.app-top-bar {
  position: relative;
  z-index: 20;
  display: flex;
  align-items: center;
  width: 100%;
  min-width: 0;
  height: 3.25rem;
  padding: 0.375rem 0.75rem;
  gap: 0.5rem;
  background: linear-gradient(180deg, #0b0b0b, #252525);
  color: #fff;
}

.top-bar-title {
  margin-right: 0.35rem;
  color: #fff;
  font-size: 0.92rem;
  font-weight: 700;
  letter-spacing: 0.12em;
}

.top-bar-user-menu {
  position: relative;
  margin-left: auto;
  margin-right: 0.25rem;
}

.top-bar-user-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  min-width: 2.25rem;
  height: 2.25rem;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: #d32f2f;
  color: #fff;
  font: inherit;
  font-weight: 700;
  line-height: 1;
}

.top-bar-user-button.active {
  background: #d32f2f;
}

.top-bar-user-dropdown {
  position: absolute;
  top: calc(100% + 0.45rem);
  right: 0;
  z-index: 24;
  display: grid;
  min-width: 12rem;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 0.5rem;
  padding: 0.6rem;
  border: 1px solid #deded8;
  border-radius: 0.9rem;
  background: #fff;
  color: #222;
  box-shadow: 0 8px 24px rgb(0 0 0 / 0.14);
}

.top-bar-user-name {
  min-width: 0;
  overflow: hidden;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.top-bar-user-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.75rem;
  min-width: 2.75rem;
  height: 2.75rem;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: #d32f2f;
  color: #fff;
}

.top-bar-user-action:hover,
.top-bar-user-action:focus-visible {
  background: #b71c1c;
}

.top-bar-user-action svg,
.conversation-icon-button svg,
.thread-action-button svg {
  width: 1.15rem;
  height: 1.15rem;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.workspace {
  height: auto;
  min-height: 0;
}

.chat {
  height: 100%;
}

.conversation-icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  min-width: 2.25rem;
  height: 2.25rem;
  padding: 0;
}

.thread-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.2rem;
  border-radius: 0.55rem;
}

.thread-row.active,
.thread-row:hover {
  background: #eaeae6;
}

.thread-row .thread-button,
.thread-row .thread-button:hover,
.thread-row .thread-button.active {
  min-width: 0;
  background: transparent;
}

.thread-actions {
  display: inline-flex;
  align-items: center;
  gap: 0.1rem;
  padding-right: 0.25rem;
}

.thread-action-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.85rem;
  min-width: 1.85rem;
  height: 1.85rem;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: #666;
}

.thread-action-button:hover,
.thread-action-button:focus-visible {
  background: #deded9;
  color: #222;
}

.thread-action-delete:hover,
.thread-action-delete:focus-visible {
  color: #a3261f;
}

.thread-action-button:disabled {
  opacity: 0.45;
}

@media (max-width: 760px) {
  .sidebar {
    inset: 3.25rem auto 0 0;
    height: calc(100vh - 3.25rem);
  }
}

@media (prefers-color-scheme: dark) {
  .top-bar-user-dropdown {
    border-color: #444;
    background: #262626;
    color: #eee;
  }

  .thread-row.active,
  .thread-row:hover {
    background: #2f2f2f;
  }

  .thread-action-button {
    color: #aaa;
  }

  .thread-action-button:hover,
  .thread-action-button:focus-visible {
    background: #3a3a3a;
    color: #eee;
  }

  .thread-action-delete:hover,
  .thread-action-delete:focus-visible {
    color: #ff8a80;
  }
}


/* FAH-173: shared contextual surface and mobile conversation controls. */
.sidebar-actions {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.sidebar-close-button {
  display: none;
}

.sidebar-backdrop {
  display: none;
}

.thread-row {
  grid-template-columns: minmax(0, 1fr) auto auto;
}

.thread-spinner {
  width: 0.95rem;
  height: 0.95rem;
  border: 2px solid #c9c9c4;
  border-top-color: #555;
  border-radius: 999px;
  animation: thread-spin 700ms linear infinite;
}

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

.thread-action-button {
  font-size: 1.3rem;
  font-weight: 700;
  line-height: 1;
}

eq-contextual-container:not([data-ready="true"]) {
  display: none;
}

eq-contextual-container[data-ready="true"] {
  display: contents;
}

.eq-contextual-dialog {
  width: min(36rem, calc(100vw - 2rem));
  max-width: 100%;
  max-height: calc(100dvh - 2rem);
  margin: auto;
  padding: 0;
  border: 1px solid #deded8;
  border-radius: 1rem;
  background: #fff;
  color: #202123;
  box-shadow: 0 18px 50px rgb(0 0 0 / 0.18);
  overflow: hidden;
}

.eq-contextual-dialog::backdrop {
  background: rgb(0 0 0 / 0.48);
}

.eq-contextual-panel {
  max-height: inherit;
  overflow: auto;
  padding: 1rem;
}

.eq-contextual-dialog[data-mode="sheet"] {
  width: 100%;
  max-width: 42rem;
  margin: auto 0 0;
  border-radius: 1rem 1rem 0 0;
}

.context-sheet {
  display: grid;
  gap: 0.65rem;
}

.context-sheet-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.sheet-icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  min-width: 2.25rem;
  height: 2.25rem;
  padding: 0;
  border-radius: 999px;
  background: transparent;
  color: #333;
}

.sheet-icon-button svg,
.context-sheet-action svg {
  width: 1.15rem;
  height: 1.15rem;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.context-sheet-action {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  min-height: 2.8rem;
  gap: 0.7rem;
  background: transparent;
  color: #202123;
  text-align: left;
}

.context-sheet-action:hover,
.context-sheet-action:focus-visible {
  background: #f1f1ef;
}

.context-sheet-action.danger {
  color: #a3261f;
}

.context-sheet-action.delete-pending:disabled {
  cursor: default;
  opacity: 1;
}

.context-sheet-action.delete-pending span {
  display: none;
}

.context-sheet-action.delete-pending svg {
  animation: thread-delete-blink 0.8s ease-in-out infinite;
}

@keyframes thread-delete-blink {
  0%,
  100% {
    opacity: 1;
  }

  50% {
    opacity: 0.2;
  }
}

@media (prefers-reduced-motion: reduce) {
  .context-sheet-action.delete-pending svg {
    animation: none;
    opacity: 0.5;
  }
}

.context-sheet-hint {
  margin: 0;
  color: #666;
  font-size: 0.88rem;
}

.thread-error-message {
  min-height: 9rem;
  resize: vertical;
  padding: 0.75rem;
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 0.78rem;
}

.copy-status {
  min-height: 1rem;
  color: #666;
  font-size: 0.78rem;
}

@media (max-width: 760px) {
  .sidebar-close-button {
    display: inline-flex;
  }

  .sidebar-backdrop:not(.hidden) {
    position: fixed;
    z-index: 9;
    inset: 3.25rem 0 0;
    display: block;
    width: 100%;
    border-radius: 0;
    background: rgb(0 0 0 / 0.38);
    padding: 0;
  }
}

@media (prefers-color-scheme: dark) {
  .thread-spinner {
    border-color: #555;
    border-top-color: #ddd;
  }

  .eq-contextual-dialog {
    border-color: #444;
    background: #262626;
    color: #eee;
  }

  .sheet-icon-button,
  .context-sheet-action {
    color: #eee;
  }

  .context-sheet-action:hover,
  .context-sheet-action:focus-visible {
    background: #333;
  }

  .context-sheet-action.danger {
    color: #ff8a80;
  }

  .context-sheet-hint,
  .copy-status {
    color: #aaa;
  }
}
