/* น้องเช็ค: mascot colours, empty-state sizes, the launcher and the chat panel.
   Pixel art scales by whole numbers of its 24-unit width (48, 72, 96 px). */
:root {
  --m-line: #4a2a1e;
  --m-body: #fffaf4;
  --m-shade: #efe0d2;
  --m-check: #c9623e;
  --m-eye: #1d1714;
  --m-glass: #d6ecf5;
  --m-glint: #ffffff;
  --m-handle: #8a5a3c;
  --m-metal: #cfcac0;
  --m-blush: #f4b8a2;
  --m-fur: #a8693f;
  --m-fur-dark: #86522f;
  --m-cream: #f3dfc6;
}
:root[data-palette="classic"] { --m-check: #4f5fe0; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { --m-line: #d6c4b6; --m-check: #e08a6c; }
  :root[data-palette="classic"]:not([data-theme="light"]) { --m-check: #8f99ff; }
}
:root[data-theme="dark"] { --m-line: #d6c4b6; --m-check: #e08a6c; }
:root[data-theme="dark"][data-palette="classic"] { --m-check: #8f99ff; }

.m-o { fill: var(--m-line); }
.m-w { fill: var(--m-body); }
.m-s { fill: var(--m-shade); }
.m-c { fill: var(--m-check); }
.m-e { fill: var(--m-eye); }
.m-g { fill: var(--m-glass); }
.m-h { fill: var(--m-glint); }
.m-b { fill: var(--m-handle); }
.m-k { fill: var(--m-metal); }
.m-p { fill: var(--m-blush); }
.m-r { fill: var(--m-fur); }
.m-d { fill: var(--m-fur-dark); }
.m-n { fill: var(--m-cream); }
.mascot { display: inline-block; flex: none; width: 72px; line-height: 0; }
.mascot-svg { display: block; width: 100%; height: auto; }
.empty-mascot { width: 72px; margin-bottom: 2px; }
.onboard-mascot { width: 96px; }

/* Settings: the mascot picker, each friend standing on its own card. */
.mascot-choices { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.mascot-choice {
  display: grid; justify-items: center; gap: 2px; padding: 8px 6px 7px; border: 1px solid var(--line); border-radius: 10px;
  background: var(--surface); color: var(--ink-3); font: inherit; font-size: 12px; white-space: nowrap; cursor: pointer; transition: border-color .15s, color .15s, box-shadow .15s;
}
.mascot-choice:hover { border-color: var(--line-2); color: var(--ink); }
.mascot-choice[aria-pressed="true"] { border-color: var(--accent); color: var(--ink); box-shadow: 0 0 0 1px var(--accent); }
.mascot-choice:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.mascot-choice .mascot { width: 48px; }

/* Launcher: the mascot itself, standing free in the corner. Its own shadow
   (not a box) keeps it readable over whatever scrolls beneath. */
.helper-launcher {
  position: fixed; right: 18px; bottom: 14px; z-index: 250;
  display: block; padding: 0; border: 0; background: none; cursor: pointer;
  filter: drop-shadow(0 5px 6px rgba(20, 20, 19, .22)); transition: transform .15s;
}
.helper-launcher .mascot { width: 72px; }
.helper-launcher:hover { transform: translateY(-3px); }
.helper-launcher:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; border-radius: 14px; }
.signed-out :is(.helper-launcher, .helper-panel) { display: none; }

/* Panel */
.helper-panel {
  position: fixed; right: 20px; bottom: 96px; z-index: 260;
  display: grid; grid-template-rows: auto minmax(0, 1fr) auto auto;
  width: min(400px, calc(100vw - 32px)); height: min(600px, calc(100vh - 136px));
  border: 1px solid var(--line); border-radius: 18px; background: var(--surface);
  box-shadow: var(--shadow-lg); overflow: hidden;
}
.helper-panel[hidden] { display: none; }
.helper-head { display: flex; align-items: center; gap: 10px; padding: 10px 10px 10px 12px; border-bottom: 1px solid var(--line); }
.helper-head .mascot { width: 48px; }
.helper-head h2 { margin: 0; font-size: 16px; line-height: 1.3; }
.helper-head .icon-btn { margin-left: auto; flex: none; }
.helper-log { display: grid; align-content: start; gap: 10px; padding: 14px 12px; overflow-y: auto; background: var(--surface-2); overscroll-behavior: contain; }
.helper-msg { max-width: 94%; padding: 9px 12px; border-radius: 14px; font-size: 14px; line-height: 1.55; overflow-wrap: anywhere; }
.helper-msg p { margin: 0; }
.helper-msg.me { justify-self: end; border-bottom-right-radius: 4px; background: var(--primary); color: var(--on-primary); }
.helper-msg.bot { justify-self: start; width: 94%; border: 1px solid var(--line); border-bottom-left-radius: 4px; background: var(--surface); }
.helper-title { color: var(--ink); font-weight: 600; }
.helper-msg .helper-line { margin-top: 4px; color: var(--ink-2); font-size: 13px; }
.helper-figures { display: grid; grid-template-columns: repeat(auto-fit, minmax(104px, 1fr)); gap: 6px; margin-top: 8px; }
.helper-figures > span { display: grid; gap: 1px; padding: 6px 9px; border-radius: 10px; background: var(--surface-3); }
.helper-figures small { color: var(--ink-3); font-size: 11.5px; }
.helper-figures b { font-size: 14px; font-variant-numeric: tabular-nums; }
.helper-figures .tone-warn b { color: var(--amber); }
.helper-figures .tone-ok b { color: var(--green); }
.helper-rows { display: grid; gap: 4px; margin: 8px 0 0; padding: 0; list-style: none; }
.helper-rows button {
  display: flex; align-items: center; justify-content: space-between; gap: 8px; width: 100%; padding: 7px 9px;
  border: 1px solid var(--line); border-radius: 10px; background: var(--surface); color: inherit; font: inherit; text-align: left; cursor: pointer;
}
.helper-rows button:hover { background: var(--surface-hover); border-color: var(--line-2); }
.helper-rows button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.helper-row-main { display: grid; min-width: 0; }
.helper-row-main :is(strong, small) { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.helper-row-main strong { font-size: 13px; font-weight: 600; }
.helper-row-main small { color: var(--ink-3); font-size: 12px; }
.helper-row-side { display: grid; justify-items: end; gap: 2px; flex: none; }
.helper-row-side b { font-size: 12.5px; font-variant-numeric: tabular-nums; }
.helper-row-side .status { font-size: 11px; }
.helper-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.helper-typing { display: flex; gap: 4px; width: auto; padding: 12px 14px; }
.helper-typing span { width: 6px; height: 6px; border-radius: 50%; background: var(--ink-4); animation: helper-dot 1s infinite ease-in-out; }
.helper-typing span:nth-child(2) { animation-delay: .15s; }
.helper-typing span:nth-child(3) { animation-delay: .3s; }
@keyframes helper-dot { 0%, 80%, 100% { opacity: .3; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-3px); } }
/* Suggestions wrap onto more lines rather than scroll out of sight. */
.helper-chips { display: flex; flex-wrap: wrap; gap: 6px; padding: 8px 12px 0; }
.helper-chips[hidden] { display: none; }
.helper-chips button {
  flex: none; padding: 5px 11px; border: 1px solid var(--accent-line); border-radius: 999px;
  background: var(--accent-soft); color: var(--accent); font: inherit; font-size: 13px; white-space: nowrap; cursor: pointer;
}
.helper-chips button:hover { border-color: var(--accent); }
.helper-form { display: flex; gap: 8px; padding: 10px 12px 12px; }
.helper-form input {
  flex: 1; min-width: 0; height: 40px; padding: 0 12px; border: 1px solid var(--line-2); border-radius: 12px;
  background: var(--surface); color: var(--ink); font: inherit; font-size: 14px;
}
.helper-form input:focus { outline: none; border-color: var(--accent); box-shadow: var(--focus); }
.helper-form .btn { flex: none; width: 40px; height: 40px; padding: 0; justify-content: center; }

@media (max-width: 900px) {
  .helper-launcher { right: 10px; bottom: calc(84px + env(safe-area-inset-bottom)); }
  .helper-panel { right: 8px; left: 8px; bottom: calc(152px + env(safe-area-inset-bottom)); width: auto; height: min(66vh, 560px); }
}
@media (pointer: coarse) { .helper-form input { font-size: 16px; } }
@media (prefers-reduced-motion: reduce) {
  .helper-launcher, .mascot-choice { transition: none; }
  .helper-typing span { animation: none; opacity: .6; }
}
