:root {
  color-scheme: light;
  --ink: #253329;
  --muted: #78827a;
  --paper: #fbf8f1;
  --panel: #fffefa;
  --green: #4c7054;
  --green-dark: #355640;
  --green-soft: #e6f0e2;
  --line: #e9e6dc;
  --gold: #f1d17d;
  font-family: 'IBM Plex Sans Thai', 'Tahoma', sans-serif;
}

* { box-sizing: border-box; }
html, body { min-width: 320px; min-height: 100%; margin: 0; }
body { background: var(--paper); color: var(--ink); }
button, textarea { font: inherit; }
button { color: inherit; }
.app-shell { display: flex; width: 100%; min-height: 100vh; }
.sidebar { position: relative; display: flex; flex: 0 0 248px; flex-direction: column; min-height: 100vh; padding: 25px 16px 18px; border-right: 1px solid var(--line); background: #f4f2ec; }
.brand { display: inline-flex; align-items: center; gap: 10px; width: fit-content; margin: 2px 0 27px 5px; text-decoration: none; font-size: 19px; font-weight: 700; letter-spacing: -.04em; }
.brand-mark { position: relative; display: grid; place-items: center; width: 34px; height: 34px; border-radius: 12px; background: var(--green); color: white; font-family: Arial, sans-serif; font-size: 20px; font-weight: 700; }
.new-chat { display: flex; align-items: center; gap: 9px; min-height: 41px; padding: 0 12px; border: 1px solid #dfe4d9; border-radius: 11px; background: #fffefa; cursor: pointer; text-align: left; font-size: 12px; font-weight: 600; }
.new-chat:hover { background: #f4f7ef; border-color: #cbd7c2; }
.new-chat span { color: var(--green); font-size: 18px; line-height: 1; }
.sidebar-label { margin: 29px 0 10px 6px; color: #96988f; font-size: 10px; font-weight: 600; letter-spacing: .04em; }
.topic-list { display: grid; gap: 3px; }
.topic-list button { display: flex; align-items: center; gap: 10px; min-height: 38px; padding: 0 8px; border: 0; border-radius: 9px; background: transparent; color: #667060; cursor: pointer; text-align: left; font-size: 15px; }
.topic-list button span { color: #525950; font-size: 11px; }
.topic-list button:hover { background: #e9ece2; }
.sidebar-bottom { margin-top: auto; }
.local-card { display: flex; align-items: center; gap: 9px; padding: 11px 9px; border: 1px solid #e3e5dc; border-radius: 12px; background: #f9f9f4; }
.local-icon { display: grid; place-items: center; width: 29px; height: 29px; border-radius: 9px; background: var(--green-soft); color: var(--green); font-size: 18px; }
.local-card strong, .local-card span { display: block; }
.local-card strong { font-size: 10px; }
.local-card div > span { margin-top: 2px; color: #92968d; font-size: 9px; }
.version-label { display: block; margin: 12px 5px 0; color: #a3a59e; font-size: 9px; }
.chat-panel { position: relative; display: flex; flex: 1; flex-direction: column; min-width: 0; height: 100vh; max-height: 100vh; }
.chat-header { display: flex; flex: 0 0 61px; align-items: center; justify-content: flex-end; padding: 0 34px; border-bottom: 1px solid #eeece5; }
.bot-status { display: flex; align-items: center; gap: 8px; color: #7c8278; font-size: 10px; }
.online-dot { width: 7px; height: 7px; border-radius: 50%; background: #8dad75; box-shadow: 0 0 0 3px #8dad7520; }
.mobile-brand, .mobile-new-chat { display: none; }
.messages { display: flex; flex: 1; flex-direction: column; align-items: center; overflow: auto; padding: 24px 24px 16px; scrollbar-color: #d8dbd1 transparent; scrollbar-width: thin; }
.welcome { display: flex; flex: 1; flex-direction: column; align-items: center; justify-content: center; width: 100%; max-width: 620px; padding: 14px 0 30px; text-align: center; }
.welcome.is-hidden { display: none; }
.welcome-avatar { position: relative; display: grid; place-items: center; width: 66px; height: 66px; margin-bottom: 17px; border: 5px solid #f0f2e9; border-radius: 24px; background: var(--green); color: white; box-shadow: 0 5px 15px #506b401b; font-family: Arial, sans-serif; font-size: 36px; font-weight: 700; }
.welcome-avatar i { position: absolute; right: -9px; bottom: -7px; display: grid; place-items: center; width: 23px; height: 23px; border: 2px solid var(--paper); border-radius: 50%; background: #efcf89; color: #745e31; font-size: 12px; font-style: normal; }
.welcome-kicker { color: var(--green); font-size: 11px; font-weight: 600; }
.welcome h1 { margin: 7px 0 6px; font-size: clamp(30px, 3.5vw, 43px); line-height: 1.28; letter-spacing: -.055em; }
.mobile-break { display: none; }
.welcome p { margin: 0; color: #7e837a; font-size: 12px; line-height: 1.8; }
.suggestions { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-top: 24px; }
.suggestions button { display: inline-flex; align-items: center; gap: 7px; padding: 9px 12px; border: 1px solid #e8e8df; border-radius: 11px; background: #fffefa; color: #596253; cursor: pointer; font-size: 10px; transition: background .15s ease, transform .15s ease; }
.suggestions button span { color: var(--green); font-size: 13px; }
.suggestions button:hover { transform: translateY(-1px); background: #f4f7ef; }
.message-row { display: flex; width: min(100%, 720px); align-items: flex-start; gap: 10px; margin: 8px 0; animation: appear .2s ease-out; }
.message-row.user-row { justify-content: flex-end; }
.bot-avatar { display: grid; flex: 0 0 30px; place-items: center; width: 30px; height: 30px; border-radius: 11px; background: var(--green); color: white; font-family: Arial, sans-serif; font-size: 17px; font-weight: 700; }
.bubble { max-width: min(78%, 530px); padding: 11px 14px; border: 1px solid #e9e8e0; border-radius: 4px 16px 16px 16px; background: var(--panel); color: #41483e; font-size: 12px; line-height: 1.8; white-space: pre-wrap; overflow-wrap: anywhere; box-shadow: 0 3px 10px #3f4c3510; }
.user-row .bubble { border-color: #5c7653; border-radius: 16px 4px 16px 16px; background: var(--green); color: #fff; box-shadow: none; }
.message-time { display: block; margin-top: 3px; color: #a1a49a; font-size: 8px; }
.user-row .message-time { text-align: right; color: #d9e3d3; }
.typing-row { display: flex; width: min(100%, 720px); align-items: flex-start; gap: 10px; margin: 7px 0 10px; }
.typing-row[hidden] { display: none; }
.small-avatar { flex-basis: 30px; }
.typing-bubble { display: flex; align-items: center; gap: 4px; height: 34px; padding: 0 12px; border: 1px solid #e9e8e0; border-radius: 4px 14px 14px 14px; background: white; }
.typing-bubble i { width: 5px; height: 5px; border-radius: 50%; background: #a6b39d; animation: bounce 1s infinite ease-in-out; }
.typing-bubble i:nth-child(2) { animation-delay: .12s; }
.typing-bubble i:nth-child(3) { animation-delay: .24s; }
.composer-wrap { width: min(calc(100% - 48px), 720px); margin: 0 auto; padding: 10px 0 17px; }
.composer { display: flex; align-items: flex-end; gap: 9px; min-height: 54px; padding: 8px 8px 8px 15px; border: 1px solid #e4e4db; border-radius: 17px; background: #fffefa; box-shadow: 0 6px 20px #343d2a0b; }
.composer:focus-within { border-color: #bccbb1; box-shadow: 0 0 0 3px #79936c17; }
.composer textarea { display: block; flex: 1; min-height: 30px; max-height: 120px; resize: none; padding: 6px 0 3px; border: 0; outline: 0; background: transparent; color: var(--ink); font-size: 12px; line-height: 1.55; }
.composer textarea::placeholder { color: #a2a59d; }
.composer button { display: flex; flex: 0 0 auto; align-items: center; gap: 7px; height: 36px; padding: 0 11px; border: 0; border-radius: 11px; background: var(--green); color: white; cursor: pointer; font-size: 10px; transition: background .15s ease, opacity .15s ease; }
.composer button:hover { background: var(--green-dark); }
.composer button:disabled { cursor: default; opacity: .42; }
.composer button b { display: grid; place-items: center; width: 19px; height: 19px; border-radius: 7px; background: #ffffff24; font-size: 14px; line-height: 1; }
.composer-note { display: flex; justify-content: space-between; padding: 6px 5px 0; color: #a0a39a; font-size: 8px; }
@keyframes appear { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: translateY(0); } }
@keyframes bounce { 0%, 60%, 100% { transform: translateY(0); opacity: .55; } 30% { transform: translateY(-4px); opacity: 1; } }

@media (max-width: 720px) {
  .sidebar { display: none; }
  .chat-panel { height: 100dvh; max-height: 100dvh; }
  .chat-header { flex-basis: 57px; justify-content: space-between; padding: 0 16px; }
  .mobile-brand { display: flex; align-items: center; gap: 8px; font-size: 15px; letter-spacing: -.03em; }
  .mobile-brand .brand-mark { width: 29px; height: 29px; border-radius: 10px; font-size: 18px; }
  .mobile-new-chat { display: grid; place-items: center; width: 30px; height: 30px; border: 1px solid var(--line); border-radius: 10px; background: #fffefa; color: var(--green); font-size: 17px; }
  .messages { padding: 14px 15px 10px; }
  .welcome { padding: 5px 0 25px; }
  .welcome-avatar { width: 58px; height: 58px; border-radius: 21px; font-size: 31px; }
  .welcome h1 { font-size: 34px; }
  .mobile-break { display: initial; }
  .welcome p { max-width: 310px; }
  .suggestions { gap: 6px; margin-top: 18px; }
  .suggestions button { padding: 8px 9px; }
  .composer-wrap { width: calc(100% - 26px); padding-bottom: max(10px, env(safe-area-inset-bottom)); }
  .bubble { max-width: 85%; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
}

/* Puenlen's playful identity: a little garden of color around the chat. */
body { background: linear-gradient(135deg, #faf8f0 0%, #f8f7f1 52%, #f3f6ed 100%); }
.sidebar { flex-basis: 265px; background: linear-gradient(165deg, #edf3e8 0%, #f1f1e8 72%, #f5efe3 100%); border-right-color: #e1e7da; }
.brand { gap: 11px; margin-bottom: 22px; }
.brand-mark { width: 41px; height: 41px; flex: 0 0 41px; overflow: visible; border: 3px solid #f8faef; border-radius: 15px 15px 15px 6px; background: linear-gradient(145deg, #648465, #426749); box-shadow: 0 4px 0 #d9e4d2; transform: rotate(-4deg); }
.brand-mark > span { transform: rotate(4deg); font-size: 22px; }
.brand-mark > i { position: absolute; right: -5px; bottom: -3px; width: 10px; height: 10px; border: 2px solid #f7f8ef; border-radius: 50%; background: #f1ce78; }
.brand-copy b, .brand-copy small { display: block; }
.brand-copy b { font-size: 17px; line-height: 1.2; }
.brand-copy small { margin-top: 3px; color: #87927f; font-size: 9px; font-weight: 500; letter-spacing: .015em; }
.name-note { position: relative; display: flex; align-items: flex-start; gap: 9px; margin-top: 19px; padding: 11px 10px; overflow: hidden; border: 1px solid #e1e7d9; border-radius: 14px; background: #fbfcf5; }
.name-note-star { display: grid; flex: 0 0 25px; place-items: center; width: 25px; height: 25px; border-radius: 9px; background: #f6e8b9; color: #9e7f38; font-size: 13px; }
.name-note strong, .name-note div > span { display: block; }
.name-note strong { margin: 1px 0 3px; color: #52684f; font-size: 10px; }
.name-note div > span { color: #8b9286; font-size: 9px; line-height: 1.55; }
.name-note-doodle { position: absolute; right: 7px; bottom: -11px; color: #e7eadb; font-size: 43px; transform: rotate(14deg); }
.new-chat { min-height: 43px; border-color: #dce5d6; border-radius: 13px; background: #fffefa; box-shadow: 0 3px 0 #e5e9de; }
.new-chat:hover { background: #fff; box-shadow: 0 4px 0 #dce5d6; }
.sidebar-label { margin-top: 28px; color: #82907d; }
.topic-list { gap: 5px; }
.topic-list button { min-height: 41px; padding: 0 10px; border-radius: 11px; }
.topic-list button:hover { background: #e1ebda; }
.topic-list button:nth-child(1) { color: #dd8768; }
.topic-list button:nth-child(2) { color: #8e7ab1; }
.topic-list button:nth-child(3) { color: #bd983e; }
.topic-list button:nth-child(4) { color: #6488a0; }
.local-card { border-color: #e3e8dd; background: #f8f9f3; }
.local-icon { background: #f4e9c5; color: #967a3b; }
.chat-panel { background: radial-gradient(ellipse at 48% 43%, #fffdf8 0, #fffdf866 31%, transparent 68%); }
.chat-header { border-bottom-color: #efede5; }
.bot-status { padding: 7px 11px; border: 1px solid #e5ebdf; border-radius: 999px; background: #fffdf7cc; color: #74836f; }
.online-dot { background: #87ae77; box-shadow: 0 0 0 3px #a6c69533; animation: pulse 2.2s infinite; }
.welcome { position: relative; isolation: isolate; max-width: 760px; }
.welcome::before, .welcome::after { position: absolute; z-index: -1; display: block; border-radius: 50%; content: ''; pointer-events: none; }
.welcome::before { top: 18%; left: 7%; width: 120px; height: 120px; background: #f6ead1; opacity: .46; filter: blur(2px); }
.welcome::after { right: 6%; bottom: 18%; width: 155px; height: 155px; background: #e3eddf; opacity: .58; filter: blur(3px); }
.buddy-stage { position: relative; display: grid; width: 292px; height: 179px; place-items: center; margin: -5px 0 1px; }
.orbit { position: absolute; display: block; border: 1px dashed #d6dfcf; border-radius: 50%; transform: rotate(-13deg); }
.orbit-one { width: 180px; height: 116px; }
.orbit-two { width: 235px; height: 151px; border-color: #e9dfc8; transform: rotate(15deg); }
.welcome-avatar { z-index: 1; display: grid; width: 92px; height: 92px; margin: 0; place-items: center; border: 5px solid #f8f7ee; border-radius: 36px 31px 35px 30px; background: linear-gradient(150deg, #88a977, #557e5d 72%); box-shadow: 0 9px 0 #dce6d2, 0 17px 28px #526c4524; transform: rotate(-5deg); animation: buddy-bob 3.4s ease-in-out infinite; }
.buddy-face { position: relative; display: flex; align-items: center; justify-content: center; gap: 19px; width: 44px; height: 24px; transform: rotate(5deg); }
.buddy-face i { position: static; right: auto; bottom: auto; display: block; width: 5px; height: 8px; border: 0; border-radius: 50%; background: #263c2b; box-shadow: none; }
.buddy-face b { position: absolute; bottom: -3px; left: 17px; width: 12px; height: 7px; border-bottom: 2px solid #263c2b; border-radius: 0 0 12px 12px; }
.buddy-cheek { position: absolute; top: 49px; width: 11px; height: 6px; border-radius: 50%; background: #e9a28c; opacity: .85; }
.cheek-left { left: 19px; }
.cheek-right { right: 19px; }
.buddy-sticker { position: absolute; z-index: 2; display: inline-flex; align-items: center; gap: 5px; padding: 6px 10px; border: 1px solid #eee7d6; border-radius: 10px 10px 10px 3px; background: #fffdf7; color: #758368; font-size: 9px; font-weight: 600; box-shadow: 0 4px 12px #4b5b3c12; }
.sticker-left { top: 35px; left: 5px; transform: rotate(-8deg); }
.sticker-left i { color: #d4955f; font-size: 13px; font-style: normal; }
.sticker-right { right: 1px; bottom: 35px; border-color: #e8e7d7; background: #f3f4e8; color: #657c5e; transform: rotate(7deg); }
.buddy-sparkle { position: absolute; color: #d0a649; }
.sparkle-a { top: 20px; right: 48px; font-size: 19px; }
.sparkle-b { bottom: 17px; left: 44px; color: #ca8b74; font-size: 15px; }
.welcome-kicker { display: flex; align-items: center; gap: 6px; color: #718b62; }
.welcome-kicker span { color: #d6ad50; }
.welcome h1 { margin-top: 9px; color: #2d3d30; font-size: clamp(35px, 4.2vw, 49px); line-height: 1.19; }
.welcome p { color: #7c867a; font-size: 12px; }
.welcome p strong { color: #526d4f; font-weight: 600; }
.suggestions { max-width: 570px; gap: 9px; margin-top: 23px; }
.suggestions button { min-height: 39px; padding: 8px 13px; border-color: #e7e7db; border-radius: 13px; background: #fffdf8; box-shadow: 0 3px 0 #edede3; color: #5d665b; font-size: 10px; }
.suggestions button:nth-child(1) span { color: #dc8a67; }
.suggestions button:nth-child(2) span { color: #8e7ab1; }
.suggestions button:nth-child(3) span { color: #b79744; }
.suggestions button:hover { border-color: #dbe4d4; background: #f9fbf4; box-shadow: 0 4px 0 #e4ebde; }
.bot-avatar { border-radius: 11px 11px 11px 4px; box-shadow: 0 3px 0 #dce6d6; }
.bubble { border-color: #e8e8de; background: #fffefa; }
.user-row .bubble { border-color: #59775a; background: linear-gradient(135deg, #628162, #4a6e51); }
.composer { border-color: #e5e4da; border-radius: 18px; background: #fffefa; box-shadow: 0 7px 24px #515b4110; }
.composer:focus-within { border-color: #b8c9ad; box-shadow: 0 0 0 4px #8aab791c; }
.composer button { border-radius: 12px; background: linear-gradient(135deg, #658465, #4b6f52); }
.composer button:hover { background: #3f6449; }
.composer-note { color: #92988d; }
.mobile-brand { letter-spacing: -.02em; }
.mobile-brand .brand-mark { width: 31px; height: 31px; flex-basis: 31px; border-radius: 12px 12px 12px 5px; }
.mobile-brand .brand-mark > span { font-size: 17px; }
.mobile-brand .brand-mark > i { width: 8px; height: 8px; right: -4px; bottom: -2px; }
.mobile-new-chat { box-shadow: 0 2px 0 #e7e8de; }
@keyframes buddy-bob { 0%, 100% { transform: translateY(0) rotate(-5deg); } 50% { transform: translateY(-5px) rotate(-2deg); } }
@keyframes pulse { 0%, 100% { box-shadow: 0 0 0 3px #a6c69533; } 50% { box-shadow: 0 0 0 5px #a6c69519; } }

@media (max-width: 720px) {
  .chat-panel { background: radial-gradient(ellipse at 52% 39%, #fffdf8 0, #fffdf866 45%, transparent 80%); }
  .chat-header { background: #fbf9f3e8; }
  .bot-status { padding: 6px 8px; font-size: 9px; }
  .welcome::before { top: 19%; left: -10%; width: 87px; height: 87px; }
  .welcome::after { right: -10%; bottom: 19%; width: 110px; height: 110px; }
  .buddy-stage { width: 250px; height: 154px; margin-top: -3px; }
  .welcome-avatar { width: 78px; height: 78px; border-radius: 30px 27px 30px 26px; }
  .buddy-cheek { top: 41px; }
  .cheek-left { left: 17px; }
  .cheek-right { right: 17px; }
  .orbit-one { width: 157px; height: 103px; }
  .orbit-two { width: 205px; height: 132px; }
  .sticker-left { left: -1px; top: 29px; }
  .sticker-right { right: -4px; bottom: 27px; }
  .sparkle-a { top: 12px; right: 39px; }
  .sparkle-b { bottom: 10px; left: 35px; }
  .welcome h1 { font-size: 36px; }
  .desktop-break { display: none; }
  .suggestions { margin-top: 19px; }
}

@media (prefers-reduced-motion: reduce) {
  .welcome-avatar { animation: none; }
}

.chat-header { gap: 11px; }
.auth-actions { display: flex; align-items: center; gap: 8px; min-width: 0; }
.auth-status { max-width: 180px; overflow: hidden; color: #788273; font-size: 9px; text-overflow: ellipsis; white-space: nowrap; }
.google-button-slot { display: flex; min-height: 32px; align-items: center; }
.google-button-slot[hidden] { display: none; }
.auth-button { min-height: 32px; padding: 0 11px; border: 1px solid #dce5d6; border-radius: 11px; background: #fffefa; color: #526d4f; cursor: pointer; font: inherit; font-size: 9px; font-weight: 600; transition: background .15s ease, opacity .15s ease; }
.auth-button:hover:not(:disabled) { background: #eff4e9; }
.auth-button:disabled { cursor: default; opacity: .55; }
.auth-button[hidden], .auth-status[hidden] { display: none; }
.sign-out-button { border-color: #e8e7dc; color: #73796f; }
.composer-note #connection-note { max-width: calc(100% - 48px); }

@media (max-width: 720px) {
  .chat-header { gap: 7px; }
  .bot-status, .auth-status { display: none; }
  .auth-actions { margin-left: auto; }
  .auth-button { min-height: 30px; padding: 0 9px; font-size: 8px; }
  .composer-note { gap: 8px; }
  .composer-note #connection-note { max-width: calc(100% - 42px); }
}
