/* HTML Artifact V1.1 card: compact notebook header, calm paper-and-ink surface, 44px touch targets with compact visual pills. */
.message-text .code-block.html-artifact {
  margin: 10px 0;
  background: var(--paper, #f5f5f2);
  border: 1px solid var(--rule, #d9ddd6);
  border-radius: 13px 11px 14px 10px;
  overflow: visible;
  max-width: 100%;
  box-sizing: border-box;
}

.html-artifact-head {
  position: relative;
  z-index: 2;
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  min-height: 34px;
  padding: 4px 6px 4px 10px;
  background: color-mix(in srgb, var(--sage, #dfe8df) 32%, var(--paper, #f5f5f2));
  border-bottom: 1px solid var(--rule, #d9ddd6);
  border-radius: 12px 10px 0 0;
  min-width: 0;
  box-sizing: border-box;
}

.html-artifact-title {
  display: flex;
  align-items: center;
  gap: 5px;
  min-width: 0;
  flex: 1 1 56px;
  color: var(--ink, #393d42);
  font-size: 12px;
  line-height: 1.25;
}

.html-artifact-title svg {
  width: 13px;
  height: 13px;
  flex: 0 0 13px;
  fill: none;
  stroke: var(--muted, #747971);
  stroke-width: 1.45;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.html-artifact-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.html-artifact-actions {
  display: flex;
  align-items: center;
  flex-wrap: nowrap;
  flex: 0 0 auto;
  gap: 1px;
  max-width: 100%;
}

.html-artifact-switch {
  display: inline-flex;
  align-items: center;
  padding: 1px;
  border: 1px solid var(--rule, #d9ddd6);
  border-radius: 8px 7px 9px 7px;
  background: var(--paper, #f5f5f2);
  gap: 1px;
}

.html-artifact-tab,
.html-artifact-btn {
  position: relative;
  z-index: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  min-width: 44px;
  margin-block: -9px;
  padding: 0 6px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--muted, #747971);
  font-size: 11.5px;
  line-height: 1.15;
  white-space: nowrap;
  cursor: pointer;
  touch-action: manipulation;
  box-sizing: border-box;
  transition:
    color 140ms var(--ease-out, ease-out),
    transform 100ms var(--ease-out, ease-out);
}

.html-artifact-tab::before,
.html-artifact-btn::before {
  content: "";
  position: absolute;
  inset: 10px 2px;
  border-radius: 6px 5px 7px 5px;
  background: transparent;
  z-index: -1;
  transition: background-color 140ms var(--ease-out, ease-out);
}

.html-artifact-tab[aria-pressed="true"] {
  color: var(--ink, #393d42);
}

.html-artifact-tab[aria-pressed="true"]::before {
  background: var(--sage, #dfe8df);
}

.html-artifact-btn {
  color: var(--ink, #393d42);
}

.html-artifact-tab:disabled,
.html-artifact-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.html-artifact-tab:focus-visible,
.html-artifact-btn:focus-visible {
  outline: 2px solid #70857b;
  outline-offset: -6px;
}

@media (hover: hover) and (pointer: fine) {
  .html-artifact-tab:not(:disabled):hover,
  .html-artifact-btn:not(:disabled):hover {
    color: var(--ink, #393d42);
  }
  .html-artifact-tab:not(:disabled):hover::before,
  .html-artifact-btn:not(:disabled):hover::before {
    background-color: color-mix(in srgb, var(--sage, #dfe8df) 55%, transparent);
  }
}

.html-artifact-preview {
  background: #ffffff;
  width: 100%;
  min-width: 0;
  border-radius: 0 0 13px 9px;
  overflow: hidden;
}

.html-artifact-preview[hidden],
.html-artifact-code[hidden],
.html-artifact-note[hidden] {
  display: none !important;
}

.html-artifact-frame {
  display: block;
  width: 100%;
  height: clamp(260px, 48dvh, 460px);
  border: 0;
  background: #ffffff;
}

.html-artifact-code {
  background: #eceeea;
  max-height: min(52dvh, 420px);
  overflow: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  border-radius: 0 0 13px 9px;
}

.message-text .html-artifact-code pre {
  margin: 0;
  padding: 10px 12px;
  overflow: visible;
  font-size: 0.85em;
  line-height: 1.6;
}

.message-text .html-artifact-code code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "LXGW WenKai", monospace;
}

.html-artifact-note {
  margin: 0;
  padding: 6px 10px;
  font-size: 11.5px;
  line-height: 1.45;
  color: var(--muted, #747971);
  border-top: 1px dashed var(--rule, #d9ddd6);
  background: var(--paper, #f5f5f2);
  border-radius: 0 0 13px 9px;
  overflow-wrap: anywhere;
}

@media (max-width: 480px) {
  .html-artifact-head {
    padding: 4px 5px 4px 9px;
    gap: 4px;
  }
  .html-artifact-tab,
  .html-artifact-btn {
    padding: 0 5px;
    font-size: 11px;
  }
  .html-artifact-frame {
    height: clamp(240px, 46dvh, 400px);
  }
}

@media (prefers-reduced-motion: reduce) {
  .html-artifact-tab,
  .html-artifact-btn,
  .html-artifact-tab::before,
  .html-artifact-btn::before {
    transition: none;
  }
}

html[data-reduced="true"] .html-artifact-tab,
html[data-reduced="true"] .html-artifact-btn,
html[data-reduced="true"] .html-artifact-tab::before,
html[data-reduced="true"] .html-artifact-btn::before {
  transition: none;
}
