:root {
  color-scheme: dark;
  --orange: #ff6b00;
  --orange-soft: #ff9b52;
  --ink: #050505;
  --panel: #10100f;
  --line: rgba(255, 107, 0, .28);
  --paper: #f8f5f1;
  --muted: #9e9892;
}

* { box-sizing: border-box; }

html, body { min-height: 100%; }

body {
  margin: 0;
  background:
    linear-gradient(rgba(255, 107, 0, .035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 107, 0, .035) 1px, transparent 1px),
    radial-gradient(circle at 50% 0, rgba(255, 107, 0, .12), transparent 38%),
    var(--ink);
  background-size: 48px 48px, 48px 48px, auto, auto;
  color: var(--paper);
  font-family: Inter, Arial, Helvetica, sans-serif;
}

button, input, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
.hidden { display: none !important; }

.shell {
  display: flex;
  min-height: 100dvh;
  flex-direction: column;
}

.topbar {
  display: flex;
  min-height: 72px;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px clamp(18px, 4vw, 54px);
  border-bottom: 1px solid var(--line);
  background: rgba(5, 5, 5, .86);
  backdrop-filter: blur(18px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--paper);
  text-decoration: none;
  letter-spacing: .08em;
}

.brand svg {
  width: 32px;
  height: 38px;
  fill: var(--orange);
}

.brand span { font-size: 15px; color: #aaa39c; }
.brand strong { color: var(--paper); }

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

.model-indicator {
  padding: 7px 11px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--orange-soft);
  font-size: 11px;
  letter-spacing: .04em;
}

.icon-button {
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 12px;
}

.login-card {
  width: min(460px, calc(100% - 32px));
  margin: auto;
  padding: clamp(30px, 6vw, 52px);
  border: 1px solid var(--line);
  border-radius: 24px;
  background: linear-gradient(145deg, rgba(24, 20, 17, .96), rgba(8, 8, 8, .97));
  box-shadow: 0 30px 90px rgba(0, 0, 0, .48);
}

.login-mark {
  display: grid;
  width: 72px;
  height: 72px;
  margin-bottom: 30px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: rgba(255, 107, 0, .05);
}

.login-mark svg { width: 38px; height: 46px; fill: var(--orange); }
.eyebrow { margin: 0 0 8px; color: var(--orange); font-size: 10px; letter-spacing: .18em; }

.login-card h1,
.chat__intro h1 {
  margin: 0;
  font-size: clamp(34px, 6vw, 58px);
  font-weight: 450;
  letter-spacing: -.055em;
}

.login-card > p:not(.eyebrow),
.chat__intro > p:last-child {
  color: var(--muted);
  line-height: 1.55;
}

.login-card form { margin-top: 32px; }
.login-card label { display: block; margin-bottom: 8px; color: #bcb5ae; font-size: 12px; }
.pin-row { display: grid; grid-template-columns: 1fr auto; gap: 10px; }

.pin-row input,
.composer textarea {
  min-width: 0;
  border: 1px solid #34312e;
  border-radius: 13px;
  outline: 0;
  background: #080808;
  color: var(--paper);
}

.pin-row input {
  min-height: 50px;
  padding: 0 16px;
  letter-spacing: .22em;
}

.pin-row input:focus,
.composer textarea:focus { border-color: var(--orange); box-shadow: 0 0 0 3px rgba(255, 107, 0, .1); }

.pin-row button {
  min-height: 50px;
  padding: 0 22px;
  border: 0;
  border-radius: 13px;
  background: var(--orange);
  color: #160b03;
  cursor: pointer;
  font-weight: 750;
}

.form-status,
.chat-status { min-height: 18px; margin: 10px 0 0; color: #ff9e8d; font-size: 12px; }

.chat {
  display: flex;
  width: min(920px, 100%);
  min-height: 0;
  flex: 1;
  align-self: center;
  flex-direction: column;
  padding: clamp(24px, 4vw, 46px) clamp(16px, 4vw, 38px) 18px;
}

.chat__intro { padding: 0 4px 26px; }
.chat__intro h1 { font-size: clamp(34px, 5vw, 54px); }
.chat__intro > p:last-child { max-width: 680px; margin-bottom: 0; font-size: 13px; }

.messages {
  display: grid;
  min-height: 180px;
  flex: 1;
  align-content: end;
  gap: 13px;
  padding: 10px 4px 24px;
}

.history-more {
  align-self: center;
  margin: 0 auto 8px;
  padding: 8px 13px;
  border: 1px solid #37312d;
  border-radius: 999px;
  background: #11100f;
  color: #aaa39c;
  cursor: pointer;
  font-size: 10px;
}

.history-more:hover {
  border-color: var(--line);
  color: var(--orange-soft);
}

.message {
  width: fit-content;
  max-width: min(82%, 720px);
  padding: 13px 16px;
  border-radius: 18px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-size: 14px;
  line-height: 1.55;
}

.message--user {
  justify-self: end;
  border-bottom-right-radius: 5px;
  background: var(--orange);
  color: #160b03;
}

.message--assistant {
  justify-self: start;
  border: 1px solid #262321;
  border-bottom-left-radius: 5px;
  background: var(--panel);
  color: #e8e2dc;
}

.message__meta {
  display: block;
  margin-bottom: 5px;
  color: inherit;
  opacity: .58;
  font-size: 9px;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.message__text > a:not(.message__generated-image) {
  color: var(--orange-soft);
  text-decoration: underline;
  text-decoration-color: rgba(255, 155, 82, .45);
  text-underline-offset: 3px;
}

.message__generated-image {
  display: block;
  width: min(100%, 560px);
  margin: 10px 0 2px;
  white-space: normal;
}

.message__generated-image img {
  display: block;
  width: 100%;
  height: auto;
  max-height: 620px;
  border: 1px solid #302b27;
  border-radius: 14px;
  background: #080808;
  object-fit: contain;
}

.message__attachments {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(110px, 170px));
  gap: 8px;
  margin-top: 10px;
}

.message__attachments img {
  width: 100%;
  height: 120px;
  border-radius: 12px;
  object-fit: cover;
}

.task-timeline {
  display: grid;
  gap: 8px;
  margin: 0 4px 14px;
}

.task-card {
  border: 1px solid #2e2925;
  border-radius: 15px;
  background: rgba(14, 14, 13, .94);
  overflow: hidden;
}

.task-card[open] { border-color: var(--line); }

.task-card summary {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 42px;
  padding: 9px 12px;
  cursor: pointer;
  list-style: none;
  color: #d7d0c9;
  font-size: 11px;
}

.task-card summary::-webkit-details-marker { display: none; }
.task-card__title { flex: 1; }
.task-card__model { color: var(--orange-soft); font-size: 9px; letter-spacing: .05em; text-transform: uppercase; }

.task-card__dot {
  width: 8px;
  height: 8px;
  flex: 0 0 8px;
  border-radius: 50%;
  background: #6d6863;
}

.task-card--running .task-card__dot,
.task-card--queued .task-card__dot {
  background: var(--orange);
  animation: pulse 1.5s infinite;
}

.task-card--done .task-card__dot { background: #48b979; }
.task-card--error .task-card__dot { background: #e45b5b; }

.task-steps {
  display: grid;
  gap: 7px;
  margin: 0;
  padding: 0 12px 12px 31px;
  list-style: none;
}

.task-steps li {
  position: relative;
  color: #aaa39c;
  font-size: 11px;
  line-height: 1.4;
}

.task-steps li::before {
  content: "";
  position: absolute;
  left: -18px;
  top: 5px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #56504b;
}

.task-steps li[data-kind="tool"]::before { background: var(--orange); }
.task-steps li[data-kind="file"]::before { background: #6b8ce8; }
.task-steps li[data-kind="done"]::before { background: #48b979; }
.task-steps li[data-kind="error"]::before { background: #e45b5b; }

.working {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 4px 12px;
  color: var(--muted);
  font-size: 12px;
}

.working__pulse {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--orange);
  box-shadow: 0 0 0 0 rgba(255, 107, 0, .55);
  animation: pulse 1.5s infinite;
}

.attachments {
  display: flex;
  gap: 8px;
  margin: 0 4px 10px;
  overflow-x: auto;
}

.attachment-preview {
  position: relative;
  flex: 0 0 82px;
}

.attachment-preview img {
  width: 82px;
  height: 64px;
  border: 1px solid var(--line);
  border-radius: 11px;
  object-fit: cover;
}

.attachment-preview button {
  position: absolute;
  top: -5px;
  right: -5px;
  display: grid;
  width: 20px;
  height: 20px;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: #fff;
  color: #1b1009;
  cursor: pointer;
  font-size: 13px;
}

.composer {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: rgba(16, 16, 15, .96);
  box-shadow: 0 18px 50px rgba(0, 0, 0, .35);
}

.attach-button {
  display: grid;
  width: 48px;
  height: 48px;
  flex: 0 0 48px;
  place-items: center;
  border-radius: 15px;
  background: #24211f;
  color: #c5bdb6;
  cursor: pointer;
}

.attach-button input { display: none; }
.attach-button svg { width: 21px; fill: none; stroke: currentColor; stroke-width: 1.6; }

.composer textarea {
  min-height: 48px;
  max-height: 180px;
  flex: 1;
  resize: none;
  padding: 13px 14px;
  border-color: transparent;
  background: transparent;
  line-height: 1.45;
}

.composer button {
  display: grid;
  width: 48px;
  height: 48px;
  flex: 0 0 48px;
  place-items: center;
  border: 0;
  border-radius: 15px;
  background: var(--orange);
  color: #160b03;
  cursor: pointer;
}

.composer button:disabled { cursor: wait; opacity: .55; }
.composer button svg { width: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

@keyframes pulse {
  70% { box-shadow: 0 0 0 9px rgba(255, 107, 0, 0); }
  100% { box-shadow: 0 0 0 0 rgba(255, 107, 0, 0); }
}

@media (max-width: 640px) {
  .topbar { min-height: 62px; padding: 11px 14px; }
  .brand svg { width: 26px; height: 32px; }
  .brand span { font-size: 13px; }
  .model-indicator { max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .login-card { border-radius: 20px; }
  .chat { padding: 24px 12px 10px; }
  .chat__intro { padding-inline: 4px; }
  .message { max-width: 90%; font-size: 13px; }
}
