/* Artifact platform tokens — auto-resolved */
:root {
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
}

* {
  box-sizing: border-box;
}

html, body, #root {
  height: 100%;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-sans);
  color: var(--text);
}

.page {
  min-height: 100vh;
  width: 100%;
  background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.card {
  width: 100%;
  max-width: 780px;
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 640px;
  max-height: calc(100vh - 48px);
  position: relative;
}

.card-header {
  padding: 20px 24px 12px;
  border-bottom: 1px solid var(--neutral);
  background: var(--surface);
}

.card-header-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.card-header h1 {
  margin: 0;
  font-size: 1.4rem;
  color: var(--primary);
  font-family: var(--font-sans);
}

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

.export-menu-wrapper {
  position: relative;
  display: inline-block;
}

.export-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 20;
  min-width: 260px;
  background: var(--surface);
  border: 1px solid var(--neutral);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.export-menu-item {
  text-align: left;
  padding: 8px 10px;
  border: none;
  background: transparent;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-family: var(--font-sans);
  color: var(--text);
  cursor: pointer;
  transition: background 0.12s;
}

.export-menu-item:hover,
.export-menu-item:focus-visible {
  background: var(--primary-tint);
  color: var(--primary-dark);
  outline: none;
}

.toast {
  position: absolute;
  left: 50%;
  bottom: 76px;
  transform: translateX(-50%);
  background: var(--primary-dark);
  color: var(--surface);
  padding: 10px 16px;
  border-radius: var(--radius-md);
  font-size: 0.85rem;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  z-index: 30;
  max-width: 90%;
  text-align: center;
  animation: toast-in 0.18s ease-out;
}

@keyframes toast-in {
  from { opacity: 0; transform: translate(-50%, 6px); }
  to   { opacity: 1; transform: translate(-50%, 0); }
}

.settings-panel {
  background: var(--primary-tint);
  border-bottom: 1px solid var(--neutral);
  padding: 14px 24px 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.settings-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 4px;
}

.settings-label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--primary-dark);
}

.settings-value {
  font-variant-numeric: tabular-nums;
  background: var(--surface);
  border: 1px solid var(--neutral);
  border-radius: var(--radius-sm);
  padding: 2px 8px;
  font-weight: 700;
  color: var(--primary-dark);
  font-size: 0.85rem;
}

.settings-slider {
  width: 100%;
  accent-color: var(--primary);
  cursor: pointer;
}

.settings-slider:focus-visible {
  outline: 3px solid var(--primary);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

.settings-hint {
  font-size: 0.72rem;
  color: var(--text-muted);
  line-height: 1.35;
}

.settings-actions {
  display: flex;
  justify-content: flex-end;
}

.status-bar {
  background: var(--primary-tint);
  color: var(--primary-dark);
  padding: 12px 24px;
  font-size: 0.9rem;
  border-bottom: 1px solid var(--neutral);
  font-weight: 500;
}

.status-bar-ready {
  display: flex;
  align-items: center;
  gap: 10px;
}

.status-bar-loading {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

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

.status-icon {
  font-size: 1.25rem;
  line-height: 1;
  flex-shrink: 0;
}

.status-text {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.status-text strong {
  font-weight: 600;
  color: var(--primary-dark);
}

.status-detail {
  font-size: 0.8rem;
  font-weight: 400;
  color: var(--text-muted);
  line-height: 1.35;
}

.status-pct {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--primary-dark);
  flex-shrink: 0;
}

.progress-track {
  width: 100%;
  height: 8px;
  background: var(--surface);
  border-radius: 999px;
  overflow: hidden;
  border: 1px solid var(--neutral);
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary) 0%, var(--primary-dark) 100%);
  border-radius: 999px;
  transition: width 0.25s ease-out;
  position: relative;
}

.progress-fill::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(
    90deg,
    transparent 0%,
    var(--scrim) 50%,
    transparent 100%
  );
  animation: progress-shimmer 1.4s linear infinite;
}

@keyframes progress-shimmer {
  from { transform: translateX(-100%); }
  to   { transform: translateX(100%); }
}

.status-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 400;
}

.status-meta-item {
  font-variant-numeric: tabular-nums;
}

.status-meta-hint {
  font-style: italic;
  opacity: 0.85;
}

.chat-area {
  flex: 1;
  overflow-y: auto;
  padding: 20px 24px;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 320px;
}

.row {
  display: flex;
  width: 100%;
}

.row-user {
  justify-content: flex-end;
}

.row-assistant {
  justify-content: flex-start;
}

.bubble {
  max-width: 78%;
  padding: 10px 14px;
  border-radius: var(--radius-lg);
  font-size: 0.95rem;
  line-height: 1.5;
  white-space: pre-wrap;
  word-wrap: break-word;
  box-shadow: var(--shadow-sm);
}

.bubble-user {
  background: var(--primary);
  color: var(--surface);
  border-bottom-right-radius: var(--radius-sm);
}

.bubble-assistant {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--neutral);
  border-bottom-left-radius: var(--radius-sm);
}

.cursor {
  display: inline-block;
  margin-left: 2px;
  animation: blink 1s steps(2, start) infinite;
  color: var(--primary);
}

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

.typing {
  display: inline-flex;
  gap: 4px;
  align-items: center;
}

.typing span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--text-muted);
  animation: bounce 1.2s infinite ease-in-out;
}

.typing span:nth-child(2) { animation-delay: 0.15s; }
.typing span:nth-child(3) { animation-delay: 0.3s; }

@keyframes bounce {
  0%, 80%, 100% { transform: translateY(0); opacity: 0.4; }
  40% { transform: translateY(-6px); opacity: 1; }
}

.input-area {
  display: flex;
  gap: 8px;
  padding: 14px 24px;
  background: var(--surface);
  border-top: 1px solid var(--neutral);
  align-items: center;
}

.question-input {
  flex: 1;
  padding: 10px 14px;
  border: 1px solid var(--neutral);
  border-radius: var(--radius-md);
  font-size: 0.95rem;
  font-family: var(--font-sans);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
  background: var(--surface);
  color: var(--text);
}

.question-input:focus-visible {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-tint);
}

.question-input:disabled {
  background: var(--bg);
  color: var(--text-muted);
  cursor: not-allowed;
}

.btn {
  padding: 10px 18px;
  border: none;
  border-radius: var(--radius-md);
  font-size: 0.95rem;
  font-family: var(--font-sans);
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, transform 0.05s, opacity 0.15s;
}

.btn-sm {
  padding: 6px 12px;
  font-size: 0.8rem;
}

.btn:active:not(:disabled) {
  transform: translateY(1px);
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn-send {
  background: var(--primary);
  color: var(--surface);
}

.btn-send:hover:not(:disabled) {
  background: var(--primary-dark);
}

.btn-clear {
  background: var(--neutral);
  color: var(--primary-dark);
}

.btn-clear:hover:not(:disabled) {
  background: var(--primary-tint);
}

.btn:focus-visible {
  outline: 3px solid var(--primary);
  outline-offset: 2px;
}

.card-footer {
  padding: 10px 24px 14px;
  text-align: center;
  color: var(--text-muted);
  background: var(--surface);
  border-top: 1px solid var(--neutral);
}

.card-footer small {
  font-size: 0.78rem;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

@media (max-width: 560px) {
  .page { padding: 12px; }
  .card { min-height: calc(100vh - 24px); }
  .card-header h1 { font-size: 1.15rem; }
  .bubble { max-width: 88%; }
  .input-area { padding: 12px; }
  .btn { padding: 10px 14px; }
  .status-detail { font-size: 0.75rem; }
  .settings-panel { padding: 12px 16px 14px; }
  .export-menu { min-width: 220px; }
}
