:root {
  --bg: #f7f7f5;
  --panel: #ffffff;
  --ink: #1f2328;
  --muted: #6b7280;
  --line: #deded8;
  --soft: #f1f1ed;
  --accent: #0f6b5f;
  --accent-dark: #08433b;
  --danger: #b42318;
  --shadow: 0 18px 45px rgba(18, 22, 32, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, "Segoe UI", Arial, sans-serif;
}

button,
input,
textarea {
  font: inherit;
}

button {
  min-height: 42px;
  border: 0;
  border-radius: 8px;
  padding: 0 16px;
  background: var(--ink);
  color: #fff;
  font-weight: 800;
  cursor: pointer;
}

button:disabled {
  cursor: wait;
  opacity: 0.66;
}

input,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 13px 14px;
  color: var(--ink);
  background: #fff;
}

textarea {
  min-height: 78px;
  max-height: 280px;
  resize: vertical;
}

label {
  display: grid;
  gap: 8px;
  font-weight: 800;
}

.hidden {
  display: none !important;
}

.app-shell {
  width: min(1180px, calc(100% - 28px));
  min-height: 100vh;
  display: grid;
  place-items: center;
  margin: 0 auto;
  padding: 18px 0;
}

.login-panel,
.chat-panel {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.login-panel {
  max-width: 720px;
  display: grid;
  grid-template-columns: 1fr 300px;
  gap: 28px;
  padding: 34px;
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--accent-dark);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 2px;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: 34px;
  line-height: 1.08;
}

.intro {
  margin: 16px 0 0;
  color: var(--muted);
  line-height: 1.55;
}

.login-form {
  display: grid;
  align-content: center;
  gap: 14px;
}

.status,
.composer-actions span {
  min-height: 24px;
  margin: 0;
  color: var(--muted);
  font-weight: 700;
}

.chat-panel {
  height: calc(100vh - 36px);
  display: grid;
  grid-template-rows: auto 1fr auto;
  overflow: hidden;
}

.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 18px 22px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.94);
}

.chat-header h1 {
  font-size: 24px;
}

.logout {
  border-radius: 8px;
  padding: 10px 14px;
  background: var(--soft);
  color: var(--ink);
  text-decoration: none;
  font-weight: 800;
}

.messages {
  display: grid;
  align-content: start;
  gap: 22px;
  padding: 28px max(24px, calc((100% - 860px) / 2));
  overflow: auto;
}

.turn {
  display: grid;
  gap: 12px;
}

.bubble {
  width: min(760px, 100%);
  border-radius: 8px;
  padding: 14px 16px;
  line-height: 1.55;
}

.user-bubble {
  justify-self: end;
  background: var(--ink);
  color: #fff;
}

.codex-bubble {
  justify-self: start;
  border: 1px solid var(--line);
  background: #fff;
}

.turn.failed .codex-bubble {
  border-color: rgba(180, 35, 24, 0.35);
}

.turn.queued .codex-bubble {
  border-style: dashed;
  background: #fbfbf8;
}

.bubble-label {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 8px;
  color: inherit;
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  opacity: 0.7;
}

.bubble-label span {
  letter-spacing: 0;
  text-transform: none;
}

.bubble-text,
.assistant-output {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.assistant-output:empty {
  display: none;
}

.empty {
  margin: 0;
  padding: 30px;
  color: var(--muted);
  text-align: center;
}

.progress-list {
  display: grid;
  gap: 8px;
  margin-bottom: 10px;
}

.progress-row {
  display: grid;
  gap: 3px;
  padding: 9px 11px;
  border-left: 3px solid #c7d2da;
  border-radius: 8px;
  background: #f7f8f8;
}

.progress-row strong {
  font-size: 13px;
}

.progress-row span {
  color: var(--muted);
  font-size: 13px;
  overflow-wrap: anywhere;
}

.progress-row.command {
  border-left-color: #2563eb;
}

.progress-row.edit {
  border-left-color: #8b5cf6;
}

.progress-row.error {
  border-left-color: var(--danger);
}

.composer {
  display: grid;
  padding: 16px max(16px, calc((100% - 920px) / 2)) 18px;
  border-top: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.96);
}

.composer-dock {
  display: grid;
  gap: 10px;
  border: 1px solid #d6d6cf;
  border-radius: 16px;
  padding: 12px;
  background: #fff;
  box-shadow: 0 10px 28px rgba(18, 22, 32, 0.08);
}

.composer-dock textarea {
  min-height: 68px;
  border: 0;
  border-radius: 10px;
  padding: 8px 6px;
  outline: none;
  font-size: 15px;
  line-height: 1.5;
}

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

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

.tool-cluster,
.send-cluster {
  display: flex;
  align-items: center;
  gap: 8px;
}

.mode-tabs {
  width: fit-content;
  display: flex;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--soft);
}

.mode-tabs label {
  display: block;
  margin: 0;
  cursor: pointer;
}

.mode-tabs input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.mode-tabs span {
  min-height: 30px;
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 0 12px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 900;
}

.mode-tabs input:checked + span {
  background: #fff;
  color: var(--ink);
  box-shadow: 0 1px 4px rgba(18, 22, 32, 0.08);
}

.mode-tabs input:disabled + span {
  opacity: 0.45;
  cursor: not-allowed;
}

.icon-tool {
  width: 36px;
  height: 36px;
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0;
  background: var(--soft);
  color: var(--ink);
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
}

.icon-tool input {
  display: none;
}

.icon-tool.recording {
  width: auto;
  padding: 0 12px;
  color: #fff;
  background: var(--danger);
  border-color: var(--danger);
}

.send-cluster span {
  max-width: 240px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.send-button {
  width: 38px;
  height: 38px;
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  padding: 0;
  font-size: 22px;
  line-height: 1;
}

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

.attachment-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8f8f5;
}

.attachment-item span {
  overflow-wrap: anywhere;
  color: var(--muted);
  font-weight: 700;
}

.attachment-item button {
  min-height: 30px;
  padding: 0 10px;
  background: #f3f4f6;
  color: var(--danger);
  box-shadow: none;
}

.message-files {
  margin: 8px 0 0;
  padding-left: 18px;
  font-size: 13px;
  font-weight: 700;
  opacity: 0.82;
}

@media (max-width: 720px) {
  .app-shell {
    width: 100%;
    padding: 0;
  }

  .login-panel {
    min-height: 100vh;
    grid-template-columns: 1fr;
    align-content: center;
    border-radius: 0;
    padding: 24px;
  }

  .chat-panel {
    height: 100vh;
    border-radius: 0;
  }

  .chat-header,
  .composer-toolbar,
  .send-cluster {
    align-items: stretch;
    flex-direction: column;
  }

  .tool-cluster {
    flex-wrap: wrap;
  }

  .send-cluster span {
    max-width: 100%;
  }

  .messages {
    padding: 18px 14px;
  }

  .bubble {
    width: 100%;
  }

  h1 {
    font-size: 30px;
  }
}
