:root {
  color-scheme: light dark;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  justify-content: center;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  line-height: 1.5;
}

main {
  width: 100%;
  max-width: 48rem;
  padding: 2rem 1.25rem;
}

h1 {
  font-size: 1.75rem;
  margin: 0 0 1.5rem;
}

/* Floating chat widget — bottom-right window */
.chat-widget {
  position: fixed;
  bottom: 1.25rem;
  right: 1.25rem;
  z-index: 9999;
  width: 380px;
  max-width: calc(100vw - 2.5rem);
  display: flex;
  flex-direction: column;
  border-radius: 10px;
  overflow: hidden;
  box-shadow:
    0 4px 24px rgba(0, 0, 0, 0.18),
    0 0 0 1px rgba(0, 0, 0, 0.08);
  background: #1a1a1a;
  transition:
    width 0.2s ease,
    height 0.2s ease,
    bottom 0.2s ease,
    right 0.2s ease,
    border-radius 0.2s ease;
}

.chat-widget__titlebar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.5rem 0.625rem;
  background: #2a2a2a;
  color: #f0f0f0;
  cursor: default;
  user-select: none;
  flex-shrink: 0;
}

.chat-widget__title {
  font-size: 0.875rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-widget__controls {
  display: flex;
  gap: 0.25rem;
  flex-shrink: 0;
}

.chat-widget__btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 1.75rem;
  height: 1.75rem;
  padding: 0;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: inherit;
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
}

.chat-widget__btn:hover {
  background: rgba(255, 255, 255, 0.12);
}

.chat-widget__body {
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

/* Chattable requires 250px or greater in both dimensions. */
#chattable {
  display: block;
  width: 100%;
  height: 460px;
  border: 0;
}

/* Minimized — title bar only */
.chat-widget.is-minimized {
  width: auto;
  min-width: 12rem;
}

.chat-widget.is-minimized .chat-widget__body {
  display: none;
}

/* Maximized — full viewport */
.chat-widget.is-maximized {
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100%;
  max-width: none;
  height: 100%;
  border-radius: 0;
}

.chat-widget.is-maximized #chattable {
  height: 100%;
}
