:root {
  --stimcar-red: #e3032e;
  --stimcar-ink: #1d1d1b;
  --stimcar-paper: #f7f4f0;
  --stimcar-line: #d9d4cc;
  --stimcar-white: #fff;
}

* {
  box-sizing: border-box;
}

html, body, #root {
  height: 100%;
  margin: 0;
}

body {
  color: var(--stimcar-ink);
  background: var(--stimcar-paper);
  font-family: Poppins, Segoe UI, sans-serif;
}

a {
  color: var(--stimcar-red);
}

.studio-app {
  flex-direction: column;
  height: 100%;
  display: flex;
}

.studio-app .studio-stage {
  flex: 1;
  height: auto;
  min-height: 0;
}

.studio-account-bar {
  background: var(--stimcar-white);
  border-bottom: 1px solid var(--stimcar-line);
  justify-content: flex-end;
  align-items: center;
  gap: .75rem;
  padding: .4rem .9rem;
  font-size: .8rem;
  display: flex;
}

.studio-account-bar form {
  margin: 0;
}

.studio-account-bar .button {
  padding: .3rem .65rem;
  font-size: .75rem;
}

.studio-login {
  justify-content: center;
  align-items: center;
  min-height: 100%;
  padding: 2rem 1rem;
  display: flex;
}

.studio-login-card {
  background: var(--stimcar-white);
  border: 1px solid var(--stimcar-line);
  border-radius: 10px;
  width: 100%;
  max-width: 26rem;
  padding: 1.75rem 1.6rem;
}

.studio-login-eyebrow {
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--stimcar-red);
  margin: 0 0 .4rem;
  font-size: .75rem;
  font-weight: 600;
}

.studio-login-card h1 {
  margin: 0 0 .7rem;
  font-size: 1.35rem;
}

.studio-login-card p {
  color: #5c5c58;
  margin: 0 0 1rem;
}

.studio-login-card .button {
  text-decoration: none;
  display: inline-block;
}

.studio-stage {
  height: 100%;
  min-height: 100vh;
  display: grid;
}

.studio-site {
  background: var(--stimcar-white);
  border: 0;
  width: 100%;
  height: 100%;
  min-height: 100vh;
}

.studio-site-pending {
  color: #5c5c58;
  justify-content: center;
  align-items: center;
  font-size: .95rem;
  display: flex;
}

.studio-resize {
  background: var(--stimcar-line);
  cursor: col-resize;
  border: 0;
  width: 100%;
  height: 100%;
  padding: 0;
}

.studio-resize:hover, .studio-resize:focus-visible {
  background: var(--stimcar-red);
  outline: none;
}

.studio-chat {
  background: var(--stimcar-paper);
  border-left: 1px solid var(--stimcar-line);
  flex-direction: column;
  min-height: 100vh;
  max-height: 100vh;
  padding: 1rem 1rem 1.1rem;
  display: flex;
  overflow: hidden;
}

.studio-chat h1 {
  border-bottom: 2px solid var(--stimcar-red);
  margin: 0 0 .5rem;
  padding-bottom: .5rem;
  font-size: 1.05rem;
}

.studio-lead {
  color: #5c5c58;
  margin: 0 0 .85rem;
  font-size: .85rem;
}

.studio-form {
  flex-direction: column;
  flex: 1;
  gap: .6rem;
  min-height: 0;
  display: flex;
  overflow: auto;
}

.studio-form label {
  font-size: .85rem;
  font-weight: 600;
}

.studio-form input, .studio-form textarea {
  font: inherit;
  border: 1px solid var(--stimcar-line);
  background: var(--stimcar-paper);
  border-radius: 6px;
  padding: .55rem .7rem;
}

.button {
  font: inherit;
  cursor: pointer;
  border: 0;
  border-radius: 6px;
  padding: .6rem .9rem;
  font-weight: 600;
}

.button-primary {
  background: var(--stimcar-red);
  color: var(--stimcar-white);
}

.button-secondary {
  background: var(--stimcar-white);
  color: var(--stimcar-ink);
  border: 1px solid var(--stimcar-line);
}

.button:disabled {
  opacity: .55;
  cursor: not-allowed;
}

.alert {
  color: var(--stimcar-red);
  background: #fde8ec;
  border-radius: 6px;
  padding: .65rem .75rem;
  font-size: .85rem;
}

.session-header {
  border-bottom: 2px solid var(--stimcar-red);
  justify-content: space-between;
  align-items: flex-start;
  gap: .5rem;
  margin: 0 0 .5rem;
  padding-bottom: .5rem;
  display: flex;
}

.session-header h1 {
  border-bottom: 0;
  margin: 0;
  padding: 0;
}

.session-actions {
  flex-wrap: wrap;
  justify-content: flex-end;
  align-items: center;
  gap: .35rem;
  margin: 0;
  display: flex;
}

.session-actions .button {
  padding: .35rem .55rem;
  font-size: .75rem;
}

.button-icon-text {
  align-items: center;
  gap: .35rem;
  display: inline-flex;
}

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

.visually-hidden {
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  position: absolute;
  overflow: hidden;
}

.chat-log {
  overflow-anchor: none;
  flex-direction: column;
  flex: 1;
  gap: .65rem;
  min-height: 0;
  margin-bottom: .75rem;
  display: flex;
  overflow: auto;
}

.chat-item {
  border-left: 3px solid var(--stimcar-red);
  padding-left: .65rem;
  font-size: .9rem;
}

.chat-markdown {
  overflow-wrap: anywhere;
  line-height: 1.45;
}

.chat-markdown > :first-child {
  margin-top: .15rem;
}

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

.chat-markdown p, .chat-markdown ul, .chat-markdown ol, .chat-markdown pre, .chat-markdown blockquote {
  margin: .35rem 0;
}

.chat-markdown h1, .chat-markdown h2, .chat-markdown h3, .chat-markdown h4 {
  margin: .5rem 0 .25rem;
  font-size: 1em;
  font-weight: 600;
}

.chat-markdown ul, .chat-markdown ol {
  padding-left: 1.2rem;
}

.chat-markdown code {
  background: var(--stimcar-white);
  border-radius: 4px;
  padding: .1em .35em;
  font-family: ui-monospace, Segoe UI Mono, monospace;
  font-size: .85em;
}

.chat-markdown pre {
  border: 1px solid var(--stimcar-line);
  background: var(--stimcar-white);
  border-radius: 6px;
  padding: .55rem .65rem;
  overflow-x: auto;
}

.chat-markdown pre code {
  background: none;
  padding: 0;
}

.chat-markdown table {
  border-collapse: collapse;
  font-size: .8rem;
}

.chat-markdown th, .chat-markdown td {
  border: 1px solid var(--stimcar-line);
  text-align: left;
  padding: .25rem .45rem;
}

.chat-markdown img {
  max-width: 100%;
  height: auto;
}

.chat-item-live {
  opacity: .85;
}

.mr-link {
  margin: 0 0 .65rem;
  font-size: .8rem;
}

.agent-trace {
  border: 1px solid var(--stimcar-line);
  background: #fff;
  border-radius: 6px;
  flex-wrap: wrap;
  align-items: center;
  gap: .5rem;
  margin: 0 0 .75rem;
  padding: .55rem .75rem;
  display: flex;
}

.agent-trace-title {
  margin: 0;
  font-size: .8rem;
  font-weight: 600;
}

.chat-item-trace strong {
  text-transform: uppercase;
  letter-spacing: .03em;
  color: #5c5c58;
  font-size: .7rem;
  display: block;
}

.chat-item-trace pre {
  white-space: pre-wrap;
  font: inherit;
  margin: .15rem 0 0;
  font-size: .8rem;
}

.chat-form {
  border: 1px solid var(--stimcar-line);
  background: var(--stimcar-white);
  border-radius: 16px;
  flex-direction: column;
  gap: .45rem;
  margin-top: auto;
  padding: .55rem .65rem .5rem;
  display: flex;
  position: relative;
}

.composer-toolbar {
  justify-content: space-between;
  align-items: center;
  gap: .5rem;
  display: flex;
}

.chat-form textarea {
  font: inherit;
  resize: none;
  field-sizing: content;
  background: none;
  border: 0;
  border-radius: 0;
  width: 100%;
  min-height: 2.75rem;
  max-height: 10rem;
  padding: .2rem .15rem;
  overflow-y: auto;
}

.chat-form textarea:focus-visible {
  outline: none;
}

.chat-file-input {
  clip: rect(0 0 0 0);
  width: 1px;
  height: 1px;
  position: absolute;
  overflow: hidden;
}

.studio-stage.is-chat-maximized {
  grid-template-columns: minmax(0, 1fr) !important;
}

.studio-stage.is-chat-maximized .studio-site {
  display: none;
}

.composer-tools {
  align-items: center;
  gap: .15rem;
  display: flex;
}

.composer-tool {
  cursor: pointer;
  color: var(--stimcar-ink);
  background: none;
  border: 0;
}

.composer-tool.is-disabled {
  opacity: .55;
  cursor: not-allowed;
  pointer-events: none;
}

.composer-tool.is-active {
  color: var(--stimcar-red);
  background: #fde8ec;
}

.inspect-hint {
  color: var(--stimcar-red);
  margin: 0;
  font-size: .75rem;
}

.composer-attach {
  cursor: pointer;
  color: var(--stimcar-ink);
  background: none;
  border: 0;
}

.composer-attach.is-disabled {
  opacity: .55;
  cursor: not-allowed;
  pointer-events: none;
}

.composer-send {
  background: var(--stimcar-red);
  width: 2rem;
  height: 2rem;
  color: var(--stimcar-white);
  cursor: pointer;
  border: 0;
  border-radius: 999px;
  justify-content: center;
  align-items: center;
  padding: 0;
  display: inline-flex;
}

.composer-send:disabled {
  color: #8a8680;
  cursor: not-allowed;
  background: #d9d4cc;
}

.composer-attach:focus-visible, .composer-tool:focus-visible, .composer-send:focus-visible, .icon-button:focus-visible, .chip-remove:focus-visible {
  outline: 2px solid var(--stimcar-red);
  outline-offset: 2px;
}

.chat-attachments {
  flex-direction: column;
  gap: .35rem;
  margin: .35rem 0 0;
  padding: 0;
  list-style: none;
  display: flex;
}

.chat-pending-attachments {
  flex-wrap: wrap;
  gap: .35rem;
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
}

.chat-pending-attachments li {
  border: 1px solid var(--stimcar-line);
  background: var(--stimcar-paper);
  border-radius: 999px;
  align-items: center;
  gap: .2rem;
  max-width: 100%;
  padding: .15rem .2rem .15rem .55rem;
  font-size: .75rem;
  display: flex;
}

.chat-pending-name {
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 10rem;
  overflow: hidden;
}

.chip-remove {
  width: 1.35rem;
  height: 1.35rem;
  color: var(--stimcar-ink);
  cursor: pointer;
  background: none;
  border: 0;
  border-radius: 999px;
  justify-content: center;
  align-items: center;
  padding: 0;
  display: inline-flex;
}

.chip-remove:disabled {
  opacity: .55;
  cursor: not-allowed;
}

.chat-attachment-image {
  border: 1px solid var(--stimcar-line);
  border-radius: 6px;
  max-width: 100%;
  max-height: 12rem;
  display: block;
}

.chat-attachment-file {
  font-size: .85rem;
}

.agent-step-thinking pre {
  color: #5c5c58;
  font-style: italic;
}

.session-layout, .session-column {
  flex-direction: column;
  flex: 1;
  min-height: 0;
  display: flex;
}

@media (max-width: 900px) {
  .studio-stage {
    grid-template-rows: minmax(40vh, 1fr) .55rem minmax(20rem, 45vh);
    grid-template-columns: 1fr !important;
  }

  .studio-stage.is-chat-maximized {
    grid-template-rows: minmax(0, 1fr);
  }

  .studio-resize {
    cursor: row-resize;
  }

  .studio-site, .studio-chat {
    min-height: 0;
  }

  .studio-chat {
    border-left: 0;
    border-top: 1px solid var(--stimcar-line);
    max-height: none;
  }
}

