.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.kopi-mascot {
  display: block;
  width: 110px;
  height: auto;
  max-width: 120px;
  object-fit: contain;
  object-position: center;
  background: transparent;
  animation: kopi-mascot-in 320ms ease;
}

.kopi-mascot--hero {
  width: 110px;
  max-width: 120px;
}

.kopi-mascot--msg,
.kopi-mascot--brand {
  width: 40px;
  max-width: 44px;
  animation: none;
}

.kopi-mascot--brand {
  width: 32px;
  max-width: 36px;
}

.kopi-fab {
  position: fixed;
  right: 1.1rem;
  bottom: 1.1rem;
  z-index: 80;
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  border: 1px solid rgba(43, 102, 217, 0.28);
  background: #fff;
  color: #0b1728;
  font: 600 0.9rem "Outfit", sans-serif;
  padding: 0.35rem 0.85rem 0.35rem 0.35rem;
  border-radius: 999px;
  box-shadow: 0 10px 28px rgba(11, 23, 40, 0.1);
  cursor: pointer;
}

.kopi-fab .kopi-mascot {
  width: 36px;
}

.kopi-panel {
  position: fixed;
  z-index: 90;
  right: 1rem;
  bottom: 4.2rem;
  width: min(26rem, calc(100vw - 1.5rem));
  max-height: min(34rem, calc(100dvh - 6rem));
  overflow: auto;
  background: #fff;
  border: 1px solid rgba(11, 23, 40, 0.12);
  border-radius: 16px;
  box-shadow: 0 18px 40px rgba(11, 23, 40, 0.14);
  padding: 1rem 1.05rem 1.1rem;
}

.kopi-panel[hidden] {
  display: none !important;
}

.kopi-panel__head,
.kopi-toolbar {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  align-items: center;
}

.kopi-panel__hello,
.kopi-trust {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  margin: 0;
  font-family: "Outfit", sans-serif;
  font-weight: 650;
  font-size: 0.82rem;
  color: #0b1728;
}

.kopi-more {
  appearance: none;
  border: 0;
  background: transparent;
  color: #1e4fad;
  padding: 0.2rem 0;
  font: 600 0.78rem "Outfit", sans-serif;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.kopi-close,
.kopi-skip,
.kopi-showfull,
.kopi-retry {
  appearance: none;
  border: 0;
  background: transparent;
  color: #5b6b7f;
  border-radius: 8px;
  padding: 0.25rem 0.45rem;
  font: 600 0.78rem "Outfit", sans-serif;
  cursor: pointer;
}

.kopi-close {
  border: 1px solid rgba(11, 23, 40, 0.16);
  background: #fff;
}

.kopi-retry {
  color: #1e4fad;
  padding: 0;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.kopi-chips {
  display: flex;
  gap: 0.4rem;
  overflow-x: auto;
  padding-bottom: 0.15rem;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.kopi-chips::-webkit-scrollbar {
  display: none;
}

.kopi-chip {
  appearance: none;
  flex: 0 0 auto;
  border: 1px solid rgba(43, 102, 217, 0.18);
  background: #fff;
  color: #1e4fad;
  border-radius: 999px;
  padding: 0.32rem 0.7rem;
  font-size: 0.78rem;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.kopi-chip:hover {
  border-color: rgba(43, 102, 217, 0.4);
  background: rgba(43, 102, 217, 0.05);
}

.kopi-thread {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  margin: 0.4rem 0 0.6rem;
  max-height: 12rem;
  overflow: auto;
}

.kopi-toolbar {
  display: flex;
  justify-content: flex-end;
  min-height: 0;
}

.kopi-toolbar:has(.kopi-skip[hidden]) {
  display: none;
}

.kopi-intro {
  display: grid;
  gap: 0.85rem;
  max-width: 38rem;
  animation: kopi-fade 200ms ease;
}

.kopi-intro__identity {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.kopi-intro__name {
  margin: 0;
  font-family: "Outfit", sans-serif;
  font-weight: 700;
  font-size: 1.05rem;
  color: #0b1728;
}

.kopi-intro__trust {
  margin: 0.15rem 0 0;
  font-size: 0.78rem;
  color: #5b6b7f;
}

.kopi-intro__lines {
  display: grid;
  gap: 0.55rem;
  padding-left: 0;
}

.kopi-turn {
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr);
  gap: 0.35rem 0.65rem;
  max-width: 82%;
  animation: kopi-fade 200ms ease;
}

.kopi-turn--user {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  grid-template-columns: minmax(0, 1fr);
  width: fit-content;
  max-width: 64%;
  margin-left: auto;
  min-width: 0;
}

.kopi-turn--user .kopi-turn__main {
  width: fit-content;
  max-width: 100%;
  min-width: 0;
  background: rgba(11, 23, 40, 0.05);
  border-radius: 14px 14px 4px 14px;
  padding: 0.45rem 0.75rem 0.55rem;
}

.kopi-turn.is-hero {
  max-width: 92%;
  align-items: start;
  grid-template-columns: 120px minmax(0, 1fr);
}

.kopi-turn.is-hero .kopi-mascot {
  width: 110px;
}

.kopi-turn__media {
  padding-top: 0.1rem;
}

.kopi-turn.is-thinking .kopi-mascot--msg {
  animation: kopi-think 1.8s ease-in-out infinite;
  transform-origin: 50% 70%;
}

.kopi-turn__who {
  margin: 0 0 8px;
  font-family: "Outfit", sans-serif;
  font-size: 0.72rem;
  font-weight: 700;
  color: #0b1728;
}

.kopi-turn--user .kopi-turn__who {
  color: #5b6b7f;
  text-align: right;
  margin-bottom: 4px;
}

.kopi-turn__stack {
  display: grid;
  gap: 8px;
}

.kopi-msg__body {
  margin: 0;
  font-size: 0.98rem;
  color: #0b1728;
  line-height: 1.55;
  white-space: pre-wrap;
  overflow-wrap: break-word;
  word-break: normal;
  min-height: 1.35em;
}

.kopi-turn.is-thinking .kopi-msg__body {
  color: #5b6b7f;
}

.kopi-dots::after {
  content: "···";
  display: inline-block;
  width: 1.4em;
  letter-spacing: 0.08em;
  animation: kopi-dots 1.2s steps(4, end) infinite;
}

.kopi-msg__body.is-typing {
  cursor: pointer;
}

.kopi-msg__body.is-typing::after {
  content: "|";
  margin-left: 1px;
  color: #1e4fad;
  animation: kopi-caret 1s steps(1) infinite;
}

.kopi-composer {
  display: grid;
  gap: 0.35rem;
}

.kopi-composer__field {
  position: relative;
  display: flex;
  align-items: flex-end;
}

.kopi-composer textarea {
  width: 100%;
  min-height: 52px;
  max-height: 128px;
  border: 1px solid rgba(11, 23, 40, 0.14);
  border-radius: 18px;
  padding: 0.85rem 2.6rem 0.85rem 1rem;
  font: inherit;
  resize: none;
  background: #fff;
}

.kopi-composer textarea:focus {
  outline: 2px solid rgba(43, 102, 217, 0.35);
  outline-offset: 1px;
}

.kopi-send {
  position: absolute;
  right: 0.35rem;
  bottom: 0.35rem;
  appearance: none;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: #1e4fad;
  font: 600 1rem "Outfit", sans-serif;
  cursor: pointer;
}

.kopi-send:disabled {
  opacity: 0.4;
  cursor: default;
}

.kopi-count {
  margin: 0;
  font-size: 0.72rem;
  color: #8a97a8;
}

.kopi-page-foot a,
.kopi-limit a,
.kopi-error-actions a {
  color: #5b6b7f;
}

.kopi-limit,
.kopi-error-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1rem;
  margin: 0.15rem 0 0;
  font-size: 0.88rem;
}

body.kopi-open {
  overflow: hidden;
}

body.kopi-page {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  height: 100vh;
  height: 100dvh;
  max-height: 100dvh;
  overflow: hidden;
  background: #f3f5f8;
}

body.kopi-page.kopi-keyboard {
  height: var(--kopi-app-h, 100dvh);
  max-height: var(--kopi-app-h, 100dvh);
}

body.kopi-keyboard .kopi-page-foot {
  display: none;
}

.resume-topbar__name-short,
.resume-topbar__links {
  display: none;
}

body.kopi-page .resume-topbar {
  flex-shrink: 0;
  background: rgba(243, 245, 248, 0.92);
}

.kopi-shell {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  width: min(1120px, calc(100% - 1.5rem));
  margin: 0 auto;
  min-height: 0;
  overflow: hidden;
}

.kopi-page-foot {
  flex-shrink: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.85rem 1.1rem;
  justify-content: center;
  padding: 0.55rem 1rem calc(0.7rem + env(safe-area-inset-bottom));
  font-size: 0.78rem;
  color: #5b6b7f;
  background: #f3f5f8;
}

.kopi-page-foot a {
  text-decoration: none;
}

.kopi-page-foot a:hover {
  color: #1e4fad;
}

.kopi--workspace {
  display: flex;
  flex: 1;
  width: 100%;
  min-height: 0;
  height: auto;
}

.kopi--workspace .kopi-panel {
  position: relative;
  inset: auto;
  display: grid;
  grid-template-columns: minmax(200px, 28%) minmax(0, 1fr);
  gap: 0.75rem 2rem;
  align-items: stretch;
  width: 100%;
  flex: 1;
  height: auto;
  max-height: none;
  min-height: 0;
  overflow: hidden;
  right: auto;
  bottom: auto;
  z-index: 1;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  background: transparent;
  padding: 0.35rem 1.15rem 0.85rem;
}

.kopi-mascot-col {
  position: sticky;
  top: 0;
  align-self: start;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 0.35rem 0.4rem 0;
}

.kopi-mascot--stage {
  width: min(100%, 220px);
  max-width: 220px;
  height: auto;
  transform-origin: 50% 70%;
  transition: opacity 300ms ease, transform 300ms ease;
}

.kopi-compact-bar {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  flex-shrink: 0;
  min-height: 44px;
  padding: 0.1rem 0 0.55rem;
  border-bottom: 1px solid rgba(11, 23, 40, 0.08);
}

.kopi-compact-bar[hidden] {
  display: none !important;
}

.kopi-compact-bar .kopi-mascot--brand {
  width: 44px;
  max-width: 44px;
}

.kopi-compact-bar__meta {
  min-width: 0;
  flex: 1;
}

.kopi-compact-bar .kopi-status {
  margin: 0;
  margin-left: auto;
}

.kopi-status {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  margin: 0.2rem 0 0;
  font-size: 0.72rem;
  font-family: "Outfit", sans-serif;
  font-weight: 600;
  color: #8a97a8;
}

.kopi-status__dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #3d8b6e;
}

.kopi-status[data-state="thinking"] .kopi-status__dot {
  background: #c4a35a;
}

.kopi-status[data-state="unavailable"] .kopi-status__dot {
  background: #b07070;
}

.kopi-intro__meta {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.2rem 1rem;
}

.kopi-intro__meta .kopi-intro__trust {
  margin: 0;
}

.kopi-intro {
  overflow: hidden;
  max-height: 42rem;
  transition: max-height 320ms ease, opacity 280ms ease, margin 300ms ease;
}

.kopi-intro.is-collapsed {
  max-height: 0;
  opacity: 0;
  margin: 0;
  padding: 0;
  pointer-events: none;
}

.kopi--workspace .kopi-panel {
  transition: grid-template-columns 320ms ease;
}

.kopi--workspace.is-compact .kopi-panel {
  grid-template-columns: minmax(0, 1fr);
}

.kopi--workspace.is-compact .kopi-mascot-col {
  display: none;
}

.kopi-chat {
  min-width: 0;
  display: flex;
  flex-direction: column;
  min-height: 0;
  flex: 1;
  height: auto;
  overflow: hidden;
}

.kopi--workspace .kopi-thread,
.kopi--workspace .kopi-dock {
  width: 100%;
  max-width: 54rem;
}

.kopi--workspace .kopi-turn--kopi {
  grid-template-columns: minmax(0, 1fr);
  max-width: 82%;
}

.kopi--workspace .kopi-turn--kopi .kopi-turn__media {
  display: none;
}

.kopi--workspace .kopi-turn--user {
  max-width: 66%;
  margin-left: auto;
  margin-right: 0.85rem;
}

.kopi--workspace .kopi-turn.is-error {
  grid-template-columns: 40px minmax(0, 1fr);
  max-width: 80%;
}

.kopi--workspace .kopi-turn.is-error .kopi-turn__media {
  display: block;
}

.kopi--workspace.is-thinking .kopi-mascot--stage {
  animation: kopi-breathe 1.2s ease-in-out infinite;
}

.kopi-toolbar {
  padding: 0.15rem 0 0.25rem;
}

.kopi--workspace .kopi-thread {
  flex: 1 1 auto;
  max-height: none;
  min-height: 0;
  margin: 0;
  padding: 0.5rem 1.5rem 0.7rem;
  justify-content: flex-start;
  overflow-x: hidden;
  overflow-y: auto;
  scrollbar-gutter: stable;
  scrollbar-width: thin;
  scrollbar-color: rgba(11, 23, 40, 0.28) transparent;
  -webkit-overflow-scrolling: touch;
}

.kopi--workspace .kopi-thread::-webkit-scrollbar {
  width: 8px;
}

.kopi--workspace .kopi-thread::-webkit-scrollbar-track {
  background: transparent;
}

.kopi--workspace .kopi-thread::-webkit-scrollbar-thumb {
  background: rgba(11, 23, 40, 0.28);
  border-radius: 999px;
}

.kopi-dock {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  padding-bottom: max(12px, env(safe-area-inset-bottom));
}

.kopi-dock__meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  min-height: 44px;
}

.kopi-more {
  min-height: 44px;
  padding: 0.4rem 0.2rem;
}

.kopi--workspace .kopi-composer {
  margin-top: 0;
  padding-bottom: 0;
  background: transparent;
}

.kopi-suggest {
  margin: 0;
}

.kopi-suggest.is-quiet {
  display: none;
}

.kopi-suggest__row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.35rem;
}

.kopi-suggest__label {
  margin: 0;
  font-size: 0.75rem;
  color: #5b6b7f;
}

@keyframes kopi-fade {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@keyframes kopi-mascot-in {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@keyframes kopi-think {
  0%,
  100% {
    transform: rotate(-1.4deg) scale(1);
  }
  50% {
    transform: rotate(1.4deg) scale(1.03);
  }
}

@keyframes kopi-breathe {
  0%,
  100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.015);
  }
}

@keyframes kopi-caret {
  50% {
    opacity: 0;
  }
}

@keyframes kopi-dots {
  0% {
    content: "";
  }
  25% {
    content: "·";
  }
  50% {
    content: "··";
  }
  75% {
    content: "···";
  }
}

@media (max-width: 768px) {
  .kopi-panel {
    inset: auto 0 0;
    width: 100%;
    max-height: min(85dvh, 40rem);
    bottom: 0;
    right: 0;
    border-radius: 16px 16px 0 0;
  }

  body.kopi-page .resume-topbar {
    min-height: 56px;
    height: 56px;
    padding: 0 16px;
    gap: 0.65rem;
  }

  body.kopi-page .resume-topbar__meta {
    display: none;
  }

  body.kopi-page .resume-topbar__links {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    margin-left: auto;
    font-size: 0.82rem;
    font-weight: 600;
  }

  body.kopi-page .resume-topbar__links a {
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    color: #5b6b7f;
    text-decoration: none;
  }

  body.kopi-page .resume-topbar__name-full {
    display: none;
  }

  body.kopi-page .resume-topbar__name-short {
    display: inline;
  }

  body.kopi-page .kopi-page-foot {
    display: none;
  }

  body.kopi-page .kopi-shell {
    width: 100%;
    height: auto;
    flex: 1 1 auto;
    min-height: 0;
  }

  .kopi--workspace .kopi-panel {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    padding: 0.15rem 16px 0;
    flex: 1;
    height: auto;
    min-height: 0;
    overflow: hidden;
  }

  .kopi-mascot-col {
    position: static;
    justify-content: flex-start;
    padding: 0.1rem 0 0.15rem;
    flex-shrink: 0;
  }

  .kopi-mascot--stage {
    width: 88px;
    max-width: 96px;
  }

  .kopi--workspace.is-compact .kopi-mascot-col {
    display: none;
  }

  .kopi-compact-bar {
    min-height: 44px;
    padding: 0.15rem 0 0.4rem;
  }

  .kopi-thread {
    gap: 1.5rem;
  }

  .kopi--workspace .kopi-thread {
    padding: 0.4rem 0 0.7rem;
    padding-right: 0.75rem;
    scrollbar-gutter: stable;
  }

  .kopi-turn,
  .kopi--workspace .kopi-turn--kopi {
    grid-template-columns: 40px minmax(0, 1fr);
    max-width: 92%;
    gap: 0.3rem 0.55rem;
  }

  .kopi--workspace .kopi-turn--kopi .kopi-turn__media {
    display: block;
  }

  .kopi-mascot--hero {
    width: 80px;
    max-width: 90px;
  }

  .kopi-mascot--msg {
    width: 36px;
  }

  .kopi-turn.is-hero {
    grid-template-columns: 88px minmax(0, 1fr);
  }

  .kopi-turn.is-hero .kopi-mascot {
    width: 80px;
  }

  .kopi-turn--user,
  .kopi--workspace .kopi-turn--user {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    grid-template-columns: none;
    width: fit-content;
    max-width: 82%;
    margin-left: auto;
    margin-right: 0.5rem;
  }

  .kopi-turn--user .kopi-turn__main {
    width: fit-content;
    max-width: 100%;
  }

  .kopi-msg__body {
    font-size: 1.05rem;
  }

  .kopi-intro__name {
    font-size: 1.25rem;
  }

  .kopi-composer textarea {
    min-height: 52px;
    max-height: 78px;
    border-radius: 16px;
    font-size: 16px;
  }

  .kopi-dock {
    background: linear-gradient(180deg, rgba(243, 245, 248, 0), #f3f5f8 22%);
    padding-top: 0.35rem;
  }

  .kopi-retry,
  .kopi-more,
  .kopi-error-actions a {
    min-height: 44px;
    display: inline-flex;
    align-items: center;
  }
}

@media (prefers-reduced-motion: reduce) {
  .kopi-turn,
  .kopi-chip,
  .kopi-mascot,
  .kopi-intro,
  .kopi--workspace .kopi-panel,
  .kopi-turn.is-thinking .kopi-mascot--msg,
  .kopi--workspace.is-thinking .kopi-mascot--stage {
    animation: none;
    transition: none;
  }

  .kopi-msg__body.is-typing::after,
  .kopi-dots::after {
    animation: none;
  }
}
