/* Megaone AI Assistant: chat widget, mobile first. Accent comes from --mgo-accent / --mgo-on-accent. */
.mgo { --mgo-ink: #1f2328; --mgo-muted: #5b6470; --mgo-line: #e3e6ea; --mgo-bg: #fff; --mgo-soft: #f1f3f5; --mgo-field: #fff; --mgo-err-bg: #fdecec; --mgo-err: #8a1c1c;
	position: fixed; z-index: 99990; bottom: calc(16px + env(safe-area-inset-bottom, 0px));
	font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; color: var(--mgo-ink);
	-webkit-tap-highlight-color: transparent; -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
.mgo--right { right: calc(16px + env(safe-area-inset-right, 0px)); }
.mgo--left { left: calc(16px + env(safe-area-inset-left, 0px)); }
.mgo *, .mgo *::before, .mgo *::after { box-sizing: border-box; }
.mgo button, .mgo textarea { touch-action: manipulation; }
.mgo [hidden] { display: none !important; }

@media (prefers-color-scheme: dark) {
	.mgo { --mgo-ink: #e8eaed; --mgo-muted: #a0a7b1; --mgo-line: #343a42; --mgo-bg: #1b1f24; --mgo-soft: #2a3038; --mgo-field: #242a31; --mgo-err-bg: #3a1f1f; --mgo-err: #f3b4b4; }
}

/* Launcher */
.mgo__launcher { display: flex; align-items: center; justify-content: center; width: 60px; height: 60px; padding: 0; border: 0; border-radius: 50%;
	background: var(--mgo-accent, #1f2937); color: var(--mgo-on-accent, #fff); cursor: pointer; box-shadow: 0 3px 12px rgba(0, 0, 0, .28); }
.mgo__launcher:active { transform: scale(.96); }
.mgo__launcher svg { width: 28px; height: 28px; }
.mgo--open .mgo__launcher { display: none; }
.mgo__launcher:focus-visible, .mgo__close:focus-visible, .mgo__send:focus-visible, .mgo__agree:focus-visible, .mgo__input:focus-visible { outline: 3px solid #2563eb; outline-offset: 2px; }

/* Panel: floating card on larger screens */
.mgo__panel { display: none; flex-direction: column; width: 380px; max-width: calc(100vw - 24px); height: 560px; max-height: calc(100vh - 40px);
	background: var(--mgo-bg); border: 1px solid var(--mgo-line); border-radius: 16px; overflow: hidden; box-shadow: 0 10px 34px rgba(0, 0, 0, .22); }
.mgo--open .mgo__panel { display: flex; }

.mgo__head { flex: none; display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 6px 6px 6px 16px; min-height: 56px; background: var(--mgo-accent, #1f2937); color: var(--mgo-on-accent, #fff); }
.mgo__title { margin: 0; font-size: 17px; font-weight: 600; line-height: 1.25; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mgo__close { flex: none; width: 44px; height: 44px; padding: 0; border: 0; border-radius: 50%; background: transparent; color: inherit; cursor: pointer; display: flex; align-items: center; justify-content: center; }
.mgo__close svg { width: 22px; height: 22px; }
.mgo__close:active { background: rgba(255, 255, 255, .2); }

.mgo__log { flex: 1; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; padding: 14px 14px 8px; display: flex; flex-direction: column; gap: 8px; background: var(--mgo-bg); }
.mgo__msg { max-width: 88%; padding: 10px 14px; border-radius: 18px; white-space: pre-wrap; overflow-wrap: anywhere; word-break: break-word; }
.mgo__msg--bot { align-self: flex-start; background: var(--mgo-soft); border-bottom-left-radius: 6px; }
.mgo__msg--me { align-self: flex-end; background: var(--mgo-accent, #1f2937); color: var(--mgo-on-accent, #fff); border-bottom-right-radius: 6px; }
.mgo__msg--err { align-self: flex-start; background: var(--mgo-err-bg); color: var(--mgo-err); }
.mgo__msg a { color: inherit; text-decoration: underline; text-underline-offset: 2px; }

/* Typing dots */
.mgo__dots { display: inline-flex; gap: 5px; align-items: center; height: 22px; }
.mgo__dots i { width: 7px; height: 7px; border-radius: 50%; background: var(--mgo-muted); opacity: .5; }
@media (prefers-reduced-motion: no-preference) {
	.mgo__dots i { animation: mgo-dot 1.1s infinite ease-in-out; }
	.mgo__dots i:nth-child(2) { animation-delay: .16s; }
	.mgo__dots i:nth-child(3) { animation-delay: .32s; }
	@keyframes mgo-dot { 0%, 70%, 100% { transform: translateY(0); opacity: .4; } 35% { transform: translateY(-4px); opacity: 1; } }
	.mgo--open .mgo__panel { animation: mgo-in .18s ease-out; }
	@keyframes mgo-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
}

/* Consent */
.mgo__consent { flex: none; padding: 16px 16px calc(16px + env(safe-area-inset-bottom, 0px)); background: var(--mgo-soft); border-top: 1px solid var(--mgo-line); }
.mgo__consent p { margin: 0 0 12px; font-size: 14px; color: var(--mgo-muted); }
.mgo__agree { width: 100%; min-height: 48px; padding: 12px 16px; border: 0; border-radius: 12px; background: var(--mgo-accent, #1f2937); color: var(--mgo-on-accent, #fff); font: inherit; font-weight: 600; cursor: pointer; }
.mgo__agree:active { filter: brightness(.92); }

/* Composer */
.mgo__form { flex: none; display: flex; align-items: flex-end; gap: 8px; padding: 8px 10px calc(8px + env(safe-area-inset-bottom, 0px)); border-top: 1px solid var(--mgo-line); background: var(--mgo-bg); }
.mgo__input { flex: 1; min-width: 0; min-height: 44px; max-height: 120px; padding: 10px 14px; border: 1px solid var(--mgo-line); border-radius: 22px; background: var(--mgo-field); color: var(--mgo-ink);
	font: inherit; font-size: 16px; /* 16px stops iOS zooming the page on focus */ line-height: 1.35; resize: none; -webkit-appearance: none; appearance: none; }
.mgo__input::placeholder { color: var(--mgo-muted); }
.mgo__send { flex: none; width: 44px; height: 44px; padding: 0; border: 0; border-radius: 50%; background: var(--mgo-accent, #1f2937); color: var(--mgo-on-accent, #fff); cursor: pointer; display: flex; align-items: center; justify-content: center; }
.mgo__send svg { width: 20px; height: 20px; }
.mgo__send:disabled { opacity: .4; cursor: default; }
.mgo__send:not(:disabled):active { filter: brightness(.9); }

/* Phones and small tablets: the chat takes the whole screen, like a messaging app. */
@media (max-width: 600px) {
	.mgo--open { inset: 0; bottom: 0; right: 0; left: 0; }
	.mgo--open .mgo__panel { position: fixed; top: var(--mgo-top, 0px); left: 0; width: 100%; max-width: none; height: var(--mgo-h, 100dvh); max-height: none; border: 0; border-radius: 0; box-shadow: none; }
	.mgo__head { padding-top: calc(6px + env(safe-area-inset-top, 0px)); padding-left: calc(16px + env(safe-area-inset-left, 0px)); padding-right: calc(6px + env(safe-area-inset-right, 0px)); min-height: calc(56px + env(safe-area-inset-top, 0px)); }
	.mgo__log { padding-left: calc(14px + env(safe-area-inset-left, 0px)); padding-right: calc(14px + env(safe-area-inset-right, 0px)); }
	.mgo__msg { max-width: 90%; }
}
/* Short landscape phones */
@media (max-height: 420px) and (orientation: landscape) { .mgo__head { min-height: 48px; } .mgo__log { padding-top: 8px; } }

/* Stops the page behind the chat scrolling while it is open on a phone. */
html.mgo-lock, html.mgo-lock body { overflow: hidden !important; overscroll-behavior: none; }
