.welcome-row { display: flex; justify-content: space-between; align-items: flex-start; gap: 20px; margin-bottom: 24px; }
.welcome-row p { color: var(--muted); margin: 8px 0 0; }
.market-chart-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.segmented { display: inline-flex; padding: 3px; background: var(--bg-2); border: 1px solid var(--border); border-radius: 8px; gap: 2px; }
.segmented button { padding: 5px 9px; border-radius: 5px; background: transparent; color: var(--muted); font-size: .72rem; }
.segmented button.active { background: var(--surface-2); color: var(--text); }
.market-lines { display: grid; gap: 13px; }
.market-line { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 10px; }
.market-line strong { display: block; font-size: .82rem; }
.market-line small { font-size: .7rem; }
.market-line .right { text-align: right; }

.page-toolbar { display: flex; gap: 9px; flex-wrap: wrap; margin-bottom: 16px; }
.page-toolbar > * { max-width: 100%; }
.inline-input { min-height: 39px; border: 1px solid var(--border); background: var(--surface); color: var(--text); border-radius: 8px; padding: 8px 10px; }
.metric-row { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 10px; }
.metric { padding: 12px; background: var(--bg-2); border: 1px solid var(--border); border-radius: 9px; }
.metric small { display: block; font-size: .68rem; }
.metric strong { display: block; margin-top: 5px; font-size: 1.05rem; }
.empty-state { padding: 26px 15px; text-align: center; color: var(--muted); }
.empty-state strong { color: var(--text); display: block; margin-bottom: 5px; }

/* Market asset cards: mobile presentation */
.market-cards {
  display: none;
  gap: 12px;
}

.market-asset-card {
  min-width: 0;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
}

.market-asset-top,
.market-asset-price-row,
.market-asset-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.market-asset-top .asset-cell {
  min-width: 0;
}

.market-asset-top .asset-cell > div {
  min-width: 0;
  overflow-wrap: anywhere;
}

.market-asset-price-row {
  margin-top: 16px;
  align-items: flex-start;
}

.market-asset-price-row > div,
.market-asset-change {
  display: grid;
  gap: 5px;
}

.market-asset-price-row small,
.market-asset-meta {
  color: var(--muted);
  font-size: .72rem;
}

.market-asset-price-row strong {
  font-size: 1.02rem;
  overflow-wrap: anywhere;
}

.market-asset-change {
  text-align: right;
}

.market-asset-meta {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.market-asset-meta span {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.market-asset-meta strong {
  color: var(--text);
  overflow-wrap: anywhere;
  font-weight: 650;
}

.market-asset-actions {
  justify-content: flex-start;
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

@media (max-width: 760px) {
  .market-cards {
    display: grid;
  }

  .market-table-wrap {
    display: none;
  }

  .page-toolbar > #market-search {
    flex: 1 1 100%;
    width: 100%;
  }

  .page-toolbar > #market-type,
  .page-toolbar > #market-sort {
    flex: 1 1 calc(50% - 9px);
    width: 0;
    min-width: 0;
  }

  #market-source {
    text-align: right;
    overflow-wrap: anywhere;
  }
}

/* LONEWOLF AI CHAT */
.ai-chat-panel {
  max-width: 920px;
  margin-inline: auto;
  padding: 0;
  overflow: hidden;
}
.ai-chat-top {
  margin: 0;
  padding: 18px 20px;
  border-bottom: 1px solid var(--border);
}
.ai-chat-top > div {
  display: grid;
  gap: 5px;
  min-width: 0;
}
.ai-chat-top small {
  font-size: .72rem;
  overflow-wrap: anywhere;
}
.ai-chat-notice {
  margin: 16px 20px 0;
}
.ai-chat-messages {
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-height: 300px;
  max-height: min(52vh, 560px);
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 22px 20px;
  scroll-behavior: smooth;
}
.ai-chat-welcome {
  margin: auto;
  width: min(100%, 430px);
  padding: 24px 10px;
  text-align: center;
  color: var(--muted);
}
.ai-chat-welcome[hidden] {
  display: none;
}
.ai-chat-mark {
  display: inline-grid;
  place-items: center;
  width: 48px;
  height: 48px;
  margin-bottom: 12px;
  border: 1px solid var(--border);
  border-radius: 15px;
  background: var(--surface-2);
  color: var(--text);
  font-size: 1.4rem;
}
.ai-chat-welcome h2 {
  margin: 0 0 8px;
  color: var(--text);
  font-size: 1.25rem;
}
.ai-chat-welcome p {
  font-size: .84rem;
  line-height: 1.65;
}
.ai-chat-message {
  width: fit-content;
  max-width: min(88%, 680px);
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--bg-2);
  overflow-wrap: anywhere;
}
.ai-chat-message.user {
  align-self: flex-end;
  background: var(--surface-2);
}
.ai-chat-message.assistant {
  align-self: flex-start;
}
.ai-chat-message.has-error {
  border-color: color-mix(in srgb, var(--red) 55%, var(--border));
}
.ai-chat-message-label {
  display: block;
  margin-bottom: 7px;
  color: var(--muted);
  font-size: .62rem;
  font-weight: 800;
  letter-spacing: .08em;
}
.ai-chat-message-body {
  margin: 0;
  color: var(--text);
  font-size: .88rem;
  line-height: 1.7;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.ai-chat-message.is-pending .ai-chat-message-body {
  color: var(--muted);
}
.ai-chat-form {
  display: grid;
  gap: 9px;
  padding: 16px 20px 20px;
  border-top: 1px solid var(--border);
  background: var(--surface);
}
.ai-chat-form > label {
  color: var(--muted);
  font-size: .75rem;
}
.ai-chat-form textarea {
  width: 100%;
  min-height: 82px;
  max-height: 180px;
  resize: vertical;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg-2);
  color: var(--text);
  font: inherit;
  font-size: .88rem;
  line-height: 1.5;
}
.ai-chat-form textarea:focus {
  border-color: var(--blue);
  outline: 2px solid color-mix(in srgb, var(--blue) 25%, transparent);
}
.ai-chat-form textarea:disabled {
  opacity: .65;
}
.ai-chat-form-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.ai-chat-form-bottom small {
  color: var(--muted);
  font-size: .68rem;
}
.ai-chat-form .btn:disabled {
  cursor: wait;
  opacity: .6;
}
.ai-chat-error {
  margin: 0;
  color: var(--red);
  font-size: .78rem;
  overflow-wrap: anywhere;
}
.ai-chat-error[hidden] {
  display: none;
}

/* LONEWOLF AI CHAT — VISUAL REFINEMENT */
.ai-chat-panel {
  width: 100%;
  max-width: 1000px;
  border-radius: 16px;
  box-shadow: var(--shadow);
}

.ai-chat-top {
  min-width: 0;
  align-items: center;
  gap: 14px;
  padding: 18px 22px;
  background: var(--surface);
}

.ai-chat-top strong {
  font-size: .94rem;
  letter-spacing: .01em;
}

.ai-chat-top .btn {
  flex-shrink: 0;
}

.ai-chat-notice {
  line-height: 1.6;
}

.ai-chat-messages {
  min-width: 0;
  min-height: 320px;
  padding: 26px clamp(14px, 3vw, 30px);
  background: var(--bg);
}

.ai-chat-welcome {
  max-width: 460px;
  padding: 34px 12px;
}

.ai-chat-mark {
  width: 54px;
  height: 54px;
  border-radius: 17px;
  border-color: color-mix(in srgb, var(--silver) 28%, var(--border));
  background: var(--surface);
}

.ai-chat-message {
  width: fit-content;
  max-width: min(86%, 700px);
  padding: 14px 16px;
  border-radius: 14px;
  box-shadow: 0 3px 12px rgba(0, 0, 0, .045);
}

.ai-chat-message.user {
  border-color: color-mix(in srgb, var(--silver) 25%, var(--border));
  border-bottom-right-radius: 5px;
}

.ai-chat-message.assistant {
  border-bottom-left-radius: 5px;
}

.ai-chat-message-label {
  font-size: .64rem;
}

.ai-chat-message-body {
  font-size: .9rem;
  line-height: 1.75;
}

.ai-chat-form {
  gap: 11px;
  padding: 18px 22px 20px;
  border-top: 1px solid var(--border);
}

.ai-chat-form > label {
  font-size: .76rem;
  font-weight: 700;
}

.ai-chat-form textarea {
  display: block;
  min-width: 0;
  min-height: 88px;
  width: 100%;
  padding: 14px 15px;
  border-radius: 12px;
  font-size: .92rem;
  line-height: 1.6;
  transition: border-color .15s ease, box-shadow .15s ease;
}

.ai-chat-form textarea:focus {
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--blue) 14%, transparent);
}

.ai-chat-form-bottom {
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}

.ai-chat-form-bottom small {
  flex: 1 1 180px;
  line-height: 1.55;
}

.ai-chat-form .btn-primary {
  min-height: 44px;
  min-width: 96px;
  padding-inline: 18px;
  border-radius: 11px;
}

.ai-chat-top .btn {
  min-height: 40px;
  border-radius: 10px;
}

.ai-chat-error {
  padding: 10px 12px;
  border: 1px solid color-mix(in srgb, var(--red) 40%, var(--border));
  border-radius: 9px;
  background: var(--bg-2);
  line-height: 1.55;
}

@media (prefers-reduced-motion: no-preference) {
  .ai-chat-message {
    animation: ai-chat-enter .18s ease-out both;
  }

  @keyframes ai-chat-enter {
    from { opacity: 0; transform: translateY(4px); }
    to { opacity: 1; transform: translateY(0); }
  }
}

.ai-chat-message-body {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

/* LONEWOLF AI CHAT — COMPACT MESSAGE MENU */
.ai-chat-message-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  position: relative;
  margin-bottom: 8px;
}
.ai-chat-message-header .ai-chat-message-label {
  margin: 0;
}
.ai-chat-menu-wrap {
  position: relative;
  flex: 0 0 auto;
}
.ai-chat-menu-trigger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
}
.ai-chat-menu-trigger:hover,
.ai-chat-menu-trigger:focus-visible,
.ai-chat-menu-trigger[aria-expanded="true"] {
  background: var(--surface-2);
  color: var(--text);
  border-color: var(--border);
  outline: none;
}
.ai-chat-menu-trigger:focus-visible {
  box-shadow: 0 0 0 2px var(--border);
}
.ai-chat-menu {
  position: absolute;
  z-index: 20;
  top: calc(100% + 4px);
  right: 0;
  display: flex;
  flex-direction: column;
  width: max-content;
  min-width: 176px;
  max-width: min(240px, 78vw);
  padding: 5px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: var(--shadow);
}
.ai-chat-menu[hidden],
.ai-chat-form-actions [hidden] {
  display: none !important;
}
.ai-chat-menu-item {
  display: flex;
  align-items: center;
  width: 100%;
  min-height: 42px;
  padding: 9px 11px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: .82rem;
  text-align: left;
  cursor: pointer;
}
.ai-chat-menu-item:hover,
.ai-chat-menu-item:focus-visible {
  background: var(--surface-2);
  outline: none;
}
.ai-chat-menu-item:focus-visible {
  box-shadow: inset 0 0 0 1px var(--border);
}
.ai-chat-form-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex: 0 0 auto;
}
.ai-chat-form-actions .btn {
  min-height: 42px;
}
.ai-chat-message-body {
  margin-top: 0;
}

/* LONEWOLF AI CHAT — VISUAL POLISH */
.ai-chat-panel {
  max-width: 900px;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.ai-chat-top {
  padding: 18px 22px;
  background: var(--surface);
}

.ai-chat-top strong {
  font-size: .98rem;
  font-weight: 700;
  letter-spacing: -.01em;
}

.ai-chat-top small {
  line-height: 1.5;
}

.ai-chat-notice {
  border-radius: 12px;
}

.ai-chat-messages {
  gap: 20px;
  min-height: 340px;
  padding: 30px clamp(18px, 4vw, 38px);
  background: var(--bg);
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.ai-chat-welcome {
  max-width: 480px;
  padding: 42px 14px;
}

.ai-chat-mark {
  width: 58px;
  height: 58px;
  margin-bottom: 16px;
  border-radius: 18px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .07);
}

.ai-chat-welcome h2 {
  font-size: clamp(1.25rem, 2.5vw, 1.55rem);
  letter-spacing: -.025em;
}

.ai-chat-welcome p {
  margin-block: 8px;
  font-size: .9rem;
  line-height: 1.75;
}

.ai-chat-message {
  max-width: min(88%, 720px);
  padding: 14px 17px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--surface);
  box-shadow: 0 4px 16px rgba(0, 0, 0, .035);
}

.ai-chat-message.user {
  background: var(--surface-2);
  border-bottom-right-radius: 5px;
}

.ai-chat-message.assistant {
  border-bottom-left-radius: 5px;
}

.ai-chat-message-header {
  margin-bottom: 7px;
}

.ai-chat-message-label {
  font-size: .68rem;
  font-weight: 750;
  letter-spacing: .065em;
}

.ai-chat-message-body {
  margin-bottom: 0;
  font-size: .94rem;
  line-height: 1.8;
  overflow-wrap: anywhere;
}

.ai-chat-menu-trigger {
  width: 36px;
  height: 36px;
  border-radius: 11px;
}

.ai-chat-menu {
  min-width: 190px;
  padding: 6px;
  border-radius: 13px;
  box-shadow: 0 12px 36px rgba(0, 0, 0, .16);
}

.ai-chat-menu-item {
  min-height: 44px;
  padding: 10px 12px;
  border-radius: 9px;
  font-size: .85rem;
}

.ai-chat-form {
  gap: 12px;
  padding: 20px 22px 22px;
  background: var(--surface);
}

.ai-chat-form > label {
  font-size: .8rem;
  letter-spacing: .01em;
}

.ai-chat-form textarea {
  min-height: 104px;
  max-height: 36vh;
  padding: 15px 16px;
  border: 1px solid var(--border);
  border-radius: 15px;
  background: var(--bg);
  color: var(--text);
  font-size: 16px;
  line-height: 1.65;
  resize: vertical;
}

.ai-chat-form textarea:focus {
  border-color: var(--blue);
  outline: none;
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--blue) 16%, transparent);
}

.ai-chat-form-bottom {
  gap: 12px;
}

.ai-chat-form-bottom small {
  font-size: .72rem;
}

.ai-chat-form .btn-primary {
  min-height: 46px;
  border-radius: 12px;
  font-weight: 700;
}

.ai-chat-error {
  overflow-wrap: anywhere;
}

@media (prefers-reduced-motion: no-preference) {
  .ai-chat-menu-trigger,
  .ai-chat-menu-item,
  .ai-chat-form textarea,
  .ai-chat-form .btn-primary {
    transition: background-color .16s ease, border-color .16s ease,
      box-shadow .16s ease, color .16s ease;
  }
}

/* LONEWOLF AI CHAT — CHATGPT-STYLE V2 */
.ai-chat-panel {
  width: 100%;
  max-width: 1000px;
  margin-inline: auto;
  padding: 0;
  overflow: visible;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}
.ai-chat-top {
  padding: 14px 4px 18px;
  border-bottom: 1px solid var(--border);
  background: transparent;
}
.ai-chat-top strong {
  font-size: 1rem;
  font-weight: 750;
  letter-spacing: -.025em;
}
.ai-chat-notice {
  margin: 14px 0 0;
  border-radius: 12px;
}
.ai-chat-messages {
  min-width: 0;
  min-height: 360px;
  max-height: min(58vh, 720px);
  gap: 24px;
  padding: 28px 4px 32px;
  background: transparent;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}
.ai-chat-welcome {
  max-width: 500px;
  padding: 46px 14px;
}
.ai-chat-mark {
  width: 62px;
  height: 62px;
  border-radius: 20px;
}
.ai-chat-welcome h2 {
  font-size: clamp(1.35rem, 3vw, 1.8rem);
  letter-spacing: -.04em;
}
.ai-chat-welcome p {
  font-size: .92rem;
  line-height: 1.8;
}
.ai-chat-message {
  width: fit-content;
  max-width: min(86%, 760px);
  padding: 15px 18px;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: var(--surface);
  box-shadow: 0 4px 18px rgba(0, 0, 0, .035);
}
.ai-chat-message.user {
  background: var(--surface-2);
  border-bottom-right-radius: 5px;
}
.ai-chat-message.assistant {
  width: 100%;
  max-width: 100%;
  padding: 2px 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}
.ai-chat-message.assistant .ai-chat-message-header {
  max-width: 100%;
}
.ai-chat-message-header {
  margin-bottom: 10px;
}
.ai-chat-message-label {
  font-size: .7rem;
  letter-spacing: .07em;
}
.ai-chat-message-body {
  font-size: .96rem;
  line-height: 1.9;
  overflow-wrap: anywhere;
}
.ai-chat-message.assistant .ai-chat-message-body {
  max-width: 820px;
}
.ai-chat-form {
  gap: 10px;
  margin: 0 0 14px;
  padding: 12px 14px 13px;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: var(--surface);
  box-shadow: 0 8px 28px rgba(0, 0, 0, .055);
}
.ai-chat-form > label {
  padding-inline: 3px;
  font-size: .78rem;
  font-weight: 700;
}
.ai-chat-form textarea {
  min-height: 76px;
  max-height: 34vh;
  padding: 10px 4px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  font-size: 16px;
  line-height: 1.75;
  resize: vertical;
}
.ai-chat-form textarea:focus {
  border-color: transparent;
  outline: none;
  box-shadow: none;
}
.ai-chat-form-bottom {
  align-items: center;
  gap: 12px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
}
.ai-chat-form-bottom small {
  font-size: .72rem;
  line-height: 1.6;
}
.ai-chat-form .btn-primary {
  min-height: 46px;
  min-width: 104px;
  border-radius: 13px;
  font-weight: 750;
}
.ai-chat-menu {
  z-index: 100;
}

/* LONEWOLF GUIDE + AI CHAT FINAL FIX 20261019 */

/* GUIDE — readable, theme-aware documentation */
.guide-intro {
  margin-bottom: 28px;
  padding: clamp(22px, 4vw, 38px);
  background: linear-gradient(135deg, var(--surface), var(--bg-2));
}
.guide-intro h2,
.guide-final-note h2 {
  max-width: 760px;
  margin: 12px 0;
  font-size: clamp(1.35rem, 3vw, 2rem);
  line-height: 1.25;
  letter-spacing: -.035em;
}
.guide-intro > p,
.guide-final-note > p {
  max-width: 850px;
  color: var(--muted);
  line-height: 1.85;
}
.guide-callout {
  display: grid;
  gap: 6px;
  margin-top: 22px;
  padding: 16px 18px;
  border: 1px solid var(--border);
  border-left: 3px solid var(--silver);
  border-radius: 12px;
  background: var(--surface);
  line-height: 1.75;
}
.guide-callout span { color: var(--muted); }
.guide-quick-links {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 20px;
}
.guide-section { margin: 34px 0; }
.guide-section-title { margin-bottom: 16px; }
.guide-section-title h2 {
  margin: 7px 0;
  font-size: clamp(1.2rem, 2.5vw, 1.55rem);
  letter-spacing: -.025em;
}
.guide-section-title p { color: var(--muted); line-height: 1.7; }
.guide-index {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}
.guide-index-item {
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr) 18px;
  align-items: center;
  gap: 10px;
  min-width: 0;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  color: var(--text);
  text-decoration: none;
  transition: border-color .16s ease, background .16s ease;
}
.guide-index-item:hover {
  border-color: var(--subtle);
  background: var(--surface-2);
}
.guide-index-item > span:first-child {
  color: var(--muted);
  font-size: .75rem;
  font-variant-numeric: tabular-nums;
}
.guide-index-item strong { font-size: .88rem; line-height: 1.45; }
.guide-index-item > span:last-child { color: var(--muted); }
.guide-feature-list { display: grid; gap: 14px; }
.guide-feature { scroll-margin-top: 90px; padding: clamp(16px, 3vw, 24px); }
.guide-feature-heading {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  gap: 14px;
  align-items: start;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--border);
}
.guide-feature-heading > span {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border: 1px solid var(--border);
  border-radius: 12px;
  color: var(--muted);
  font-size: .78rem;
  font-weight: 750;
}
.guide-feature-heading h2 { margin: 2px 0 8px; font-size: 1.12rem; letter-spacing: -.02em; }
.guide-feature-heading p { margin: 0; color: var(--muted); line-height: 1.8; font-size: .9rem; }
.guide-feature-details {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0 22px;
}
.guide-detail { padding: 17px 0 4px; min-width: 0; }
.guide-detail h3 { margin: 0 0 7px; font-size: .88rem; }
.guide-detail p { margin: 0; color: var(--muted); font-size: .86rem; line-height: 1.8; overflow-wrap: anywhere; }
.guide-final-note {
  margin-top: 34px;
  padding: clamp(22px, 4vw, 34px);
}

/* AI CHAT — keep controls visible and conversation vertically scrollable */
body.is-ai-chat #page-content { min-width: 0; }
body.is-ai-chat .ai-chat-panel {
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: visible;
}
body.is-ai-chat .ai-chat-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  min-width: 0;
}
body.is-ai-chat #ai-chat-clear {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  min-width: 86px;
  min-height: 40px;
  visibility: visible;
  opacity: 1;
  position: relative;
  z-index: 2;
}
body.is-ai-chat #ai-chat-messages {
  display: flex;
  flex: 1 1 0;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  height: 0;
  max-height: none;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior-y: contain;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  scroll-behavior: smooth;
}
body.is-ai-chat #ai-chat-messages > * { flex-shrink: 0; }
body.is-ai-chat #ai-chat-messages .ai-chat-message-body {
  min-width: 0;
  overflow-wrap: anywhere;
  word-break: normal;
}
body.is-ai-chat #ai-chat-form { flex: 0 0 auto; }
body.is-ai-chat #ai-chat-input {
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
}

/* Panduan: beri ruang untuk header saat melompat ke bagian */
.guide-feature { scroll-margin-top: 88px; }

/* AI CHAT MARKDOWN TYPOGRAPHY — THEME AWARE */
body.is-ai-chat .ai-chat-message-body > :first-child { margin-top: 0; }
body.is-ai-chat .ai-chat-message-body > :last-child { margin-bottom: 0; }
body.is-ai-chat .ai-chat-message-body p { margin: 0 0 12px; }
body.is-ai-chat .ai-chat-message-body h1,
body.is-ai-chat .ai-chat-message-body h2,
body.is-ai-chat .ai-chat-message-body h3,
body.is-ai-chat .ai-chat-message-body h4,
body.is-ai-chat .ai-chat-message-body h5,
body.is-ai-chat .ai-chat-message-body h6 {
  margin: 22px 0 10px;
  color: var(--text);
  font-weight: 750;
  line-height: 1.35;
  letter-spacing: -.02em;
}
body.is-ai-chat .ai-chat-message-body h1 { font-size: 1.4rem; }
body.is-ai-chat .ai-chat-message-body h2 { font-size: 1.22rem; }
body.is-ai-chat .ai-chat-message-body h3 { font-size: 1.08rem; }
body.is-ai-chat .ai-chat-message-body ul,
body.is-ai-chat .ai-chat-message-body ol {
  margin: 8px 0 16px;
  padding-left: 1.5rem;
}
body.is-ai-chat .ai-chat-message-body li { padding-left: 3px; margin: 5px 0; }
body.is-ai-chat .ai-chat-message-body strong { color: var(--text); font-weight: 750; }
body.is-ai-chat .ai-chat-message-body em { font-style: italic; }
body.is-ai-chat .ai-chat-message-body code {
  padding: 2px 5px;
  border: 1px solid var(--border);
  border-radius: 5px;
  background: var(--surface-2);
  color: var(--text);
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: .88em;
  overflow-wrap: anywhere;
}
body.is-ai-chat .ai-chat-message-body pre {
  max-width: 100%;
  margin: 12px 0 16px;
  padding: 14px;
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  color: var(--text);
  line-height: 1.6;
  -webkit-overflow-scrolling: touch;
}
body.is-ai-chat .ai-chat-message-body pre code {
  display: block;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  white-space: pre;
  overflow-wrap: normal;
}

/* AI CHAT COMPACT COMPOSER — THEME AWARE */
body.is-ai-chat #ai-chat-form {
  gap: 8px;
  padding: 10px 12px 11px;
  margin-bottom: 0;
}

body.is-ai-chat #ai-chat-input {
  box-sizing: border-box;
  width: 100%;
  min-height: 44px;
  height: 44px;
  max-height: 28vh;
  padding: 8px 4px;
  line-height: 1.45;
  resize: none;
  overflow-y: hidden;
}

body.is-ai-chat #ai-chat-form .ai-chat-form-bottom {
  gap: 8px;
  padding-top: 7px;
}

/* Preview screenshot di Chart Lab */
.upload-preview-image { max-height: 280px; max-width: 100%; border-radius: 10px; }
