:root {
  color-scheme: dark;
  --bg: #121212;
  --panel: #1b1b1b;
  --panel-strong: #242424;
  --panel-soft: #171717;
  --text: #e8e3dc;
  --muted: #9c958c;
  --muted-strong: #c2bbb2;
  --line: #303030;
  --line-soft: #242424;
  --accent: #d1a600;
  --accent-strong: #e0ba28;
  --danger: #f26d6d;
  --warning: #d1a600;
  --success: #69d391;
  --code-bg: #0d0d0d;
  --code-text: #f0ede8;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  height: 100vh;
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
}

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

button {
  border: 0;
  cursor: pointer;
}

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

.app-shell {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  height: 100vh;
  overflow: hidden;
}

.sidebar {
  min-height: 0;
  overflow: auto;
  padding: 16px;
  background: #181818;
  border-right: 1px solid var(--line);
}

.brand-row,
.chat-header,
.composer-toolbar,
.dialog-actions,
.header-actions,
.session-meta {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-row {
  justify-content: space-between;
  margin-bottom: 16px;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 20px;
  line-height: 1.15;
}

h2 {
  font-size: 15px;
  line-height: 1.25;
}

.brand-row p,
.status-text,
.session-subtitle {
  color: var(--muted);
  font-size: 12px;
}

.session-meta {
  flex: 1 1 360px;
  flex-wrap: nowrap;
  min-width: 160px;
  margin-top: 0;
  overflow: hidden;
}

.session-meta span {
  max-width: min(42vw, 720px);
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  font-size: 12px;
  padding: 3px 8px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.field-label,
.section-heading {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  margin: 18px 0 8px;
  text-transform: uppercase;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
}

select,
input,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
  color: var(--text);
  outline: none;
}

select,
input {
  height: 36px;
  padding: 0 10px;
}

textarea {
  min-height: 78px;
  max-height: 240px;
  padding: 12px 14px;
  resize: vertical;
}

textarea::placeholder {
  color: #706a63;
}

select:focus,
input:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(209, 166, 0, 0.14);
}

.prompt-field {
  position: relative;
}

.skill-suggest {
  position: absolute;
  left: 0;
  bottom: calc(100% + 8px);
  z-index: 20;
  display: grid;
  gap: 2px;
  width: min(620px, 96%);
  max-height: 280px;
  overflow: auto;
  padding: 6px;
  background: #202020;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.35);
}

.skill-suggest[hidden],
.custom-option-input[hidden] {
  display: none;
}

.skill-suggest-item {
  display: grid;
  gap: 2px;
  min-height: 44px;
  padding: 8px 10px;
  background: transparent;
  border-radius: 6px;
  color: var(--text);
  text-align: left;
}

.skill-suggest-item.active,
.skill-suggest-item:hover {
  background: #2a271d;
}

.skill-suggest-name {
  font-weight: 700;
}

.skill-suggest-description {
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.primary-button,
.ghost-button,
.icon-button,
.tool-button {
  min-height: 34px;
  border-radius: 8px;
  padding: 0 12px;
  font-weight: 700;
}

.primary-button {
  width: 100%;
  margin-top: 12px;
  background: var(--accent);
  color: #181300;
}

.primary-button:hover:not(:disabled) {
  background: var(--accent-strong);
}

.ghost-button,
.icon-button,
.tool-button {
  background: var(--panel-strong);
  color: var(--text);
}

.ghost-button:hover:not(:disabled),
.icon-button:hover:not(:disabled),
.tool-button:hover:not(:disabled) {
  background: #2d2d2d;
}

.icon-button,
.tool-button {
  width: 34px;
  padding: 0;
}

.danger-icon-button:hover:not(:disabled) {
  background: rgba(242, 109, 109, 0.18);
  color: var(--danger);
}

.session-list {
  display: grid;
  gap: 8px;
}

.session-item {
  width: 100%;
  padding: 10px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 8px;
  color: var(--text);
  text-align: left;
}

.session-item:hover {
  background: #202020;
}

.session-item.active {
  background: #242116;
  border-color: rgba(209, 166, 0, 0.45);
}

.session-title {
  overflow: hidden;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.session-subtitle {
  margin-top: 4px;
}

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

.chat-header {
  justify-content: space-between;
  min-height: 44px;
  padding: 8px 24px;
  background: rgba(18, 18, 18, 0.92);
  border-bottom: 1px solid var(--line-soft);
}

.header-actions {
  flex-shrink: 0;
  gap: 8px;
}

.timeline {
  min-height: 0;
  overflow: auto;
  padding: 28px 24px 24px;
}

.messages,
.activity-inline {
  width: 100%;
  margin: 0;
}

.message {
  display: grid;
  gap: 7px;
  margin: 0 0 30px;
}

.message-role {
  color: #77716a;
  font-size: 12px;
  font-weight: 700;
}

.message.user {
  justify-items: end;
}

.message.user .message-role {
  display: none;
}

.message-body {
  max-width: 100%;
  overflow-wrap: anywhere;
  line-height: 1.62;
}

.message.user .message-body {
  max-width: min(620px, 88%);
  padding: 10px 14px;
  background: var(--panel-strong);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.message.assistant .message-body {
  color: var(--muted-strong);
}

.message.assistant .message-body > *:first-child {
  margin-top: 0;
}

.message-body > *:last-child {
  margin-bottom: 0;
}

.message h1,
.message h2,
.message h3,
.message h4,
.message h5,
.message h6 {
  margin: 20px 0 10px;
  color: var(--text);
  line-height: 1.25;
}

.message h1 {
  font-size: 24px;
}

.message h2 {
  font-size: 20px;
}

.message h3 {
  font-size: 17px;
}

.message p {
  margin: 0 0 14px;
}

.message ul,
.message ol {
  margin: 0 0 14px 22px;
  padding: 0;
}

.message li {
  margin: 5px 0;
}

.message blockquote {
  margin: 0 0 14px;
  padding: 2px 0 2px 14px;
  border-left: 3px solid var(--line);
  color: var(--muted);
}

.message a {
  color: var(--accent-strong);
  text-decoration: none;
}

.message a:hover {
  text-decoration: underline;
}

.message hr {
  height: 1px;
  margin: 22px 0;
  border: 0;
  background: var(--line-soft);
}

.message pre {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--code-bg);
  color: var(--code-text);
  margin: 0 0 14px;
  padding: 12px;
}

.message code {
  padding: 1px 4px;
  background: #252525;
  border-radius: 4px;
  color: var(--code-text);
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
}

.message-attachments {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 12px;
}

.message-attachments img {
  width: 132px;
  height: 92px;
  object-fit: cover;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
}

.message pre code {
  display: block;
  padding: 0;
  background: transparent;
  border-radius: 0;
}

.message table {
  display: block;
  width: 100%;
  max-width: 100%;
  margin: 0 0 14px;
  overflow: auto;
  border-collapse: collapse;
}

.message th,
.message td {
  padding: 8px 10px;
  border: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

.message th {
  background: var(--panel-strong);
  color: var(--text);
}

.activity-inline {
  margin-top: 44px;
  padding-top: 14px;
  border-top: 1px solid var(--line-soft);
}

.activity-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  min-height: 34px;
  padding: 0;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  text-align: left;
  text-transform: uppercase;
}

.activity-toggle::before {
  content: "v";
  width: 18px;
  color: #77716a;
  font-size: 14px;
}

.activity-toggle span:first-child {
  margin-right: auto;
}

.activity-toggle span:last-child {
  color: #77716a;
  font-weight: 600;
  text-transform: none;
}

.activity-inline.collapsed {
  margin-top: 24px;
  padding-top: 10px;
}

.activity-inline.collapsed .activity-toggle::before {
  content: ">";
}

.activity-inline.collapsed .activity-log {
  display: none;
}

.activity-log {
  display: grid;
  gap: 10px;
  min-width: 0;
  padding-bottom: 10px;
}

.activity-item {
  max-width: 100%;
  padding-left: 11px;
  border-left: 3px solid #55504a;
  color: #8c857c;
  font-size: 13px;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.activity-item.error {
  border-left-color: var(--danger);
  color: #f0a0a0;
}

.activity-item.warning {
  border-left-color: var(--warning);
  color: #cdbb7a;
}

.activity-item.success {
  border-left-color: var(--success);
  color: #9eddb4;
}

.composer {
  width: calc(100% - 48px);
  margin: 0 24px 22px;
  padding: 12px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-right: 0;
  border-left: 0;
  border-radius: 0;
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.28);
}

.composer textarea {
  min-height: 70px;
  max-height: 210px;
  padding: 8px 2px;
  background: transparent;
  border: 0;
  border-radius: 0;
  box-shadow: none;
}

.composer textarea:focus {
  box-shadow: none;
}

.image-attachments {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
}

.image-attachment {
  position: relative;
  width: 86px;
  height: 64px;
}

.image-attachment img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
}

.image-attachment-remove {
  position: absolute;
  top: -6px;
  right: -6px;
  width: 22px;
  height: 22px;
  padding: 0;
  border-radius: 999px;
  background: #d8d4ce;
  color: #171717;
  font-size: 14px;
  font-weight: 700;
  line-height: 22px;
}

.composer-toolbar {
  flex-wrap: wrap;
  margin-top: 8px;
}

.access-pill {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 0 10px;
  border-radius: 999px;
  color: var(--accent);
  font-size: 13px;
  font-weight: 700;
}

.options-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.model-option-field {
  display: flex;
  align-items: center;
  gap: 8px;
}

.model-option-field select {
  width: min(260px, 34vw);
}

.custom-option-input {
  width: min(220px, 34vw);
}

.composer-toolbar .status-text {
  margin-left: auto;
}

.composer-toolbar .primary-button {
  width: auto;
  min-width: 72px;
  margin-top: 0;
}

.stop-button {
  width: auto;
  min-width: 56px;
}

.dialog-actions .primary-button {
  width: auto;
  min-width: 96px;
  margin-top: 0;
}

.empty-state {
  color: var(--muted);
  padding: 16px 0;
}

.session-dialog {
  width: min(92vw, 480px);
  max-width: 480px;
  padding: 0;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.38);
  color: var(--text);
}

.session-dialog::backdrop {
  background: rgba(0, 0, 0, 0.48);
}

.session-dialog form {
  padding: 18px;
}

.session-dialog h3 {
  margin: 0 0 14px;
  font-size: 18px;
  line-height: 1.2;
}

.dialog-actions {
  justify-content: flex-end;
  margin-top: 18px;
}

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

  .timeline {
    padding: 22px 24px;
  }
}

@media (max-width: 720px) {
  body {
    height: auto;
    overflow: auto;
  }

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

  .sidebar {
    max-height: 38vh;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .chat-pane {
    height: auto;
    min-height: 72vh;
    overflow: visible;
  }

  .timeline {
    overflow: visible;
    padding-right: 12px;
    padding-left: 12px;
  }

  .composer {
    position: sticky;
    bottom: 12px;
    width: calc(100% - 24px);
    margin-right: 12px;
    margin-left: 12px;
    margin-bottom: 12px;
  }

  .model-option-field select,
  .custom-option-input {
    width: 100%;
  }

  .options-row,
  .model-option-field {
    width: 100%;
  }

  .session-meta {
    flex-basis: 100%;
    flex-wrap: wrap;
  }

  .session-meta span {
    max-width: 100%;
  }

  .composer-toolbar .status-text {
    margin-left: 0;
  }
}
