* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --accent: #d97534;
  --accent-hover: #c56629;
  --bg-primary: #fafafa;
  --bg-secondary: #f5f5f5;
  --bg-tertiary: #efefef;
  --text-primary: #1c1917;
  --text-secondary: #57534e;
  --text-muted: #78716c;
  --border: #e7e5e4;
  --code-bg: #f5f5f4;
  --user-bg: #fef3eb;
  --assistant-bg: #ffffff;
  --error-bg: #fef2f2;
  --error-border: #fecaca;
  --error-text: #b91c1c;
}

html, body {
  height: 100%;
  height: 100dvh;
  overflow: hidden;
}

body {
  font-family: 'Space Grotesk', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  font-size: 13px;
  display: flex;
  flex-direction: column;
}

#auth-loading-overlay {
  display: none;
  position: absolute;
  inset: 0;
  top: 0;
  z-index: 50;
  background: var(--bg-primary);
  align-items: center;
  justify-content: center;
}

.auth-loading #auth-loading-overlay {
  display: flex;
}

header {
  padding: 0.625rem 0.75rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--bg-secondary);
  flex-shrink: 0;
  min-height: 44px;
  box-sizing: border-box;
}

header h1 {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.9375rem;
  font-weight: 500;
  color: var(--accent);
}

header span {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.chat-container {
  flex: 1;
  overflow-y: auto;
  padding: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.625rem;
  min-height: 0;
}

.message {
  max-width: 100%;
  padding: 0.625rem 0.75rem;
  border-radius: 8px;
  font-size: 14px;
  line-height: 1.6;
  word-wrap: break-word;
  overflow-wrap: break-word;
}

.message.user {
  align-self: flex-end;
  background: var(--user-bg);
  border: 1px solid rgba(231, 138, 78, 0.4);
  max-width: 90%;
}

.message.assistant {
  align-self: stretch;
  background: var(--assistant-bg);
  border: 1px solid var(--border);
}

.message pre {
  background: var(--code-bg);
  padding: 0.5rem;
  border-radius: 0 0 6px 6px;
  overflow-x: auto;
  margin: 0;
  border: 1px solid var(--border);
  border-top: none;
  white-space: pre-wrap;
  word-break: break-word;
}

.message code {
  font-family: 'JetBrains Mono', 'SF Mono', 'Fira Code', monospace;
  font-size: 0.75rem;
}

.message p code {
  background: var(--code-bg);
  padding: 0.125rem 0.375rem;
  border-radius: 4px;
}

.code-panel {
  margin: 0.5rem 0;
  border-radius: 6px;
  overflow: hidden;
}

.code-panel summary {
  background: var(--bg-tertiary);
  padding: 0.375rem 0.625rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.375rem;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.75rem;
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: 6px;
  user-select: none;
  list-style: none;
}

.code-panel[open] summary {
  border-radius: 6px 6px 0 0;
  border-bottom: none;
}

.code-panel summary::-webkit-details-marker {
  display: none;
}

.code-panel summary::before {
  content: '▶';
  font-size: 0.625rem;
  transition: transform 0.15s;
}

.code-panel[open] summary::before {
  transform: rotate(90deg);
}

.code-panel summary:hover {
  color: var(--text-secondary);
}

.code-panel summary .lang {
  color: var(--accent);
  flex: 1;
}

.code-panel summary .copy-btn,
.code-panel summary .edit-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0.25rem;
  border-radius: 4px;
}

.code-panel summary .copy-btn:hover,
.code-panel summary .edit-btn:hover {
  background: var(--border);
  color: var(--text-secondary);
}

.code-panel summary .action-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.25rem;
  margin-left: auto;
}

.formula-panel {
  border: 1px solid var(--accent);
  border-radius: 6px;
}

.formula-panel summary {
  background: rgba(231, 138, 78, 0.1);
  border-color: transparent;
}

.formula-panel[open] summary {
  border-bottom: 1px solid var(--accent);
}

.formula-panel pre {
  border-color: var(--accent);
}

.code-panel pre {
  margin: 0;
  border-radius: 0 0 6px 6px;
}

.monaco-container {
  border-radius: 0 0 6px 6px;
  overflow: hidden;
}

.test-panel {
  margin: 0.25rem 0 0.5rem;
  border-radius: 6px;
  overflow: hidden;
}

.test-panel summary {
  background: var(--bg-tertiary);
  padding: 0.25rem 0.625rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.375rem;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.7rem;
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: 6px;
  user-select: none;
  list-style: none;
}

.test-panel[open] summary {
  border-radius: 6px 6px 0 0;
  border-bottom: none;
}

.test-panel summary::-webkit-details-marker {
  display: none;
}

.test-panel summary::before {
  content: '▶';
  font-size: 0.5rem;
  transition: transform 0.15s;
}

.test-panel[open] summary::before {
  transform: rotate(90deg);
}

.test-panel summary .lang {
  color: var(--text-muted);
  flex: 1;
}

.run-tests-btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.65rem;
  padding: 0.125rem 0.5rem;
  border-radius: 4px;
  cursor: pointer;
}

.run-tests-btn:hover {
  background: var(--border);
  color: var(--text-secondary);
}

.test-lines {
  margin: 0;
  padding: 0.5rem 0.75rem;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.7rem;
  color: var(--text-secondary);
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-top: none;
  border-radius: 0 0 6px 6px;
  white-space: pre-wrap;
  line-height: 1.5;
}

.action-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.375rem 0.625rem;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text-secondary);
  font-family: 'Space Grotesk', sans-serif;
  font-size: 0.75rem;
  cursor: pointer;
  transition: all 0.15s;
}

.action-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.action-btn.primary,
.action-btn.primary:visited {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.action-btn.primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
  color: #fff;
}

.message p {
  margin-bottom: 0.375rem;
}

.message p:last-child {
  margin-bottom: 0;
}

.message ul, .message ol {
  margin: 0.375rem 0 0.375rem 1.25rem;
}

.message li {
  margin-bottom: 0.125rem;
}

.message strong {
  color: var(--text-primary);
}

.message h1, .message h2, .message h3 {
  font-family: 'JetBrains Mono', monospace;
  color: var(--text-primary);
  margin: 0.625rem 0 0.375rem 0;
  font-weight: 500;
}

.message h1 { font-size: 0.9375rem; }
.message h2 { font-size: 0.875rem; }
.message h3 { font-size: 0.8125rem; }

.thinking {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.5rem 0.75rem;
  background: var(--assistant-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-muted);
  align-self: flex-start;
  font-size: 0.8125rem;
}

.thinking-dots {
  display: flex;
  gap: 3px;
}

.thinking-dots span {
  width: 6px;
  height: 6px;
  background: var(--accent);
  border-radius: 50%;
  animation: bounce 1.4s infinite ease-in-out;
}

.thinking-dots span:nth-child(1) { animation-delay: -0.32s; }
.thinking-dots span:nth-child(2) { animation-delay: -0.16s; }

@keyframes bounce {
  0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
  40% { transform: scale(1); opacity: 1; }
}

.input-area {
  padding: 0.625rem 0.75rem;
  border-top: 1px solid var(--border);
  background: var(--bg-secondary);
  flex-shrink: 0;
}

.input-wrapper {
  display: flex;
  gap: 0.5rem;
}

.input-footer {
  display: flex;
  justify-content: flex-end;
  margin-top: 0.25rem;
}

.feedback-link {
  font-size: 0.6875rem;
  color: var(--text-secondary);
  text-decoration: none;
  opacity: 0.6;
  transition: opacity 0.15s;
}

.feedback-link:hover {
  opacity: 1;
  text-decoration: underline;
}

textarea {
  flex: 1;
  padding: 0.5rem 0.625rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg-tertiary);
  color: var(--text-primary);
  font-family: 'Space Grotesk', -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 0.8125rem;
  resize: none;
  min-height: 60px;
  max-height: 120px;
  line-height: 1.4;
  overflow-y: auto;
}

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

textarea::placeholder {
  color: var(--text-muted);
}

button#send {
  padding: 0 0.875rem;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 6px;
  font-family: 'Space Grotesk', sans-serif;
  font-size: 0.8125rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s;
  white-space: nowrap;
}

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

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

.empty-state {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  text-align: center;
  padding: 1rem;
}

.empty-state h2 {
  font-family: 'JetBrains Mono', monospace;
  font-size: 1rem;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 0.375rem;
}

.empty-state p {
  font-size: 0.8125rem;
  line-height: 1.5;
  color: var(--text-secondary);
}

.suggestions {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
  margin-top: 1rem;
  width: 100%;
}

.suggestion {
  padding: 0.5rem 0.75rem;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-secondary);
  font-family: 'Space Grotesk', sans-serif;
  font-size: 0.8125rem;
  cursor: pointer;
  transition: all 0.15s;
  text-align: left;
}

.suggestion:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* In-message suggestions */
.suggestions-container {
  margin-top: 0.625rem;
  padding-top: 0.625rem;
  border-top: 1px solid var(--border);
}

.suggestions-header {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 0.375rem;
}

.message .suggestions {
  margin-top: 0;
  width: auto;
}

.error {
  background: var(--error-bg);
  border-color: var(--error-border);
  color: var(--error-text);
}

.compile-error {
  margin: 8px 0 0 0;
  padding: 8px 10px;
  background: var(--bg-secondary);
  border-radius: 4px;
  font-size: 11px;
  line-height: 1.4;
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-word;
}

/* Scrollbar styling for narrow pane */
.chat-container::-webkit-scrollbar {
  width: 6px;
}

.chat-container::-webkit-scrollbar-track {
  background: var(--bg-primary);
}

.chat-container::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}

.chat-container::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* Header buttons */
.header-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.25rem;
  padding: 0 0.5rem;
  height: 28px;
  font-size: 0.7rem;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s;
  color: var(--text-secondary);
}

.header-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.header-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

/* Panels */
.panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.panel.hidden {
  display: none;
}

.panel-content {
  flex: 1;
  overflow-y: auto;
  padding: 0.75rem;
}

.panel-content h2 {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.9375rem;
  font-weight: 500;
  color: var(--text-primary);
  margin-bottom: 0.5rem;
}

.panel-content h3 {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-secondary);
  margin: 1rem 0 0.375rem 0;
}

.panel-content h3:first-of-type {
  margin-top: 0.75rem;
}

.panel-content p {
  font-size: 0.8125rem;
  line-height: 1.5;
  color: var(--text-secondary);
  margin-bottom: 0.5rem;
}

.panel-content ul {
  font-size: 0.8125rem;
  line-height: 1.5;
  color: var(--text-secondary);
  margin: 0.375rem 0 0.375rem 1.25rem;
}

.panel-content li {
  margin-bottom: 0.25rem;
}

.panel-content a,
.panel-content a:visited {
  color: var(--accent);
  text-decoration: none;
}

.panel-content a:hover {
  text-decoration: underline;
}

.panel-content .text-muted {
  color: var(--text-muted);
  font-style: italic;
}

.build-section,
.help-section {
  margin-bottom: 1.5rem;
}

.help-section + .help-section {
  padding-top: 0.25rem;
}

.userinfo-table {
  border-collapse: collapse;
  font-size: 0.8125rem;
  width: 100%;
}

.userinfo-table tr {
  border-bottom: 1px solid var(--border);
}

.userinfo-table tr:last-child {
  border-bottom: none;
}

.userinfo-table td {
  padding: 6px 0;
}

.userinfo-label {
  color: var(--text-muted);
  white-space: nowrap;
  width: 4.5rem;
  padding-right: 1rem !important;
}

.empty-box {
  padding: 0.75rem;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-muted);
  font-size: 0.8125rem;
  text-align: center;
}

.empty-box-hint {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  margin-top: 0.375rem;
  color: var(--text-secondary);
}

.empty-box-hint svg {
  flex-shrink: 0;
}

.build-section .action-btn {
  margin-bottom: 0.5rem;
}

.build-download-btn {
  padding: 0.625rem 1rem;
  font-size: 0.875rem;
  gap: 0.375rem;
}

.build-download-btn svg {
  width: 18px;
  height: 18px;
}

.action-btn.secondary {
  background: var(--bg-secondary);
  border-color: var(--accent);
  color: var(--accent);
}

.action-btn.secondary:hover {
  background: rgba(217, 117, 52, 0.1);
}


.preview-badge {
  font-size: 0.625rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: rgba(255, 255, 255, 0.25);
  padding: 0.1rem 0.35rem;
  border-radius: 3px;
}

/* Light mode refinements */
.message.user {
  border-color: rgba(217, 117, 52, 0.3);
}

.message.assistant {
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

.code-panel summary {
  background: var(--bg-secondary);
}

.formula-panel summary {
  background: rgba(217, 117, 52, 0.08);
}

/* Formula/function insert actions */
.formula-actions,
.function-actions {
  margin-top: 0.625rem;
  padding-top: 0.625rem;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 0.5rem;
}

/* Info box (breakdown, recommendation) */
.info-box {
  margin: 0.5rem 0;
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
}

.info-box-header {
  background: var(--bg-tertiary);
  padding: 0.375rem 0.625rem;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.info-box-content {
  margin: 0;
  padding: 0.25rem 0.375rem 0.25rem 1rem;
  list-style: disc;
}

.info-box-item {
  font-size: 0.8125rem;
  line-height: 1.5;
  color: var(--text-secondary);
  padding-left: 0.25rem;
}

/* Examples box */
.examples-box {
  margin: 0.5rem 0;
  border: 1px solid #f59e0b;
  border-radius: 6px;
  overflow: hidden;
}

.examples-box-header {
  background: #fef3c7;
  padding: 0.375rem 0.625rem;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.75rem;
  color: #92400e;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.examples-run-all-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.2rem 0.5rem;
  background: none;
  border: 1px solid #f59e0b;
  border-radius: 4px;
  font-family: 'Space Grotesk', sans-serif;
  font-size: 0.6875rem;
  color: #92400e;
  cursor: pointer;
  transition: all 0.15s;
}

.examples-run-all-btn:hover {
  background: rgba(245, 158, 11, 0.15);
  border-color: #d97706;
  color: #78350f;
}

.examples-list {
  display: flex;
  flex-direction: column;
}

.example-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.375rem 0.625rem;
  border-top: 1px solid #f59e0b;
  background: #fffbeb;
}

.example-formula {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.75rem;
  color: var(--text-primary);
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.example-result {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.75rem;
  color: var(--text-muted);
  white-space: nowrap;
}

.example-result.running {
  color: var(--text-muted);
}

.example-result.success {
  color: #16a34a;
}

.example-result.error {
  color: var(--error-text);
  font-size: 0.6875rem;
}

.example-run-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  background: none;
  border: 1px solid #f59e0b;
  border-radius: 4px;
  color: #92400e;
  cursor: pointer;
  transition: all 0.15s;
  flex-shrink: 0;
}

.example-run-btn:hover {
  background: rgba(245, 158, 11, 0.15);
  border-color: #d97706;
  color: #78350f;
}

.example-run-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.example-send-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  background: none;
  border: 1px solid #f59e0b;
  border-radius: 4px;
  color: #92400e;
  cursor: pointer;
  transition: all 0.15s;
  flex-shrink: 0;
}

.example-send-btn:hover {
  background: rgba(245, 158, 11, 0.15);
  border-color: #d97706;
  color: #78350f;
}


.function-actions .action-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
}

.function-actions code {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.75rem;
  background: rgba(255, 255, 255, 0.15);
  padding: 0.125rem 0.375rem;
  border-radius: 3px;
}

/* Note hint text */
.note-hint {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-style: italic;
  margin: 0.25rem 0 0.5rem 0;
  line-height: 1.4;
}

/* Function hint */
.function-hint {
  display: block;
  margin-top: 0.5rem;
  font-size: 0.7rem;
  color: var(--text-muted);
}

.function-hint code {
  font-family: 'JetBrains Mono', monospace;
  background: var(--bg-tertiary);
  padding: 0.1rem 0.3rem;
  border-radius: 3px;
}

/* Add to add-in button */
.add-to-addin-container {
  margin-top: 0.625rem;
  padding-top: 0.625rem;
  border-top: 1px solid var(--border);
}

.add-to-addin-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.5rem 0.75rem;
  background: #16a34a;
  border: 1px solid #16a34a;
  border-radius: 6px;
  color: #fff;
  font-family: 'Space Grotesk', sans-serif;
  font-size: 0.8125rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
}

.add-to-addin-btn:hover {
  background: #15803d;
  border-color: #15803d;
}

.add-to-addin-btn:disabled {
  background: var(--bg-tertiary);
  border-color: var(--border);
  color: var(--text-muted);
  cursor: default;
}

/* AI generated badge in code panel header */
.ai-badge {
  font-size: 0.625rem;
  font-weight: 400;
  color: var(--text-muted);
  font-style: italic;
}

/* Verified stdlib badge in code panel header */
.verified-badge {
  color: var(--green, #22c55e);
}

.verified-badge svg {
  vertical-align: -0.125em;
}

/* Functions list on build page */
.functions-list {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
}

.function-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 0.625rem;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: 6px;
}

.function-item-info code {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.8125rem;
  color: var(--text-primary);
}

.function-item-actions {
  display: flex;
  gap: 0.25rem;
}

.function-item-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  background: none;
  border: none;
  border-radius: 4px;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s;
}

.function-item-btn:hover {
  background: var(--border);
  color: var(--accent);
}

.function-item-btn.delete:hover {
  background: var(--error-bg);
  color: var(--error-text);
}

/* Code update message from editor */
.message.code-update {
  align-self: stretch;
  background: var(--bg-tertiary);
  border-color: var(--border);
}

.code-update-header {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  font-size: 0.8125rem;
  color: var(--text-secondary);
}

.code-update-header svg {
  color: var(--accent);
  flex-shrink: 0;
}

.code-update-header strong {
  font-family: 'JetBrains Mono', monospace;
  color: var(--accent);
}

.code-update-hint {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin: 0.25rem 0 0.5rem 0;
}

/* Header spacer */
.header-spacer {
  flex: 1;
}

/* Sign-in button */

.user-initial {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 0.75rem;
  font-weight: 600;
}

.signed-in-check {
  position: absolute;
  bottom: 2px;
  right: 2px;
  background: var(--accent);
  border-radius: 50%;
  padding: 1px;
  stroke: #fff;
}

.signin-btn {
  position: relative;
  white-space: nowrap;
  width: auto;
  padding: 0 0.625rem;
  gap: 0.375rem;
  height: 28px;
  margin-left: auto;
}

.signin-btn.signed-in {
  gap: 0.25rem;
  background: rgba(217, 117, 52, 0.15);
  border-color: var(--accent);
  color: var(--accent);
}

.user-name {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 0.75rem;
  font-weight: 500;
  max-width: 100px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.logout-icon {
  flex-shrink: 0;
  opacity: 0.7;
}

.signin-btn.signed-in:hover .logout-icon {
  opacity: 1;
}

/* Anonymous state */
.signin-btn.anonymous {
  background: var(--bg-tertiary);
  border: 1px dashed var(--text-muted);
  color: var(--text-muted);
}

.signin-btn.anonymous:hover {
  border-color: var(--accent);
  border-style: solid;
  color: var(--accent);
}

.anon-label {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 0.6875rem;
  font-weight: 500;
}

/* Anonymous mode - muted header */
body.anonymous header {
  background: #e8e6e3;
  border-bottom-color: #d6d3d0;
}

body.anonymous .header-btn {
  background: #ddd9d5;
  border-color: #ccc8c4;
}

body.anonymous .header-btn.active {
  background: var(--text-muted);
  border-color: var(--text-muted);
}

/* Build header */
.build-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.build-header h2 {
  margin-bottom: 0;
}

/* Build form */
.build-form {
  display: flex;
  flex-direction: column;
}

.build-label {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin: 0.625rem 0 0.25rem 0;
}

.build-label:first-child {
  margin-top: 0;
}

.build-form .build-hint {
  margin-top: 0.25rem;
}

.build-form .build-hint:last-child {
  margin-bottom: 0;
}

.build-input {
  padding: 0.375rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg-tertiary);
  color: var(--text-primary);
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.75rem;
  max-width: 260px;
}

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

.build-input::placeholder {
  color: var(--text-muted);
  font-family: 'Space Grotesk', sans-serif;
}

.build-form-container,
.build-download-box {
  background: #fff8f3;
  border: 1px solid rgba(217, 117, 52, 0.2);
  border-radius: 6px;
  padding: 0.375rem 0.75rem 0.625rem;
}

.panel-content .build-download-box h3,
.panel-content .build-form-container h3 {
  margin: 0.25rem 0 0.75rem 0;
  font-size: 0.85rem;
}

.build-download-box .build-hint {
  margin-bottom: 0.5rem;
}

.build-download-box .build-hint:last-child {
  margin-bottom: 0;
}

/* Collapsible build settings */
.build-settings-details {
  margin-bottom: 1rem;
}

.build-settings-summary {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  cursor: pointer;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-secondary);
  padding: 0.5rem 0.75rem;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: 6px;
  list-style: none;
  user-select: none;
}

.build-settings-summary::-webkit-details-marker {
  display: none;
}

.build-settings-summary::after {
  content: '';
  margin-left: auto;
  border: 4px solid transparent;
  border-top: 5px solid var(--text-muted);
  transition: transform 0.15s;
}

.build-settings-details[open] .build-settings-summary::after {
  transform: rotate(180deg);
}

.build-settings-details[open] .build-settings-summary {
  border-radius: 6px 6px 0 0;
  border-bottom-color: transparent;
}

.build-settings-details .build-form {
  border: 1px solid var(--border);
  border-top: none;
  border-radius: 0 0 6px 6px;
  padding: 0.5rem 0.75rem 0.625rem;
  background: var(--bg-secondary, #fafafa);
}

/* Build tabs */
.build-tabs {
  display: flex;
  gap: 2px;
  margin-bottom: 0.75rem;
  background: var(--bg-tertiary);
  border-radius: 6px;
  padding: 2px;
}

.build-tab {
  flex: 1;
  padding: 0.375rem 0.5rem;
  border: none;
  background: transparent;
  border-radius: 4px;
  font-family: 'Space Grotesk', -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s;
}

.build-tab:hover {
  color: var(--text-primary);
}

.build-tab.active {
  background: #fff;
  color: var(--accent);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
}

.build-tab-content {
  display: none;
}

.build-tab-content.active {
  display: block;
}

/* Office JS radio options */
.build-officejs-options {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
  margin-bottom: 0.75rem;
}

.build-radio-label {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  cursor: pointer;
  font-size: 0.8125rem;
}

.build-radio-label input[type="radio"] {
  margin-top: 3px;
  accent-color: var(--accent);
}

.build-radio-label span {
  display: flex;
  flex-direction: column;
}

.build-radio-label strong {
  font-size: 0.8125rem;
}

.build-radio-label .build-hint {
  margin: 0;
  display: inline;
}

.build-hint {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin: 0.125rem 0 0 0;
}

.build-hint code {
  font-family: 'JetBrains Mono', monospace;
  background: var(--bg-tertiary);
  padding: 0.1rem 0.3rem;
  border-radius: 3px;
}

.build-status {
  font-size: 0.8125rem;
  margin-bottom: 0.5rem;
  padding: 0.5rem 0.625rem;
  border-radius: 6px;
}

.build-status.error {
  background: var(--error-bg);
  border: 1px solid var(--error-border);
  color: var(--error-text);
}

.build-status.success {
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  color: #16a34a;
}

.build-status.loading {
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.build-status.loading::before {
  content: '';
  width: 14px;
  height: 14px;
  border: 2px solid var(--border, #ddd);
  border-top-color: var(--text-secondary, #666);
  border-radius: 50%;
  animation: build-spin 0.6s linear infinite;
  flex-shrink: 0;
}

@keyframes build-spin {
  to { transform: rotate(360deg); }
}

/* Auth-only buttons disabled when anonymous */
body.anonymous .header-btn.auth-only {
  opacity: 0.4;
  cursor: not-allowed;
}

/* Modal overlay */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 1rem;
}

.modal-overlay.hidden {
  display: none;
}

/* Modal */
.modal {
  background: var(--bg-primary);
  border-radius: 12px;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.15);
  max-width: 320px;
  width: 100%;
  padding: 1.25rem;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.5rem;
}

.modal-header h3 {
  font-family: 'JetBrains Mono', monospace;
  font-size: 1rem;
  font-weight: 500;
  color: var(--text-primary);
  margin: 0;
}

.modal-close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  background: none;
  border: none;
  border-radius: 6px;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s;
}

.modal-close:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

.modal-desc {
  font-size: 0.8125rem;
  color: var(--text-secondary);
  line-height: 1.5;
  margin-bottom: 0.375rem;
}

.modal-desc a {
  color: var(--accent);
}

.modal-disclaimer {
  font-size: 0.6875rem;
  color: var(--text-muted);
  line-height: 1.4;
  margin-bottom: 1rem;
}

/* Sign-in buttons */
.signin-buttons {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.signin-provider {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.625rem 0.875rem;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-primary);
  font-family: 'Space Grotesk', sans-serif;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
}

.signin-provider:hover {
  background: var(--bg-tertiary);
  border-color: var(--text-muted);
}

.signin-provider svg {
  flex-shrink: 0;
}

/* Confirm modal */
.modal-confirm {
  text-align: center;
  max-width: 260px;
}

.confirm-message {
  font-size: 0.875rem;
  color: var(--text-primary);
  margin-bottom: 1rem;
}

.confirm-buttons {
  display: flex;
  gap: 0.5rem;
  justify-content: center;
}

.confirm-buttons .action-btn {
  min-width: 70px;
}


