:root {
  --bg: #0f1115;
  --surface: #161922;
  --surface-2: #1d212d;
  --border: #2a2f3d;
  --text: #e6e8ee;
  --text-muted: #9ba2b1;
  --accent: #c084fc;
  --accent-hover: #a855f7;
  --user-bg: #2d3344;
  --tool-bg: #1a2030;
  --tool-border: #2d4a7c;
  --error: #f87171;
  --radius: 12px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.5;
}

body {
  display: flex;
  flex-direction: column;
  max-width: 880px;
  margin: 0 auto;
  padding: 16px;
}

header {
  border-bottom: 1px solid var(--border);
  padding-bottom: 12px;
  margin-bottom: 16px;
}

header h1 {
  margin: 0;
  font-size: 20px;
  font-weight: 600;
}

.subtitle {
  margin: 4px 0 0;
  color: var(--text-muted);
  font-size: 13px;
}

#claude-name {
  border-bottom: 1px dotted var(--text-muted);
  cursor: help;
}

.conversation {
  flex: 1;
  overflow-y: auto;
  padding: 8px 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.msg {
  padding: 12px 14px;
  border-radius: var(--radius);
  max-width: 100%;
  word-wrap: break-word;
}

.msg.user {
  background: var(--user-bg);
  align-self: flex-end;
  max-width: 80%;
  white-space: pre-wrap;
}

.msg.assistant {
  background: var(--surface);
  align-self: flex-start;
  max-width: 95%;
}

.msg.assistant .content > :first-child { margin-top: 0; }
.msg.assistant .content > :last-child { margin-bottom: 0; }

.msg.assistant p { margin: 6px 0; }
.msg.assistant h1,
.msg.assistant h2,
.msg.assistant h3,
.msg.assistant h4 {
  margin: 14px 0 6px;
  line-height: 1.25;
  font-weight: 600;
}
.msg.assistant h1 { font-size: 20px; }
.msg.assistant h2 { font-size: 17px; }
.msg.assistant h3 { font-size: 15px; }
.msg.assistant h4 { font-size: 14px; color: var(--text-muted); }

.msg.assistant ul,
.msg.assistant ol {
  margin: 6px 0;
  padding-left: 22px;
}
.msg.assistant li { margin: 2px 0; }

.msg.assistant a {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 2px;
}
.msg.assistant a:hover { color: var(--accent-hover); }

.msg.assistant strong { font-weight: 600; }

.msg.assistant code {
  background: var(--surface-2);
  padding: 1px 6px;
  border-radius: 4px;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 0.9em;
}
.msg.assistant pre {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  overflow-x: auto;
  margin: 8px 0;
}
.msg.assistant pre code {
  background: transparent;
  padding: 0;
  border-radius: 0;
  font-size: 12.5px;
}

.msg.assistant blockquote {
  margin: 8px 0;
  padding: 4px 12px;
  border-left: 3px solid var(--border);
  color: var(--text-muted);
}

.msg.assistant table {
  display: block;
  width: max-content;
  max-width: 100%;
  overflow-x: auto;
  border-collapse: collapse;
  margin: 10px 0;
  font-size: 13px;
}
.msg.assistant th,
.msg.assistant td {
  border: 1px solid var(--border);
  padding: 6px 10px;
  text-align: left;
  vertical-align: top;
}
.msg.assistant th {
  background: var(--surface-2);
  font-weight: 600;
}
.msg.assistant tbody tr:nth-child(even) td {
  background: rgba(255, 255, 255, 0.02);
}

.msg.assistant hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 12px 0;
}

.msg.error {
  background: rgba(248, 113, 113, 0.1);
  border: 1px solid var(--error);
  color: var(--error);
}

.tool-block {
  align-self: flex-start;
  max-width: 95%;
  background: var(--tool-bg);
  border: 1px solid var(--tool-border);
  border-radius: var(--radius);
  font-size: 13px;
  overflow: hidden;
}

.tool-block details {
  padding: 0;
}

.tool-block summary {
  cursor: pointer;
  padding: 8px 12px;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  color: var(--accent);
  user-select: none;
}

.tool-block summary:hover {
  background: rgba(192, 132, 252, 0.05);
}

.tool-block .body {
  padding: 0 12px 12px;
  border-top: 1px solid var(--tool-border);
  margin-top: 4px;
}

.tool-block pre {
  margin: 8px 0 0;
  font-size: 12px;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  color: var(--text-muted);
  white-space: pre-wrap;
  word-wrap: break-word;
  max-height: 320px;
  overflow: auto;
}

.tool-block .label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-top: 8px;
}

.tool-block.error {
  border-color: var(--error);
}

.composer {
  display: flex;
  gap: 8px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

#input {
  flex: 1;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 12px 14px;
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 15px;
  resize: vertical;
  min-height: 48px;
  max-height: 200px;
}

#input:focus {
  outline: none;
  border-color: var(--accent);
}

#send {
  background: var(--accent);
  color: #0f1115;
  border: none;
  padding: 0 20px;
  border-radius: var(--radius);
  font-weight: 600;
  cursor: pointer;
  font-size: 14px;
  align-self: stretch;
}

#send:hover:not(:disabled) {
  background: var(--accent-hover);
}

#send:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.cursor {
  display: inline-block;
  width: 8px;
  height: 16px;
  background: var(--accent);
  margin-left: 2px;
  vertical-align: text-bottom;
  animation: blink 1s steps(2, start) infinite;
}

@keyframes blink {
  to { visibility: hidden; }
}
