/* ============================================================
   WEBCHAT THEME — WorkOne AI

   Design: Light pastel gradient, white card, minimal
   Palette: Teal accent, coral send button
   ============================================================ */


/* === 1. Color System — Force light === */

:root,
:root[data-theme=dark],
:root[data-theme=light] {
  --bg: #ffffff;
  --bg-accent: #f8f9fa;
  --bg-elevated: #ffffff;
  --bg-hover: #f0f1f3;
  --bg-muted: #f0f1f3;
  --bg-content: #ffffff;
  --card: #f8f9fa;
  --card-foreground: #3d3d3d;
  --card-highlight: transparent;
  --panel: #ffffff;
  --panel-strong: #f8f9fa;
  --panel-hover: #f0f1f3;
  --chrome: rgba(255,255,255,0.96);
  --chrome-strong: rgba(255,255,255,0.98);
  --popover: #ffffff;
  --popover-foreground: #3d3d3d;
  --secondary: #f0f1f3;
  --secondary-foreground: #3d3d3d;

  --text: #666;
  --text-strong: #3d3d3d;
  --chat-text: #444;
  --muted: #999;
  --muted-strong: #bbb;
  --muted-foreground: #999;

  --border: rgba(0,0,0,0.06);
  --border-strong: rgba(0,0,0,0.1);
  --border-hover: rgba(0,0,0,0.15);
  --input: rgba(0,0,0,0.04);

  --accent: #5bbfb5;
  --accent-hover: #4db0a6;
  --accent-muted: #5bbfb5;
  --accent-subtle: rgba(91,191,181,0.08);
  --accent-foreground: #ffffff;
  --accent-glow: rgba(91,191,181,0.06);
  --ring: #5bbfb5;
  --primary: #5bbfb5;
  --primary-foreground: #ffffff;

  --accent-2: #34b88c;
  --accent-2-muted: rgba(52,184,140,0.7);
  --accent-2-subtle: rgba(52,184,140,0.08);
  --ok: #34b88c;
  --danger: #e5534b;
  --destructive: #e5534b;
  --destructive-foreground: #ffffff;
  --warn: #d4952a;
  --warn-subtle: rgba(212,149,42,0.08);
  --info: #5bbfb5;

  --shadow-sm: none;
  --shadow-md: none;
  --shadow-lg: none;
  --shadow-xl: none;
  --shadow-glow: none;
  --focus: rgba(91,191,181,0.15);
  --focus-ring: 0 0 0 2px #fff, 0 0 0 3.5px #5bbfb5;
  --focus-glow: 0 0 0 2px #fff, 0 0 0 3.5px #5bbfb5;

  --font-body: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  --font-display: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  --mono: "SF Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  --radius-full: 9999px;
  --radius: 8px;

  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --duration-fast: 0.1s;
  --duration-normal: 0.15s;

  /* Webchat-specific */
  --wc-teal: #5bbfb5;
  --wc-coral: #f4845f;

  color-scheme: light;
}


/* === 2. Document Level — Aurora background === */

body {
  margin: 0 !important;
  padding: 0 !important;
  background: #dde8e7 !important;
  min-height: 100vh !important;
}

/* Aurora layer 1 — slow clockwise rotation (GPU-composited) */
body::before {
  content: '' !important;
  display: block !important;
  position: fixed !important;
  top: -50% !important;
  left: -50% !important;
  width: 200% !important;
  height: 200% !important;
  z-index: 0 !important;
  background:
    radial-gradient(circle at 30% 40%, rgba(91, 191, 181, 0.4) 0%, transparent 50%),
    radial-gradient(circle at 75% 60%, rgba(150, 200, 240, 0.3) 0%, transparent 45%) !important;
  animation: aurora-1 40s linear infinite !important;
  pointer-events: none !important;
  will-change: transform !important;
}

/* Aurora layer 2 — slow counter-clockwise rotation */
body::after {
  content: '' !important;
  display: block !important;
  position: fixed !important;
  top: -50% !important;
  left: -50% !important;
  width: 200% !important;
  height: 200% !important;
  z-index: 0 !important;
  background:
    radial-gradient(circle at 60% 25%, rgba(200, 180, 240, 0.35) 0%, transparent 45%),
    radial-gradient(circle at 35% 75%, rgba(240, 200, 180, 0.15) 0%, transparent 40%) !important;
  animation: aurora-2 55s linear infinite !important;
  pointer-events: none !important;
  will-change: transform !important;
}

@keyframes aurora-1 {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}

@keyframes aurora-2 {
  from { transform: rotate(0deg); }
  to   { transform: rotate(-360deg); }
}

#app-root {
  position: relative !important;
  z-index: 1 !important;
  justify-content: center !important;
}

openclaw-app {
  display: flex !important;
  flex-direction: column !important;
  background: #ffffff !important;
  overflow: hidden !important;
  transition: margin 0.35s cubic-bezier(0.4, 0, 0.2, 1) !important;
}

/* Large screens: phone-like card with rounded corners and margin */
@media (min-width: 768px) {
  openclaw-app {
    margin: 24px !important;
    max-width: 480px !important;
    width: 100% !important;
    border-radius: 24px !important;
    box-shadow:
      0 8px 40px rgba(0, 0, 0, 0.1),
      0 2px 12px rgba(0, 0, 0, 0.06) !important;
    max-height: calc(100vh - 48px) !important;
  }

  /* When widget panel is open, keep card shape but shift left */
  openclaw-app.has-widget-panel {
    flex: 0 0 auto !important;
    max-width: 480px !important;
    margin-right: 0 !important;
  }

  openclaw-app #wc-header {
    border-radius: 24px 24px 0 0 !important;
  }

  .shell {
    border-radius: 0 0 32px 32px !important;
  }

  /* Widget panel on desktop — same vertical margin as chat card */
  .chat-widget-panel {
    margin: 24px 24px 24px 12px !important;
    max-width: 420px !important;
    max-height: calc(100vh - 48px) !important;
    border-radius: 24px !important;
    overflow: hidden !important;
  }
}


/* === 3. Custom Header — Minimal icon-based === */

#wc-header {
  position: absolute !important;
  top: 0 !important;
  left: 0 !important;
  right: 0 !important;
  height: 44px !important;
  display: flex !important;
  align-items: center !important;
  gap: 8px !important;
  padding: 30px 20px !important;
  z-index: 100 !important;
  font-family: var(--font-body) !important;
}

.wc-h-spacer {
  flex: 1;
}

/* Info popover */
.wc-info-anchor {
  position: absolute;
  top: 0;
  left: 0;
  pointer-events: none;
}

.wc-info-popover {
  display: none;
  position: absolute;
  top: 48px;
  left: 10px;
  background: #ffffff;
  border: 1px solid rgba(0,0,0,0.08);
  border-radius: 14px;
  padding: 10px 14px;
  min-width: 200px;
  max-width: 320px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.1);
  z-index: 1001;
  pointer-events: auto;
}

.wc-info-popover.open {
  display: block;
}

.wc-info-row {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 6px 0;
}

.wc-info-row + .wc-info-row {
  border-top: 1px solid rgba(0,0,0,0.04);
}

.wc-info-label {
  font-size: 10px;
  font-weight: 600;
  color: #999;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
  flex-shrink: 0;
  min-width: 48px;
}

.wc-info-value {
  font-size: 13px;
  font-weight: 500;
  color: #3d3d3d;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.wc-info-mono {
  font-family: 'SF Mono', 'Monaco', 'Consolas', monospace;
  font-size: 11px;
  color: #666;
}


/* === 4. Layout — White rounded card === */

.topbar {
  display: none !important;
  height: 0 !important;
  min-height: 0 !important;
  overflow: hidden !important;
}

.nav {
  display: none !important;
  width: 0 !important;
  height: 0 !important;
  overflow: hidden !important;
}

.shell {
  display: grid !important;
  grid-template-columns: 1fr !important;
  grid-template-rows: 1fr !important;
  grid-template-areas: "content" !important;
  background: transparent !important;
  border-radius: 0 !important;
  margin: 0 !important;
  flex: 1 !important;
  min-height: 0 !important;
  max-height: none !important;
  box-shadow: none !important;
  overflow: hidden !important;
  padding: 0 !important;
  box-sizing: border-box !important;
}

.content {
  grid-area: content !important;
  padding: 0 !important;
  gap: 0 !important;
  background: transparent !important;
}

.content--chat {
  padding: 0 !important;
}

.content-header {
  display: none !important;
}

/* Widget panel: align top with wc-header */
.chat-widget-panel {
  box-sizing: border-box !important;
  background: transparent !important;
  border-left: none !important;
  animation: widget-panel-enter 0.4s cubic-bezier(0.4, 0, 0.2, 1) both !important;
  will-change: transform, opacity !important;
}

@keyframes widget-panel-enter {
  from {
    opacity: 0;
    transform: translateX(24px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

.chat-widget-panel__body {
  padding: 12px 16px !important;
}

.chat-widget-panel--exiting {
  animation: widget-panel-exit 0.25s cubic-bezier(0.4, 0, 1, 1) both !important;
  pointer-events: none !important;
}

@keyframes widget-panel-exit {
  from {
    opacity: 1;
    transform: scale(1);
    max-width: 420px;
  }
  to {
    opacity: 0;
    transform: scale(0.95);
    max-width: 0;
    margin: 24px 0;
    padding: 0;
  }
}

.chat-focus-exit {
  display: none !important;
}

/* Hide original new session button — replaced by avatar */
.chat-compose__actions .btn:not(.primary):not(.danger) {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  overflow: hidden !important;
  clip: rect(0,0,0,0) !important;
  border: 0 !important;
  padding: 0 !important;
  margin: -1px !important;
}


/* === 5. Tab Bar (injected via JS) === */

.wc-tabs {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px 6px;
}

.wc-tab {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  border: none;
  background: transparent;
  color: #c0c0c0;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s ease;
  padding: 0;
  font-family: var(--font-body);
}

.wc-tab:hover {
  background: #f0f1f3;
  color: #888;
}

.wc-tab.active {
  background: #2d2d2d;
  color: #ffffff;
}

.wc-tab svg {
  display: block;
}


/* === 6. Welcome State (injected via JS) === */

.wc-welcome {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 55vh;
  gap: 8px;
  pointer-events: none;
  user-select: none;
}

.wc-welcome-title {
  font-size: 22px;
  font-weight: 600;
  color: #3d3d3d;
  font-family: var(--font-body);
}

.wc-welcome-sub {
  font-size: 15px;
  color: var(--wc-teal);
  font-family: var(--font-body);
}


/* === 7. Chat Thread & Bubbles === */

.chat-thread {
  max-width: 100%;
  margin: 0;
  padding: 100px 0px 140px !important;
  width: 100%;
  box-sizing: border-box;
}

.chat-group {
  margin-bottom: 4px;
}

.chat-bubble {
  border-radius: 14px !important;
  line-height: 1.6 !important;
  font-size: 14px !important;
}

.chat-group.user .chat-bubble {
  background: rgba(91,191,181,0.08) !important;
  border: none !important;
}

.chat-group.assistant .chat-bubble,
.chat-group.other .chat-bubble {
  background: #f8f9fa !important;
  border: 1px solid rgba(0,0,0,0.04) !important;
}

.chat-sender-name {
  font-size: 12px !important;
  font-weight: 600 !important;
  color: #3d3d3d !important;
  letter-spacing: -0.01em !important;
}

/* Replace "Claw" name with "AI" for non-user messages */
.chat-group:not(.user) .chat-sender-name {
  font-size: 0 !important;
  line-height: 0 !important;
}

.chat-group:not(.user) .chat-sender-name::after {
  content: "AI" !important;
  font-size: 12px !important;
  font-weight: 600 !important;
  color: #3d3d3d !important;
  line-height: normal !important;
}

.chat-group-timestamp {
  font-size: 11px !important;
  color: #999 !important;
  font-weight: 400 !important;
}

.chat-avatar {
  width: 28px !important;
  height: 28px !important;
  border-radius: 50% !important;
  font-size: 13px !important;
}

/* Replace crab avatar with "AI" for non-user messages */
.chat-group:not(.user) .chat-avatar {
  font-size: 0 !important;
  background: var(--wc-teal) !important;
  color: white !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  overflow: hidden !important;
}

.chat-group:not(.user) .chat-avatar::after {
  content: "AI" !important;
  font-size: 11px !important;
  font-weight: 700 !important;
  color: white !important;
  letter-spacing: -0.02em !important;
}

.chat-text {
  font-size: 14px !important;
  line-height: 1.65 !important;
  color: #444 !important;
}


/* === 8. Tool Cards === */

.chat-tool-card {
  background: #f8f9fa !important;
  border: 1px solid rgba(0,0,0,0.05) !important;
  border-radius: 10px !important;
  box-shadow: none !important;
  position: relative !important;
  overflow: hidden !important;
}

.chat-tool-card::before {
  content: '' !important;
  position: absolute !important;
  left: 0 !important;
  top: 0 !important;
  bottom: 0 !important;
  width: 3px !important;
  background: var(--wc-teal) !important;
}

.chat-tool-card__title {
  font-size: 13px !important;
  font-weight: 600 !important;
  color: #3d3d3d !important;
}

.chat-tool-card__status-text {
  font-size: 11px !important;
  color: var(--wc-teal) !important;
}

.chat-tool-card__preview {
  font-size: 12px !important;
  line-height: 1.5 !important;
  opacity: 0.6 !important;
}


/* === 9. Streaming Cursor === */

.streaming-cursor::after {
  content: '\2502' !important;
  animation: wc-blink 1s steps(2) infinite !important;
  color: var(--wc-teal) !important;
  margin-left: 1px;
}

@keyframes wc-blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0; }
}


/* === 10. Compose Area — ChatGPT-style vertical layout === */

.chat-compose,
.shell--chat .chat-compose,
.shell--chat-focus .chat-compose {
  position: absolute !important;
  bottom: 0 !important;
  left: 0 !important;
  right: 0 !important;
  background: transparent !important;
  gap: 0 !important;
  margin-top: 0 !important;
  border-radius: 0 !important;
  z-index: 10 !important;
}

.chat-compose__row {
  max-width: 100%;
  margin: 0;
  width: 100%;
  gap: 0 !important;
  background: rgba(255, 255, 255, 0.75) !important;
  backdrop-filter: blur(20px) !important;
  -webkit-backdrop-filter: blur(20px) !important;
  border: 1px solid rgba(0,0,0,0.08) !important;
  border-radius: 16px !important;
  display: flex !important;
  flex-direction: column !important;
  flex-wrap: nowrap !important;
  align-items: stretch !important;
  padding: 0 !important;
  transition: border-color 0.15s ease;
  overflow: hidden !important;
}

.chat-compose__row:focus-within {
  border-color: rgba(0,0,0,0.18) !important;
  box-shadow: none !important;
}

.chat-compose__field {
  flex: 1 1 auto !important;
  min-width: 0 !important;
  display: flex !important;
  align-items: stretch !important;
  gap: 0 !important;
  width: 100% !important;
}

.chat-compose__field textarea,
.chat-compose .chat-compose__field textarea {
  background: transparent !important;
  border: none !important;
  border-radius: 0 !important;
  box-shadow: none !important;
  outline: none !important;
  resize: none !important;
  min-height: 36px !important;
  height: auto !important;
  max-height: 120px !important;
  width: 100% !important;
  font-family: var(--font-body) !important;
  font-size: 16px !important;
  line-height: 1.5 !important;
  color: #3d3d3d !important;
  padding: 12px 14px 6px !important;
}

.chat-compose__field textarea:focus,
.chat-compose .chat-compose__field textarea:focus {
  box-shadow: none !important;
  border: none !important;
  outline: none !important;
}

.chat-compose .chat-compose__field textarea::placeholder {
  color: #bbb !important;
  font-weight: 400 !important;
}

/* Actions: bottom toolbar row */
.chat-compose__actions {
  flex: 0 0 auto !important;
  display: flex !important;
  align-items: center !important;
  align-self: stretch !important;
  justify-content: flex-end !important;
  padding: 14px 14px !important;
  gap: 4px !important;
  border-top: 1px solid rgba(0,0,0,0.06) !important;
  width: 100% !important;
  box-sizing: border-box !important;
}

/* Toolbar icons (injected via JS) */
.wc-toolbar {
  display: flex;
  align-items: center;
  gap: 2px;
  flex: 1 1 auto;
}

.wc-toolbar-btn {
  background: transparent;
  border: none;
  color: #999;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  border-radius: 6px;
  padding: 0;
  transition: color 0.12s ease, background 0.12s ease;
}

.wc-toolbar-btn:hover {
  color: #555;
  background: rgba(0,0,0,0.05);
}

.wc-toolbar-btn svg {
  display: block;
}

/* Send button */
.chat-compose__actions .btn.primary {
  background: #3d3d3d !important;
  color: transparent !important;
  border-radius: 50% !important;
  width: 30px !important;
  height: 30px !important;
  min-width: 30px !important;
  min-height: 30px !important;
  max-height: 30px !important;
  padding: 0 !important;
  font-size: 0 !important;
  line-height: 0 !important;
  text-indent: -9999px !important;
  overflow: hidden !important;
  box-shadow: none !important;
  transition: opacity 0.15s ease !important;
  border: none !important;
  position: relative !important;
  flex-shrink: 0 !important;
}

/* Arrow-up send icon — absolute center */
.chat-compose__actions .btn.primary::after {
  content: '' !important;
  position: absolute !important;
  top: 50% !important;
  left: 50% !important;
  transform: translate(-50%, -50%) !important;
  width: 16px !important;
  height: 16px !important;
  text-indent: 0 !important;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 19V5'/%3E%3Cpath d='m5 12 7-7 7 7'/%3E%3C/svg%3E") !important;
  background-size: contain !important;
  background-repeat: no-repeat !important;
  background-position: center !important;
}

.chat-compose__actions .btn.primary:hover {
  opacity: 0.7 !important;
}

.chat-compose__actions .btn.primary:disabled {
  background: #ccc !important;
  opacity: 1 !important;
}

.chat-compose__actions .btn.primary:disabled::after {
  opacity: 0.5 !important;
}

/* Hide keyboard hint */
.btn-kbd {
  display: none !important;
}

/* Stop button */
.chat-compose__actions .btn.danger {
  background: #3d3d3d !important;
  color: transparent !important;
  border-radius: 50% !important;
  width: 30px !important;
  height: 30px !important;
  min-width: 30px !important;
  min-height: 30px !important;
  padding: 0 !important;
  font-size: 0 !important;
  line-height: 0 !important;
  text-indent: -9999px !important;
  overflow: hidden !important;
  border: none !important;
  position: relative !important;
  flex-shrink: 0 !important;
}

.chat-compose__actions .btn.danger::after {
  content: '' !important;
  position: absolute !important;
  top: 50% !important;
  left: 50% !important;
  transform: translate(-50%, -50%) !important;
  width: 14px !important;
  height: 14px !important;
  text-indent: 0 !important;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect width='14' height='14' x='5' y='5' rx='1'/%3E%3C/svg%3E") !important;
  background-size: contain !important;
  background-repeat: no-repeat !important;
}

.chat-controls {
  max-width: 100%;
  margin: 0;
}


/* === 11. Suggestion Buttons === */

.wc-suggestions {
  display: flex;
  gap: 8px;
  padding: 0 0 4px;
  flex-wrap: wrap;
  max-width: 100%;
  margin: 0;
  width: 100%;
  box-sizing: border-box;
}

.wc-suggestion-btn {
  background: #ffffff;
  border: 1px solid rgba(0,0,0,0.08);
  border-radius: var(--radius-full);
  color: #666;
  font-size: 13px;
  padding: 7px 16px;
  cursor: pointer;
  transition: all 0.15s ease;
  font-family: var(--font-body);
  white-space: nowrap;
  line-height: 1.3;
}

.wc-suggestion-btn:hover {
  border-color: var(--wc-teal);
  color: var(--wc-teal);
  background: rgba(91,191,181,0.04);
}

.wc-suggestion-btn:active {
  transform: scale(0.97);
}


/* === 12. Prose / Markdown === */

.prose {
  font-size: 14px !important;
  line-height: 1.65 !important;
  color: #444 !important;
}

.prose pre {
  background: #f8f9fa !important;
  border: 1px solid rgba(0,0,0,0.05) !important;
  border-radius: 8px !important;
  font-size: 13px !important;
  box-shadow: none !important;
}

.prose code {
  font-family: var(--mono) !important;
  font-size: 12.5px !important;
}

.prose p code {
  background: rgba(0,0,0,0.04) !important;
  border: 1px solid rgba(0,0,0,0.06) !important;
  border-radius: 4px !important;
  padding: 0.1em 0.35em !important;
  font-size: 12.5px !important;
  color: #3d3d3d !important;
}

.prose a {
  color: var(--wc-teal) !important;
  text-decoration: none !important;
}

.prose a:hover {
  text-decoration: underline !important;
}

.prose blockquote {
  border-left: 2px solid rgba(0,0,0,0.1) !important;
  color: #999 !important;
}

.prose th {
  background: #f8f9fa !important;
  font-size: 12px !important;
  font-weight: 600 !important;
}


/* === 13. Scrollbar === */

::-webkit-scrollbar {
  width: 4px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: rgba(0,0,0,0.07);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(0,0,0,0.14);
}

* {
  scrollbar-width: thin;
  scrollbar-color: rgba(0,0,0,0.07) transparent;
}

::selection {
  background: rgba(91,191,181,0.15);
}


/* === 14. Misc === */

.chat-reading-indicator {
  color: var(--wc-teal) !important;
}

.chat-thinking {
  border-color: rgba(0,0,0,0.05) !important;
  background: #f8f9fa !important;
  font-size: 12px !important;
}

/* body::before is used for aurora effect — see section 2 */

.callout {
  padding: 6px 12px !important;
  border-radius: 20px !important;
  font-size: 12px !important;
  line-height: 1.4 !important;
  text-align: center !important;
  white-space: nowrap !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
  max-width: 100% !important;
  margin: 0 auto !important;
  border: none !important;
  background: rgba(0, 0, 0, 0.04) !important;
  color: var(--muted, #9ca3af) !important;
}

.callout.danger {
  background: rgba(239, 68, 68, 0.06) !important;
  color: rgba(239, 68, 68, 0.7) !important;
  border: none !important;
}

.callout + .callout {
  margin-top: 4px !important;
}

.btn {
  border-radius: var(--radius-md) !important;
  font-weight: 500 !important;
  letter-spacing: 0 !important;
}


/* === 15. Visual Stability — 스트리밍 중 깜빡임 방지 === */

/* 쉘/그리드 전환 애니메이션 제거 */
.shell,
.shell--chat,
.shell--chat-focus {
  transition: none !important;
}

/* content-header 높이 전환 제거 (레이아웃 시프트 원인) */
.content-header {
  transition: none !important;
  max-height: 0 !important;
  padding: 0 !important;
  overflow: hidden !important;
}

/* 채팅 스레드 레이아웃 격리 — 내부 변경이 외부에 영향 안 줌 */
.chat-thread {
  contain: layout style !important;
  overflow-anchor: auto !important;
}

/* 스트리밍 버블 border 애니메이션을 부드러운 opacity로 교체 */
.chat-bubble.streaming {
  animation: none !important;
  border-color: transparent !important;
}

/* 채팅 그룹 전환 애니메이션 제거 */
.chat-group {
  animation: none !important;
  transition: none !important;
}

/* Lit 컴포넌트 재렌더링 시 레이아웃 시프트 방지 */
.chat-group-messages {
  contain: layout style !important;
}

/* 커서 깜빡임만 유지 (GPU 합성 — opacity만 사용) */
.streaming-cursor::after {
  will-change: opacity !important;
}

/* focus 모드 전환 애니메이션 제거 */
.nav,
.topbar {
  transition: none !important;
}


/* === 16. Responsive — Mobile stability === */

/* Prevent rubber-band overscroll on mobile */
html, body {
  overscroll-behavior: none !important;
}

@media (max-width: 767px) {
  /* ── Height: fill viewport dynamically ── */
  #app-root {
    height: 100dvh !important;
    height: -webkit-fill-available !important;
    overflow: hidden !important;
  }

  openclaw-app {
    height: 100% !important;
    max-height: none !important;
    margin: 0 !important;
    border-radius: 0 !important;
    box-shadow: none !important;
  }

  /* ── Header: absolute overlay on mobile too ── */
  #wc-header {
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    height: 44px !important;
    padding: 0 12px !important;
  }

  /* ── Chat container: proper flex column ── */
  .chat {
    display: flex !important;
    flex-direction: column !important;
    overflow: hidden !important;
    min-height: 0 !important;
  }

  /* ── Thread: fill available space, top padding for header overlay ── */
  .chat-thread {
    flex: 1 1 0 !important;
    min-height: 0 !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch !important;
    padding-top: 52px !important;
    padding-bottom: 16px !important;
  }

  /* ── Compose: flex-end instead of absolute overlay ── */
  .chat-compose,
  .shell--chat .chat-compose,
  .shell--chat-focus .chat-compose {
    position: relative !important;
    left: auto !important;
    right: auto !important;
    bottom: auto !important;
    flex-shrink: 0 !important;
    z-index: auto !important;
    padding-bottom: env(safe-area-inset-bottom, 10px) !important;
  }

  /* ── Textarea: 16px prevents iOS auto-zoom on focus ── */
  .chat-compose__field textarea,
  .chat-compose .chat-compose__field textarea {
    font-size: 16px !important;
    max-height: 100px !important;
  }

  /* ── Compose row: opaque background on mobile (no glassmorphism overlay) ── */
  .chat-compose__row {
    background: #f0f1f3 !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
  }

  /* ── Aurora: disable rotation animation for GPU savings ── */
  body::before,
  body::after {
    animation: none !important;
  }

  /* ── Remove layout containment on mobile (interferes with keyboard resize) ── */
  .chat-thread {
    contain: none !important;
  }

  .chat-group-messages {
    contain: none !important;
  }
}

/* === 17. User Menu — Avatar icon only === */

.wc-user-menu {
  position: relative;
  display: flex;
  align-items: center;
}

.wc-avatar-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  border-radius: 50%;
  padding: 0;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.wc-avatar-btn:hover {
  transform: scale(1.05);
}

.wc-avatar-btn:active {
  transform: scale(0.95);
}

.wc-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--wc-teal);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  flex-shrink: 0;
}

.wc-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  background: #ffffff;
  border: 1px solid rgba(0,0,0,0.08);
  border-radius: 14px;
  min-width: 200px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.1);
  padding: 6px;
  z-index: 1001;
}

.wc-dropdown-header {
  padding: 10px 14px 8px;
}

.wc-dropdown-name {
  font-size: 14px;
  font-weight: 600;
  color: #3d3d3d;
}

.wc-dropdown-email {
  font-size: 12px;
  color: #999;
  margin-top: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.wc-dropdown-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 10px 14px;
  border: none;
  background: transparent;
  color: #3d3d3d;
  font-size: 14px;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
  font-family: var(--font-body);
  border-radius: 8px;
  transition: background 0.15s ease;
}

.wc-dropdown-item:hover {
  background: #f0f1f3;
}

.wc-dropdown-item svg {
  flex-shrink: 0;
  color: #999;
}

.wc-dropdown hr {
  margin: 4px 0;
  border: none;
  border-top: 1px solid rgba(0,0,0,0.05);
}

@media (max-width: 640px) {
  #wc-header {
    padding: 0 8px;
    height: 40px;
  }

  .wc-avatar {
    width: 28px;
    height: 28px;
    font-size: 12px;
  }

  .chat-thread {
    padding: 48px 0 16px !important;
    max-width: 100%;
  }

  .chat-compose__row {
    max-width: 100%;
  }

  .chat-compose {
    padding: 6px 12px !important;
    padding-bottom: env(safe-area-inset-bottom, 10px) !important;
  }

  .chat-bubble {
    font-size: 13.5px !important;
  }

  .wc-welcome-title {
    font-size: 20px;
  }

  .chat-widget-panel {
    padding-top: 40px !important;
  }
}

@media (max-width: 400px) {
  #wc-header {
    padding: 0 6px;
    height: 38px;
  }

  .chat-widget-panel {
    padding-top: 38px !important;
  }

  .chat-compose {
    padding: 6px 10px !important;
    padding-bottom: env(safe-area-inset-bottom, 10px) !important;
  }
}
