/* ChatYoshi markdown (assistant article). Theme via :root on app.css. */

.msg.assistant .bubble {
  white-space: normal;
  background: transparent;
  border: 0;
  border-radius: 0;
  padding: 0;
  max-width: 100%;
  width: 100%;
}

.cy-md {
  white-space: normal;
  overflow-wrap: break-word;
  word-break: break-word;
  min-width: 0;
  max-width: 100%;
  font-size: 16.5px;
  line-height: 1.65;
  color: var(--text);
}

.cy-md p {
  margin: 0.9em 0;
}

.cy-md p:first-child {
  margin-top: 0;
}

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

.cy-md ul,
.cy-md ol {
  margin: 0.9em 0;
  padding-left: 1.7em;
}

.cy-md li {
  margin: 0.4em 0;
  padding-left: 0.15em;
}

.cy-md li > ul,
.cy-md li > ol {
  margin: 0.35em 0;
}

.cy-md blockquote {
  margin: 1em 0;
  padding: 0.7em 1em;
  color: var(--text);
  background: color-mix(in srgb, var(--coat) 10%, var(--urajiro));
  border-left: 3px solid var(--coat);
  border-radius: 0 8px 8px 0;
}

.cy-md-h,
.cy-md h1,
.cy-md h2,
.cy-md h3,
.cy-md h4,
.cy-md h5,
.cy-md h6 {
  font-weight: 700;
  margin: 1.35em 0 0.55em;
  line-height: 1.25;
  color: var(--text);
  letter-spacing: -0.02em;
}

.cy-md-h1, .cy-md h1 { font-size: 1.7em; font-weight: 750; }
.cy-md-h2, .cy-md h2 {
  font-size: 1.35em;
  padding-bottom: 0.28em;
  border-bottom: 1px solid color-mix(in srgb, var(--coat) 42%, var(--bg));
}
.cy-md-h3, .cy-md h3 { font-size: 1.15em; font-weight: 650; }
.cy-md h4 { font-size: 1.05em; }
.cy-md h5 { font-size: 0.95em; }
.cy-md h6 { font-size: 0.9em; color: var(--muted); }

.cy-md a {
  color: var(--link);
  text-decoration: none;
  font-weight: 650;
}

.cy-md a:hover,
.cy-md a:focus-visible {
  text-decoration: underline;
}

.cy-md hr {
  border: 0;
  height: 0;
  border-top: 1px solid color-mix(in srgb, var(--coat) 42%, var(--bg));
  margin: 1.6em 0;
}

.cy-table-wrap {
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  margin: 1em 0;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
}

.cy-md table {
  border-collapse: collapse;
  margin: 0;
  width: 100%;
  min-width: 100%;
  color: var(--text);
}

.cy-md th,
.cy-md td {
  border: 0;
  border-bottom: 1px solid var(--border);
  padding: 8px 12px;
  text-align: left;
  vertical-align: top;
}

.cy-md tr:last-child td {
  border-bottom: 0;
}

.cy-md th {
  background: color-mix(in srgb, var(--coat) 18%, var(--urajiro));
  font-weight: 650;
  color: var(--ink);
}

.cy-md tbody tr:nth-child(even) td {
  background: var(--table-stripe);
}

.cy-code,
.cy-code-ph {
  position: relative;
  margin: 1em 0;
  background: var(--code-block-bg);
  border: 1px solid color-mix(in srgb, var(--coat) 22%, var(--code-block-bg));
  border-radius: 10px;
  overflow: hidden;
  max-width: 100%;
  color: var(--code-block-fg);
}

.cy-code-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  background: color-mix(in srgb, var(--urajiro) 8%, var(--code-block-bg));
  border-bottom: 1px solid color-mix(in srgb, var(--urajiro) 12%, var(--code-block-bg));
  font-size: 0.8em;
  color: var(--code-block-muted);
}

.cy-code-lang {
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  font-weight: 600;
  text-transform: lowercase;
}

.cy-code-actions {
  display: flex;
  gap: 6px;
}

.cy-copy,
.cy-preview-btn {
  border: 1px solid color-mix(in srgb, var(--urajiro) 18%, var(--code-block-bg));
  background: color-mix(in srgb, var(--urajiro) 10%, var(--code-block-bg));
  border-radius: 6px;
  padding: 2px 8px;
  font-size: 0.85em;
  cursor: pointer;
  color: var(--code-block-fg);
}

.cy-copy:hover,
.cy-preview-btn:hover {
  background: color-mix(in srgb, var(--urajiro) 16%, var(--code-block-bg));
}

.cy-code pre,
.cy-code-ph pre {
  margin: 0;
  padding: 10px 14px;
  overflow-x: auto;
  overflow-y: hidden;
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.86em;
  line-height: 1.5;
  max-width: 100%;
  background: transparent;
  color: var(--code-block-fg);
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;
}

.cy-code pre code,
.cy-md .hljs {
  padding: 0;
  background: transparent;
  color: var(--code-block-fg);
  font-family: inherit;
}

.cy-md .hljs-comment,
.cy-md .hljs-quote {
  color: var(--code-block-muted);
}

.cy-md .hljs-keyword,
.cy-md .hljs-selector-tag,
.cy-md .hljs-type {
  color: var(--coat);
}

.cy-md .hljs-string,
.cy-md .hljs-attr,
.cy-md .hljs-number,
.cy-md .hljs-literal {
  color: color-mix(in srgb, var(--cream) 82%, var(--coat));
}

.cy-md code:not(pre code) {
  padding: 0.15em 0.45em;
  margin: 0;
  font-size: 0.9em;
  background-color: color-mix(in srgb, var(--coat) 16%, var(--surface));
  color: var(--text);
  border-radius: 5px;
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

.cy-md img {
  max-width: 100%;
  height: auto;
  border-radius: 10px;
  display: block;
  margin: 0.5em 0;
}

.cy-figure {
  margin: 1em 0;
  max-width: 100%;
}

.cy-figure img {
  margin: 0;
}

.cy-caption {
  margin: 0.45em 0 0;
  font-size: 0.85em;
  line-height: 1.45;
  color: var(--muted);
}

.cy-katex-display {
  margin: 0.9em 0;
  overflow-x: auto;
  overflow-y: hidden;
  text-align: center;
  max-width: 100%;
  color: var(--text);
}

.cy-katex-inline {
  display: inline;
}

.cy-preview {
  margin: 8px 0;
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  max-width: 100%;
}

.cy-preview-label {
  font-size: 12px;
  color: var(--muted);
  background: var(--code-header);
  padding: 4px 8px;
}

.cy-preview-frame {
  display: block;
  width: 100%;
  height: 260px;
  border: 0;
  background: var(--surface);
}

.cy-file-given {
  display: none;
}

.cy-code.cy-has-file {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
}

.cy-file-card {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  max-width: 100%;
  min-width: 0;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  box-sizing: border-box;
}

.cy-file-icon {
  flex: 0 0 auto;
  width: 28px;
  height: 32px;
  border: 1px solid var(--border);
  border-radius: 3px 6px 3px 3px;
  background: color-mix(in srgb, var(--coat) 10%, var(--surface));
  position: relative;
  box-sizing: border-box;
}

.cy-file-icon::after {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  border-style: solid;
  border-width: 0 8px 8px 0;
  border-color: var(--surface) var(--surface) var(--border) var(--border);
}

.cy-file-meta {
  flex: 1 1 120px;
  min-width: 0;
}

.cy-file-name {
  font-weight: 650;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text);
}

.cy-file-size {
  font-size: 0.8em;
  color: var(--muted);
}

.cy-file-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-width: 0;
}

.cy-download,
.cy-code-toggle,
.cy-file-actions .cy-copy,
.cy-file-actions .cy-preview-btn {
  border: 1px solid var(--border);
  background: var(--bg);
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 0.85em;
  cursor: pointer;
  color: var(--text);
  min-height: 40px;
  min-width: 40px;
  touch-action: manipulation;
  box-sizing: border-box;
}

.cy-download:hover,
.cy-code-toggle:hover,
.cy-file-actions .cy-copy:hover,
.cy-file-actions .cy-preview-btn:hover {
  background: var(--item-hover);
}

.cy-code-toggle {
  display: block;
  width: calc(100% - 16px);
  margin: 6px 8px 8px;
  text-align: center;
}

.cy-code-body {
  min-width: 0;
  max-width: 100%;
  background: var(--code-block-bg);
  color: var(--code-block-fg);
}

.cy-code.cy-code-collapsed .cy-code-body {
  display: none;
}

.cy-code.cy-has-file {
  overflow: hidden;
}

.cy-sources {
  margin: 1.6em 0 0;
  padding: 1em 0 0;
  border-top: 1px solid color-mix(in srgb, var(--coat) 42%, var(--bg));
}

.cy-md .cy-sources-title {
  margin: 0 0 0.7em;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
  border: 0;
  border-bottom: 0;
  padding: 0;
}

.cy-sources-list {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0;
  padding: 0;
}

.cy-md .cy-source-chip {
  display: inline-grid;
  grid-template-columns: 22px auto;
  column-gap: 8px;
  row-gap: 1px;
  align-items: center;
  border-radius: 999px !important;
  padding: 6px 14px 6px 6px !important;
  max-width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  text-decoration: none;
  font-weight: 500;
  min-width: 0;
}

.cy-md .cy-source-chip:hover,
.cy-md .cy-source-chip:focus-visible {
  text-decoration: none;
  background: var(--item-hover);
  border-color: color-mix(in srgb, var(--coat) 40%, var(--border));
}

.cy-source-title {
  color: var(--link);
  font-weight: 650;
  overflow-wrap: anywhere;
}

.cy-source-fav {
  grid-row: span 2;
  width: 22px; height: 22px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--coat); color: #fff; font-size: 0.72rem; font-weight: 700;
}
.cy-source-title { font-size: 0.9em; line-height: 1.25; }
.cy-source-domain {
  line-height: 1.2;
  font-size: 0.78em;
  color: var(--muted);
  font-weight: 500;
}

@media (max-width: 412px) {
  .cy-file-card {
    padding: 10px;
  }

  .cy-file-actions {
    width: 100%;
  }

  .cy-file-actions button {
    flex: 1 1 auto;
  }

  .cy-md table {
    width: max-content;
    min-width: 100%;
  }
}

@media (prefers-color-scheme: dark) {
  .cy-md th {
    background: color-mix(in srgb, var(--coat) 22%, var(--ink));
    color: var(--cream);
  }

  .cy-md blockquote {
    background: color-mix(in srgb, var(--coat) 14%, var(--ink));
  }

  .cy-md code:not(pre code) {
    background-color: color-mix(in srgb, var(--coat) 18%, var(--surface));
    color: var(--cream);
  }
}

/* polish2: no mid-word breaks in tables */
.cy-md table th, .cy-md table td {
  word-break: normal;
  overflow-wrap: normal;
  hyphens: manual;
  min-width: 6.5em;
}
.cy-md table th { white-space: nowrap; }
.cy-md table td a, .cy-md table td code { overflow-wrap: anywhere; }
.cy-md table { width: max-content; min-width: 100%; }
.cy-md table td { max-width: 22em; }
