.miles-assistant {
    position: absolute;
    right: 14px;
    bottom: 40px;
    z-index: 8;
    color: #17251c;
    font-family: Inter, Arial, sans-serif;
}

.miles-launcher {
    display: flex;
    width: 196px;
    min-height: 62px;
    align-items: center;
    gap: 8px;
    border: 1px solid #183c29;
    border-radius: 8px;
    background: #f7faf8;
    padding: 4px 12px 4px 4px;
    box-shadow: 0 8px 22px rgba(21, 45, 30, .2);
    color: #183c29;
    cursor: pointer;
    text-align: left;
}

.miles-launcher:hover { background: #edf4ef; }
.miles-launcher:focus-visible,
.miles-panel button:focus-visible,
.miles-panel textarea:focus-visible { outline: 3px solid #f4b942; outline-offset: 2px; }

.miles-launcher-copy { display: grid; gap: 1px; }
.miles-launcher-copy strong { font-size: 15px; }
.miles-launcher-copy span { color: #647168; font-size: 11px; }

.miles-sprite {
    display: block;
    flex: 0 0 auto;
    width: 58px;
    height: 58px;
    background-image: url('../images/miles-night-manager-sprite.png');
    background-position: 0 0;
    background-repeat: no-repeat;
    background-size: 200% 200%;
}

.miles-panel {
    width: min(390px, calc(100vw - 28px));
    max-height: min(680px, calc(100svh - 100px));
    overflow: hidden;
    border: 1px solid #82958a;
    border-radius: 8px;
    background: #fff;
    box-shadow: 0 16px 40px rgba(19, 40, 26, .26);
}

.miles-panel:not([hidden]) { display: grid; grid-template-rows: auto minmax(140px, 1fr) auto auto auto; }
.miles-panel:not([hidden]) + .miles-launcher { display: none; }

.miles-head {
    position: relative;
    display: grid;
    grid-template-columns: 64px 1fr 36px;
    align-items: center;
    gap: 8px;
    min-height: 74px;
    border-bottom: 1px solid #d8e1db;
    background: #173c29;
    padding: 5px 8px 5px 3px;
    color: #fff;
}

.miles-head strong { display: block; font-size: 17px; }
.miles-head span:not(.miles-sprite) { display: block; margin-top: 2px; color: #d8e8dd; font-size: 11px; }
.miles-icon-button { width: 34px; height: 34px; border: 0; background: transparent; color: #fff; font-size: 27px; cursor: pointer; }

.miles-conversation { overflow-y: auto; padding: 14px; background: #f6f8f6; scroll-behavior: smooth; }
.miles-message { max-width: 92%; margin-bottom: 12px; border-radius: 7px; padding: 10px 12px; font-size: 13px; line-height: 1.5; }
.miles-message p { margin: 2px 0 0; white-space: pre-wrap; }
.miles-message strong { font-size: 11px; }
.miles-message-assistant { border-left: 3px solid #b22f32; background: #fff; }
.miles-message-user { margin-left: auto; background: #e3eee7; }
.miles-citations { display: grid; gap: 4px; margin: 8px 0 0; padding-left: 18px; font-size: 11px; }
.miles-citations a { color: #1769aa; overflow-wrap: anywhere; }
.miles-map-note { margin-top: 8px; color: #7f301f; font-size: 11px; font-weight: 700; }

.miles-prompts { display: flex; gap: 6px; overflow-x: auto; border-top: 1px solid #dfe6e1; padding: 9px 10px; }
.miles-prompts button { flex: 0 0 auto; min-height: 34px; border: 1px solid #aab9b0; border-radius: 6px; background: #fff; padding: 5px 9px; color: #285038; font-size: 11px; cursor: pointer; }
.miles-feedback { border-top:1px solid #dfe6e1; padding:8px 10px; font-size:11px; }
.miles-feedback summary { color:#285038; font-weight:700; cursor:pointer; }
.miles-feedback form { display:grid; gap:5px; margin-top:8px; }
.miles-feedback input,.miles-feedback textarea { width:100%; border:1px solid #aab9b0; border-radius:6px; padding:7px; font:inherit; }
.miles-feedback button { min-height:34px; border:1px solid #285038; border-radius:6px; background:#fff; color:#285038; font-weight:700; cursor:pointer; }
.miles-feedback p { margin:0; color:#59665e; line-height:1.4; }
.miles-honeypot { position:absolute; left:-10000px; }

.miles-form { display: grid; grid-template-columns: 1fr auto; gap: 8px; border-top: 1px solid #dfe6e1; padding: 10px; }
.miles-form textarea { min-height: 48px; max-height: 110px; resize: vertical; border: 1px solid #9eaca3; border-radius: 6px; padding: 8px; color: #17251c; font: inherit; font-size: 13px; }
.miles-form button { align-self: stretch; border: 1px solid #173c29; border-radius: 6px; background: #173c29; padding: 0 13px; color: #fff; font-weight: 700; cursor: pointer; }
.miles-form button:disabled { opacity: .55; cursor: wait; }
.miles-turnstile { grid-column: 1 / -1; overflow:hidden; }

.miles-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; border-top: 1px solid #dfe6e1; padding: 8px 10px; color: #68766d; font-size: 10px; }
.miles-foot button { flex: 0 0 auto; border: 0; background: transparent; color: #285038; font-size: 10px; font-weight: 700; cursor: pointer; }
.miles-foot-actions { display: flex; flex: 0 0 auto; gap: 8px; }
.miles-admin-note { margin: 0; border-top: 1px solid #dfe6e1; padding: 12px; color: #59665e; font-size: 12px; line-height: 1.5; }

.miles-head[data-state="thinking"] .miles-sprite,
.miles-head[data-state="scanning"] .miles-sprite { background-position: 100% 0; }
.miles-head[data-state="success"] .miles-sprite { background-position: 0 100%; }
.miles-head[data-state="coffee"] .miles-sprite { background-position: 100% 100%; }

.miles-head[data-state="scanning"]::after {
    position: absolute;
    right: 38px;
    bottom: 8px;
    width: 0;
    height: 2px;
    background: #ff4b43;
    box-shadow: 0 0 7px #ff4b43;
    content: '';
    animation: miles-scan .6s ease-out 1;
    transform-origin: right center;
}

@keyframes miles-scan {
    0% { width: 0; opacity: 0; }
    25% { opacity: 1; }
    100% { width: 245px; opacity: 0; }
}

@media (max-width: 680px) {
    .miles-assistant { right: 9px; bottom: 34px; left: 9px; }
    .miles-launcher { width: 184px; margin-left: auto; }
    .miles-panel { width: 100%; max-height: min(620px, calc(100svh - 88px)); }
}

@media (prefers-reduced-motion: reduce) {
    .miles-conversation { scroll-behavior: auto; }
    .miles-head[data-state="scanning"]::after { display: none; animation: none; }
}

.miles-assistant[data-motion="off"] .miles-conversation { scroll-behavior: auto; }
.miles-assistant[data-motion="off"] .miles-head[data-state="scanning"]::after { display: none; animation: none; }
